2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-12-23 18:48:02 +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,14 +168,18 @@ public final class RedisBungee extends Plugin {
if (pool != null) {
Jedis rsc = pool.getResource();
try {
List<String> keys = new ArrayList<>();
for (String i : getServerIds()) {
if (i.equals(configuration.getString("server-id"))) continue;
Set<String> users = rsc.smembers("server:" + i + ":usersOnline");
if (users != null && !users.isEmpty()) {
for (String user : users) {
if (UUIDTranslator.UUID_PATTERN.matcher(user).find()) {
setBuilder = setBuilder.add(UUID.fromString(user));
}
if (i.equals(configuration.getString("server-id")))
continue;
keys.add("server:" + i + ":usersOnline");
}
Set<String> users = rsc.sunion(keys.toArray(new String[keys.size()]));
if (users != null && !users.isEmpty()) {
for (String user : users) {
if (UUIDTranslator.UUID_PATTERN.matcher(user).find()) {
setBuilder = setBuilder.add(UUID.fromString(user));
}
}
}