Respawn Event Console Spam Error

Discussion in 'Spigot Plugin Development' started by EnSun580, May 23, 2015.

  1. I'm pretty sure I'm just missing a check for something, but I have no idea what it is :(
    Here's the code and the console error. (Yes, I've registered the event in the main class).

    Code (Text):
        @EventHandler
        public void onRespawn(PlayerRespawnEvent e) {
            Player p = e.getPlayer();
            World world = (World) p.getWorld();
            double x = plugin.getConfig().getDouble("spawn.x");
            double y = plugin.getConfig().getDouble("spawn.y");
            double z = plugin.getConfig().getDouble("spawn.z");
            float yaw = (float) plugin.getConfig().getDouble("spawn.yaw");
            float pitch = (float) plugin.getConfig().getDouble("spawn.pitch");
            Location spawn = new Location(world, x, y, z, yaw, pitch);
            e.setRespawnLocation(spawn);
        }
    Code (Text):

    [23:36:23 ERROR]: Could not pass event PlayerRespawnEvent to KitPvP v0.1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:302) ~[spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:509) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:494) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PlayerList.moveToWorld(PlayerList.java:5
    21) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PlayerList.moveToWorld(PlayerList.java:4
    60) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java
    :1239) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PacketPlayInClientCommand.a(SourceFile:5
    0) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PacketPlayInClientCommand.handle(SourceF
    ile:8) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186
    ) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java
    :81) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:7
    34) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    Caused by: java.lang.NullPointerException
            at me.ensun.listeners.DeathListener.onRespawn(DeathListener.java:42) ~[?
    :?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _51]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _51]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_51]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:298) ~[spigot-patched.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            ... 15 more
     
  2. Which one is line 42? :D

    Edit: Also, do all of those config keys exist in the config.yml in your plugins/<PluginName> folder?
     
  3. Line 42 would be
    Code (Text):
            double x = plugin.getConfig().getDouble("spawn.x");
     
  4. I'm going to assume getConfig() isn't null, in which case I'm curious if the config.yml in the plugin folder has the key "spawn.x"

    Edit: I'm also assuming you correctly initialized the plugin variable too xD
     
    • Friendly Friendly x 1
  5. [​IMG]
     
  6. There's no error upon /spawn command, which leads to the same place.
     
  7. Fuck me, I'm stupid. I forgot I had changed a variable. Think I've fixed myself :) Thanks for trying @iPyronic
     
    • Funny Funny x 1
  8. Haha, sorry I wasn't much help ;D