Renaming Items using ChatColor

Discussion in 'Plugin Development' started by redytedy, Jul 5, 2013.

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


    So I know how to rename items using itemmeta, but I can't use colors or bold.
  2. Offline


    pretty sure you can, atleast it works for me.
    Just do ChatColor.GOLD + "display name here"
    heres an example:
    ItemStack c4 = new ItemStack(Material.SPONGE);
    ItemMeta c4Meta = c4.getItemMeta();
    c4Meta.setDisplayName(ChatColor.LIGHT_PURPLE + "C4");
  3. Offline


    You maybe don't know the REAL color codes: These are not with &, but with §. That you also can't type ingame, so plugins started to use & for color codes and replacing them with §.
  4. Offline


    Also just make sure you have your correct import :p
    - and make sure your setting the display name and it's string concatenation.
  5. Offline


    Janmm14 Use ChatColor.translateAlternateColorCodes('&', message); This replaces all the color codes that are followed by an & character.
  6. Offline


    Thanks for all your input! What I learned is that I was getting itemmeta by doing ItemMeta

    bob = (ItemMeta)tool.getItemMeta();

    I just removed the (ItemMeta) and ChatColor works. ChatColor does not support bold item names so I just did
    §l in front of the name and it worked!
Thread Status:
Not open for further replies.

Share This Page