Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by TheBlueKing, May 6, 2017.
How can i print a message contain unicode and color code in console?
You can try using the unicode symbol itself such as », or it's code \u00BB
(I've used one of them before, can't remember which...)
I tried,doesn't work,it say ? in cmd
Then use a terminal which has unicode support. Windows Command Prompt doesn't, thus they made PowerShell.
Of course windows terminal supports unicode. By default it uses the characterpage 1252. It can be changed by the "chcp" command (windows prompt), e.g. execute chcp 65001 -> to switch over to UTF-8.
However if you're using some sort of remote console (e.g. Telnet, Putty or whatever), you need to consider their supported characterset, too.
not cmd problem,it display ? in minecraft chat too
I guess, i did not understand your problem yet.
What exactly is your problem?
config into chat
client message into chat
chat into server console
chat into remote console
remote console into server console
remote console into server chat
Which one of these points do you want to accomplish?
What exactly have you tried?
did you encode with UTF-8?
Unicodes from java code into server console
Yes,it display the right message in minecraft client,but not the console
Remote console or root console?
Do you use a dedicated root server and have remote access to the root desktop? If so check the console at the root server, not via remote console.
my own windows computer
Bukkit uses UTF-8, windows uses (as mentioned above) characterpage 1252.
You need to change the character page before starting the server.
Execute "chcp 65001" before you start the server in the same terminal.
it still not working
What is not working???
You still doesn't show us what you did.
At least show us your server start command and the complete server log when your unicode symbol fails.
The unicode show as
[02:45:44] [Server thread/INFO]: [0;37;1m?[0;31;1mRMW[0;32;1m?????[0;37;1m? ?[0;33;1m???? [0;37;1m? [m
[02:45:44] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[02:45:44] [Server thread/INFO]: CONSOLE: [0;32;1mReload complete.[m
[02:45:44] [Craft Scheduler Thread - 3/INFO]: [Vault] Checking for Updates ...
[02:45:45] [Craft Scheduler Thread - 3/INFO]: [Vault] No new version available
start command: java -Xmx512M -jar spigot-1.11.2.jar
i do chcp 65001 before start the server
Colors in console Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "asd");
Turns out, the problem is more trivial.
The terminal font does not support unicode characters. It's just that simple.
By default there are 3 fonts:
"Consolas" and "Lucida Console" only support a few special unicode characters.
You need to add a new font (e.g. "Arial Unicode MS Standard"), which supports unicode characters, which isn't quite easy. Some registry modifications might be necessary.
New fonts can be added by the windows registry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont". Once you created a new key with the value of the font there, you can select it as font in the properties window, i posted above. Not all fonts were working and only few fonts really support many unicodes. I found "DejaVu Sans mono" pretty suitable.
But then it still doesn't work. Because Java uses the system default character set, by starting a new JRE. So you need to set the JRE encoding, too.
In the end, this is how it works:
If your plugin contains special characters inside of the code, make sure you use UTF-8 when exporting your plugin JAR. This mostly can be set by the project settings of your IDE.
E.g. Eclipse: Project properties -> Resource -> Text file encoding.
Execute "chcp 65001" before you start your server in the same terminal.
Add "-Dfile.encoding="UTF-8"" as JRE startup parameter to set the Java Encoding
E.g. complete server start command: "%JAVA_HOME%"\Java.exe -Dfile.encoding="UTF-8" -jar -Xmx2G -Xms512M spigot-1.11.2.jar
this.getLogger().info("Want some unicodes??? Here you go:");