Error with player interact event

Discussion in 'Spigot Plugin Development' started by dyenxunit, Jun 20, 2015.

  1. So what i was trying to do is to check if the player is wearing a specific skull and if they are when they are sneaking they will open a gui but i have ran into an error i have redone the code and in my second try i got the error.
    [/SPOILER]

    Code (Text):
    Could not pass event PlayerInteractEvent to TestPlugin v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:226) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:193) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:189) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:682) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:50) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:80) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_65]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_65]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:683) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [spigot.jar:git-Spigot-952179b-bc03b6f]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_65]
    Caused by: java.lang.NullPointerException
        at me.dyenxunit.main.addon.Main.HelmetEvent(Main.java:27) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_65]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-952179b-bc03b6f]
        ... 17 more
     
     
    #1 dyenxunit, Jun 20, 2015
    Last edited: Jun 20, 2015
  2. Read the stacktrace.
    Line 27 in class Main.

    You need to check if the player even has a helmet before checking it's metadata.