Cancel Naming of Item

Discussion in 'Spigot Plugin Development' started by MrWaffleman, Jun 27, 2016.

  1. I looked at this useful thread, but I'm still confused about what I need to do in order to cancel the naming of a specific item. For example, there's an item named "Item", and someone is trying to rename it to "NotItem", I want to detect if the item's name is indeed "Item", then cancel the event. Is the display name the result of naming the item, or is it the previous item's name?
  2. Could try an inventoryclickevent for anvils
  3. Click the link :p, it does have the exact event, I'm just confused about what is inside the event.
  4. Oh sorry I didn't even see the link XD
    What do you mean what is inside the event? It has pretty good comments explaining everything.
    1. Check if it's an anvil being clicked
    2. Check if the clicked slot is slot 2, the output slot
    3. Get the item inside slot 0, check if it's the item you don't want people to rename
    4. If it is, event.setCancelled(true)
  5. Well really, the real question is: Is the ItemStack "item" referring to item before the naming or after with the new name and all?