Make server monitor support MCS and servers with multiple '-' characters

This commit is contained in:
AlexTheCoder 2016-12-14 23:29:00 -05:00 committed by cnr
parent bd4fa1f2d4
commit fe62e5a683
3 changed files with 16 additions and 4 deletions

View File

@ -325,7 +325,8 @@ public class ServerGroup
String serverName = server.getName();
try
{
int serverNum = Integer.parseInt(serverName.split("-")[1]);
String[] nameArgs = serverName.split("-");
int serverNum = Integer.parseInt(nameArgs[nameArgs.length - 1]);
if (serverNum == id)
{

View File

@ -211,6 +211,14 @@ public class ServerMonitor
System.out.println("Removed MPS : " + groupStatus.getName());
}
if (groupStatus.getServerType().equalsIgnoreCase("Community"))
{
_repository.removeServerGroup(groupStatus);
_serverGroupMap.remove(groupStatus.getName());
groupStatusIterator.remove();
System.out.println("Removed MCS : " + groupStatus.getName());
}
}
}
@ -226,7 +234,8 @@ public class ServerMonitor
try
{
MinecraftServer server = serverIterator.next();
int serverNum = Integer.parseInt(server.getName().split("-")[1]);
String[] nameArgs = server.getName().split("-");
int serverNum = Integer.parseInt(nameArgs[nameArgs.length - 1]);
if (serverMap.containsKey(serverNum))
{

View File

@ -9,9 +9,11 @@ public class ServerSorter implements Comparator<MinecraftServer>
@Override
public int compare(MinecraftServer first, MinecraftServer second)
{
if (Integer.parseInt(first.getName().split("-")[1]) < Integer.parseInt(second.getName().split("-")[1]))
String[] args1 = first.getName().split("-");
String[] args2 = second.getName().split("-");
if (Integer.parseInt(args1[args1.length - 1]) < Integer.parseInt(args2[args2.length - 1]))
return -1;
else if (Integer.parseInt(second.getName().split("-")[1]) < Integer.parseInt(first.getName().split("-")[1]))
else if (Integer.parseInt(args2[args2.length - 1]) < Integer.parseInt(args1[args1.length - 1]))
return 1;
return 0;