I am beyond confused why this is throwing errors. It throws an error at this line: Code: listen.infract(args[0]); Integer.parseInt(args[1], listen.pointamount); listen is my listener, and infract is a method. Here is the method: Code: public void infract(String s){ if(Bukkit.getServer().getPlayer(s) != null){ namedplayer = Bukkit.getServer().getPlayer(s); stupidity.put(namedplayer, pointamount); if(plugin.admin != null){ plugin.admin.sendMessage(ChatColor.GREEN + namedplayer.getDisplayName() + " had " + pointamount + " point(s) added to their infraction level."); if(plugin != null){ if(pointamount >= 0){ namedplayer.sendMessage(ChatColor.RED + "You had " + pointamount + " point(s) added to your infraction level."); namedplayer.sendMessage(ChatColor.RED + "Your current infraction level is " + stupidity.get(namedplayer)); namedplayer.sendMessage(ChatColor.RED + "Get to 100 points and you'll be banned."); } if(pointamount < 0){ namedplayer.sendMessage(ChatColor.GREEN + "You had points removed from your infraction level! Good job!"); namedplayer.sendMessage(ChatColor.GREEN + "Your current infraction level is " + stupidity.get(namedplayer)); } } else{ plugin.admin.sendMessage(ChatColor.RED + "Please specifiy a value."); } plugin.getConfig().set(namedplayer.getName(), stupidity.get(namedplayer)); } } else{ if(plugin.admin != null){ plugin.admin.sendMessage(ChatColor.RED + "The player could not be found! Are they online?"); plugin.admin.sendMessage(ChatColor.RED + "If this is an error, please contact KaiBB or an admin."); } else{ plugin.log.severe("The player could not be found! Are they online?"); plugin.log.severe(ChatColor.RED + "If this is an error, please contact KaiBB or an admin."); } } }
Quidam If you want me to guess, there is ArrayIndexOutOfBoundsException, NumberFormatException or NullPointerException... If you want a solution, post the actual stacktrace
Code: [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'infract' in plugin Infraction v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186) at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:514) at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:979) at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:897) at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:852) at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44) at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290) at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112) at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39) at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30) at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598) at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224) at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494) at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849) Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at kai.infraction.Main.onCommand(Main.java:56) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ... 15 more
WOW. Thanks! I totally forgot about that xD fireblast709 It throws a NullPointerException for: Code: if(Bukkit.getServer.getPlayer(plugin.admin.getName()) != null){ Bump. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
fireblast709 Stacktrace from console: Code: [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'infract' in plugin Infraction v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186) at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:514) at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:979) at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:897) at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:852) at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44) at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290) at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112) at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39) at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30) at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598) at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224) at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494) at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427) at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849) Caused by: java.lang.NullPointerException at kai.infraction.EventListener.infract(EventListener.java:40) at kai.infraction.Main.onCommand(Main.java:56) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ... 15 more The section of EventListener that contains line 40: Code: public void infract(String s){ if(Bukkit.getServer().getPlayer(s) != null){ namedplayer = Bukkit.getServer().getPlayer(s); stupidity.put(namedplayer, pointamount); if(Bukkit.getServer().getPlayer(plugin.admin.getName()) != null){ plugin.admin.sendMessage(ChatColor.GREEN + namedplayer.getDisplayName() + " had " + pointamount + " point(s) added to their infraction level."); if(plugin != null){ if(pointamount >= 0){ namedplayer.sendMessage(ChatColor.RED + "You had " + pointamount + " point(s) added to your infraction level."); namedplayer.sendMessage(ChatColor.RED + "Your current infraction level is " + stupidity.get(namedplayer)); namedplayer.sendMessage(ChatColor.RED + "Get to 100 points and you'll be banned."); } if(pointamount < 0){ namedplayer.sendMessage(ChatColor.GREEN + "You had points removed from your infraction level! Good job!"); namedplayer.sendMessage(ChatColor.GREEN + "Your current infraction level is " + stupidity.get(namedplayer)); } } else{ plugin.admin.sendMessage(ChatColor.RED + "Please specifiy a value."); } plugin.getConfig().set(namedplayer.getName(), stupidity.get(namedplayer)); } } else{ if(plugin.admin != null){ plugin.admin.sendMessage(ChatColor.RED + "The player could not be found! Are they online?"); plugin.admin.sendMessage(ChatColor.RED + "If this is an error, please contact KaiBB or an admin."); } else{ plugin.log.severe("The player could not be found! Are they online?"); plugin.log.severe(ChatColor.RED + "If this is an error, please contact KaiBB or an admin."); } } } NOTE: Line 40 is Code: if(Bukkit.getServer().getPlayer(plugin.admin.getName()) != null){ The section of Main that contains line 56: Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ if(cmd.getName().equalsIgnoreCase("infract")){ if(sender instanceof Player){ admin = (Player)sender; listen.infract(args[0]); if(args.length > 0){ Integer.parseInt(args[1], listen.pointamount); } } else{ admin = null; } return true; } if(cmd.getName().equals("infractionlevel")){ if(sender instanceof Player){ Player p = (Player)sender; if(listen.stupidity.get(p) != null){ p.sendMessage(ChatColor.GOLD + "Your infraction level is " + listen.stupidity.get(p) + "."); } else{ p.sendMessage(ChatColor.GOLD + "Your infraction level is 0."); } } else{ log.severe(ChatColor.RED + "This command can only be used by players."); } } return false; } NOTE: Line 56 is Code: listen.infract(args[0]);
plugin is defined only once, and it is set as the class Main. So it's not plugin. That leaves admin to be null, but how can CommandSender be null?
I'm putting my commands in the Main, not a CommandExecutor. Wait, I just realized I haven't registered the commands in onEnable. Could that be what's throwing a NullPointerException? fireblast709 Registered them in onEnable(). No change in the errors. EDIT by Moderator: merged posts, please use the edit button instead of double posting.