Coloured Text (How)

Discussion in 'Plugin Development' started by azoundria, Jan 27, 2011.

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


    Can someone please tell me how to send coloured text from a plug-in, including how to have a username coloured?

    I've checked the org.bukkit.ChatColor and it's very confusing to me. There are no examples and little documentation on this. And I can't find any help in the entire Google.
  2. Offline


    To send colored texts you do it like this:

    import org.bukkit.ChatColor;


    player.sendMessage(ChatColor.AQUA + "This is an aquamarine message");
  3. Offline


    Thanks a ton. I did eventually figure it out. I do wish there was some documentation in that class.
  4. Offline


    Some tricks:

    If you have the name of a colour (let's say "dark purple") in a string, you can get the ChatColor object by doing this:

    String arg = "dark purple";
    ChatColor c = ChatColor.valueOf(arg.replace(' ','_').toUpperCase()); 
    This works because ChatColor is an enumerate type. You can then use this to print colours in your messages, as phaed explained.
Thread Status:
Not open for further replies.

Share This Page