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

Optimize getPlayers()

This commit is contained in:
Tux 2014-04-26 19:43:09 -04:00
parent c5d35a2a1c
commit d84f42952c

View File

@ -168,9 +168,14 @@ public final class RedisBungee extends Plugin {
if (pool != null) { if (pool != null) {
Jedis rsc = pool.getResource(); Jedis rsc = pool.getResource();
try { try {
List<String> keys = new ArrayList<>();
for (String i : getServerIds()) { for (String i : getServerIds()) {
if (i.equals(configuration.getString("server-id"))) continue; if (i.equals(configuration.getString("server-id")))
Set<String> users = rsc.smembers("server:" + i + ":usersOnline"); continue;
keys.add("server:" + i + ":usersOnline");
}
Set<String> users = rsc.sunion(keys.toArray(new String[keys.size()]));
if (users != null && !users.isEmpty()) { if (users != null && !users.isEmpty()) {
for (String user : users) { for (String user : users) {
if (UUIDTranslator.UUID_PATTERN.matcher(user).find()) { if (UUIDTranslator.UUID_PATTERN.matcher(user).find()) {
@ -178,7 +183,6 @@ public final class RedisBungee extends Plugin {
} }
} }
} }
}
} catch (JedisConnectionException e) { } catch (JedisConnectionException e) {
// Redis server has disappeared! // Redis server has disappeared!
getLogger().log(Level.SEVERE, "Unable to get connection from pool - did your Redis server go away?", e); getLogger().log(Level.SEVERE, "Unable to get connection from pool - did your Redis server go away?", e);