Class CommandDispatcher
java.lang.Object
tech.guilhermekaua.spigotboot.commands.execution.CommandDispatcher
-
Constructor Summary
ConstructorsConstructorDescriptionCommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver) Creates a dispatcher with an empty interceptor chain and the default keyed-message renderer.CommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver, CommandInterceptorChain interceptorChain) Creates a dispatcher with the given interceptor chain and the default keyed-message renderer.CommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver, CommandInterceptorChain interceptorChain, CommandMessageRenderer messageRenderer) Creates a dispatcher with all collaborators supplied explicitly. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanUseAnyRoute(CompiledRootCommand root, CommandSenderHandle sender) Returns whether the sender can use at least one route of the given root command — either the default handler or any subcommand route whose@Permissionthe sender satisfies (a route with no permission is always usable).complete(Context context, CompiledRootCommand root, CommandSenderHandle sender, String label, String[] args) booleandispatch(Context context, CompiledRootCommand root, CommandSenderHandle sender, String label, String[] args)
-
Constructor Details
-
CommandDispatcher
public CommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver) Creates a dispatcher with an empty interceptor chain and the default keyed-message renderer. Convenience overload that delegates toCommandDispatcher(CommandParameterBinder, CommandInvocationExecutor, CommandMessagesProvider, CompletionResolver, CommandInterceptorChain, CommandMessageRenderer).- Parameters:
parameterBinder- binds raw input tokens to invocation arguments; must not benullinvocationExecutor- invokes the resolved command handler; must not benullmessagesProvider- resolves the activeCommandMessagesfor a context; must not benullcompletionResolver- produces tab-completion suggestions; must not benull
-
CommandDispatcher
public CommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver, CommandInterceptorChain interceptorChain) Creates a dispatcher with the given interceptor chain and the default keyed-message renderer. Convenience overload that delegates toCommandDispatcher(CommandParameterBinder, CommandInvocationExecutor, CommandMessagesProvider, CompletionResolver, CommandInterceptorChain, CommandMessageRenderer).- Parameters:
parameterBinder- binds raw input tokens to invocation arguments; must not benullinvocationExecutor- invokes the resolved command handler; must not benullmessagesProvider- resolves the activeCommandMessagesfor a context; must not benullcompletionResolver- produces tab-completion suggestions; must not benullinterceptorChain- the chain of interceptors run around each invocation; must not benull
-
CommandDispatcher
public CommandDispatcher(CommandParameterBinder parameterBinder, CommandInvocationExecutor invocationExecutor, CommandMessagesProvider messagesProvider, CompletionResolver completionResolver, CommandInterceptorChain interceptorChain, CommandMessageRenderer messageRenderer) Creates a dispatcher with all collaborators supplied explicitly.- Parameters:
parameterBinder- binds raw input tokens to invocation arguments; must not benullinvocationExecutor- invokes the resolved command handler; must not benullmessagesProvider- resolves the activeCommandMessagesfor a context; must not benullcompletionResolver- produces tab-completion suggestions; must not benullinterceptorChain- the chain of interceptors run around each invocation; must not benullmessageRenderer- renders keyedCommandMessageExceptionfailures; must not benull- Throws:
NullPointerException- if any argument isnull
-
-
Method Details
-
dispatch
public boolean dispatch(Context context, CompiledRootCommand root, CommandSenderHandle sender, String label, String[] args) -
complete
public List<String> complete(Context context, CompiledRootCommand root, CommandSenderHandle sender, String label, String[] args) -
canUseAnyRoute
Returns whether the sender can use at least one route of the given root command — either the default handler or any subcommand route whose@Permissionthe sender satisfies (a route with no permission is always usable). Platform adapters use this to gate command visibility (client-side tab completion / the command tree) so a command is hidden from senders who cannot run any of its routes, mirroring the per-route filteringcomplete(tech.guilhermekaua.spigotboot.core.context.Context, tech.guilhermekaua.spigotboot.commands.route.CompiledRootCommand, tech.guilhermekaua.spigotboot.commands.CommandSenderHandle, java.lang.String, java.lang.String[])already applies to argument suggestions. The@CatchUnknownhandler is intentionally not counted: it handles unmatched input rather than representing a usable command path.- Parameters:
root- the compiled root command; must not benullsender- the sender to test; must not benull- Returns:
trueif the default handler or at least one route is permitted forsender
-