Solved Item lore

Discussion in 'Plugin Development' started by Nojus, May 17, 2014.

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

    Nojus

    How to check if an item has a sertain lore? I'm trying to make if lore is something like "Can't drop" then the player can't drop the item. Please help.

    HELP??

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

    hugokk

    If you want to check the first line of the lore you can try something like this:
    Code:java
    1. ItemStack item;
    2. if(item.getItemMeta().getLore() != null)
    3. if(item.getItemMeta().getLore().get(0).equalsIgnoreCase("loreyouwanttocheck"))
    4. {
    5. //Code to execute when it has the lore
    6. }
    7.  
     
    Nojus likes this.
  3. Offline

    Nojus

    so the ItemStack item would be ItemStack item = (ItemStack) e.getItemDrop(); ?
     
  4. Offline

    hugokk

    Yes, and make sure your listeners are registered
    EDIT:
    No sorry it's like this:
    Code:java
    1. ItemStack item = e.getItemDrop().getItemStack();
     
    Nojus likes this.
  5. Offline

    Nojus

    Ah i figured it out, thanks. It's actualy ItemStack item = e.getItemDrop().getItemStack();
     
Thread Status:
Not open for further replies.

Share This Page