diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index b9b0fc030..0981410ef 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import mineplex.core.MiniPlugin; import mineplex.core.account.command.UpdateRank; @@ -48,8 +49,8 @@ public class CoreClientManager extends MiniPlugin private Object _clientLock = new Object(); - private static int _clientsConnecting = 0; - private static int _clientsProcessing = 0; + private static AtomicInteger _clientsConnecting = new AtomicInteger(0); + private static AtomicInteger _clientsProcessing = new AtomicInteger(0); public CoreClientManager(JavaPlugin plugin, String webServer) { @@ -124,7 +125,7 @@ public class CoreClientManager extends MiniPlugin public int getPlayerCountIncludingConnecting() { - return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting); + return Bukkit.getOnlinePlayers().size() + Math.max(0, _clientsConnecting.get()); } @EventHandler(priority = EventPriority.LOWEST) @@ -132,8 +133,8 @@ public class CoreClientManager extends MiniPlugin { try { - _clientsConnecting++; - while (_clientsProcessing >= 5) + _clientsConnecting.incrementAndGet(); + while (_clientsProcessing.get() >= 5) { try { @@ -147,20 +148,18 @@ public class CoreClientManager extends MiniPlugin try { - _clientsProcessing++; + _clientsProcessing.incrementAndGet(); LoadClient(Add(event.getName()), event.getUniqueId(), event.getAddress().getHostAddress()); } catch(Exception exception) { Logger.Instance.log(exception); - event.disallow(Result.KICK_OTHER, "Error retrieving information from web, please retry in a minute."); - System.out.println(exception.getMessage()); } finally { - _clientsProcessing--; + _clientsProcessing.decrementAndGet(); } if (Bukkit.hasWhitelist() && !Get(event.getName()).GetRank().Has(Rank.MODERATOR)) @@ -178,7 +177,7 @@ public class CoreClientManager extends MiniPlugin } finally { - _clientsConnecting--; + _clientsConnecting.decrementAndGet(); } } @@ -448,8 +447,8 @@ public class CoreClientManager extends MiniPlugin return; System.out.println("====="); - System.out.println("Connecting : " + _clientsConnecting); - System.out.println("Processing : " + _clientsProcessing); + System.out.println("Connecting : " + _clientsConnecting.get()); + System.out.println("Processing : " + _clientsProcessing.get()); System.out.println("====="); }