Solved Check when player clicks on another player

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, Jun 10, 2016.

  1. How do I check if a player has a certain named item and they right click a player with it?
     
  2. PlayerInteractEntityEvent, check is the cliked entity a player and the item that the clicker holds is your special item
     
  3. To check if the clicken entity is a player use this:
    Code (Text):

    if(Entity instanceof Player){
    //Your code here
    }
     
    To check if the player that clicks the player is holding the item:
    Code (Text):

    if(player.getItemInHand().equals(//your itemstack here){
    //Your code here
    }