mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Fixes bug that caused /list to not display properly
This commit is contained in:
parent
39b9147484
commit
a48596de8a
@ -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<String> players;
|
||||
List<TextComponent> 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("<blue>There are <red><count></red> 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("<blue>There are <red><count></red> out of a maximum of <red><max></red> players online.",
|
||||
Placeholder.unparsed("count", String.valueOf(FUtil.getFakePlayerCount())),
|
||||
Placeholder.unparsed("max", String.valueOf(server.getMaxPlayers())));
|
||||
}
|
||||
|
||||
msgNew("Connected <type>: <players>",
|
||||
Placeholder.unparsed("type", listFilter.name().toLowerCase().replace('_', ' ')),
|
||||
Placeholder.component("players", Component.join(JoinConfiguration.commas(true), players)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user