From ba97dfe7d99e327c79b77f0f212905748e5c0d31 Mon Sep 17 00:00:00 2001 From: coooookies <1164557342@qq.com> Date: Sun, 1 May 2022 03:43:41 +0800 Subject: [PATCH] Uids will not be showed until the parameter is added, like this: /list uid --- .../command/commands/ListCommand.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java index 9ff8d2fe1..416a10538 100644 --- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java @@ -8,29 +8,41 @@ import emu.grasscutter.game.player.Player; import java.util.List; import java.util.Map; -@Command(label = "list", description = "List online players") +@Command(label = "list", usage = "list [uid]", + description = "List online players", aliases = {"players"}) public final class ListCommand implements CommandHandler { @Override public void execute(Player sender, List args) { Map playersMap = Grasscutter.getGameServer().getPlayers(); + boolean needUID = false; + + if (args.size() > 0) { + needUID = args.get(0).equals("uid"); + } CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size())); if (playersMap.size() != 0) { StringBuilder playerSet = new StringBuilder(); + boolean finalNeedUID = needUID; + playersMap.values().forEach(player -> { playerSet.append(player.getNickname()); - if (sender != null) { - playerSet.append(", "); - } else { - playerSet.append(", "); + if (finalNeedUID) { + if (sender != null) { + playerSet.append(""); + } else { + playerSet.append(""); + } } + + playerSet.append(", "); }); String players = playerSet.toString();