Solved PlayerInteractEvent Triggered Twice??

Discussion in 'Plugin Development' started by Junrall, Mar 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Junrall

    Here is the code... very simple.
    If I left/right click on a block, the PlayerInteractEvent is triggered twice. So if I click on a grass block, the messages are printed twice:

    derp
    LEFT CLICK GRASS
    derp
    LEFT CLICK GRASS

    I am not using any other events... and PlayerInteractEvent is not duplicated.

    Any ideas of how to fix this? Or am I missing something?

    Thanks!


    Code:
    @EventHandler
          public void onPlayerSignClick(PlayerInteractEvent event){
            Player player = event.getPlayer();
            Block block = event.getClickedBlock();
            Material blockType = block.getType();
            Action mouseclick = event.getAction();
           
            player.sendMessage(ChatColor.YELLOW + "derp");
           
            if (block != null) {
               
                if (mouseclick == Action.LEFT_CLICK_BLOCK){
                    player.sendMessage(ChatColor.YELLOW + "LEFT CLICK" + blockType.toString());
                }
               
                if (mouseclick == Action.RIGHT_CLICK_BLOCK){
                    player.sendMessage(ChatColor.YELLOW + "RIGHT CLICK: " + blockType.toString());
                }
            }
           
        }
     
  2. Offline

    ZeusAllMighty11

    Pretty sure it's a bug, I've had this happen before
     
  3. Offline

    RealDope

    I have as well.
     
  4. Offline

    Junrall

    Hmmm...
    is there a "work-around" for this?

    Gaaa!
    Nevermind! I was being a big derp!

    I had mistakenly registered the event twice.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page