(Not A Bug) PlayerInteractEvent runs twice in 1.12.2

Discussion in 'Bukkit Discussion' started by 0ct0berBkkitPlgins, Mar 8, 2018.

Thread Status:
Not open for further replies.
  1. The Bug

    PlayerInteractEvent seems to be running twice in a row in 1.12.2 upon right-clicking a block, which is an issue for plugins that involve right clicking. I don't know if this is a Minecraft code error (I don't think it is- otherwise we probably would place blocks twice), a client error, or a Bukkit bug, but this is indeed occurring. I have also tested this on Spigot 1.12.2, of recent versions for both, and the bug still occurs.

    I have also noticed this bug occur with WorldGuard in latest versions- I'll get a not allowed to use that here message when I try and interact in a region not allowed twice at the same time.

    The Problem

    Plugins that involve right-clicking blocks may unexpectedly get two of the event at the same time, and not work as intended when in 1.12 unless the author knows of the bug and makes it so that their plugin interprets two right clicks at the same time as one.

    I was working on a simple plugin that involved right clicking and had written it under 1.8.8 code. It was supposed to do something different on the second right click than the first- mark the first block clicked as a first position, and then on the second click measure the distance between the next block clicked and the first position. This worked fine in 1.8, but did not work in 1.12 (the first block was clicked twice). There were no other code errors and the only in-game logic used was listening for a player interact event, checking the item in hand and if the player is sneaking.

    Steps to re-create

    Just listen to PlayerInteractEvent, and send the player a message every time the action is RIGHT_CLICK_BLOCK.


    1.8.8 Server:


    1.12.2 Server:

  2. Offline

    timtower Administrator Administrator Moderator

  3. Code:
        public void onInteract(PlayerInteractEvent event) {
  4. Offline

    timtower Administrator Administrator Moderator

  5. @timtower Oh... so this is sort of an intended feature... I'll edit the title and post then, but this seems like it would be confusing and very easy to make this mistake; although I can see problems that would occur both if this were kept the way it is or if the off hand was made into a separate event.

    Can you lock the thread?
Thread Status:
Not open for further replies.

Share This Page