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

fix glist command when UUID to name translation fails by returning the uuid

This commit is contained in:
mohammed jasem alaajel 2022-07-19 07:41:21 +04:00
parent d806bc2d41
commit f722b8c9d3
2 changed files with 13 additions and 6 deletions

View File

@ -60,7 +60,9 @@ public class RedisBungeeCommands {
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) { for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false)); // if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
String playerName = plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false);
human.put(entry.getKey(), playerName != null ? playerName : entry.getValue().toString());
} }
for (String server : new TreeSet<>(serverToPlayers.keySet())) { for (String server : new TreeSet<>(serverToPlayers.keySet())) {
TextComponent serverName = new TextComponent(); TextComponent serverName = new TextComponent();

View File

@ -58,7 +58,11 @@ public class RedisBungeeCommands {
if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) { if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
serverToPlayers.forEach((key, value) -> human.put(key, plugin.getUuidTranslator().getNameFromUuid(value, false))); serverToPlayers.forEach((key, value) -> {
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
String playerName = plugin.getUuidTranslator().getNameFromUuid(value, false);
human.put(key, playerName != null ? playerName : value.toString());
});
for (String server : new TreeSet<>(serverToPlayers.keySet())) { for (String server : new TreeSet<>(serverToPlayers.keySet())) {
Component serverName = Component.text("[" + server + "] ", NamedTextColor.GREEN); Component serverName = Component.text("[" + server + "] ", NamedTextColor.GREEN);
Component serverCount = Component.text("(" + serverToPlayers.get(server).size() + "): ", NamedTextColor.YELLOW); Component serverCount = Component.text("(" + serverToPlayers.get(server).size() + "): ", NamedTextColor.YELLOW);
@ -281,6 +285,7 @@ public class RedisBungeeCommands {
public static class ServerIds implements SimpleCommand { public static class ServerIds implements SimpleCommand {
private final RedisBungeeVelocityPlugin plugin; private final RedisBungeeVelocityPlugin plugin;
public ServerIds(RedisBungeeVelocityPlugin plugin) { public ServerIds(RedisBungeeVelocityPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }