2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

Fix count updates...

This commit is contained in:
Tux 2013-10-31 19:07:37 -04:00
parent 73af35aeee
commit 4359b251b9

View File

@ -59,7 +59,6 @@ public class RedisBungee extends Plugin implements Listener {
int c = 0; int c = 0;
try { try {
c = plugin.getProxy().getOnlineCount(); c = plugin.getProxy().getOnlineCount();
rsc.set("server:" + plugin.getServerId() + ":playerCount", String.valueOf(c));
for (String i : plugin.getServers()) { for (String i : plugin.getServers()) {
if (i.equals(plugin.getServerId())) continue; if (i.equals(plugin.getServerId())) continue;
if (rsc.exists("server:" + i + ":playerCount")) if (rsc.exists("server:" + i + ":playerCount"))
@ -167,6 +166,17 @@ public class RedisBungee extends Plugin implements Listener {
} finally { } finally {
pool.returnResource(tmpRsc); pool.returnResource(tmpRsc);
} }
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
Jedis rsc = pool.getResource();
try {
rsc.set("server:" + plugin.getServerId() + ":playerCount", String.valueOf(getProxy().getOnlineCount()));
} finally {
pool.returnResource(rsc);
}
}
}, 1, 3, TimeUnit.SECONDS);
getProxy().getPluginManager().registerCommand(this, new Command("glist", "bungeecord.command.glist", "redisbungee") { getProxy().getPluginManager().registerCommand(this, new Command("glist", "bungeecord.command.glist", "redisbungee") {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {