Solved PlayerInteractEvent Problem

Discussion in 'Spigot Plugin Development' started by tom2208, May 25, 2017.

  1. Hello i have a problem with the PlayerInteractEvent.
    I'm calling a method if an specific item gets clicked.
    There is the problem, if I'm holding two items in my hands, than my method gets called two times, no matter if the secondc item is the specific item or not because I'm using the p.getItemInHand() method, i would have the same problem if i use this new getItemInMainHandMethod(). How can i fix this, or have can i get the hand which calls the PlayerInteractEvent?

    ~ Tom
     
  2. Check if the hand is the main one using e#getHand() and comparing with the EquipmentSlot.HAND
    Code (Text):
    if(e.getHand() != EquipmentSlot.HAND) return;
     
    • Useful Useful x 1
  3. Ohh, thank you! ^^ It's working.