mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 10:38:01 +00:00
Make ServerPlayers messages looking for counts be less expensive to run by skipping the UUID lookup.
This commit is contained in:
parent
66996a295c
commit
86efdeaf8e
@ -182,11 +182,24 @@ public class RedisBungeeListener implements Listener {
|
||||
} catch (Exception e) {}
|
||||
out.writeUTF("ServerPlayers");
|
||||
Multimap<String, UUID> multimap = RedisBungee.getApi().getServerToPlayers();
|
||||
Multimap<String, String> human = HashMultimap.create();
|
||||
for (Map.Entry<String, UUID> entry : multimap.entries()) {
|
||||
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false));
|
||||
|
||||
boolean includesUsers = type1.equals("PLAYERS");
|
||||
|
||||
if (includesUsers) {
|
||||
Multimap<String, String> human = HashMultimap.create();
|
||||
for (Map.Entry<String, UUID> entry : multimap.entries()) {
|
||||
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false));
|
||||
}
|
||||
serializeMultimap(human, true, out);
|
||||
} else {
|
||||
// Due to Java generics, we are forced to coerce UUIDs into strings. This is less
|
||||
// expensive than looking up names, since we just want counts.
|
||||
Multimap<String, String> flunk = HashMultimap.create();
|
||||
for (Map.Entry<String, UUID> entry : multimap.entries()) {
|
||||
flunk.put(entry.getKey(), entry.getValue().toString());
|
||||
}
|
||||
serializeMultimap(flunk, false, out);
|
||||
}
|
||||
serializeMultimap(human, type1.equals("PLAYERS"), out);
|
||||
break;
|
||||
case "Proxy":
|
||||
out.writeUTF("Proxy");
|
||||
|
Loading…
Reference in New Issue
Block a user