mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
Get a fresh resource each time instead.
This commit is contained in:
parent
dd4f49b199
commit
49c8b83e52
@ -11,23 +11,19 @@ import redis.clients.jedis.Jedis;
|
||||
public class UpdateCountTask implements Runnable {
|
||||
|
||||
private RedisBungee plugin;
|
||||
private Jedis rsc;
|
||||
private boolean kill = false;
|
||||
|
||||
public UpdateCountTask(RedisBungee plugin) {
|
||||
this.plugin = plugin;
|
||||
rsc = plugin.getPool().getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (kill) {
|
||||
if (rsc != null) {
|
||||
plugin.getPool().returnResource(rsc);
|
||||
rsc = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Jedis rsc = plugin.getPool().getResource();
|
||||
try {
|
||||
int c = plugin.getProxy().getOnlineCount();
|
||||
rsc.set("server:" + plugin.getServerId() + ":playerCount", String.valueOf(c));
|
||||
for (String i : plugin.getServers()) {
|
||||
@ -36,6 +32,9 @@ public class UpdateCountTask implements Runnable {
|
||||
c += Integer.valueOf(rsc.get("server:" + i + ":playerCount"));
|
||||
}
|
||||
plugin.setCount(c);
|
||||
} finally {
|
||||
plugin.getPool().returnResource(rsc);
|
||||
}
|
||||
}
|
||||
|
||||
protected void kill() {
|
||||
|
Loading…
Reference in New Issue
Block a user