Development Assistance Help with an Exception?

Discussion in 'Plugin Help/Development/Requests' started by GODofCRAFTERS, Apr 13, 2015.

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

    GODofCRAFTERS

    I can't seem to figure out what this exception means:
    Code:
    org.bukkit.command.CommandException: Unhandled exception executing command 'reqt
    p' in plugin Requests v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
    0) ~[craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServe
    r.java:625) ~[craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:1058) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java
    :919) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(SourceFile:37) [craft
    bukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(SourceFile:9) [craftb
    ukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [cra
    ftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_40]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:6
    56) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:2
    84) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:6
    09) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java
    :517) [craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
    Caused by: java.lang.NullPointerException
            at org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer.teleport(CraftPlaye
    r.java:464) ~[craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity.teleport(CraftEntit
    y.java:223) ~[craftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            at me.requests.req.onCommand(req.java:187) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit-1.8-R0.1-SNAPSHOT.jar:git-Bukkit-33d5de3]
            ... 14 more
    The code at line "187" is player.teleport(loc);
    loc is a user created Location variable.
     
  2. Offline

    Monkey_Swag

    Post your code.
     
  3. Offline

    GODofCRAFTERS

    @Monkey_Swag
    This is where the error occurs.
    The last line is line 187.
    Code:
                     
                                String[] ls = loc.get(k).split(":", 4);
                              
                                World world = null;
                                Double x = null;
                                Double y = null;
                                Double z = null;
                              
                                try{
                                    world = Bukkit.getWorld(ls[0]);
                                    x = Double.parseDouble(ls[1]);
                                    y = Double.parseDouble(ls[2]);
                                    z = Double.parseDouble(ls[3]);
                                }catch(Exception e) {
                                    e.printStackTrace();
                                }
                              
                                player.teleport(new Location(world, x, y, z));
     
  4. Offline

    Scullyking

    @GODofCRAFTERS
    It's a null pointer exception. So I'd guess either world, x, y or z are null. Which suggests the try caught an error. You should teleport the player inside the catch statement.
     
  5. Offline

    GODofCRAFTERS

    @Scullyking
    @Monkey_Swag

    I changed the code a bit now.
    I'm still getting a null pointer exception...
    Code:
                        
                                String[] ls = loc.get(k).split(":", 4);
                               
                                    World world = Bukkit.getWorld(ls[0]);
                                    double x = Double.parseDouble(ls[1]);
                                    double y = Double.parseDouble(ls[2]);
                                    double z = Double.parseDouble(ls[3]);
                               
                                player.teleport(new Location(world, x, y, z));
    The "loc" is a HashMap which contains everything after the first ":" in the first string under locations:
    Code:
    number: 1
    requests:
    - '1:GODofCRAFTERS:Test Server:test '
    locations:
    - 1:CraftWorld{name=world}:-376.5696007938933:11.0:130.13676530441109
     
  6. Offline

    SuperOriginal

    Save the world's name or its UUID. Not the world object itself.
     
  7. Offline

    GODofCRAFTERS

    done thanks :)
     
    Last edited: Apr 13, 2015
  8. Offline

    Scullyking

    @GODofCRAFTERS
    All you did was remove the try statement which was catching the error. So yes, I'm not surprised you're still getting the error. SuperOriginal is right in suggesting you should save the world UUID (I wouldn't save the name, just incase it changes).
     
  9. Offline

    GODofCRAFTERS

    @Scullyking
    @SuperOriginal

    Wait. It still didn't work. Here's my assignment statements and my execution statement.
    This is how I assigned the values into the HashMap:
    Code:
    loc.put(number + 1, ploc.getWorld().getUID() + ":" + ploc.getX() + ":" + ploc.getY() + ":" + ploc.getZ() + ":" + ploc.getPitch() + ":" + ploc.getYaw());
    Here's how I'm splitting it and teleporting the player:
    Code:
    String[] ls = loc.get(k).split(":", 6);
                              
                                    World world = Bukkit.getWorld(ls[0]);
                                    double x = Double.parseDouble(ls[1]);
                                    double y = Double.parseDouble(ls[2]);
                                    double z = Double.parseDouble(ls[3]);
                                    float pitch = Float.parseFloat(ls[4]);
                                    float yaw = Float.parseFloat(ls[5]);
                              
                                player.teleport(new Location(world, x, y, z, pitch, yaw));
    I'm still getting a NullPointerException at the last line.

    problem solved. a new problem arose though. when the player is teleported to the location, he/she isn't facing the same direction when he/she set the location, how do I do that?

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Apr 13, 2015
  10. Offline

    SuperOriginal

    I faintly remember an issue I had with this a while back. What I did was call Location#setPitch() and Location#setYaw() and I believe that fixed it.
     
Thread Status:
Not open for further replies.

Share This Page