Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-10-11 23:10:09 +11:00
commit 42d22ac38f
6 changed files with 34 additions and 7 deletions

View File

@ -38,7 +38,7 @@ public class ServerStatusManager extends MiniPlugin
{ {
super("Server Status Manager", plugin); super("Server Status Manager", plugin);
_startUpDate = Utility.currentTimeMillis(); _startUpDate = Utility.currentTimeSeconds();
_lagMeter = lagMeter; _lagMeter = lagMeter;
if (new File("IgnoreUpdates.dat").exists()) if (new File("IgnoreUpdates.dat").exists())

View File

@ -103,7 +103,7 @@ public class MinecraftServer
public boolean isJoinable() public boolean isJoinable()
{ {
if (_motd != null && (_motd.contains("Starting") || _motd.contains("Recruiting") if (_motd != null && (_motd.contains("Starting") || _motd.contains("Recruiting")
|| _motd.contains("Waiting") || _motd.contains("Cup") || _motd.isEmpty())) || _motd.contains("Waiting") || _motd.contains("Open in") || _motd.isEmpty()))
{ {
if (_playerCount < _maxPlayerCount) if (_playerCount < _maxPlayerCount)
{ {

View File

@ -325,7 +325,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
protected Long currentTime() protected Long currentTime()
{ {
return Utility.currentTimeMillis(); return Utility.currentTimeSeconds();
} }
/** /**

View File

@ -151,7 +151,7 @@ public class RedisServerRepository implements ServerRepository
String serverName = serverData.getName(); String serverName = serverData.getName();
String setKey = concatenate("serverstatus", "minecraft", _region.toString()); String setKey = concatenate("serverstatus", "minecraft", _region.toString());
String dataKey = concatenate(setKey, serverName); String dataKey = concatenate(setKey, serverName);
long expiry = Utility.currentTimeMillis() + timeout; long expiry = Utility.currentTimeSeconds() + timeout;
Transaction transaction = jedis.multi(); Transaction transaction = jedis.multi();
transaction.set(dataKey, serializedData); transaction.set(dataKey, serializedData);
@ -308,7 +308,7 @@ public class RedisServerRepository implements ServerRepository
try try
{ {
String min = "(" + Utility.currentTimeMillis(); String min = "(" + Utility.currentTimeSeconds();
String max = "+inf"; String max = "+inf";
names = jedis.zrangeByScore(key, min, max); names = jedis.zrangeByScore(key, min, max);
} }
@ -341,7 +341,7 @@ public class RedisServerRepository implements ServerRepository
try try
{ {
String min = "-inf"; String min = "-inf";
String max = Utility.currentTimeMillis() + ""; String max = Utility.currentTimeSeconds() + "";
names = jedis.zrangeByScore(key, min, max); names = jedis.zrangeByScore(key, min, max);
} }
catch (JedisConnectionException exception) catch (JedisConnectionException exception)

View File

@ -59,6 +59,27 @@ public class Utility
return result; return result;
} }
/**
* @return the current timestamp (in seconds) fetched from the central jedis repository
* for synced timestamps.
*/
public static long currentTimeSeconds()
{
long currentTime = 0;
Jedis jedis = getPool().getResource();
try
{
currentTime = Long.parseLong(jedis.time().get(0));
}
finally
{
getPool().returnResource(jedis);
}
return currentTime;
}
/** /**
* @return the current timestamp (in milliseconds) fetched from the central jedis repository * @return the current timestamp (in milliseconds) fetched from the central jedis repository
* for synced timestamps. * for synced timestamps.

View File

@ -92,6 +92,12 @@ public class ServerMonitor
for (MinecraftServer minecraftServer : serverStatuses) for (MinecraftServer minecraftServer : serverStatuses)
{ {
if (minecraftServer.getMotd().contains("Finished"))
{
killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true);
continue;
}
for (DedicatedServer server : dedicatedServers) for (DedicatedServer server : dedicatedServers)
{ {
if (serverGroupMap.containsKey(minecraftServer.getGroup()) && minecraftServer.getPublicAddress().equalsIgnoreCase(server.getPrivateAddress())) if (serverGroupMap.containsKey(minecraftServer.getGroup()) && minecraftServer.getPublicAddress().equalsIgnoreCase(server.getPrivateAddress()))