mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 00:12:29 +00:00
Uids will not be showed until the parameter <uid> is added,
like this: /list uid
This commit is contained in:
parent
c0b7859f93
commit
ba97dfe7d9
@ -8,29 +8,41 @@ import emu.grasscutter.game.player.Player;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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 {
|
public final class ListCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, List<String> args) {
|
public void execute(Player sender, List<String> args) {
|
||||||
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
|
Map<Integer, Player> 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()));
|
CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size()));
|
||||||
|
|
||||||
if (playersMap.size() != 0) {
|
if (playersMap.size() != 0) {
|
||||||
StringBuilder playerSet = new StringBuilder();
|
StringBuilder playerSet = new StringBuilder();
|
||||||
|
boolean finalNeedUID = needUID;
|
||||||
|
|
||||||
playersMap.values().forEach(player -> {
|
playersMap.values().forEach(player -> {
|
||||||
playerSet.append(player.getNickname());
|
playerSet.append(player.getNickname());
|
||||||
|
|
||||||
if (sender != null) {
|
if (finalNeedUID) {
|
||||||
playerSet.append("<color=green><UID:")
|
if (sender != null) {
|
||||||
.append(player.getUid())
|
playerSet.append("<color=green><UID:")
|
||||||
.append("></color>, ");
|
.append(player.getUid())
|
||||||
} else {
|
.append("></color>");
|
||||||
playerSet.append("<UID:")
|
} else {
|
||||||
.append(player.getUid())
|
playerSet.append("<UID:")
|
||||||
.append(">, ");
|
.append(player.getUid())
|
||||||
|
.append(">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerSet.append(", ");
|
||||||
});
|
});
|
||||||
|
|
||||||
String players = playerSet.toString();
|
String players = playerSet.toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user