Solved Multiple Lore Lines?

Discussion in 'Spigot Plugin Development' started by Dartanman, May 31, 2016.

  1. Hey guys! I'm working on a plugin, for the most part, it works. However, there is one problem. I explain it in this video:

    NOTE: "CustomEnchants" are defined by Lore.

    Here's the code that needs help with the lore setting:
  2. I'm not sure why we needed a video description for this :p anyways you keep making a new list every time instead of getting the existing lore.
    Code (Text):
    ItemMeta im = hand.getItemMeta();
    List<String> loreList = new ArrayList<String>();
    loreList.add(ChatColor.RED + "Fish I");
    You should first check if the ItemMeta#hasLore() and then get it with ItemMEta#getLore(). For there I would check that the lore doesn't already contain ChatColor.RED + "Fish I". Then add it to the lore and put the updated list back on the item with ItemMeta#setLore(loreList).
    • Useful Useful x 1
  3. Thank you!
  4. Code (Text):
    ItemMeta im = hand.getItemMeta();
    This should also work fine and it's quite handy sometimes.
    • Like Like x 1
    • Useful Useful x 1