Renaming Items using ChatColor

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

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

    redytedy

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

    artish1

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

    Janmm14

    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

    Unknowncmbk

    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

    GodzOfMadness

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

    redytedy

    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