增加补全
This commit is contained in:
parent
5a975a1195
commit
115364f202
1 changed files with 9 additions and 6 deletions
|
@ -104,16 +104,19 @@ public class CommandSend implements SimpleCommand {
|
|||
String[] currentArgs = invocation.arguments();
|
||||
switch (currentArgs.length) {
|
||||
case 0, 1 -> {
|
||||
List<String> arg = new ArrayList<>(server.getPlayerCount() + 2);
|
||||
arg.add("all");
|
||||
arg.add("current");
|
||||
List<String> 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);
|
||||
|
|
Loading…
Reference in a new issue