Solved String Null?

Discussion in 'Plugin Development' started by The Fancy Whale, Apr 12, 2014.

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

    The Fancy Whale

    For some reason one of these lines comes up null when it has players in it... any help is greatly appreciated. Thanks!
    Code:java
    1. public void endGame(){
    2. if (inGame){
    3. for (String playername : game) { //this line came up null but still ran the method leaveGame
    4. Player player = getServer().getPlayerExact(playername);
    5. if (player != null) {
    6. leaveGame(player);
    7. }
    8. }
    9. game.clear();
    10. rteam.clear();
    11. bteam.clear();
    12. inGame = false;
    13. }
    14. }
     
  2. Offline

    zDylann

    Can I see the error?
     
  3. Offline

    The Fancy Whale

    zDylann
    Code:
    [00:06:57] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'gf' in plugin GrifBall v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:196) ~[bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:542) ~[bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:932) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.util.ConcurrentModificationException
    at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372) ~[?:1.6.0_45]
    at java.util.AbstractList$Itr.next(AbstractList.java:343) ~[?:1.6.0_45]
    at tfw.grifball.Main.endGame(Main.java:254) ~[?:?]
    at tfw.grifball.Main.onCommand(Main.java:360) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[bukkit-dev-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    
    Line 254 is the one where I put the comment
     
  4. Offline

    zDylann


    What is "game" pointing to in the enhanced loop?
     
  5. Offline

    The Fancy Whale

    zDylann an arraylist containing playernames
     
  6. Offline

    zDylann

    Hm, I'm really not sure what would be causing that error. ConcurrentModifcationException in this scenario must mean that the game list is being manipulated the same time its being looped through.
     
    The Fancy Whale likes this.
  7. Offline

    The Fancy Whale

    zDylann Oh figured out the issue. My leaveGame(Player) method was changing the array list
     
Thread Status:
Not open for further replies.

Share This Page