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