fix-commodore (#27)

This commit is contained in:
Alexander Söderberg 2020-10-06 12:39:06 +02:00 committed by GitHub
parent 8f8f98b189
commit c3469706ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 435 additions and 11 deletions

View file

@ -256,6 +256,7 @@ public final class CloudBrigadierManager<C, S> {
* @param label Command label
* @param cloudCommand Cloud command instance
* @param permissionChecker Permission checker
* @param forceRegister Whether or not to force register an executor at every node
* @param executor Command executor
* @return Literal command node
*/
@ -263,6 +264,7 @@ public final class CloudBrigadierManager<C, S> {
final @NonNull Command<C> cloudCommand,
final @NonNull BiPredicate<@NonNull S,
@NonNull CommandPermission> permissionChecker,
final boolean forceRegister,
final com.mojang.brigadier.@NonNull Command<S> executor) {
final CommandTree.Node<CommandArgument<C, ?>> node = this.commandManager
.getCommandTree().getNamedNode(cloudCommand.getArguments().get(0).getName());
@ -272,10 +274,13 @@ public final class CloudBrigadierManager<C, S> {
.requires(sender -> permissionChecker.test(sender, (CommandPermission) node.getNodeMeta()
.getOrDefault("permission",
Permission.empty())));
if (forceRegister || (node.getValue() != null && node.getValue().getOwningCommand() != null)) {
literalArgumentBuilder.executes(executor);
}
literalArgumentBuilder.executes(executor);
final LiteralCommandNode<S> constructedRoot = literalArgumentBuilder.build();
for (final CommandTree.Node<CommandArgument<C, ?>> child : node.getChildren()) {
constructedRoot.addChild(this.constructCommandNode(true, child,
constructedRoot.addChild(this.constructCommandNode(forceRegister, child,
permissionChecker, executor, provider).build());
}
return constructedRoot;