Fixed redis server time functions.
Added kill option for servers with motd Finished in servermonitor
This commit is contained in:
parent
9c8ed5360d
commit
d3788e8ddc
@ -38,7 +38,7 @@ public class ServerStatusManager extends MiniPlugin
|
||||
{
|
||||
super("Server Status Manager", plugin);
|
||||
|
||||
_startUpDate = Utility.currentTimeMillis();
|
||||
_startUpDate = Utility.currentTimeSeconds();
|
||||
_lagMeter = lagMeter;
|
||||
|
||||
if (new File("IgnoreUpdates.dat").exists())
|
||||
|
@ -103,7 +103,7 @@ public class MinecraftServer
|
||||
public boolean isJoinable()
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -325,7 +325,7 @@ public class RedisDataRepository<T extends Data> implements DataRepository<T>
|
||||
|
||||
protected Long currentTime()
|
||||
{
|
||||
return Utility.currentTimeMillis();
|
||||
return Utility.currentTimeSeconds();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,7 +151,7 @@ public class RedisServerRepository implements ServerRepository
|
||||
String serverName = serverData.getName();
|
||||
String setKey = concatenate("serverstatus", "minecraft", _region.toString());
|
||||
String dataKey = concatenate(setKey, serverName);
|
||||
long expiry = Utility.currentTimeMillis() + timeout;
|
||||
long expiry = Utility.currentTimeSeconds() + timeout;
|
||||
|
||||
Transaction transaction = jedis.multi();
|
||||
transaction.set(dataKey, serializedData);
|
||||
@ -308,7 +308,7 @@ public class RedisServerRepository implements ServerRepository
|
||||
|
||||
try
|
||||
{
|
||||
String min = "(" + Utility.currentTimeMillis();
|
||||
String min = "(" + Utility.currentTimeSeconds();
|
||||
String max = "+inf";
|
||||
names = jedis.zrangeByScore(key, min, max);
|
||||
}
|
||||
@ -341,7 +341,7 @@ public class RedisServerRepository implements ServerRepository
|
||||
try
|
||||
{
|
||||
String min = "-inf";
|
||||
String max = Utility.currentTimeMillis() + "";
|
||||
String max = Utility.currentTimeSeconds() + "";
|
||||
names = jedis.zrangeByScore(key, min, max);
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
|
@ -59,6 +59,27 @@ public class Utility
|
||||
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
|
||||
* for synced timestamps.
|
||||
@ -67,7 +88,7 @@ public class Utility
|
||||
{
|
||||
long currentTime = 0;
|
||||
Jedis jedis = getPool().getResource();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
currentTime = Long.parseLong(jedis.time().get(0));
|
||||
|
@ -92,6 +92,12 @@ public class ServerMonitor
|
||||
|
||||
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)
|
||||
{
|
||||
if (serverGroupMap.containsKey(minecraftServer.getGroup()) && minecraftServer.getPublicAddress().equalsIgnoreCase(server.getPrivateAddress()))
|
||||
|
Loading…
Reference in New Issue
Block a user