matchingPlayers = new ArrayList<>();
+ for (var p : this.server.getWorld().getPlayers().values()) {
+ if (Integer.toString(p.getId()).equals(query) || p.getName().equals(query)) {
+ matchingPlayers.add(p);
+ }
+ }
+ if (matchingPlayers.isEmpty()) {
+ System.out.println("No matching players found.");
+ } else if (matchingPlayers.size() > 1) {
+ System.out.println("More than one matching player found.");
+ } else {
+ Player player = matchingPlayers.get(0);
+ this.server.kickPlayer(player);
+ System.out.println("Kicked player " + player.getName() + ".");
+ }
+ }
+}
diff --git a/server/src/main/java/nl/andrewlalis/aos_server/command/ListPlayersCommand.java b/server/src/main/java/nl/andrewlalis/aos_server/command/ListPlayersCommand.java
new file mode 100644
index 0000000..431e39e
--- /dev/null
+++ b/server/src/main/java/nl/andrewlalis/aos_server/command/ListPlayersCommand.java
@@ -0,0 +1,35 @@
+package nl.andrewlalis.aos_server.command;
+
+import nl.andrewlalis.aos_core.model.Player;
+import nl.andrewlalis.aos_server.Server;
+
+import java.util.stream.Collectors;
+
+public class ListPlayersCommand implements Command {
+ private final Server server;
+
+ public ListPlayersCommand(Server server) {
+ this.server = server;
+ }
+
+ @Override
+ public void execute(String[] args) {
+ if (this.server.getWorld().getPlayers().isEmpty()) {
+ System.out.println("There are no players currently online.");
+ return;
+ }
+ String message = this.server.getWorld().getPlayers().values().stream()
+ .sorted()
+ .map(player -> String.format(
+ "%d | %s Team: %s, Health: %.1f / %.1f, Gun: %s",
+ player.getId(),
+ player.getName(),
+ player.getTeam() == null ? "none" : player.getTeam().getName(),
+ player.getHealth(),
+ Player.MAX_HEALTH,
+ player.getGun().getType().name()
+ ))
+ .collect(Collectors.joining("\n"));
+ System.out.println(message);
+ }
+}
diff --git a/server/src/main/java/nl/andrewlalis/aos_server/command/ResetCommand.java b/server/src/main/java/nl/andrewlalis/aos_server/command/ResetCommand.java
new file mode 100644
index 0000000..9394298
--- /dev/null
+++ b/server/src/main/java/nl/andrewlalis/aos_server/command/ResetCommand.java
@@ -0,0 +1,17 @@
+package nl.andrewlalis.aos_server.command;
+
+import nl.andrewlalis.aos_server.Server;
+
+public class ResetCommand implements Command {
+ private final Server server;
+
+ public ResetCommand(Server server) {
+ this.server = server;
+ }
+
+ @Override
+ public void execute(String[] args) {
+ this.server.resetGame();
+ System.out.println("Reset the game.");
+ }
+}
diff --git a/server/src/main/java/nl/andrewlalis/aos_server/command/StopCommand.java b/server/src/main/java/nl/andrewlalis/aos_server/command/StopCommand.java
new file mode 100644
index 0000000..cbc95e0
--- /dev/null
+++ b/server/src/main/java/nl/andrewlalis/aos_server/command/StopCommand.java
@@ -0,0 +1,16 @@
+package nl.andrewlalis.aos_server.command;
+
+import nl.andrewlalis.aos_server.Server;
+
+public class StopCommand implements Command {
+ private final Server server;
+
+ public StopCommand(Server server) {
+ this.server = server;
+ }
+
+ @Override
+ public void execute(String[] args) {
+ this.server.shutdown();
+ }
+}
diff --git a/server/src/main/resources/help.txt b/server/src/main/resources/help.txt
new file mode 100644
index 0000000..e9a7d52
--- /dev/null
+++ b/server/src/main/resources/help.txt
@@ -0,0 +1,16 @@
+Ace of Shades - Server CLI Help
+-------------------------------
+
+This command-line interface is used to issue commands while the server is
+running, to change the state of the game or configuration options, without
+having to restart.
+
+The following commands are available:
+
+stop Stops the server, disconnecting all clients.
+reset Resets the server by respawning all players and resets scores.
+help Shows this help message.
+
+list Show a list of all connected players.
+kick Kick a player with the given id or name. If more than one player
+ exists with a given name, you need to use their unique id.