Simplify Argument.tabCompleteSupplier
Dieser Commit ist enthalten in:
Ursprung
72863f30f0
Commit
ee85ec6696
@ -117,9 +117,7 @@ public class Argument<T> {
|
||||
// Check number constraints if needed
|
||||
if (argumentType.number && !constraint.test(argumentMapped)) return Optional.empty();
|
||||
}
|
||||
List<String> strings = Arrays.stream(tabCompletes.apply(s)).filter(t -> t.startsWith(s)).collect(Collectors.toList());
|
||||
if (strings.isEmpty()) strings.add(s);
|
||||
return Optional.of(strings);
|
||||
return Optional.of(Arrays.stream(tabCompletes.apply(s)).filter(t -> t.startsWith(s)).collect(Collectors.toList()));
|
||||
} catch (NumberFormatException e) {
|
||||
return Optional.empty();
|
||||
} catch (Exception e) {
|
||||
|
@ -59,8 +59,7 @@ public class SWCommandBundle {
|
||||
public List<String> tabComplete(String[] args) {
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (SWCommand swCommand : swCommandList) {
|
||||
Optional<List<String>> tabCompletes = swCommand.tabComplete(args);
|
||||
if (tabCompletes.isPresent()) strings.addAll(tabCompletes.get());
|
||||
swCommand.tabComplete(args).ifPresent(strings::addAll);
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren