From 115364f202baa85db660bd52554adb35a8ea3de3 Mon Sep 17 00:00:00 2001 From: Sodium-Aluminate Date: Sun, 24 Dec 2023 23:35:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../de/strifel/VTools/commands/CommandSend.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/strifel/VTools/commands/CommandSend.java b/src/main/java/de/strifel/VTools/commands/CommandSend.java index def1c11..c4d8ba6 100644 --- a/src/main/java/de/strifel/VTools/commands/CommandSend.java +++ b/src/main/java/de/strifel/VTools/commands/CommandSend.java @@ -104,16 +104,19 @@ public class CommandSend implements SimpleCommand { String[] currentArgs = invocation.arguments(); switch (currentArgs.length) { case 0, 1 -> { - List arg = new ArrayList<>(server.getPlayerCount() + 2); - arg.add("all"); - arg.add("current"); + List args = new ArrayList<>(server.getPlayerCount() + 2); + args.add("all"); + args.add("current"); for (Player player : server.getAllPlayers()) { - arg.add(player.getUsername()); + args.add(player.getUsername()); } - return arg; + return currentArgs.length==0?args: + args.stream().filter(arg->arg.regionMatches(true,0,currentArgs[0],0,currentArgs[0].length())).toList(); } case 2 -> { - return server.getAllServers().stream().map(s -> s.getServerInfo().getName()).toList(); + return server.getAllServers().stream().map(s -> s.getServerInfo().getName()) + .filter(name -> name.regionMatches(true, 0, currentArgs[1], 0, currentArgs[1].length())) + .toList(); } default -> { return new ArrayList<>(0);