Bit of a noob

Discussion in 'Plugin Development' started by Jamwalle, Apr 5, 2014.

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

    Jamwalle

    So this is the code[​IMG] for setting a warp and then doing it

    Code:
    if (label.equalsIgnoreCase("SetWarp")) {
    getConfig().set("Warp.World", p.getLocation().getWorld());
    getConfig().set("Warp.X", p.getLocation().getX());
    getConfig().set("Warp.Y", p.getLocation().getY());
    getConfig().set("Warp.Z", p.getLocation().getZ());
     
    p.sendMessage(ChatColor.GREEN
    + "The Warp has been set!");
    return true;
    }
     
    if (label.equalsIgnoreCase("Warp")) {
    World W = Bukkit.getServer().getWorld(
    getConfig().getString("Warp.World"));
    double X = getConfig().getDouble("Warp.X");
    double Y = getConfig().getDouble("Warp.Y");
    double Z = getConfig().getDouble("Warp.Z");
    p.teleport(new Location(W, X, Y, Z));
    }
    
    Btw the class and package were called 'idk' cus i made a new one to show it was just this and not the rest of my plugin. I also made a new server so this is the only plugin on there.
    The console error is
    [09:06:06 INFO]: jamwalle issued server command: /warp
    [09:06:06 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'warp
    ' in plugin idk v1.0.o
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    2) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:542) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:930) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :812) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    .java:47) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    51) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    41) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :453) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    Caused by: java.lang.NullPointerException
    at org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer.teleport(CraftPlaye
    r.java:455) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity.teleport(CraftEntit
    y.java:200) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    at me.jamwalle.idk.idk.onCommand(idk.java:45) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Bukkit-1.6.4-R2.0-26-g31d7c5f-b2943jnks]
    ... 13 more

    And I think that this part 'at me.jamwalle.idk.idk.onCommand(idk.java:45) ~[?:?]' is important (but idk) Line 45 is 'p.teleport(new Location(W, X, Y, Z));' So I think there is something wrong with that line.

    The set warp works (and without that the teleporting doesnt work anyway, i tried it where X, Y and Z were all zero)
    It comes up with this error whenever i try to teleport with that code http://gyazo.com/dbe4625e148875c9a26ba74d88e9f306
    I've checked the code with other people in vids and stuff and it looks pretty much the same :p So if u know why then I'd appreciate some help, Thanks.
     
  2. Offline

    xXSniperzzXx_SD

    Jamwalle
    When you save the locations in the config, print out the values to make sure they are setting, and if that doesn't work you should probably try saving the file after setting the x,y,z, and world :p
     
  3. Offline

    Jamwalle

    Ok thanks I'll try that :D
     
Thread Status:
Not open for further replies.

Share This Page