Solved Interact with Item that has a custom name

Discussion in 'Plugin Development' started by nivek1212, Sep 12, 2014.

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


    Hey Guys,

    So with the PlayInteracterEvent you can check if the player is right-clicking with a specific item. But how can you detect if the item has a name?

    Just solved it myself C:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 14, 2016
  2. Offline


  3. Offline


    then it would be nice to post the code here for people who need C:
  4. Offline


    That's the Code
    1. @EventHandler
    2. public void onClick(PlayerInteractEvent e) {
    3. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    4. if(e.getMaterial().equals(Material.SLIME_BALL)) { // Here the item
    5. if(e.getItem().getItemMeta().getDisplayName().equals("Hi")) { // Here the Name of the item
    6. Bukkit.broadcastMessage("Hi"); // Here Your Command
    7. }
    9. }
    10. }
    11. }
Thread Status:
Not open for further replies.

Share This Page