Solved Checking if an Item has certain Lore

Discussion in 'Plugin Development' started by Jake230599, May 5, 2013.

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

    Jake230599

    Code:
      Removed....
    
    I have this code, but I am unable to retrieve the item lore. It gets the item displayname just fine but when I try to check if the item has certain Lore, I get no errors, the item with the Lore doesn't trigger the event. It basically renders the code useless. Could someone explain to me why this may be happening? Am I doing something wrong when checking the Lore?
     
  2. Offline

    MP5K

    Hello Jake230599,
    ItemMeta.getLore() returns a List<String> so try to use: getLore().contains("Small");
     
  3. Offline

    Jake230599

    Thanks for the help, I can't believe it was such a small change... **Sigh**
     
  4. Offline

    Regenwurm97

    Could anyone of you maybe explain me how to actually edit the lore of an item?
    So I want the diamond axe called "Thor's Hammer" but I dont really know how to set the Item Meta...
    maybe someone of you can help me with this?

    Got this:
    Code:
    if(e.getPlayer().getInventory().getItemInHand().getItemMeta().getLore().contains("Wool")) {
                ItemStack hand = e.getPlayer().getInventory().getItemInHand();
                ItemMeta meta = hand.getItemMeta();
                meta.setLore(ChatColor.GREEN + "Thors Hammer");
     
            }
    The problem is eclipse says setLore requires a String List but I only want to use 1 string...should I really create a list with 1 entry called "Thors Hammer"?!
     
  5. Offline

    molenzwiebel

    Yes, or use Arrays.asList(line1, line2, ...)
     
  6. Offline

    Regenwurm97

    Well...this could be improved tho :l
    But thx, working fine now ;)
     
Thread Status:
Not open for further replies.

Share This Page