From a48596de8a752b10adebb4d4bff3878b3551f35e Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 5 Apr 2023 19:34:17 -0600 Subject: [PATCH] Fixes bug that caused /list to not display properly --- .../totalfreedommod/command/Command_list.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java index 504e0078..254bbbc3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_list.java @@ -2,6 +2,10 @@ package me.totalfreedom.totalfreedommod.command; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; +import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang.StringUtils; import org.bukkit.command.Command; @@ -48,39 +52,29 @@ public class Command_list extends FreedomCommand listFilter = ListFilter.PLAYERS; } - String onlineStats; - List players; + List players; if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender)) { - players = plugin.btb.getConnectedAdmins().stream().map(Admin::getName).toList(); - onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + players.size() + ChatColor.BLUE - + " admins connected to telnet."; + players = plugin.btb.getConnectedAdmins().stream().map(admin -> Component.text(admin.getName())).toList(); + msgNew("There are admins connected to telnet.", + Placeholder.unparsed("count", String.valueOf(players.size()))); } else { - onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + FUtil.getFakePlayerCount() + ChatColor.BLUE - + " out of a maximum " + ChatColor.RED + server.getMaxPlayers() + ChatColor.BLUE + " players online."; - players = server.getOnlinePlayers().stream().filter(pl -> (listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId())) || (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId())) || (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player -> - plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList(); - } - - String onlineUsers = "Connected " + listFilter.name().toLowerCase().replace('_', ' ') + ": " + ChatColor.WHITE + - StringUtils.join(players, ChatColor.WHITE + ", " + ChatColor.WHITE); - - if (senderIsConsole) - { - msg(ChatColor.stripColor(onlineStats)); - msg(ChatColor.stripColor(onlineUsers)); - } else - { - msg(onlineStats); - msg(onlineUsers); + Component.textOfChildren(plugin.rm.getDisplay(player).getColoredTag().append(Component.text(player.getName())))).toList(); + + msgNew("There are out of a maximum of players online.", + Placeholder.unparsed("count", String.valueOf(FUtil.getFakePlayerCount())), + Placeholder.unparsed("max", String.valueOf(server.getMaxPlayers()))); } + msgNew("Connected : ", + Placeholder.unparsed("type", listFilter.name().toLowerCase().replace('_', ' ')), + Placeholder.component("players", Component.join(JoinConfiguration.commas(true), players))); return true; }