SteamWar/SpigotCore
Archiviert
13
0

Optimize SWCommand

Dieser Commit ist enthalten in:
yoyosource 2021-05-05 09:58:08 +02:00
Ursprung 259d6fef99
Commit ee9f9d40ce

Datei anzeigen

@ -60,13 +60,14 @@ public abstract class SWCommand {
@Override @Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
String string = args[args.length - 1].toLowerCase();
return commandList.stream() return commandList.stream()
.map(s -> s.tabComplete(sender, args)) .map(s -> s.tabComplete(sender, args))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.filter(s -> !s.isEmpty()) .filter(s -> !s.isEmpty())
.filter(s -> !s.isBlank()) .filter(s -> !s.isBlank())
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase())) .filter(s -> s.toLowerCase().startsWith(string))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
}; };