§id vs ChatColor.Color

Discussion in 'Bukkit Discussion' started by UniqueNameDen, Jan 26, 2015.

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


    What's the difference between using § and ChatColor...

    sendMessage(ChatColor.RED + "Red message")
    sendMessage("§2Red message")

    It's much more compact and easier to use, but when you use § if outputs a [​IMG] symbol...?

    and are there any cons using it...?
  2. @UniqueNameDen

    Pros: (symbol)
    Easier and quicker

    Pros: (ChatColor)
    Better if you don't know the colour code and just the colour name.
    Will still work if Minecraft ever changed the code
  3. Offline


    @bwfcwalshy Quicker/Easier is fairly opinion and experienced based. Using the symbol will require you to have them memorized, which isn't always the case for lesser used ones. As for ChatColor, (mostly) everyone will understand the meaning of "Red". On top of that, static imports easily make it shorter to type.


    As for another Pro for ChatColor, readability/conventions. Magic numbers/values aren't the best to have in code, and anyone who may not play minecraft will understand what "ChatColor.BOLD" means versus "&l"

    I see no reason for one to use the symbol other then not properly knowing how to handle enums or following some "tutorial" on coding that says to, both of which are fairly invalid reasons, one being the fact that you should know Java before using Bukkit, and the other being tutorials have degraded to the point of spreading bad conventions and practices
  4. Offline


    If the ChatColor codes ever change, all you (you as in the API devs) would have to do is make some changes to the ChatColor enum rather than fix every plugin that uses the codes.
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page