Could not pass event PlayerJoinEvent on Update

Discussion in 'Plugin Development' started by thapengwin, Apr 14, 2013.

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

    thapengwin

    I've been using R0.1 for developing my plugin, but when I've updated to R0.2, it throws me this:
    Code:
    [SEVERE] Could not pass event PlayerJoinEvent to NoDupeIP v0.1
    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_R2.PlayerList.c(PlayerList.java:204)
    at net.minecraft.server.v1_5_R2.PlayerList.a(PlayerList.java:100)
    at net.minecraft.server.v1_5_R2.PendingConnection.d(PendingConnection.java:129)
    at net.minecraft.server.v1_5_R2.PendingConnection.c(PendingConnection.java:44)
    at net.minecraft.server.v1_5_R2.DedicatedServerConnectionThread.a(DedicatedServerConnectionThread.java:41)
    at net.minecraft.server.v1_5_R2.DedicatedServerConnection.b(SourceFile:29)
    at net.minecraft.server.v1_5_R2.MinecraftServer.r(MinecraftServer.java:580)
    at net.minecraft.server.v1_5_R2.DedicatedServer.r(DedicatedServer.java:225)
    at net.minecraft.server.v1_5_R2.MinecraftServer.q(MinecraftServer.java:476)
    at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java:409)
    at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:573)
    Caused by: java.lang.NullPointerException
    at tk.thapengwin.NoDupeIP.NoDupeIP.ipOnJoin(NoDupeIP.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
    ... 14 more
    
    Here's the code it's pointing to starting from line 36:
    Code:
          if(getConfig().getString("user-list." + daship).isEmpty()){
              getConfig().set("user-list." + daship, player.getName());
              saveConfig();
          } else {
          if(!getConfig().getString("user-list." + daship).equals(player.getName())){
        Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "kick " + player.getName() + " You cannot log in as another user. Please log in as \"" + getConfig().getString("user-list." + daship) + "\"");
        for(Player player1: getServer().getOnlinePlayers()) {
            if(player1.hasPermission("NoDupeIP.iponjoin")) {
            player1.sendMessage(ChatColor.RED + (ip + " joined with a changed username!"));
            }
         }
          }
          }
    
     
  2. Offline

    caseif

    Use .exists() instead of .isEmpty(). isEmpty() will return true only if the key exists, but the value is absent.
     
  3. Offline

    davejavu

    Things that could be null on that line:
    getConfig()
    daship
    the string returned by getConfig().getString()

    Well, the most likely is daship - could you post the line where you declare that variable?
     
  4. AngryNerd
    He's using it on a String not on the config :p

    davejavu
    Using null as value is perfectly fine, it would've translated to "user-list.null" and it wouldn't have thrown a NPE.
    A NPE occurs when you try to access a method or field on a Object pointer (variable) that is asigned to null... which translates to 'null.method()' which can't happen.

    thapengwin
    If a key doesn't exist it returns the default value for that key, if no default value it returns null.

    Most likely it returns null and you using .isEmpty() on null is not really appreciated by the code :}

    I suggest you store the value then check if it's == null then do stuff with it.
     
  5. Offline

    thapengwin

    Thanks! That fixed it :p
     
Thread Status:
Not open for further replies.

Share This Page