diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java index 99abd7ac7..c57c0c1ee 100644 --- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java @@ -8,20 +8,43 @@ 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(); - playersMap.values().forEach(player -> - playerSet.append(player.getNickname()).append(", ")); - + boolean finalNeedUID = needUID; + + playersMap.values().forEach(player -> { + playerSet.append(player.getNickname()); + + if (finalNeedUID) { + if (sender != null) { + playerSet.append(" (") + .append(player.getUid()) + .append(")"); + } else { + playerSet.append(" (") + .append(player.getUid()) + .append(")"); + } + } + + playerSet.append(", "); + }); + String players = playerSet.toString(); CommandHandler.sendMessage(sender, players.substring(0, players.length() - 2)); }