mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
Fix brigadier command registration with no required arguments
This fixes issues with optional arguments and Default subcommands
This commit is contained in:
@@ -86,10 +86,16 @@ public class ACFBrigadierManager<S> {
|
|||||||
LiteralArgumentBuilder<S> rootBuilder = LiteralArgumentBuilder.<S>literal(root.getLiteral())
|
LiteralArgumentBuilder<S> rootBuilder = LiteralArgumentBuilder.<S>literal(root.getLiteral())
|
||||||
.requires(sender -> permCheckerRoot.test(rootCommand, sender));
|
.requires(sender -> permCheckerRoot.test(rootCommand, sender));
|
||||||
|
|
||||||
|
RegisteredCommand defaultCommand = rootCommand.getDefaultRegisteredCommand();
|
||||||
|
if (defaultCommand != null) {
|
||||||
|
if (defaultCommand.requiredResolvers == 0) {
|
||||||
|
rootBuilder.executes(executor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
root = rootBuilder.build();
|
root = rootBuilder.build();
|
||||||
boolean isForwardingCommand = rootCommand.getDefCommand() instanceof ForwardingCommand;
|
boolean isForwardingCommand = rootCommand.getDefCommand() instanceof ForwardingCommand;
|
||||||
|
|
||||||
RegisteredCommand defaultCommand = rootCommand.getDefaultRegisteredCommand();
|
|
||||||
if (defaultCommand != null) {
|
if (defaultCommand != null) {
|
||||||
registerParameters(defaultCommand, root, suggestionProvider, executor, permCheckerSub);
|
registerParameters(defaultCommand, root, suggestionProvider, executor, permCheckerSub);
|
||||||
}
|
}
|
||||||
@@ -126,8 +132,8 @@ public class ACFBrigadierManager<S> {
|
|||||||
LiteralArgumentBuilder<S> argumentBuilder = LiteralArgumentBuilder.<S>literal(commandName)
|
LiteralArgumentBuilder<S> argumentBuilder = LiteralArgumentBuilder.<S>literal(commandName)
|
||||||
.requires(subPermChecker);
|
.requires(subPermChecker);
|
||||||
|
|
||||||
// if we have no params, this command is actually executable
|
// if we have no required params, this command is actually executable
|
||||||
if (subCommand.getValue().consumeInputResolvers == 0) {
|
if (subCommand.getValue().requiredResolvers == 0) {
|
||||||
argumentBuilder.executes(executor);
|
argumentBuilder.executes(executor);
|
||||||
}
|
}
|
||||||
subCommandNode = argumentBuilder.build();
|
subCommandNode = argumentBuilder.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user