From 97a24339dcf8996a9afa57ac03bdb3bde864c17a Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 1 Jan 2016 20:19:29 -0500 Subject: [PATCH] Restart Command avoid ConcurrentModification Issuing the restart command in some cases can throw a ConcurrentModificationException Error leaving the server offline. This will prevent that and allow for a clean restart as is the expected behavior. --- src/main/java/org/spigotmc/RestartCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java index 9016a52..5427f91 100644 --- a/src/main/java/org/spigotmc/RestartCommand.java +++ b/src/main/java/org/spigotmc/RestartCommand.java @@ -41,10 +41,15 @@ public class RestartCommand extends Command System.out.println( "Attempting to restart with " + SpigotConfig.restartScript ); // Kick all players - for ( net.minecraft.entity.player.EntityPlayerMP p : (List< net.minecraft.entity.player.EntityPlayerMP>) net.minecraft.server.MinecraftServer.getServer().getConfigurationManager().playerEntityList ) + for ( Object p : net.minecraft.server.MinecraftServer.getServer().getConfigurationManager().playerEntityList.toArray() ) { - p.playerNetServerHandler.kickPlayerFromServer(SpigotConfig.restartMessage); - p.playerNetServerHandler.netManager.isChannelOpen(); + if(p instanceof net.minecraft.entity.player.EntityPlayerMP) + { + net.minecraft.entity.player.EntityPlayerMP mp = ( net.minecraft.entity.player.EntityPlayerMP)p; + mp.playerNetServerHandler.kickPlayerFromServer(SpigotConfig.restartMessage); + mp.playerNetServerHandler.netManager.isChannelOpen(); + } + } // Give the socket a chance to send the packets try