Fixed potential mass-kick

This would happen if an admin joins the game when the server is full
This commit is contained in:
unknown 2013-12-01 18:21:43 +01:00
parent bed78248fb
commit 808e02f660
2 changed files with 7 additions and 5 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Sun Dec 01 17:31:33 CET 2013 #Sun Dec 01 18:16:33 CET 2013
build.number=648 build.number=650

View File

@ -326,23 +326,25 @@ public class TFM_ServerInterface
} }
} }
if (server.getOnlinePlayers().length >= server.getMaxPlayers()) int count = server.getOnlinePlayers().length;
if (count >= server.getMaxPlayers())
{ {
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (!TFM_SuperadminList.isUserSuperadmin(player)) if (!TFM_SuperadminList.isUserSuperadmin(player))
{ {
p.kickPlayer("You have been kicked to free up room for an admin."); p.kickPlayer("You have been kicked to free up room for an admin.");
count--;
} }
if (server.getOnlinePlayers().length < server.getMaxPlayers()) if (count < server.getMaxPlayers())
{ {
break; break;
} }
} }
} }
if (server.getOnlinePlayers().length >= server.getMaxPlayers()) if (count >= server.getMaxPlayers())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!"); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
return; return;