mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
Cache player count once again
This commit is contained in:
parent
e00d476233
commit
b811a574fd
@ -60,6 +60,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
private ScheduledTask heartbeatTask;
|
private ScheduledTask heartbeatTask;
|
||||||
private boolean usingLua;
|
private boolean usingLua;
|
||||||
private LuaManager.Script serverToPlayersScript;
|
private LuaManager.Script serverToPlayersScript;
|
||||||
|
private volatile int playerCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the {@link RedisBungeeAPI} object created on plugin start.
|
* Fetch the {@link RedisBungeeAPI} object created on plugin start.
|
||||||
@ -153,6 +154,10 @@ public final class RedisBungee extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int getCount() {
|
final int getCount() {
|
||||||
|
return playerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int getCurrentCount() {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
try (Jedis rsc = pool.getResource()) {
|
try (Jedis rsc = pool.getResource()) {
|
||||||
@ -262,6 +267,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
getLogger().info("Looks like you have a really big UUID cache! Run https://www.spigotmc.org/resources/redisbungeecleaner.8505/ as soon as possible.");
|
getLogger().info("Looks like you have a really big UUID cache! Run https://www.spigotmc.org/resources/redisbungeecleaner.8505/ as soon as possible.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
playerCount = getCurrentCount();
|
||||||
serverIds = getCurrentServerIds(true, false);
|
serverIds = getCurrentServerIds(true, false);
|
||||||
uuidTranslator = new UUIDTranslator(this);
|
uuidTranslator = new UUIDTranslator(this);
|
||||||
heartbeatTask = getProxy().getScheduler().schedule(this, new Runnable() {
|
heartbeatTask = getProxy().getScheduler().schedule(this, new Runnable() {
|
||||||
@ -275,6 +281,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
getLogger().log(Level.SEVERE, "Unable to update heartbeat - did your Redis server go away?", e);
|
getLogger().log(Level.SEVERE, "Unable to update heartbeat - did your Redis server go away?", e);
|
||||||
}
|
}
|
||||||
serverIds = getCurrentServerIds(true, false);
|
serverIds = getCurrentServerIds(true, false);
|
||||||
|
playerCount = getCurrentCount();
|
||||||
}
|
}
|
||||||
}, 0, 3, TimeUnit.SECONDS);
|
}, 0, 3, TimeUnit.SECONDS);
|
||||||
dataManager = new DataManager(this);
|
dataManager = new DataManager(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user