From 808e02f66007138c9fd05366e201b686a7eb3c62 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Dec 2013 18:21:43 +0100 Subject: [PATCH] Fixed potential mass-kick This would happen if an admin joins the game when the server is full --- buildnumber.properties | 4 ++-- .../StevenLawson/TotalFreedomMod/TFM_ServerInterface.java | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/buildnumber.properties b/buildnumber.properties index 58563d77..dd261e2a 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Dec 01 17:31:33 CET 2013 -build.number=648 +#Sun Dec 01 18:16:33 CET 2013 +build.number=650 diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java index 91e92041..83c783d5 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java @@ -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()) { if (!TFM_SuperadminList.isUserSuperadmin(player)) { 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; } } } - 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!"); return;