From caffe859b82498c00b6d68324a6e08ad1a6c7317 Mon Sep 17 00:00:00 2001
From: coooookies <1164557342@qq.com>
Date: Sun, 1 May 2022 00:17:08 +0800
Subject: [PATCH 1/4] List command should show player uid
---
.../command/commands/ListCommand.java | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
index 99abd7ac7..9ff8d2fe1 100644
--- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java
+++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
@@ -19,9 +19,20 @@ public final class ListCommand implements CommandHandler {
if (playersMap.size() != 0) {
StringBuilder playerSet = new StringBuilder();
- playersMap.values().forEach(player ->
- playerSet.append(player.getNickname()).append(", "));
-
+ playersMap.values().forEach(player -> {
+ playerSet.append(player.getNickname());
+
+ if (sender != null) {
+ playerSet.append(", ");
+ } else {
+ playerSet.append(", ");
+ }
+ });
+
String players = playerSet.toString();
CommandHandler.sendMessage(sender, players.substring(0, players.length() - 2));
}
From 1d6916bca18b209fc3d64e6ac7127b04618fbd20 Mon Sep 17 00:00:00 2001
From: coooookies <1164557342@qq.com>
Date: Sun, 1 May 2022 03:43:41 +0800
Subject: [PATCH 2/4] 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();
From 3a45a5b5c423a2174d4395205da62fb0341c42ef Mon Sep 17 00:00:00 2001
From: Magix
Date: Sat, 30 Apr 2022 16:14:40 -0400
Subject: [PATCH 3/4] Change to `()` and add space
---
.../java/emu/grasscutter/command/commands/ListCommand.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
index 416a10538..f1b5d5429 100644
--- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java
+++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
@@ -36,9 +36,9 @@ public final class ListCommand implements CommandHandler {
.append(player.getUid())
.append(">");
} else {
- playerSet.append("");
+ .append(")");
}
}
From 78f6e6b7cf0dc1a51612f8148bb8aae3a06e5d01 Mon Sep 17 00:00:00 2001
From: Magix
Date: Sat, 30 Apr 2022 16:15:39 -0400
Subject: [PATCH 4/4] Forgot to add to null execution
---
.../java/emu/grasscutter/command/commands/ListCommand.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
index f1b5d5429..c57c0c1ee 100644
--- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java
+++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java
@@ -32,9 +32,9 @@ public final class ListCommand implements CommandHandler {
if (finalNeedUID) {
if (sender != null) {
- playerSet.append("(")
.append(player.getUid())
- .append(">");
+ .append(")");
} else {
playerSet.append(" (")
.append(player.getUid())