From f2d13804784805b0264f51fc3ee51c8af9eed730 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 1 Aug 2014 00:46:00 -0700 Subject: [PATCH] Fixed bug with Server monitor. --- .../servermonitor/GroupStatusData.java | 25 ++++++++++++++----- .../mineplex/servermonitor/ServerMonitor.java | 6 ++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java index f29f1cd09..bd19c0d8f 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java @@ -6,9 +6,11 @@ import java.util.List; public class GroupStatusData { + private int _serverNum = 0; private int _totalCount = 0; private int _joinableCount = 0; + private int _freeServerNum = 0; private int _freeTotalCount = 0; private int _freeJoinableCount = 0; @@ -135,22 +137,33 @@ public class GroupStatusData public int getNextServerNumber(boolean free) { - int startNumber = 1; + if (free) + _freeServerNum++; + else + _serverNum++; while (true) { if (free) { - if (!FreeServers.containsKey(startNumber)) - return startNumber; + if (!FreeServers.containsKey(_freeServerNum)) + break; } else { - if (!Servers.containsKey(startNumber)) - return startNumber; + if (!Servers.containsKey(_serverNum)) + break; } - startNumber++; + if (free) + _freeServerNum++; + else + _serverNum++; } + + if (free) + return _freeServerNum; + else + return _serverNum; } } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index d14b30ca6..dbedf19e4 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -149,7 +149,7 @@ public class ServerMonitor handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, false); - if (serverGroup.GenerateFreeVersions && _count % 2 == 0) + if (serverGroup.GenerateFreeVersions && _count % 6 == 0) { handleGroupChanges(dynamicServers, serverTracker, serverGroup, groupStatus, true); } @@ -246,12 +246,12 @@ public class ServerMonitor break; } - if (serverTracker.containsKey(serverGroup.Prefix + "-" + serverNum)) + if (serverTracker.containsKey(serverGroup.Prefix + "-" + serverNum + (free ? "-FREE" : ""))) System.out.println("[WAITING] On " + serverGroup.Prefix + "-" + serverNum + " to finish starting..."); else { startServer(bestServer, serverGroup, serverNum, free); - serverTracker.put(serverGroup.Prefix + "-" + serverNum, new AbstractMap.SimpleEntry(bestServer.Address, System.currentTimeMillis())); + serverTracker.put(serverGroup.Prefix + "-" + serverNum + (free ? "-FREE" : ""), new AbstractMap.SimpleEntry(bestServer.Address, System.currentTimeMillis())); } serversToAdd--;