Hello, I got a problem with this script: Code:java ]package Main; import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.event.Listener;import org.bukkit.plugin.Plugin;import org.bukkit.plugin.java.JavaPlugin; public class main extends JavaPlugin implements Listener{ public void onEnable() { getConfig().options().copyDefaults(true); saveConfig(); Bukkit.getServer().getPluginManager().registerEvents(this, this); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() { public void run() { for (Player p : Bukkit.getServer().getOnlinePlayers()) { String l = p.getPlayerListName(); int lx = getConfig().getInt(l + ".exlevel"); String le = getConfig().getString(l + ".Level"); p.setCustomName(le); p.setExp(lx); } } }, 0, 20);} public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player p = (Player) sender; if (!(sender instanceof Player)) { sender.sendMessage("You have to be online."); return true; } if (cmd.getName().equalsIgnoreCase("xs")) { if(args.length == 0){ p.sendMessage(ChatColor.GREEN + "Use /xs help"); return true; }if(args.equals("help")){ p.sendMessage("todo"); return true; }if(args[0].equals("add")){ if(args[1].equals("level")){ if(Bukkit.getPlayer(args[2]).isOnline()){ if(isInt(args[3])){ String le = getConfig().getString(p + ".Level"); getConfig().set(le, le + args[2]); return true; } } } } } return true; } public boolean isInt(String str) { try { Integer.parseInt(str); return true; } catch (NumberFormatException e) { return false; } } } The error: Code: org.bukkit.command.CommandException: Unhandled exception executing command 'xs' in plugin Xpsystem v0.1 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_60] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_60] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:714) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556) [spigot_server.jar:git-Spigot-fdc1440-53fac9f] at java.lang.Thread.run(Unknown Source) [?:1.8.0_60] Caused by: java.lang.IllegalArgumentException: Cannot set to an empty path at org.apache.commons.lang.Validate.notEmpty(Validate.java:321) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] at org.bukkit.configuration.MemorySection.set(MemorySection.java:163) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] at Main.main.onCommand(main.java:50) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot_server.jar:git-Spigot-fdc1440-53fac9f] ... 15 more Code: name: Xpsystem main: Main.main version: 0.1 author: Magicdutchcraft commands: xs: description: Xpsystemcommand usage: /<command> Bart
@kingsofbart getConfig().set(le, le + args[2]); le = null, or at least not usable. Please use naming conventions, let variable names tell what they contain. Use a different main, you will get into trouble with that very fast. Use p.getName() or p.getUniqueUid().toString() instead of using it directly in strings. Check if the args is long enough
@kingsofbart On line 50, you are trying to grab a string called "Level" that is under the player's name. Are you sure this string exists ? Where the error says "cannot set to an empty path" that is because the variable LE is null. Always implement checks on your code. Code: if(le == null) { getLogger().info("Couldn't grab the required string! Aborting ... "); return false; }
Don't use Code: if (args.equals(/*string/*) { //Stuff } Instead, use Code: if (args[/*argument number you want to check*/].equalsIgnoreCase(/*string*/)) { //do stuff }