Solved Easyest way to add a lore

Discussion in 'Spigot Plugin Development' started by Stellrow, Jul 19, 2018.

  1. Can anyone tell me what is the easyest way to add a lore to an itemstack?
    I have checked many sites but i keep seeing the code being too complex to comprehend
     
  2. Code (Java):

    ItemStack item = ....

    ItemMeta meta = item.getItemMeta(); // Getting the itemmeta


    // creating the lore.
    List<String> lore = new ArrayList<>();
    lore.add("This is the first line lore");
    lore.add("This is the second line of the lore");

    meta.setLore(lore); // setting the lore to the itemmeta

    item.setItemMeta(meta); // setting the modified itemmeta
     
    Not sure where or what you searched exactly but this is a simple way of setting a lore.
     
  3. So i changed the itemstack of the item to this:
    Code (Text):
            ItemStack sabiefier = new ItemStack(Material.IRON_SWORD);
                    ItemMeta sabiefiermeta = sabiefier.getItemMeta();
                    List<String> lore = new ArrayList<>();
                    lore.add("Costa 100 banuti");
                    sabiefiermeta.setLore(lore); // setting the lore to the itemmeta
                    sabiefiermeta.setDisplayName(ChatColor.YELLOW + "Sabie de fier");
                    sabiefier.setItemMeta(sabiefiermeta); // setting the modified itemmeta
    But the lore its not showing
     
  4. Everything seems fine. The issue is 100% not how you set the itemmeta but rather something/somewhere else in your code.
     
  5. There is nothing in the code that modifies any metadata does it have to do with the fact that im using it in a inventory event?

    When i did the additem it sends the item with the lore

    Nvm forgot the first onclick had the item without the lore.mb