Search code examples
javabukkit

Print colored log messages


I want to log a message (such as "Enabled!") with some color. So far I have:

public void onEnabled() {
    // Here goes the method to say "Enabled!" colored
}

I have tried:

getLogger().info(ChatColor.GREEN + "Enabled!");

But it doesn't work: it shows as if I didn't add ChatColor.GREEN.


Solution

  • You have to send the message to the console sender:

    Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Enabled!");
    

    So it would be:

    public void onEnabled() {
        Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Enabled!");
    }