Solved How to set a custom item name and lore?

Discussion in 'Plugin Development' started by slash14459, Aug 31, 2013.

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

    slash14459

    So I made a command on my server that spawns a God Sword in and I was wondering how I could set a name and lore for it with colors. Please help me if you can :)
     
  2. slash14459
    Use ItemMeta, and its setDisplayName()- and setLore methods.
     
  3. Offline

    Deleted user

    @slah14459
    Code:java
    1. ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
    2. ItemMeta im = item.getItemMeta();
    3. im.setDisplayName(ChatColor.COLOR_NAME + "displayName");
    4. List<String> loreList = new ArrayList<String>();
    5. loreList.add(ChatColor.COLOR_NAME + "lore");//This is the first line of lore
    6. loreList.add(ChatColor.COLOR_NAME + "lore2");//This is the second line of lore
    7. im.setLore(loreList);
    8. item.setItemMeta(im);
     
    Shortninja66 and slash14459 like this.
  4. Offline

    slash14459

    That worked. Thank you!
     
  5. Offline

    Deleted user

    slash14459
    No prob, just change title to solved
     
  6. Offline

    XvBaseballkidvX

    An easier way to add Lores is by doing this:

    Code:java
    1. setLore(Arrays.asList("lore 1", "lore 2", "lore 3"));


    EDIT: Fixed Typo
     
Thread Status:
Not open for further replies.

Share This Page