Solved IllegalArgumentException: Name cannot be null

Discussion in 'Spigot Plugin Development' started by MrGamingLion66, Jun 3, 2017.

  1. Hey everyone, in my plugin I have to get a world based on the name in a config file. Everything worked fine on my test server but when I uploaded it to my main server the same code and config file generated an the exception in the title. I can't figure out how to fix it.

    Here is the method that gets the world based on the world name:
    Code (Text):
    public World getWorld()
    {
        String s = arenaConfiguration.getString("World-Name");
        return Bukkit.getWorld(s);
    }
    World-Name: "RomanEmpire"

    02.06 18:21:57 [Multicraft] Skipped 1 lines due to rate limit (30/s)
    02.06 18:21:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at com.crimsoncentral.skywars.SkyWarsArenaManager.onInventoryClick(SkyWarsArenaManager.java:85) ~[?:?]
    02.06 18:21:31 [Server] INFO at com.crimsoncentral.skywars.SkyWarsArenaManager.createRandomNewArena(SkyWarsArenaManager.java:940) ~[?:?]
    02.06 18:21:31 [Server] INFO at com.crimsoncentral.skywars.SkyWarsArenaConfig.getWorld(SkyWarsArenaConfig.java:102) ~[?:?]
    02.06 18:21:31 [Server] INFO at org.bukkit.Bukkit.getWorld(Bukkit.java:500) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.bukkit.craftbukkit.v1_10_R1.CraftServer.getWorld(CraftServer.java:1020) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO Caused by: java.lang.IllegalArgumentException: Name cannot be null
    02.06 18:21:31 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:567) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:668) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:400) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:732) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_101]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.PacketPlayInWindowClick.a(SourceFile:10) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.PacketPlayInWindowClick.a(SourceFile:33) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:1861) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[custom_server.jar:git-Spigot-72c2605-251a5b6]
    02.06 18:21:31 [Server] INFO org.bukkit.event.EventException
    02.06 18:21:31 [Server] ERROR Could not pass event InventoryClickEvent to Crimson_Central v1.0
     
  2. Something is going wrong and Bukkit is returning null when you call #getString() make sure you are loading/saving your config properly.

    Edit that might actually be wrong, still a good idea to add a null check there as you never know what users might or might not put in their config, please put SkyWarsArenaManager line 85 and any other relevant code in the post.
     
  3. Are you loading the config properly? Try printing the entire contents of the configuration.
     
  4. @GamerKing195 @FlyingLlama
    Getting the string returns null, the big thing that is confusing me though is that when I get the string on my test server it works just fine, but when I attempt on my main server the string returns null.
     
  5. There must be some difference in the config or plugin code then, try and do some digging as to what is different and problem solve from there, then if you get stuck on something put it on spigot and we'll help more.
     
  6. @GamerKing195
    I already have, I synced both the configs and the plugins and the code still doesn't work.
     
  7. It says this is only happening on an inventory click event which means that it doesn't mean it's the world name unless you are calling the world name from the config from a click event. If you are make sure you are updating and saving the config correctly and double check you aren't miss reading it somewhere else in the code.
     
  8. I am calling it from a click event. Also, the big thing is that this is happening on one server but not another server, both of which have the same config files and resources to access.
     
  9. Check the world names on both servers?
     
  10. It could potentially be java version differences, maybe if you are using a snapshot a different version of it. Config isn't saving correctly, or even a simple spelling mistake. It could be a lot of things, if you don't mind can you send me the plugin files before you export it so I can take a look at it?

    Send to skype: theboss5462
     
    • Like Like x 1