Fix brigadier command registration with no required arguments

This fixes issues with optional arguments and Default subcommands
This commit is contained in:
chickeneer
2022-08-01 02:01:05 -05:00
parent c35e45477e
commit 0f75b89a2e
@@ -86,10 +86,16 @@ public class ACFBrigadierManager<S> {
LiteralArgumentBuilder<S> rootBuilder = LiteralArgumentBuilder.<S>literal(root.getLiteral())
.requires(sender -> permCheckerRoot.test(rootCommand, sender));
RegisteredCommand defaultCommand = rootCommand.getDefaultRegisteredCommand();
if (defaultCommand != null) {
if (defaultCommand.requiredResolvers == 0) {
rootBuilder.executes(executor);
}
}
root = rootBuilder.build();
boolean isForwardingCommand = rootCommand.getDefCommand() instanceof ForwardingCommand;
RegisteredCommand defaultCommand = rootCommand.getDefaultRegisteredCommand();
if (defaultCommand != null) {
registerParameters(defaultCommand, root, suggestionProvider, executor, permCheckerSub);
}
@@ -126,8 +132,8 @@ public class ACFBrigadierManager<S> {
LiteralArgumentBuilder<S> argumentBuilder = LiteralArgumentBuilder.<S>literal(commandName)
.requires(subPermChecker);
// if we have no params, this command is actually executable
if (subCommand.getValue().consumeInputResolvers == 0) {
// if we have no required params, this command is actually executable
if (subCommand.getValue().requiredResolvers == 0) {
argumentBuilder.executes(executor);
}
subCommandNode = argumentBuilder.build();