Solved [1.8] Teleporting a Player doesn't work

Discussion in 'Spigot Plugin Development' started by Lane1105, Jan 14, 2018.

  1. I'm trying to make a spawn plugin and when I do /spawn to teleport to the spawn it makes an error
    The teleporting part (p is the player that executed the command):
    Code (Text):

    World world = Bukkit.getWorld(cfg.getString("spawn.X"));
    double x = cfg.getDouble("spawn.X");
    double y = cfg.getDouble("spawn.Y");
    double z = cfg.getDouble("spawn.Z");
    float pitch = (float) cfg.getDouble("spawn.Pitch");
    float yaw = (float) cfg.getDouble("spawn.Yaw");
    Location spawn = new Location(world, x, y, z, yaw, pitch);
    p.teleport(spawn);
     
    The error:
    Code (Text):

    [07:18:58 INFO]: LaneHD issued server command: /spawn
    [07:18:58 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'spawn' in plugin Spawn v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_151]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_151]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
    Caused by: java.lang.NullPointerException
            at org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer.teleport(CraftPlayer.java:464) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity.teleport(CraftEntity.java:223) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            at ch.lanehd.lobby.commands.SpawnCmd.onCommand(SpawnCmd.java:30) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.jar:git-Spigot-550ebace-7019900e]
            ... 14 more
     
    I know that it is the teleporting part because if I make it a comment it obviously doesn't teleport me but no error happens
     
  2. World world = Bukkit.getWorld(cfg.getString("spawn.X"));
     
    • Agree Agree x 2
  3. Thank you
     

Share This Page