Hello, A guy who downloaded my plugin has errors with every command that's using chatcolor! Error: Code (Java): 19.05 19:34:24 [Server] [Informatie] Fetching all due players... 19.05 19:34:26 [Server] [Informatie] Fetched due players (0 found). 19.05 19:34:27 [Server] [Informatie] redstoneronald issued server command: /kingdom 19.05 19:34:28 [Server] [Informatie] [Zwerver] Christophe6: ok w8 ff 19.05 19:34:30 [Server] [Informatie] redstoneronald issued server command: /kingdom help 19.05 19:34:33 [Server] [Informatie] CONSOLE issued server command: /list 19.05 19:34:33 [Server] [Informatie] Default: [Member] Christophe6 19.05 19:34:33 [Server] [Informatie] oheldaria: [Owner][Eldaria][Hertog] redstoneronald 19.05 19:34:34 [Server] [Informatie] Christophe6 issued server command: /kingdom create Christophia 19.05 19:34:42 [Server] [Informatie] Christophe6 issued server command: /kingdom create Christopia 19.05 19:34:42 [Server] ERROR null 19.05 19:34:42 [Server] [Informatie] org.bukkit.command.CommandException: Unhandled exception executing command 'kingdom' in plugin Kingdom v1.0 19.05 19:34:42 [Server] [Informatie] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] Caused by: java.lang.NoClassDefFoundError: net/md_5/bungee/api/ChatColor 19.05 19:34:42 [Server] [Informatie] at me.christophe6.kingdom.KingdomCommand.onCommand(KingdomCommand.java:67) ~[?:?] 19.05 19:34:42 [Server] [Informatie] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] ... 15 more 19.05 19:34:42 [Server] [Informatie] Caused by: java.lang.ClassNotFoundException: net.md_5.bungee.api.ChatColor 19.05 19:34:42 [Server] [Informatie] at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:42 [Server] [Informatie] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_91] 19.05 19:34:42 [Server] [Informatie] at me.christophe6.kingdom.KingdomCommand.onCommand(KingdomCommand.java:67) ~[?:?] 19.05 19:34:56 [Server] Skipped 2 lines due to rate limit (30/s) 19.05 19:34:56 [Server] [Informatie] Christophe6 issued server command: /kingdom removemember Christophe6 19.05 19:34:56 [Server] ERROR null 19.05 19:34:56 [Server] [Informatie] org.bukkit.command.CommandException: Unhandled exception executing command 'kingdom' in plugin Kingdom v1.0 19.05 19:34:56 [Server] [Informatie] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:620) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1106) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:966) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:37) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(SourceFile:9) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_91] 19.05 19:34:56 [Server] [Informatie] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_91] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91] 19.05 19:34:56 [Server] [Informatie] Caused by: java.lang.NoClassDefFoundError: net/md_5/bungee/api/ChatColor 19.05 19:34:56 [Server] [Informatie] at me.christophe6.kingdom.KingdomCommand.onCommand(KingdomCommand.java:175) ~[?:?] 19.05 19:34:56 [Server] [Informatie] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cb1.8.jar:git-Bukkit-18fbb24] 19.05 19:34:56 [Server] [Informatie] ... 15 more My code: Code (Java): import net.md_5.bungee.api.ChatColor; //LINE 67 MessageManager.getInstance().good(player, "You've made a new kingdom called: " + args[1].toLowerCase() + ChatColor.GREEN + "!"); //LINE 175 MessageManager.getInstance().good(player, "You've removed a player from the kingdom: " + KingdomHandler.getInstance().getKingdom(player) + ChatColor.GREEN + "!"); MY MESSAGEMANAGER: Code (Java): package me.christophe6.kingdom; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class MessageManager { public static MessageManager instance = new MessageManager(); public static MessageManager getInstance() { return instance; } public String prefix = ChatColor.GREEN + "[" + ChatColor.AQUA + "Kingdom" + ChatColor.GREEN + "]"; public void severe(Player player, String string) { player.sendMessage(prefix + ChatColor.RED + " " + string); } public void info(Player player, String string) { player.sendMessage(prefix + ChatColor.YELLOW + " " + string); } public void good(Player player, String string) { player.sendMessage(prefix + ChatColor.GREEN + " " + string); } public void msg(String string) { for(Player player : Bukkit.getServer().getOnlinePlayers()) { player.sendMessage(prefix + ChatColor.AQUA + " " + string); } } } He uses bungeecord, but the plugin is running on a connected server.
You're using the wrong import. You don't want to use net.md_5.bungee.api.ChatColor;, but dev.bukkit.ChatColor or something.
As the two replies before me mentioned, its your import. You are using a class that is not in CraftBukkit servers. Its only in Spigot. Change your import to the Bukkit version and your plugin will become compatible with CraftBukkit servers again. Unless you use other Spigot only features, too.
I don't think you're understanding. The md_5 import is for servers running Spigot. The reason there's an error is because the user was running CraftBukkit rather than Spigot. net.md_5.bungee.api.ChatColor does not exist in the Bukkit API
That is not API based. What if Minecraft changes their ways to reference colors in the new 1.10 snapshots? What if all of a sudden section symbols are not supported in the API anymore? That's why you SHOULD use the API over section symbols. There's no guarantee that it will work in a future version, but ChatColor will always be there
It's not an API because Mojang might change it. They probably never will change it. The reason you should NEVER past the section symbol into your code is because it's a unicode character based on a specific charset encoding (aka, locale). If you compile your plugin on Windows you are most likely compiling with the CP-1252 charset. This means your plugin is now dependent on that specific charset to display/use those characters. If someone was to put your plugin on a Linux or Mac server then they wont see the section symbol. They will see whatever encoding their host is set to. Most commonly you will see your section symbols turn into » looking symbol which completely breaks your colors and just looks horrible. If you had 100% control over the host server's locale this would not be a problem, however you have no control over it at all. Even if you use UTF8 encoding when you compile your plugin there is no 100% guarantee it will not have issues. It is best to use the proper unicode escape code so the end host will end up using the exact symbol you want it to. The internals of ChatColor do this for you automatically and are highly advised to use because of this. Here is a fine example on how to use ChatColor class in a very dynamic way. Code (Text): ChatColor.translateAlternateColorCodes('&', "&4Red Text."); With this code you can use & symbol (which all charsets parse the same) for your color codes. ChatColor will "translate" that & symbol into the correct escaped unicode for the section symbol for you. You dont have to use the & symbol here. You can use anything you want. But remember that 99.9% of users are already accustomed to using the & symbol from using other plugins that take this approach. If for some reason you are seriously hellbent on NOT using the ChatColor class for some odd ass reason.. Then you can use other techniques that do not require using the unicode symbol itself. Like regex: Code (Text): "&Red Text.".replaceAll("(?i)&([a-f0-9k-or])", "\u00a7$1"); This is a safe way to "translate" the & symbol into the escaped unicode section symbol. There are better, more efficient ways to use regex, but this works decently for it's purpose (as long as you are not parsing 1,000,000 colored strings per second). I see a lot of people doing something like this: Code (Text): "&4Red Text.".replace("&", "\u00a7"); But this is WRONG and will break chats that use the & symbol as a real & symbol, like "Billy & Bob's Market". So, to save yourself from headaches, just use the damn ChatColor class. It was provided to you in the API for a good reason, even if you dont understand that reason. Thank you for reading ^_^ Now I can call you ignorant if you still choose to put unicode symbols directly into your code and break servers. Edit: Sorry, @Christophe6 , for hijacking your thread. I just had to straighten something out