Development Assistance Really weird NPE

Discussion in 'Plugin Help/Development/Requests' started by Ziron5, Mar 15, 2015.

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

    Ziron5

    Hi folks! :)

    I'll make it quick. I get a bunch of NullPointerExceptions when triggering my method chain wich is like the following:

    onBlockPlaceGame() is the Event Listener
    identifier() takes the data from the Listener and checks if the placed block has to trigger an Action.
    blockAction() takes the data from the identifier and decides wich action the block has to trigger.

    If a block triggers and action is stored in a yml file. The identifier compares the coordinates of a placed block with all coordinates in the yml file.


    The blockAction() method now invokes a method outside of the EventListener Class.
    Now the weir thing is I get a NPE at every line where one method calls the next. And the source of the error is the part where blockAtion() invokes a method in a different Class.
    This is the part of the blockEventListener Class where the 3 Methods mentioned above are in:

    http://pastebin.com/2uDYCVFD


    Now look at line 58 . The Method callTimer(args) from the TimerClass is called.

    This is the callTimer() method:
    http://pastebin.com/uhEW6DUZ
    Notice the systemOutPrint lines. I inserted them to debug the code. You can see the messages in the following stacktrace and notice that 3 of them are null. Why? How can this be? I just passed the Strings that callTimer() needs directly in line 58:

    Code:
    TimerClass.callTimer(p, "Red", "base", world.getName());
    Why isn't the debug message showing "Red", "base" and the world name? It works with the player name (Ziron5) wich is even more confusing?

    (The line numbers in the stacktrace aren't correct since I didn't paste the whole class to pastebin.)
    Stacktrace (open)

    Code:
    [12:50:00] [Server thread/INFO]: TEST
    [12:50:00] [Server thread/INFO]: Ziron5
    [12:50:00] [Server thread/INFO]: null
    [12:50:00] [Server thread/INFO]: null
    [12:50:00] [Server thread/INFO]: null
    [12:50:00] [Server thread/ERROR]: Could not pass event BlockPlaceEvent to ColorKeyBattle v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[start.jar:git-Spigot-952179b-43207df]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[start.jar:git-Spigot-952179b-43207df]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [start.jar:git-Spigot-952179b-43207df]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [start.jar:git-Spigot-952179b-43207df]
        at org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callBlockPlaceEvent(CraftEventFactory.java:125) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.ItemStack.placeItem(ItemStack.java:154) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.PlayerInteractManager.interact(PlayerInteractManager.java:503) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:724) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:50) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:80) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [start.jar:git-Spigot-952179b-43207df]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_40]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:685) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [start.jar:git-Spigot-952179b-43207df]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526) [start.jar:git-Spigot-952179b-43207df]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
    Caused by: java.lang.NullPointerException
        at org.Ziron5.main.TimerClass.callTimer(TimerClass.java:34) ~[?:?]
        at org.Ziron5.main.BlockEventListener.blockAction(BlockEventListener.java:220) ~[?:?]
        at org.Ziron5.main.BlockEventListener.identifier(BlockEventListener.java:189) ~[?:?]
        at org.Ziron5.main.BlockEventListener.onBlockPlaceGame(BlockEventListener.java:161) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[start.jar:git-Spigot-952179b-43207df]
        ... 17 more


    Can someone help me out on this? Thanks in advance!

    mfg


    Ziron5
     
  2. Offline

    Lolmewn

    colors = color;
    spawner = spawner;
    worlds = world;

    That's what you have in your TimerClass. Probably color, spawner and world are null and should be turned around.
     
    Ziron5 likes this.
  3. Offline

    Ziron5

    Thank you so much! ^^ I am not a smart man! It was so simple I coudn't see it xD Thanks man!
     
  4. Offline

    Lolmewn

    And that's why I always use "this.x = x" where this is a pointer to the current class and its variables :) Can never go wrong.
     
    Ziron5 likes this.
Thread Status:
Not open for further replies.

Share This Page