mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
fix glist command when UUID to name translation fails by returning the uuid
This commit is contained in:
parent
d806bc2d41
commit
f722b8c9d3
@ -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();
|
||||||
|
@ -30,7 +30,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
* @since 0.2.3
|
* @since 0.2.3
|
||||||
*/
|
*/
|
||||||
public class RedisBungeeCommands {
|
public class RedisBungeeCommands {
|
||||||
|
|
||||||
private static final Component NO_PLAYER_SPECIFIED =
|
private static final Component NO_PLAYER_SPECIFIED =
|
||||||
Component.text("You must specify a player name.", NamedTextColor.RED);
|
Component.text("You must specify a player name.", NamedTextColor.RED);
|
||||||
private static final Component PLAYER_NOT_FOUND =
|
private static final Component PLAYER_NOT_FOUND =
|
||||||
@ -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,14 +285,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Invocation invocation) {
|
public void execute(Invocation invocation) {
|
||||||
invocation.source().sendMessage(
|
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
|
@Override
|
||||||
@ -306,7 +311,7 @@ public class RedisBungeeCommands {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Invocation invocation) {
|
public void execute(Invocation invocation) {
|
||||||
CommandSource sender= invocation.source();
|
CommandSource sender = invocation.source();
|
||||||
String[] args = invocation.arguments();
|
String[] args = invocation.arguments();
|
||||||
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
||||||
String proxy = args.length >= 1 ? args[0] : plugin.getConfiguration().getProxyId();
|
String proxy = args.length >= 1 ? args[0] : plugin.getConfiguration().getProxyId();
|
||||||
|
Loading…
Reference in New Issue
Block a user