NullPointer Without Visible Cause (Help Appreciated)

Discussion in 'Plugin Development' started by Code0, Aug 4, 2014.

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

    Code0

    StackTrace (Error caused in ListenersYHG at line 251):
    Code:
    [18:01:02 ERROR]: Could not pass event PlayerQuitEvent to YetiHG v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerList.disconnect(PlayerList.java:307) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:705) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:130) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    Caused by: java.lang.NullPointerException
        at com.Code0.YetiHG.Main.ListenersYHG.onPlayerQuit(ListenersYHG.java:251) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.6.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[?:1.6.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[?:1.6.0_65]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[?:1.6.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        ... 11 more
    
    ListenersYHG Full IF Statement which contains line 251:
    Code:java
    1. if(plugin.totalPlayers == 1){
    2. Bukkit.getServer().broadcastMessage(ChatColor.GOLD + "[HG] " + ChatColor.RED + event.getPlayer().getName() + ChatColor.BLUE + " bugged out!");
    3. Bukkit.getServer().broadcastMessage(ChatColor.GOLD + "[HG] " + ChatColor.BLUE + "A bug managed to break the round... We're sorry about the inconvenience this may cause. Please message an admin/developer as fast as possible. You will receive rewards.");
    4. Line 251 -> methods.removePlayer(event.getPlayer(), false);
    5. methods.addToConfigList(event.getPlayer());
    6. methods.endRound();
    7. return;
    8. }

    MethodsYHG's removePlayer method:
    Code:java
    1. public void removePlayer(Player player, boolean isOnline){
    2. if(isOnline == false){
    3. plugin.totalPlayers --;
    4. plugin.joinedPlayers.remove(player.getName());
    5. return;
    6. }else if(isOnline == true){
    7. plugin.totalPlayers --;
    8. plugin.joinedPlayers.remove(player.getName());
    9. player.teleport(new Location(player.getWorld(), 0, 67, 0));
    10. player.setHealth(20.0);
    11. player.setFoodLevel(20);
    12. return;
    13. }
    14. }


    So yea :p I can't figure out why it's throwing that NullPointer... Got the problem for days now.

    Thanks for any help!
     
  2. Offline

    hugokk

    It appears to be your field 'methods' is null, since the exception does not point further to the class where the removePlayer method is in.
     
  3. Offline

    Code0

    I have thought about that, but it isn't. I even checked with a if condition and a sysout... hugokk

    (Anyone else very welcome to comment)
     
  4. Offline

    fireblast709

    Code0 paste the full class. I would like to see where you initialize it then :3
     
  5. Offline

    Code0

    fireblast709 I figured it out. It's just some detail about which class you initialize first. :p

    Now I'm getting stupid errors again....

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    _Filip

    We can't help you if you don't say what errors......................
     
  7. Offline

    hugokk

    Code0 Please post your errors and code if you are having trouble
     
Thread Status:
Not open for further replies.

Share This Page