I’m trying to split code in classes. This code is sending to console text with B
letter in start of line, but shouldn’t.
Code:
static ConsoleWrapper cw = new ConsoleWrapper(); cw.notify("using url:" + database.sql_url); cw.notify("Plugin loaded!");
in ConsoleWrapper.java
public class ConsoleWrapper { static String pluginName = App.pluginName; static ConsoleCommandSender console = Bukkit.getConsoleSender(); public void notify(String msg) { // wrapper for console messages console.sendMessage(("§6[" + pluginName + "]" + msg)); } public void alarm(String msg) { // wrapper for console messages console.sendMessage(("§c[" + pluginName + "]" + msg)); } }
but if console.sendMessage(("§c[" + pluginName + "]" + msg));
executing in main class, letter B
doesn’t appeat in console.
output with
cw.notify
[12:01:07 INFO]: В[EggCounter] Plugin is starting first time, or restoring! [12:01:08 INFO]: В[EggCounter]using url:jdbc:MYSQL://192.168.0.186:9889/easter_eggs
output with
console.sendMessage()
[12:13:21 INFO]: [EggCounter]using url:jdbc:MYSQL://192.168.0.186:9889/easter_eggs [12:13:21 INFO]: [EggCounter]Plugin loaded!
Advertisement
Answer
It’s not recommended to write your own §
because of possible encoding problem.
Prefer use ChatColor
enum, like that:
public class ConsoleWrapper { static String pluginName = App.pluginName; static ConsoleCommandSender console = Bukkit.getConsoleSender(); public void notify(String msg) { // wrapper for console messages console.sendMessage(ChatColor.GOLD + "[" + pluginName + "]" + msg); } public void alarm(String msg) { // wrapper for console messages console.sendMessage(ChatColor.RED + "[" + pluginName + "]" + msg); } }
You can find all color codes here.