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.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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 net.md_5.bungee.api.ChatColor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -48,39 +52,29 @@ public class Command_list extends FreedomCommand
|
|||||||
listFilter = ListFilter.PLAYERS;
|
listFilter = ListFilter.PLAYERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
String onlineStats;
|
List<TextComponent> players;
|
||||||
List<String> players;
|
|
||||||
|
|
||||||
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
if (listFilter == ListFilter.TELNET_SESSIONS && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
players = plugin.btb.getConnectedAdmins().stream().map(Admin::getName).toList();
|
players = plugin.btb.getConnectedAdmins().stream().map(admin -> Component.text(admin.getName())).toList();
|
||||||
onlineStats = ChatColor.BLUE + "There are " + ChatColor.RED + players.size() + ChatColor.BLUE
|
msgNew("<blue>There are <red><count></red> admins connected to telnet.",
|
||||||
+ " admins connected to telnet.";
|
Placeholder.unparsed("count", String.valueOf(players.size())));
|
||||||
} else
|
} 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 ->
|
players = server.getOnlinePlayers().stream().filter(pl ->
|
||||||
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId()))
|
(listFilter == ListFilter.ADMINS && plugin.al.isAdmin(pl) && !plugin.al.isVanished(pl.getUniqueId()))
|
||||||
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId()))
|
|| (listFilter == ListFilter.VANISHED_ADMINS && plugin.al.isVanished(pl.getUniqueId()))
|
||||||
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player ->
|
|| (listFilter == ListFilter.PLAYERS && !plugin.al.isVanished(pl.getUniqueId()))).map(player ->
|
||||||
plugin.rm.getDisplay(player).getColoredTag() + player.getName()).toList();
|
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.",
|
||||||
String onlineUsers = "Connected " + listFilter.name().toLowerCase().replace('_', ' ') + ": " + ChatColor.WHITE +
|
Placeholder.unparsed("count", String.valueOf(FUtil.getFakePlayerCount())),
|
||||||
StringUtils.join(players, ChatColor.WHITE + ", " + ChatColor.WHITE);
|
Placeholder.unparsed("max", String.valueOf(server.getMaxPlayers())));
|
||||||
|
|
||||||
if (senderIsConsole)
|
|
||||||
{
|
|
||||||
msg(ChatColor.stripColor(onlineStats));
|
|
||||||
msg(ChatColor.stripColor(onlineUsers));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
msg(onlineStats);
|
|
||||||
msg(onlineUsers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msgNew("Connected <type>: <players>",
|
||||||
|
Placeholder.unparsed("type", listFilter.name().toLowerCase().replace('_', ' ')),
|
||||||
|
Placeholder.component("players", Component.join(JoinConfiguration.commas(true), players)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user