Solved ClickEventListener

Discussion in 'Spigot Plugin Development' started by kirkhendrix, May 29, 2016.

  1. Hi,

    I've a problem with the PlayerInteractEvent..... here's the code:

    Code (Text):
    @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerClickedBlock(PlayerInteractEvent event) {
            if(event.getAction() == Action.RIGHT_CLICK_BLOCK)

    If I click any block with any item in my hand I'll get ONE message with the block I've clicked. That's fine..... but if I click any block WITHOUT an item in my hand I'll get TWO messages with the same Block. So if I click a stone-block without an item in my hand I'll get two times "STONE". Why does this happen? Is there a way to get only one message?
  2. That's how minecraft works.
  3. Are you using 1.9 or 1.8?
  4. 1.9.2
  5. In 1.9+ you have 2 hands.

    Something like: #getItemInMainHand();
  6. Check which hand the player is using by using event.getHand()
  7. Code (Text):
    if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getHand() == EquipmentSlot.HAND)
    Yeah! Works! Awesome! Thanks! : >