Solved PlayerInteractEvent not catching right click?

Discussion in 'Spigot Plugin Development' started by torpkev, Jun 24, 2021.

  1. I'm trying to update some code for 1.17, part of that involves me catching the PlayerInteractEvent, checking the action and then hand.

    With paper 1.17-46 - it works perfectly.
    With spigot (latest build as of about 5 minutes ago - (CraftBukkit version 3161-Spigot-f773da8-f81f499 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)) it catches action with LEFT_CLICK_BLOCK, but does not catch RIGHT_CLICK_BLOCK

    with spigot - left click works, right click does nothing
    upload_2021-6-24_9-56-19.png

    with paper:
    upload_2021-6-24_9-57-44.png


    Code (Java):
    @EventHandler(priority = EventPriority.MONITOR)
        public void onInteract(org.bukkit.event.player.PlayerInteractEvent event) {

            Logging.log("onInteract", "PlayerInteractEvent fired");
            if (event.getAction() != null) {
                Logging.log("onInteract", "Event - " + event.getAction().name());
            }
            if (event.getHand() != null) {
                Logging.log("onInteract", "Hand - " + event.getHand().name());
            }
    }
    Did something change?
     

    Attached Files:

  2. AFAIK the event is only called when you have an item in the hand, I am not sure though. Did you try it with an empty hand only?
     
  3. It seems to gets fired either way (which would make sense.. my code worked fine in 1.16)

    but I think I've found my difference - but still confused as to why.
    In my paper world, the player is op'd, the spigot world they are not

    So I used an alt account, with op, right click is generated, without op, it is not.

    That seems super weird.. anyone any idea why?

    Code (Text):

    [12:38:15] [Server thread/INFO]: Made MrIbex a server operator
    [12:38:19] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:19] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - RIGHT_CLICK_BLOCK[m
    [12:38:19] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - HAND[m
    [12:38:22] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:22] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - RIGHT_CLICK_BLOCK[m
    [12:38:22] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - OFF_HAND[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - RIGHT_CLICK_BLOCK[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - HAND[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - RIGHT_CLICK_BLOCK[m
    [12:38:31] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - OFF_HAND[m
    [12:38:33] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:33] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - LEFT_CLICK_BLOCK[m
    [12:38:33] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - HAND[m
    [12:38:40] [Server thread/INFO]: Made MrIbex no longer a server operator
    [12:38:44] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mPlayerInteractEvent fired[m
    [12:38:44] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mEvent - LEFT_CLICK_BLOCK[m
    [12:38:44] [Server thread/INFO]: [0;35;22m[0;33;22m[onInteract] [0;37;1mHand - HAND[m

     
     
  4. I hate everyone and everything.

    vanilla spawn protection prevents right clicking for non-op players.

    I changed it to spawn-protection=0 in server.properties, and suddenly I can right click to my hearts content.
     
  5. Oh sorry, I was thinking that you were talking about RIGHT_CLICK_AIR, not block.

    Your problem 99% is this: You are inside the protected spawn area :p Had the same problem with PlayerInteractAtEntityEvent at some point in my AngelChest plugin...

    EDIT: Damn, 20 seconds too late!
     
    • Like Like x 1