Posts: 21
Threads: 3
Joined: Sep 2014
Thanks: 2
Given 4 thank(s) in 4 post(s)
Is there any function to convert chat colors?
When I say chat colors I mean, when someone types
"Hi &aI &bLove &cColors"
I can just run a command and it will auto convert the &(Color Code) to a color?
I know bukkit has translateAlternateColorCodes() but I am wondering if MCServer might have any similiar function or will I need to make my own function?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
You don't need any translation, for chat messages it works automatically, only use @ instead of & (we need to change this, because it mangles email addresses and @mentions; just didn't get around to it).
Posts: 21
Threads: 3
Joined: Sep 2014
Thanks: 2
Given 4 thank(s) in 4 post(s)
I have a motd file and it contains &(color code) colors in it, so I need to convert that string to chat colors.
Right now I am trying to convert the colors in the server desc (the desc of a server, in the server list) so I assume its just to convert them to chat colors?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Unlike chat messages, the server description doesn't auto-convert colors, you need to specify them explicitly using the § character (and be careful about utf-8 encoding).
Posts: 21
Threads: 3
Joined: Sep 2014
Thanks: 2
Given 4 thank(s) in 4 post(s)
hmm... So I just replace all the &(chat code) with §(chat code) no need to use cChatColor?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Not really, the cChatColor is only a container for the constants, not much else.