Add lore in ItemStack

Discussion in 'Plugin Development' started by BuzzSmooth, Jun 18, 2014.

?

Add lore in ItemStack?

  1. Add lore in ItemStack

    3 vote(s)
    100.0%
  2. Add lore in ItemStack

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    BuzzSmooth

    Hi, my problem is I can not put a lore. Please help

    Code:java
    1. import org.bukkit.ChatColor;
    2. import org.bukkit.Material;
    3. import org.bukkit.entity.Player;
    4. import org.bukkit.inventory.ItemStack;
    5. import org.bukkit.inventory.meta.ItemMeta;
    6.  
    7. public class GameUtils {
    8.  
    9. public static void equipPlayer(Player p) {
    10. p.getInventory().clear();
    11. p.getInventory().setArmorContents(null);
    12.  
    13. ItemStack WOOD_SWORD = new ItemStack(Material.WOOD_SWORD);
    14. ItemMeta meta = WOOD_SWORD.getItemMeta();
    15. meta.setDisplayName(ChatColor.AQUA + "SWORD");
    16. WOOD_SWORD.setItemMeta(meta);
    17. p.getInventory().setItem(0, WOOD_SWORD);
    18.  
    19. p.getInventory().setItem(1, new ItemStack(Material.BOW));
    20. p.getInventory().addItem(new ItemStack(Material.ARROW));
    21. }
    22. }
    23.  
     
  2. Offline

    Gater12

  3. Offline

    BuzzSmooth

  4. Offline

    xize

    BuzzSmooth

    you need to clone the metadata with getItemMeta() from that item and then change it, then readd the new metadata with setItemMeta(meta), p.s in the metadata you can set lores to.
     
  5. Offline

    yewtree8

    instead of doing that create a method to create an item and set it's lore and name, by doing this you will also make the process a lot less messier.
     
  6. Try meta.setLore(Array.asList("lore") or so
     
  7. Offline

    Garris0n

    With the method that he just said the name of? You could've easily found this with a quick search, this thread is completely unnecessary.
     
Thread Status:
Not open for further replies.

Share This Page