Solved org.bukkit.command.CommandException: Unhandled exception executing command

Discussion in 'Plugin Development' started by GxDD, Jan 2, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    GxDD

    I cannot think of any solution. Can you please help me? Error log:
    Error Log (open)

    [WARNING] Unexpected exception while parsing console command "newpoint"
    org.bukkit.command.CommandException: Unhandled exception executing command 'newpoint' in plugin Checkpoint v0.0.1-SNAPSHOT
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:140) ~[craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:628) ~[craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:614) [craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:408) [craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:372) [craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:651) [craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:555) [craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
    Caused by: java.lang.NullPointerException
    at me.alluseri.checkpoints.Checkpoint.Checkpoint.onCommand(Checkpoint.java:26) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit-1.12.2.jar:git-Bukkit-2b93d83]
    ... 8 more

    and Eclipse doesn't show any errors.
    I don't want to share my code because it has Russian in it and probably you guys won't understand anything.
     
  2. Offline

    Zombie_Striker

    @GxDD
    1. Method names are still the same, even if variable names are different. We should still be able to understand that code.
    2. The issue is that one of the objects on line 26 is null. Since I do not know what line 26 is, I'd recommend you go through and null-check each of the objects called on that line. Once you find the object that is null, either review your code to figure out why it is null, or add a check beforehand to only run the problematic code if the object is not null.
     
  3. Offline

    GxDD

    Okay, thank you, I'll try right now
    But what could be null there:
    Location loc = Bukkit.getServer().getPlayer(sender.getName()).getLocation();
    Plus, it's happening on every command, not even not in "newpoint"(command I executed in logs), but in "tphere" or "rempoint".
     
    Last edited: Jan 3, 2019
  4. Offline

    knokko

    @GxDD

    Theoretically, the objects that can be null are:
    -the result of Bukkit.getServer()
    -the result of getServer().getPlayer(sender.getName())
    -sender

    I had say that case 2 is the most likely, but doesn't make much sense either. This would definitely cause a NullPointerException when the sender is not a player (but console or command block).
    However, it should work when the sender is indeed a player.

    If you want to debug properly, add the following lines before that line:
    System.out.println("server is " + Bukkit.getServer());
    System.out.println("sender is " + sender);
    System.out.println("player is " + Bukkit.getServer().getPlayer(sender.getName()));

    Share the results with us (or solve it yourself if you can)
     
  5. Offline

    GxDD

    Thank you, I fixed it with your help!!!
     
Thread Status:
Not open for further replies.

Share This Page