2
0
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:
Tux 2015-05-17 14:54:35 -04:00
parent 66996a295c
commit 86efdeaf8e

View File

@ -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");