Changed ServerConfiguration to only pull its groupName specifically.

Changed StatsManager to only run once every second and to upload all stats.
This commit is contained in:
Jonathan Williams 2015-01-12 12:19:13 -08:00
parent 9839edeeee
commit cd5574ab43
4 changed files with 37 additions and 14 deletions

View File

@ -25,7 +25,7 @@ public class ServerConfiguration extends MiniPlugin
String groupName = plugin.getConfig().getString("serverstatus.group");
String serverName = plugin.getConfig().getString("serverstatus.name");
// Ugh serializing json to redis converts a players name that is only numbers to name.0 so we have to parse this off so things don't go boom. hackfix ftw
// Ugh serializing json to redis converts a players name that is only numbers to 'name.0' so we have to parse this off so things don't go boom. hackfix ftw
try
{
String name = serverName.split("-")[0];
@ -39,17 +39,12 @@ public class ServerConfiguration extends MiniPlugin
// Nothing stupid..
}
for (ServerGroup serverGroup : ServerManager.getServerRepository(region).getServerGroups(null))
{
if (serverGroup.getName().equalsIgnoreCase(groupName))
{
_serverGroup = serverGroup;
break;
}
}
_serverGroup = ServerManager.getServerRepository(region).getServerGroup(groupName);
if (_serverGroup == null)
return;
{
_serverGroup = new ServerGroup(null, null);
}
try
{

View File

@ -42,7 +42,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
}
};
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, _saveRunnable, 1L, 1L);
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, _saveRunnable, 20L, 20L);
}
for (Stat stat : _repository.retrieveStats())
@ -144,9 +144,6 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
}
statIterator.remove();
// Only process one player per tick/call.
break;
}
}

View File

@ -508,6 +508,35 @@ public class RedisServerRepository implements ServerRepository
}
}
@Override
public ServerGroup getServerGroup(String serverGroup)
{
ServerGroup server = null;
Jedis jedis = _jedisPool.getResource();
try
{
String key = concatenate("servergroups", serverGroup);
Map<String, String> data = jedis.hgetAll(key);
server = new ServerGroup(data, null);
}
catch (JedisConnectionException exception)
{
exception.printStackTrace();
_jedisPool.returnBrokenResource(jedis);
jedis = null;
}
finally
{
if (jedis != null)
{
_jedisPool.returnResource(jedis);
}
}
return server;
}
/*
* <region> = "US" or "EU"
* serverstatus.minecraft.<region>.<name> stores the JSON encoded information of an active MinecraftServer instance.

View File

@ -63,6 +63,8 @@ public interface ServerRepository
*/
public Collection<ServerGroup> getServerGroups(Collection<MinecraftServer> servers);
public ServerGroup getServerGroup(String serverGroup);
public Collection<MinecraftServer> getDeadServers();
void updateServerGroup(ServerGroup serverGroup);