Could not pass event PlayerMoveEvent. Name cannot be null

Discussion in 'Plugin Development' started by WauloK, Apr 19, 2014.

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

    WauloK

    Hi.

    Trying to figure a random error. Only happens on some servers. My plugin has been running for months on up to 214 servers with over 400 players, but a small number of users get this error:

    Code:
    [12:49:09] [Server thread/ERROR]: Could not pass event PlayerMoveEvent to InsanityRun v2.7
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:471) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:234) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInFlying.a(SourceFile:137) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.PacketPlayInPositionLook.handle(SourceFile:20) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.IllegalArgumentException: Name cannot be null
        at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftServer.getWorld(CraftServer.java:998) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at com.obsidianloft.insanityrun.events.PlayerListener.ScoresUpdate(PlayerListener.java:433) ~[?:?]
        at com.obsidianloft.insanityrun.events.PlayerListener.endLevelOrGame(PlayerListener.java:325) ~[?:?]
        at com.obsidianloft.insanityrun.events.PlayerListener.onPlayerMoveEvent(PlayerListener.java:155) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_05]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        ... 13 more
    There's 526 lines of code in this file so will not post all of it.

    Section from line 154 onwards (Note: They do not have ice blocks in their game-arena):

    Code:java
    1. case ICE: // ICE = freeze player
    2. currentPlayerObject.setFrozen(true);
    3. Bukkit.getScheduler().scheduleSyncDelayedTask(InsanityRun.plugin, new BukkitRunnable() {
    4. public void run() {
    5. currentPlayerObject.setFrozen(false);
    6. }
    7. }, 20 * 2); // 20 ticks per second x 'gracetime' seconds
    8. break;


    Section from 325 onwards:

    Code:java
    1. Firework fw = (Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
    2. FireworkMeta fwm = fw.getFireworkMeta();
    3. Random r = new Random();
    4. Type type = Type.BALL;
    5. Color c1 = Color.GREEN;
    6. Color c2 = Color.YELLOW;
    7. FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
    8. fwm.addEffect(effect);
    9. fwm.setPower(1);
    10. fw.setFireworkMeta(fwm);


    Section from 433:

    Code:java
    1. // Convert time
    2. private static String formatIntoHHMMSS(Long millisecs)
    3. {
    4. int secs = (int) (millisecs / 1000);
    5. int remainder = secs % 3600;
    6. int minutes = remainder / 60;
    7. int seconds = remainder % 60;
    8.  
    9. return new StringBuilder().append(minutes).append(":").append(seconds < 10 ? "0" : "").append(seconds).toString();
    10. }


    I run the plugin on my server with no issues whatsoever. I should add they seem to get the error only when the player crosses the finish line (walks on Redstone blocks).

    My pastebin of all the code in this file, if it helps.
    http://pastebin.com/1yAucVkp

    TIA!
     
  2. Offline

    ZeusAllMighty11

    Actually the real issue is at at com.obsidianloft.insanityrun.events.PlayerListener.ScoresUpdate(PlayerListener.java:433) ~[?:?]
     
  3. Offline

    thisguy128512

    Without looking at the code, when I hear "name cannot be null," my instinct is that you're passing a value that might be null to a function which assumes it isn't. Therefore, I would assume the fix looks something like,

    Code:java
    1. if (value == null) {
    2. throw new hissyFit();
    3. }
     
  4. Offline

    Garris0n

    1. You should not have a method called "ScoresUpdate", it should be called "scoresUpdate" or really "updateScores". Please read up on the Java naming conventions.
    2. You should use config.getString() instead of config.get() cast to a string.
    3. You could just set the world to the value from the config and check if it's null instead of getting it twice.
    4. As for the actual issue, the string from the config is null.
     
  5. Offline

    WauloK

    Thanks for that, but which line is the config string null that it's getting?
    The only way I can see that happening is if people don't create their arenas. All strings I set myself are not null.

    Line 433 has nothing to do with config.get()

    Line 433 says:
    Code:java
    1. private static String formatIntoHHMMSS(Long millisecs)


    There is also no 'config.get()' in my code so I'm assuming you didn't read it at all!?!

    Garris0n

    Do you mean line 450?

    Code:
    if (InsanityRun.plugin.getServer().getWorld((String) InsanityRun.plugin.getConfig().get(arenaName + ".fastsign.world"))==null) { return; }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    RawCode

    I will explain how to read traces:


    1) Go to frame0
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ok cause is inside main server thread and not caused by random plugin making his own threads

    2) Go to frame1 then frame 2 then frame 3 as long as you not reached your frames thar reference your code:
    at com.obsidianloft.insanityrun.events.PlayerListener.ScoresUpdate(PlayerListener.java:433) ~[?:?]
    at com.obsidianloft.insanityrun.events.PlayerListener.endLevelOrGame(PlayerListener.java:325) ~[?:?]
    at com.obsidianloft.insanityrun.events.PlayerListener.onPlayerMoveEvent(PlayerListener.java:155) ~[?:?]

    3) check given lines and remember them, you may need to remember +-10 lines in each direction.
    you dont need to keep this data in head - just mark your code

    4) go next:

    Caused by: java.lang.IllegalArgumentException: Name cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.getWorld(CraftServer.java:998) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]

    5) notNull is assertion and can be ignored - answer is getWorld method.

    6) Open your code and check all cases of usage of getWorld

    7) Was soo hard?
     
    AdamQpzm likes this.
  7. Offline

    WauloK

    ok. Figured it. Thanks guys, esp Garris0n

    RawCode The method mentioned didn't have any config info in it. I did however figure the correct line which was 450. Glad we have some condescension to help developers. Really helps.

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

    RawCode

    ever if you can't get correct line for any reason, you always can use text search for specific method...
     
  9. Offline

    Garris0n

    ಠ_ಠ
     
    AoH_Ruthless likes this.
  10. Offline

    WauloK

    Garris0n

    I explained I thought you literally meant "config.get()" which does not exist. I realised later you weren't giving actual code and that you were referring to
    Code:java
    1. InsanityRun.plugin.getConfig().get(

    I was searching my code for config.get().
     
Thread Status:
Not open for further replies.

Share This Page