[Tutorial] Easy Colours

Discussion in 'Spigot Plugin Development' started by 28091, May 4, 2015.

Thread Status:
Not open for further replies.
  1. With this code you can do
    Code (Text):
    Bukkit.broadcastMessage(green + bold + "Green and Bold!")
    And other things easily like that!
    With this you can use a colour and bold or a colour and italics...
    Or a coloured, bold, underlined, strikethroughed...? if you like!
    Just use the colour name!
    Copy and paste this code to under your 'public class' or whatever bit in the class you want to use this on.
    Code (Text):

    String white = ChatColor.WHITE + "";
    String reset = ChatColor.RESET + "";
    String red = ChatColor.RED + "";
    String gold = ChatColor.GOLD + "";
    String gray = ChatColor.GRAY + "";
    String green = ChatColor.GREEN + "";
    String lightpurple = ChatColor.LIGHT_PURPLE + "";
    String magic = ChatColor.MAGIC + "";
    String darkred = ChatColor.DARK_RED + "";
    String darkpurple = ChatColor.DARK_PURPLE + "";
    String darkgreen = ChatColor.DARK_GREEN + "";
    String darkgray = ChatColor.DARK_GRAY + "";
    String darkblue = ChatColor.DARK_BLUE + "";
    String darkaqua = ChatColor.DARK_AQUA + "";
    String blue = ChatColor.BLUE + "";
    String black = ChatColor.BLACK + "";
    String aqua = ChatColor.AQUA + "";
    String bold = ChatColor.BOLD + "";
    String italic = ChatColor.ITALIC + "";
    String underline = ChatColor.UNDERLINE + "";
    String yellow = ChatColor.YELLOW + "";
    String strikethrough = ChatColor.STRIKETHROUGH + "";

    ...
    I know right?!
    So useful!
     
    #1 28091, May 4, 2015
    Last edited: May 4, 2015
    • Funny Funny x 5
    • Optimistic Optimistic x 3
  2. I'm waiting for tutorial how to spawn real player from thin air, with no work or investment.
     
  3. I did state how useful it was
     
  4. Still not as useful as the ChatColor class itself! :rolleyes:
     
    #4 Raino, May 4, 2015
    Last edited: May 4, 2015
    • Agree Agree x 2
    • Like Like x 1
  5. Code (Text):
    import static org.bukkit.ChatColor.*;
    Code (Text):
    String example = "Hello " + RED + "World";
     
    • Like Like x 1
    • Agree Agree x 1
    • Winner Winner x 1
  6. HOW DARE YOU INSULT MY DERPINESS!

    Er
    It's called scrolling down :p
     
    #6 28091, May 4, 2015
    Last edited by a moderator: May 4, 2015
  7. [​IMG]
     
  8. That was for yellow
    Read what the message that I quoted said
    I changed it
     
  9. go away :(
     
  10. Color Codes with § are still the easiest.
     
  11. And are still a terrible idea.
     
  12. How? You have to copy and paste that character or constantly use ALT keys.
     
  13. It's on a key on my keyboard...
     
  14. Not for UK keyboards.
     
  15. Should move to Belgium then :p
     
    • Friendly Friendly x 1
  16. German keyboard ;)
     
    • Agree Agree x 1
  17. Not for a majority of people who use the english language, and it's also not a part of ASCII. Not to mention by convention you shouldn't have unicode characters within java source files. (It's supported for data injection, not so people can make unicode characters everywhere).
     
  18. Not having § in ASCII is the most reasonable argument. Some old (but still in use) operating systems use ASCII as the default text codec, which can result in corrupted §'s.
     
  19. It's not about it being used in an ASCII environment, it's about it being used in any environment that isn't unicode or the source encoding where it's non-ASCII.
     
Thread Status:
Not open for further replies.