UHC tweaks and message changes.

This commit is contained in:
Jonathan Williams 2014-11-07 16:04:06 -08:00
parent 3a3c2002f5
commit 48c627db74

View File

@ -39,6 +39,8 @@ public class ServerMonitor
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
private static Logger _logger = Logger.getLogger("ServerMonitor");
private static int _totalPlayers = 0;
public static void main (String args[])
{
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
@ -74,6 +76,7 @@ public class ServerMonitor
while (true)
{
_totalPlayers = 0;
Collection<ServerGroup> serverGroups = _repository.getServerGroups(true);
Collection<MinecraftServer> serverStatuses = _repository.getServerStatuses();
@ -88,7 +91,10 @@ public class ServerMonitor
for (ServerGroup serverGroup : serverGroups)
{
serverGroupMap.put(serverGroup.getName(), serverGroup);
_totalPlayers += serverGroup.getPlayerCount();
}
System.out.println("Total Players : " + _totalPlayers);
for (MinecraftServer minecraftServer : serverStatuses)
{
@ -277,16 +283,26 @@ public class ServerMonitor
serversToAdd = 0;
}
}
else if (serverGroup.getName().equalsIgnoreCase("UltraHardcore"))
{
int maxUHC = Math.max(1, _totalPlayers / 6000);
if (serversToAdd > 0)
serversToAdd = maxUHC - joinableServers;
if (joinableServers > maxUHC)
serversToKill = maxUHC - joinableServers;
}
while (serversToAdd > 0)
{
serverNum = serverGroup.generateUniqueId(serverNum + 1);
Collections.sort(dedicatedServers, new DedicatedServerSorter());
DedicatedServer bestServer = getBestDedicatedServer(dedicatedServers, serverGroup);
if (bestServer == null)
{
System.out.println("No best dynamic server available for group " + serverGroup.getName());
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!! NO DEDICATED SERVER AVAILABLE FOR GROUP " + serverGroup.getName() + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
break;
}
@ -398,8 +414,7 @@ public class ServerMonitor
if (serverData.getAvailableRam() > serverGroup.getRequiredRam()
&& serverData.getAvailableCpu() > serverGroup.getRequiredCpu())
{
if (bestServer == null
|| serverData.getServerCount(serverGroup) < bestServer.getServerCount(serverGroup))
if (bestServer == null || serverData.getServerCount(serverGroup) < bestServer.getServerCount(serverGroup))
{
bestServer = serverData;
}
@ -427,9 +442,9 @@ public class ServerMonitor
public void run(Boolean error)
{
if (error)
log("[" + serverName + ":" + serverAddress + "] Errored " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")");
log("[" + serverName + ":" + serverAddress + " Free Resources; CPU " + serverSpace.getAvailableCpu() + " RAM " + serverSpace.getAvailableRam() + "MB] Errored " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")");
else
log("[" + serverName + ":" + serverAddress + "] Added " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")");
log("[" + serverName + ":" + serverAddress + " Free Resources; CPU " + serverSpace.getAvailableCpu() + " RAM " + serverSpace.getAvailableRam() + "MB] Added " + serverName + "(" + groupPrefix+ "-" + serverNum + (free ? "-FREE" : "") + ")");
}
});