I don't know what's wrong.. Code: 2012-01-29 23:50:41 [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'n' in plugin ServerNews v1.3 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:386) at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:777) at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:737) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:725) at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:33) at net.minecraft.server.NetworkManager.b(NetworkManager.java:226) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:100) at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:536) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:434) at net.minecraft.server.ThreadServerApplication.run(SourceFile:465) Caused by: java.lang.NullPointerException at me.edocsyl.ServerNews.ServerNews.onCommand(ServerNews.java:249) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40) ... 12 more I have the same code onPlayer join, there it works.. Source: https://github.com/Edocsyl/ServerNews/blob/master/src/me/edocsyl/ServerNews/ServerNews.java#L250 Nobody who can say me, why i become this error? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
two things that might be the problem: first: it will give you a nullpointerexception every time you use the console, because p will still be null when it's not an instance of the player. second: did you define news and n in the plugin.yml?
Slayer9x9 The Plugin.yml https://github.com/Edocsyl/ServerNews/blob/master/plugin.yml kumpelblase2 What should i take ? Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ Player p = null; if (sender instanceof Player) { p = (Player) sender; }
i would place the code INSIDE the if. Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args{ { if (sender instanceof Player) { Player p = (Player)sender; // rest of the code here } }
Can you post current code? In plugin.yml you dont need a separate command for aliases. You can do this Code: commands: servernews: description: Main Command with args. aliases: [sn] usage: | /sn <values> -- Main Command with args. news: description: Main Command with args. aliases: [n] usage: | /news <values> -- Main Command with args.
Yurij Here it is: https://github.com/Edocsyl/ServerNews kumpelblase2 Code: 2012-01-31 17:14:54 [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'news' in plugin ServerNews v1.3 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168) at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:386) at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:777) at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:737) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:725) at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:33) at net.minecraft.server.NetworkManager.b(NetworkManager.java:226) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:100) at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78) at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:536) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:434) at net.minecraft.server.ThreadServerApplication.run(SourceFile:465) Caused by: java.lang.NullPointerException at me.edocsyl.ServerNews.ServerNews.onCommand(ServerNews.java:258) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40) ... 12 more The same
Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("This command can be only used in-game!"); return true; }
is the line 258 on github the same as your line 258, but i have no idea why cmd.getName().equalsIgnoreCase("news") could throw a nullpointerexception if you declared it in the plugin.yml like Yurij did....
the change I suggested of the plugin.yml shouldn't have solved anything. If the commands only should be used ingame and not in the console you should check Jozeth's answer above.
I changed this from Jozeth but there is still the same eroor.. Is ths if (cmd.getName().equalsIgnoreCase("news")) { } Maby this (red) is the problem.. i change to sender, it dont print out the content but the Commentar in the *plugin.yml* file...
The special thing is.. Code: /sn /sn toggle this works If i make Code: /sn n /sn news this don't works.. maby the content is incorrect, but i use the same content in the player join listener class and it works..
A other thing.. If i make it so: Code: if (cmd.getName().equalsIgnoreCase("news")) { p.sendMessage(this.plugin.strPhpHeader.replaceAll("(?i)&([a-f0-9])", "\u00A7$1")); return true; } i got an error If i make it so: Code: if (cmd.getName().equalsIgnoreCase("news")) { p.sendMessage(strPhpHeader.replaceAll("(?i)&([a-f0-9])", "\u00A7$1")); return true; } i dont get the error
This was the problem : Code: this.plugin. Does anyone know why this makes an error? Maybe would be very helpfully for other programmer too. Yurij without "this.plugin" i don't get any errors!
in your case, since you only use things in you main class, you don't need it. but come on, if you don't know how you set a value LEARN SOME JAVA.