Could Not Pass PlayerJoinEvent Error

Discussion in 'Plugin Development' started by Croug, Jun 25, 2013.

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

    Croug

    Im trying to catalog users in a yaml file upon first time joining the server, but it keeps failing to pass the player join event, any help would be appreciated.

    Stack Trace:
    Code:
    2013-06-25 09:58:33 [SEVERE] Could not pass event PlayerJoinEvent to ThisIsNotAPlugin v1.0.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
        at net.minecraft.server.v1_5_R3.PlayerList.c(PlayerList.java:204)
        at net.minecraft.server.v1_5_R3.PlayerList.a(PlayerList.java:100)
        at net.minecraft.server.v1_5_R3.PendingConnection.d(PendingConnection.java:129)
        at net.minecraft.server.v1_5_R3.PendingConnection.c(PendingConnection.java:44)
        at net.minecraft.server.v1_5_R3.DedicatedServerConnectionThread.a(DedicatedServerConnectionThread.java:41)
        at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:29)
        at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:581)
        at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226)
        at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
        at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410)
        at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NullPointerException
        at tk.CalcuProcessing.ThisIsNotAPlugin.PlayerListener.onPlayerLogin(PlayerListener.java:20)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
        ... 14 more
    Listener Class Code:
    Code:java
    1. package tk.CalcuProcessing.ThisIsNotAPlugin;
    2.  
    3. import org.bukkit.entity.Player;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.HandlerList;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.*;
    8.  
    9. public class PlayerListener implements Listener{
    10.  
    11. private Main plugin;
    12.  
    13. public PlayerListener(Main plugin){
    14. plugin.getServer().getPluginManager().registerEvents(this, plugin);
    15. }
    16.  
    17. @EventHandler
    18. public void onPlayerLogin(PlayerJoinEvent evt){
    19. Player player = evt.getPlayer();
    20. if(!plugin.users.contains(player.getDisplayName())){
    21. plugin.users.set(player.getDisplayName() + ".nodrop", plugin.config.get("nodrop-default"));
    22. }
    23. }
    24.  
    25. public void Disable(Main plugin){
    26. HandlerList.unregisterAll(plugin);
    27. }
    28.  
    29. }
    30.  
     
  2. Offline

    caseif


    One of the variables on that line is null. Do some debugging to figure out which one. ;)
     
  3. Offline

    Croug

    The problem is in passing the event to the plugin, I encased the inside of the void in a try and it still gave me the same error
     
  4. Offline

    caseif

    It will always say it failed to pass the event if your plugin throws an exception while handling it. Take another look at the line to see if you can find the problem code.
     
  5. Offline

    Croug

    but the try didn't yield the message like it should have, but I also realized that the stack trace changed to line 25, which is in the catch, in both instances the error pointed to a point where I called my plugin variable which is my reference to the main class, do you have any Idea why the variable would be null?

    Nevermind, I fixed it, I initialized the plugin variable with "this"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
Thread Status:
Not open for further replies.

Share This Page