1
0
Fork 0
forked from mc/VTools

增加补全

This commit is contained in:
Sodium-Aluminate 2023-12-24 23:35:08 +08:00
parent 5a975a1195
commit 115364f202

View file

@ -104,16 +104,19 @@ public class CommandSend implements SimpleCommand {
String[] currentArgs = invocation.arguments(); String[] currentArgs = invocation.arguments();
switch (currentArgs.length) { switch (currentArgs.length) {
case 0, 1 -> { case 0, 1 -> {
List<String> arg = new ArrayList<>(server.getPlayerCount() + 2); List<String> args = new ArrayList<>(server.getPlayerCount() + 2);
arg.add("all"); args.add("all");
arg.add("current"); args.add("current");
for (Player player : server.getAllPlayers()) { 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 -> { 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 -> { default -> {
return new ArrayList<>(0); return new ArrayList<>(0);