2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-12-23 02: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, String> human = HashMultimap.create();
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())) {
TextComponent serverName = new TextComponent();

View File

@ -30,7 +30,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
* @since 0.2.3
*/
public class RedisBungeeCommands {
private static final Component NO_PLAYER_SPECIFIED =
Component.text("You must specify a player name.", NamedTextColor.RED);
private static final Component PLAYER_NOT_FOUND =
@ -58,7 +58,11 @@ public class RedisBungeeCommands {
if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getApi().getServerToPlayers();
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())) {
Component serverName = Component.text("[" + server + "] ", NamedTextColor.GREEN);
Component serverCount = Component.text("(" + serverToPlayers.get(server).size() + "): ", NamedTextColor.YELLOW);
@ -281,14 +285,15 @@ public class RedisBungeeCommands {
public static class ServerIds implements SimpleCommand {
private final RedisBungeeVelocityPlugin plugin;
public ServerIds(RedisBungeeVelocityPlugin plugin) {
this.plugin =plugin;
this.plugin = plugin;
}
@Override
public void execute(Invocation invocation) {
invocation.source().sendMessage(
Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getApi().getAllProxies()), NamedTextColor.YELLOW));
Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getApi().getAllProxies()), NamedTextColor.YELLOW));
}
@Override
@ -306,7 +311,7 @@ public class RedisBungeeCommands {
@Override
public void execute(Invocation invocation) {
CommandSource sender= invocation.source();
CommandSource sender = invocation.source();
String[] args = invocation.arguments();
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
String proxy = args.length >= 1 ? args[0] : plugin.getConfiguration().getProxyId();