Solved What Is Null In THIS Thing? [HELP]

Discussion in 'Plugin Development' started by Ambamore2000, Nov 15, 2014.

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

    Ambamore2000

    Hello, so, I couldn't fix this problem, and if it is a simple fix, I will feel stupid, but anyways, I get a nullpointerexception, and I can't find out what in it is null exactly.

    Error Code:
    Code:
    [16:22:36 ERROR]: Could not pass event BlockBreakEvent to pClasses v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[opprison1.jar:git-Spigot-1622]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[opprison1.jar:git-Spigot-1622]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [opprison1.jar:git-Spigot-1622]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.PlayerInteractManager.breakBlock(PlayerInteractManager.java:264) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.PlayerInteractManager.a(PlayerInteractManager.java:192) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:565) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.PacketPlayInBlockDig.a(SourceFile:53) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.PacketPlayInBlockDig.handle(SourceFile:8) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:184) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [opprison1.jar:git-Spigot-1622]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [opprison1.jar:git-Spigot-1622]
    Caused by: java.lang.NullPointerException
            at com.ambamore2000.pclasses.pClasses.isRanger(pClasses.java:65) ~[?:?]
            at com.ambamore2000.pclasses.pClasses.onChatEvent(pClasses.java:55) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_65]
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_65]
            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:298) ~[opprison1.jar:git-Spigot-1622]
            ... 15 more
    isRanger is a boolean method, and here's what's line 65, and what else is needed:
    Code:java
    1.  
    2. PlayerInventory inv = player.getInventory();
    3. if (inv.getHelmet().equals(new ItemStack(Material.LEATHER_HELMET))

    Here is an event, where I used to test the boolean, but it no work, line 55 and other needed lines:
    Code:java
    1. @EventHandler
    2. public void onChatEvent(BlockBreakEvent e) {
    3. Player p = e.getPlayer();
    4. if (isRanger(p)) {
    5. p.sendMessage("Yes");
    6. } else {
    7. p.sendMessage("No");
    8. }
    9. }
     
  2. Offline

    teej107

    Ambamore2000 Tell me one thing. What if the PlayerInventory doesn't have a helmet? What would that getHelmet() method return?
     
    Ambamore2000 likes this.
  3. Offline

    Ambamore2000

    teej107
    I found that out, and then when I refresh the page, you say it. :p
     
Thread Status:
Not open for further replies.

Share This Page