Crash report after teleporting all players to another map

Discussion in 'Plugin Development' started by zajacmp3, Aug 18, 2012.

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



    I sometimes have a crash report on function that removes players from map to another one.
    Function is working perfectly well sometimes and sometimes not. I can't find why it does crash server sometimes.

    Here is the crash report:
    2012-08-18 07:38:16 [INFO] Removing players from 1 map
    2012-08-18 07:38:16 [SEVERE] java.util.ConcurrentModificationException
    2012-08-18 07:38:16 [SEVERE]     at java.util.ArrayList$Itr.checkForComodification(
    2012-08-18 07:38:16 [SEVERE]     at java.util.ArrayList$
    2012-08-18 07:38:16 [SEVERE]     at net.minecraft.server.World.tickEntities(
    2012-08-18 07:38:16 [SEVERE]     at net.minecraft.server.MinecraftServer.q(
    2012-08-18 07:38:16 [SEVERE]     at net.minecraft.server.DedicatedServer.q(
    2012-08-18 07:38:16 [SEVERE]     at net.minecraft.server.MinecraftServer.p(
    2012-08-18 07:38:16 [SEVERE]     at
    2012-08-18 07:38:16 [SEVERE]     at
    2012-08-18 07:38:16 [SEVERE] Encountered an unexpected exception ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(
        at java.util.ArrayList$
        at net.minecraft.server.World.tickEntities(
        at net.minecraft.server.MinecraftServer.q(
        at net.minecraft.server.DedicatedServer.q(
        at net.minecraft.server.MinecraftServer.p(
    2012-08-18 07:38:16 [SEVERE] This crash report has been saved to: /minecraft/./crash-reports/crash-2012-08-18_07.38.16-server.txt
    Any ideas?

    My function that is running here:
        public static void removePlayersFromMap(String map) {
            System.out.println("Removing players from "+map+" map");
            World world = Bukkit.getServer().getWorld("Lobby");
            List<Player> players = Bukkit.getServer().getWorld(map).getPlayers();
            for(int temp = 0; temp<players.size() ; temp++){
                Location location = players.get(temp).getLocation();
                    players.get(temp).kickPlayer("Kicked! Cause of being dead and inactive on reloading map!");
                    File datfile = new File("Lobby/players/"+players.get(temp).getName()+".dat");

    I need any ideas how to avoid crashes like that. Any ideas that I can work and try to work with.
  2. Offline


    Looking at the position where the CME is occuring (when the server ticks its entities), it appears to me that you are running that code from another thread.
    Never every possibly do teleporting or any change to the world from a separate thread! I can't stress that enough. Almost nothing of the Bukkit API or Minecraft server in general is thread-safe, and eventually it will cause world corruption and server crashes.
    If you use the scheduler already, make sure everything is "sync" instead of "async".
  3. Offline


    Okay, I am getting somewhere. Just need a bit more of your guidance.
    This function is in main class and from some point it is really in scheduler. So I will change it to "sync" cause it is now "async".

    And another question. I have now 2x 1GHZ in my hosting. So that may be not enough computing power you say for this thread that I am running yes?
    If I change the hosting to some better like I think to will it minimize the risk of future crashes with it?
  4. Offline


    No, it depends on the fact that two things that work at the same time use the same data, no matter how fast these run, they still run next to each other. Also, there is no benefit whatsoever of having your thing threaded, because it doesn't do any long-taking operations.
    The time and CPU effort it takes to launch the new Thread is way more than what your code "slows" the main thread.
Thread Status:
Not open for further replies.

Share This Page