CMDoS because Brigadier
Dieser Commit ist enthalten in:
Ursprung
7e02212680
Commit
66ae2a837c
@ -47,6 +47,29 @@ class SWCommandBrigadier implements SWCommand.SWCommandInterface {
|
||||
|
||||
protected SWCommandBrigadier(SWCommand swCommand, String command, String... aliases) {
|
||||
this.swCommand = swCommand;
|
||||
this.command = new Command(command, "", "/" + command, Arrays.asList(aliases)) {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String alias, String[] args) {
|
||||
if (commandList.stream().anyMatch(s -> s.invoke(sender, args))) return false;
|
||||
commandHelpList.stream().anyMatch(s -> s.invoke(sender, args));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
String string = args[args.length - 1].toLowerCase();
|
||||
return commandList.stream()
|
||||
.map(s -> s.tabComplete(sender, args))
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(Collection::stream)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.filter(s -> s.toLowerCase().startsWith(string))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
unregister();
|
||||
register();
|
||||
|
||||
SWCommandUtils.createList(swCommand, commandList, commandHelpList, localTypeMapper, this::createSubCommand);
|
||||
Stream.of(commandList, commandHelpList).flatMap(List::stream).forEach(subCommand -> {
|
||||
register(command, subCommand, command, aliases);
|
||||
@ -82,10 +105,7 @@ class SWCommandBrigadier implements SWCommand.SWCommandInterface {
|
||||
}
|
||||
argumentBuilder = requiredArgumentBuilder;
|
||||
if (i == current.arguments.length - 1) {
|
||||
argumentBuilder.executes(commandContext -> {
|
||||
current.invoke((CommandSender) commandContext.getCommand(), commandContext.getInput().split(" "));
|
||||
return 0;
|
||||
});
|
||||
argumentBuilder.executes(commandContext -> 1);
|
||||
}
|
||||
}
|
||||
if (current.varArgType != null) {
|
||||
@ -117,28 +137,6 @@ class SWCommandBrigadier implements SWCommand.SWCommandInterface {
|
||||
if (subCommand.argumentNode == null) {
|
||||
return;
|
||||
}
|
||||
if (subCommand.normalTabCompleteNeeded && command == null) {
|
||||
this.command = new Command(command, "", "/" + command, Arrays.asList(aliases)) {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String alias, String[] args) {
|
||||
if (commandList.stream().anyMatch(s -> s.invoke(sender, args))) return false;
|
||||
commandHelpList.stream().anyMatch(s -> s.invoke(sender, args));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
String string = args[args.length - 1].toLowerCase();
|
||||
return commandList.stream()
|
||||
.map(s -> s.tabComplete(sender, args))
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(Collection::stream)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.filter(s -> s.toLowerCase().startsWith(string))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
literalArgumentBuilder.then(subCommand.argumentNode);
|
||||
SWCommand.dispatcher.register(literalArgumentBuilder);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren