Class BaseCommandHandler
- All Implemented Interfaces:
CommandHandler
- Direct Known Subclasses:
BukkitHandler
,BungeeHandler
,CLIHandler
,JDAHandler
,SpongeHandler
,VelocityHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<CommandPath,
revxrsal.commands.core.BaseCommandCategory> protected final Map<CommandPath,
revxrsal.commands.core.CommandExecutable> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull CommandHandler
accept
(@NotNull CommandHandlerVisitor visitor) Accepts the givenCommandHandlerVisitor
and allows it to visit this command handler.@NotNull CommandHandler
Disables stacktrace sanitization.<T> @NotNull Optional<@Nullable T>
dispatch
(@NotNull CommandActor actor, @NotNull String commandInput) Evaluates the command from the given input<T> @NotNull Optional<@Nullable T>
dispatch
(@NotNull CommandActor actor, @NotNull ArgumentStack arguments) Evaluates the command from the given arguments@NotNull CommandHandler
Sets the command to fail when too many arguments are specified in the command.@NotNull ArgumentParser
Returns theArgumentParser
responsible for controlling the logic of parsing strings.@NotNull AutoCompleter
Returns the auto-completion handler of this command handler@UnmodifiableView @NotNull Map<CommandPath,
CommandCategory> Returns an unmodifiable view of all the registered categories in this command handler.getCategory
(@NotNull CommandPath path) Returns the givenCommandCategory
that matches the given path.getCommand
(@NotNull CommandPath path) Returns the givenExecutableCommand
that matches the given path.@UnmodifiableView @NotNull Map<CommandPath,
ExecutableCommand> Returns an unmodifiable view of all the registered commands in this command handler.<T> Supplier<T>
getDependency
(@NotNull Class<T> dependencyType) Returns the dependency registered for the given type<T> Supplier<T>
getDependency
(@NotNull Class<T> dependencyType, Supplier<T> def) Returns the dependency registered for the given type, otherwise returns the givendef
value.@NotNull CommandExceptionHandler
Returns the command exception handler currently used by this command handler@NotNull String
Returns the prefix that comes before allFlag
parameters when they are fetched from the command.<T> CommandHelpWriter<T>
Returns theCommandHelpWriter
of this command handler.@NotNull Locale
Gets the current, default locale used by this handler@NotNull String
Returns the prefix that preceds all messages sent byCommandActor.reply(String)
andCommandActor.error(String)
.@NotNull MethodCallerFactory
Returns theMethodCallerFactory
responsible for generating reflective calls.<T> ParameterResolver<T>
getResolver
(CommandParameter parameter) @NotNull Set<CommandPath>
Returns all the root commands or categories paths in this command handler.@NotNull String
Returns the prefix that comes before allSwitch
parameters when they are fetched from the command.@NotNull Translator
Returns the translator of this command handlerparseArguments
(String... arguments) Parses the string array and returns anArgumentStack
for it.parseArgumentsForCompletion
(String... arguments) Parses the string and returns anArgumentStack
for it.@NotNull CommandHandler
Registers the specified command from an instance.<T extends Annotation>
@NotNull CommandHandlerregisterAnnotationReplacer
(@NotNull Class<T> annotationType, @NotNull AnnotationReplacer<T> replacer) Registers an annotation replacer.@NotNull CommandHandler
registerCondition
(@NotNull CommandCondition condition) Registers the specified condition in which all commands will be validated with.<T> @NotNull CommandHandler
registerContextResolver
(int priority, @NotNull Class<T> type, @NotNull ContextResolver<T> resolver) Registers a parameter resolver that gets its value from the command context.<T> @NotNull CommandHandler
registerContextResolver
(@NotNull Class<T> type, @NotNull ContextResolver<T> resolver) Registers a parameter resolver that gets its value from the command context.@NotNull CommandHandler
registerContextResolverFactory
(int priority, @NotNull ContextResolverFactory factory) Registers aContextResolverFactory
to this handler@NotNull CommandHandler
registerContextResolverFactory
(@NotNull ContextResolverFactory factory) Registers aContextResolverFactory
to this handler<T> @NotNull CommandHandler
registerContextValue
(int priority, @NotNull Class<T> type, T value) Registers a parameter type to always be a static value.<T> @NotNull CommandHandler
registerContextValue
(@NotNull Class<T> type, T value) Registers a parameter type to always be a static value.<T> @NotNull CommandHandler
registerDependency
(@NotNull Class<T> type, @NotNull Supplier<T> supplier) Registers a dependency for dependency injection.<T> @NotNull CommandHandler
registerDependency
(@NotNull Class<T> type, T value) Registers a (static) dependency for dependency injection.<T extends Throwable>
@NotNull CommandHandlerregisterExceptionHandler
(@NotNull Class<T> exceptionType, @NotNull BiConsumer<CommandActor, T> handler) Convenient method to register exception handlers.<T> @NotNull CommandHandler
registerParameterValidator
(@NotNull Class<T> type, @NotNull ParameterValidator<T> validator) Registers aParameterValidator
for the specified parameter type.@NotNull CommandHandler
registerPermissionReader
(@NotNull PermissionReader reader) Registers the given permission reader, which allows registering customCommandPermission
implementations with annotations.<T> @NotNull CommandHandler
registerResponseHandler
(@NotNull Class<T> responseType, @NotNull ResponseHandler<T> handler) Registers a response handler for the specified response type.@NotNull CommandHandler
registerSenderResolver
(@NotNull SenderResolver resolver) Registers the given sender resolver, which resolves parameters at index 0 that may be potentially a custom sender implementation.<T> @NotNull CommandHandler
registerValueResolver
(int priority, @NotNull Class<T> type, @NotNull ValueResolver<T> resolver) Registers a parameter resolver that gets its value from the command arguments.<T> @NotNull CommandHandler
registerValueResolver
(@NotNull Class<T> type, @NotNull ValueResolver<T> resolver) Registers a parameter resolver that gets its value from the command arguments.@NotNull CommandHandler
registerValueResolverFactory
(int priority, @NotNull ValueResolverFactory factory) Registers aValueResolverFactory
to this handler@NotNull CommandHandler
registerValueResolverFactory
(@NotNull ValueResolverFactory factory) Registers aValueResolverFactory
to this handler<T extends Annotation>
@Nullable List<Annotation>replaceAnnotation
(AnnotatedElement element, T ann) setArgumentParser
(@NotNull ArgumentParser argumentParser) Sets theArgumentParser
responsible for controlling the logic of parsing strings.protected void
@NotNull CommandHandler
setExceptionHandler
(@NotNull CommandExceptionHandler handler) Sets theCommandExceptionHandler
to use for handling any exceptions that are thrown from the command.@NotNull CommandHandler
setFlagPrefix
(@NotNull String prefix) Sets the prefix that all parameters annotated withFlag
will be checked against.<T> @NotNull CommandHandler
setHelpWriter
(@NotNull CommandHelpWriter<T> helpWriter) Sets theCommandHelpWriter
responsible for generating help pagesvoid
Sets the locale of this handler.@NotNull CommandHandler
setMessagePrefix
(@NotNull String prefix) Returns the prefix that should preced all messages sent withCommandActor.reply(String)
andCommandActor.error(String)
.@NotNull CommandHandler
setMethodCallerFactory
(@NotNull MethodCallerFactory factory) Sets theMethodCallerFactory
responsible for generating access to reflection methods.@NotNull CommandHandler
setSwitchPrefix
(@NotNull String prefix) Sets the prefix that all parameters annotated withSwitch
will be checked against.boolean
unregister
(@NotNull String commandPath) Unregisters the given path and all the sub-paths that belong to itboolean
unregister
(@NotNull CommandPath path) Unregisters the given path and all the sub-paths that belong to itvoid
Unregisters all the command instances in this command handler.
-
Field Details
-
executables
-
categories
-
-
Constructor Details
-
BaseCommandHandler
public BaseCommandHandler()
-
-
Method Details
-
register
Description copied from interface:CommandHandler
Registers the specified command from an instance. This will automatically set allDependency
-annotated fields with their values.- Specified by:
register
in interfaceCommandHandler
- Parameters:
commands
- The commands object instances. Can be a class if methods are static.- Returns:
- This command handler
-
getLocale
Description copied from interface:CommandHandler
Gets the current, default locale used by this handler- Specified by:
getLocale
in interfaceCommandHandler
- Returns:
- The default locale
-
setLocale
Description copied from interface:CommandHandler
Sets the locale of this handler.- Specified by:
setLocale
in interfaceCommandHandler
- Parameters:
locale
- The locale of this handler
-
getTranslator
Description copied from interface:CommandHandler
Returns the translator of this command handler- Specified by:
getTranslator
in interfaceCommandHandler
- Returns:
- The message translator
-
getPermissionReaders
-
setMethodCallerFactory
@NotNull public @NotNull CommandHandler setMethodCallerFactory(@NotNull @NotNull MethodCallerFactory factory) Description copied from interface:CommandHandler
Sets theMethodCallerFactory
responsible for generating access to reflection methods.This method allows using alternative strategy for accessing methods reflectively.
- Specified by:
setMethodCallerFactory
in interfaceCommandHandler
- Parameters:
factory
- Factory to set- Returns:
- This command handler
- See Also:
-
getArgumentParser
Description copied from interface:CommandHandler
Returns theArgumentParser
responsible for controlling the logic of parsing strings.- Specified by:
getArgumentParser
in interfaceCommandHandler
- Returns:
- The argument parser.
-
parseArgumentsForCompletion
Description copied from interface:CommandHandler
Parses the string and returns anArgumentStack
for it. This method behaves exactly likeCommandHandler.parseArguments(String[])
, however it returns a singleton list of an empty string when the text is empty, suitable for auto-completion.- Specified by:
parseArgumentsForCompletion
in interfaceCommandHandler
- Parameters:
arguments
- Strings to parse. These will get joined to a string separated by spaces.- Returns:
- The argument stack.
- Throws:
ArgumentParseException
-
parseArguments
Description copied from interface:CommandHandler
Parses the string array and returns anArgumentStack
for it.- Specified by:
parseArguments
in interfaceCommandHandler
- Parameters:
arguments
- String array to parse. This will be joined as a single string with spaces.- Returns:
- The argument stack.
- Throws:
ArgumentParseException
- See Also:
-
setArgumentParser
Description copied from interface:CommandHandler
Sets theArgumentParser
responsible for controlling the logic of parsing strings.- Specified by:
setArgumentParser
in interfaceCommandHandler
- Parameters:
argumentParser
- The argument parser to use.- Returns:
- This command handler
-
setExceptionHandler
@NotNull public @NotNull CommandHandler setExceptionHandler(@NotNull @NotNull CommandExceptionHandler handler) Description copied from interface:CommandHandler
Sets theCommandExceptionHandler
to use for handling any exceptions that are thrown from the command.If not set, a default one will be used.
- Specified by:
setExceptionHandler
in interfaceCommandHandler
- Parameters:
handler
- The exception handler- Returns:
- This command handler
- See Also:
-
registerExceptionHandler
@NotNull public <T extends Throwable> @NotNull CommandHandler registerExceptionHandler(@NotNull @NotNull Class<T> exceptionType, @NotNull @NotNull BiConsumer<CommandActor, T> handler) Description copied from interface:CommandHandler
Convenient method to register exception handlers. These will have higher priority overCommandExceptionHandler
.- Specified by:
registerExceptionHandler
in interfaceCommandHandler
- Parameters:
exceptionType
- The exception classhandler
- The exception handler- Returns:
- This command handler
- See Also:
-
setSwitchPrefix
Description copied from interface:CommandHandler
Sets the prefix that all parameters annotated withSwitch
will be checked against. If not set,-
will be used- Specified by:
setSwitchPrefix
in interfaceCommandHandler
- Parameters:
prefix
- New prefix to set- Returns:
- This command handler
-
setFlagPrefix
Description copied from interface:CommandHandler
Sets the prefix that all parameters annotated withFlag
will be checked against. If not set,-
will be used- Specified by:
setFlagPrefix
in interfaceCommandHandler
- Parameters:
prefix
- New prefix to set- Returns:
- This command handler
-
setMessagePrefix
Description copied from interface:CommandHandler
Returns the prefix that should preced all messages sent withCommandActor.reply(String)
andCommandActor.error(String)
.Note that the prefix will NOT be followed by spaces, it is your responsibility to include it in the prefix you set.
- Specified by:
setMessagePrefix
in interfaceCommandHandler
- Parameters:
prefix
- Message prefix- Returns:
- This command handler
-
setHelpWriter
@NotNull public <T> @NotNull CommandHandler setHelpWriter(@NotNull @NotNull CommandHelpWriter<T> helpWriter) Description copied from interface:CommandHandler
Sets theCommandHelpWriter
responsible for generating help pages- Specified by:
setHelpWriter
in interfaceCommandHandler
- Type Parameters:
T
- The help entry type.- Parameters:
helpWriter
- Help writer to use- Returns:
- This command handler
- See Also:
-
disableStackTraceSanitizing
Description copied from interface:CommandHandler
Disables stacktrace sanitization.By default, printed stack-trace is sanitized and stripped from internal, extra trace elements. This helps to keep the trace clean and readable, and removes away unnecessary paths. When disabled, full stacktrace will be printed.
- Specified by:
disableStackTraceSanitizing
in interfaceCommandHandler
- Returns:
- This command handler
-
failOnTooManyArguments
Description copied from interface:CommandHandler
Sets the command to fail when too many arguments are specified in the command.- Specified by:
failOnTooManyArguments
in interfaceCommandHandler
- Returns:
- This command handler
- See Also:
-
registerSenderResolver
@NotNull public @NotNull CommandHandler registerSenderResolver(@NotNull @NotNull SenderResolver resolver) Description copied from interface:CommandHandler
Registers the given sender resolver, which resolves parameters at index 0 that may be potentially a custom sender implementation.See
SenderResolver
for more information.- Specified by:
registerSenderResolver
in interfaceCommandHandler
- Parameters:
resolver
- Resolver to register- Returns:
- This command handler
- See Also:
-
registerPermissionReader
@NotNull public @NotNull CommandHandler registerPermissionReader(@NotNull @NotNull PermissionReader reader) Description copied from interface:CommandHandler
Registers the given permission reader, which allows registering customCommandPermission
implementations with annotations.- Specified by:
registerPermissionReader
in interfaceCommandHandler
- Parameters:
reader
- Permission reader to register- Returns:
- This command handler
- See Also:
-
registerValueResolver
@NotNull public <T> @NotNull CommandHandler registerValueResolver(@NotNull @NotNull Class<T> type, @NotNull @NotNull ValueResolver<T> resolver) Description copied from interface:CommandHandler
Registers a parameter resolver that gets its value from the command arguments.See
ValueResolver
for more information- Specified by:
registerValueResolver
in interfaceCommandHandler
- Parameters:
type
- The parameter type to resolveresolver
- The resolver- Returns:
- This command handler
- See Also:
-
registerValueResolver
@NotNull public <T> @NotNull CommandHandler registerValueResolver(int priority, @NotNull @NotNull Class<T> type, @NotNull @NotNull ValueResolver<T> resolver) Description copied from interface:CommandHandler
Registers a parameter resolver that gets its value from the command arguments.See
ValueResolver
for more information- Specified by:
registerValueResolver
in interfaceCommandHandler
- Parameters:
priority
- The resolver priority. Zero represents the highest.type
- The parameter type to resolveresolver
- The resolver- Returns:
- This command handler
- See Also:
-
registerContextResolver
@NotNull public <T> @NotNull CommandHandler registerContextResolver(@NotNull @NotNull Class<T> type, @NotNull @NotNull ContextResolver<T> resolver) Description copied from interface:CommandHandler
Registers a parameter resolver that gets its value from the command context.See
ContextResolver
for more information- Specified by:
registerContextResolver
in interfaceCommandHandler
- Parameters:
type
- The parameter type to resolveresolver
- The resolver- Returns:
- This command handler
- See Also:
-
registerContextResolver
@NotNull public <T> @NotNull CommandHandler registerContextResolver(int priority, @NotNull @NotNull Class<T> type, @NotNull @NotNull ContextResolver<T> resolver) Description copied from interface:CommandHandler
Registers a parameter resolver that gets its value from the command context.See
ContextResolver
for more information- Specified by:
registerContextResolver
in interfaceCommandHandler
- Parameters:
priority
- The resolver priority. Zero represents the highest.type
- The parameter type to resolveresolver
- The resolver- Returns:
- This command handler
- See Also:
-
registerContextValue
@NotNull public <T> @NotNull CommandHandler registerContextValue(@NotNull @NotNull Class<T> type, T value) Description copied from interface:CommandHandler
Registers a parameter type to always be a static value. This is useful for registering singletons as parameters.This is equivalent to calling
registerContextResolver(type, ContextResolver.of(type))
See
ContextResolver
for more information- Specified by:
registerContextValue
in interfaceCommandHandler
- Parameters:
type
- The parameter type to resolvevalue
- The value to retrun- Returns:
- This command handler
- See Also:
-
registerContextValue
@NotNull public <T> @NotNull CommandHandler registerContextValue(int priority, @NotNull @NotNull Class<T> type, @NotNull T value) Description copied from interface:CommandHandler
Registers a parameter type to always be a static value. This is useful for registering singletons as parameters.This is equivalent to calling
registerContextResolver(priority, type, ContextResolver.of(value))
See
ContextResolver
for more information- Specified by:
registerContextValue
in interfaceCommandHandler
- Parameters:
priority
- The resolver priority. Zero represents the highest.type
- The parameter type to resolvevalue
- The value to retrun- Returns:
- This command handler
- See Also:
-
registerValueResolverFactory
@NotNull public @NotNull CommandHandler registerValueResolverFactory(@NotNull @NotNull ValueResolverFactory factory) Description copied from interface:CommandHandler
Registers aValueResolverFactory
to this handler- Specified by:
registerValueResolverFactory
in interfaceCommandHandler
- Parameters:
factory
- Factory to register- Returns:
- This command handler
- See Also:
-
registerValueResolverFactory
@NotNull public @NotNull CommandHandler registerValueResolverFactory(int priority, @NotNull @NotNull ValueResolverFactory factory) Description copied from interface:CommandHandler
Registers aValueResolverFactory
to this handler- Specified by:
registerValueResolverFactory
in interfaceCommandHandler
- Parameters:
priority
- The resolver priority. Zero represents the highest.factory
- Factory to register- Returns:
- This command handler
- See Also:
-
registerContextResolverFactory
@NotNull public @NotNull CommandHandler registerContextResolverFactory(@NotNull @NotNull ContextResolverFactory factory) Description copied from interface:CommandHandler
Registers aContextResolverFactory
to this handler- Specified by:
registerContextResolverFactory
in interfaceCommandHandler
- Parameters:
factory
- Factory to register- Returns:
- This command handler
- See Also:
-
registerContextResolverFactory
@NotNull public @NotNull CommandHandler registerContextResolverFactory(int priority, @NotNull @NotNull ContextResolverFactory factory) Description copied from interface:CommandHandler
Registers aContextResolverFactory
to this handler- Specified by:
registerContextResolverFactory
in interfaceCommandHandler
- Parameters:
priority
- The resolver priority. Zero represents the highest.factory
- Factory to register- Returns:
- This command handler
- See Also:
-
registerCondition
@NotNull public @NotNull CommandHandler registerCondition(@NotNull @NotNull CommandCondition condition) Description copied from interface:CommandHandler
Registers the specified condition in which all commands will be validated with.- Specified by:
registerCondition
in interfaceCommandHandler
- Parameters:
condition
- Condition to register- Returns:
- This command handler
-
registerDependency
@NotNull public <T> @NotNull CommandHandler registerDependency(@NotNull @NotNull Class<T> type, @NotNull @NotNull Supplier<T> supplier) Description copied from interface:CommandHandler
Registers a dependency for dependency injection.Any fields in the command class or instance with the
Dependency
annotation will have their value set from this supplier.- Specified by:
registerDependency
in interfaceCommandHandler
- Type Parameters:
T
- The dependency type- Parameters:
type
- The dependency class type. This must match the field type.supplier
- The dependency supplier- Returns:
- This command handler
- See Also:
-
registerDependency
@NotNull public <T> @NotNull CommandHandler registerDependency(@NotNull @NotNull Class<T> type, T value) Description copied from interface:CommandHandler
Registers a (static) dependency for dependency injection.Any fields in the command class or instance with the
Dependency
annotation will have their value set to this value.- Specified by:
registerDependency
in interfaceCommandHandler
- Type Parameters:
T
- The dependency type- Parameters:
type
- The dependency class type. This must match the field typevalue
- The dependency value- Returns:
- This command handler
- See Also:
-
registerParameterValidator
@NotNull public <T> @NotNull CommandHandler registerParameterValidator(@NotNull @NotNull Class<T> type, @NotNull @NotNull ParameterValidator<T> validator) Description copied from interface:CommandHandler
Registers aParameterValidator
for the specified parameter type. Parameter validators can access all information about a parameter, including the name and annotations.- Specified by:
registerParameterValidator
in interfaceCommandHandler
- Type Parameters:
T
- The parameter type- Parameters:
type
- The parameter typevalidator
- The validator for this parameter- Returns:
- This command handler
-
registerResponseHandler
@NotNull public <T> @NotNull CommandHandler registerResponseHandler(@NotNull @NotNull Class<T> responseType, @NotNull @NotNull ResponseHandler<T> handler) Description copied from interface:CommandHandler
Registers a response handler for the specified response type. Response handlers do post-handling with results returned from command methods.Note that response handlers are captured by
ExecutableCommand
s when they are registered, so they should be registered before the command itself is registered.- Specified by:
registerResponseHandler
in interfaceCommandHandler
- Type Parameters:
T
- The response type- Parameters:
responseType
- The response classhandler
- The response handler implementation- Returns:
- This command handler
-
registerAnnotationReplacer
@NotNull public <T extends Annotation> @NotNull CommandHandler registerAnnotationReplacer(@NotNull @NotNull Class<T> annotationType, @NotNull @NotNull AnnotationReplacer<T> replacer) Description copied from interface:CommandHandler
Registers an annotation replacer. Annotation replacers allow to dynamically generate annotations at runtime using APIs such asAnnotations
.- Specified by:
registerAnnotationReplacer
in interfaceCommandHandler
-
accept
Description copied from interface:CommandHandler
Accepts the givenCommandHandlerVisitor
and allows it to visit this command handler.- Specified by:
accept
in interfaceCommandHandler
- Parameters:
visitor
- Visitor to accept- Returns:
- This command handler
- See Also:
-
replaceAnnotation
@Nullable public <T extends Annotation> @Nullable List<Annotation> replaceAnnotation(AnnotatedElement element, T ann) -
getAutoCompleter
Description copied from interface:CommandHandler
Returns the auto-completion handler of this command handler- Specified by:
getAutoCompleter
in interfaceCommandHandler
- Returns:
- The auto-completion handler
-
getCommand
Description copied from interface:CommandHandler
Returns the givenExecutableCommand
that matches the given path. This can return null if no command exists at such a path.Note that
CommandPath
s are, by default, case-insensitive.- Specified by:
getCommand
in interfaceCommandHandler
- Parameters:
path
- Path to look for- Returns:
- The command at the given path
-
getCategory
Description copied from interface:CommandHandler
Returns the givenCommandCategory
that matches the given path. This can return null if no category exists at such a path.Note that
CommandPath
s are, by default, case-insensitive.- Specified by:
getCategory
in interfaceCommandHandler
- Parameters:
path
- Path to look for- Returns:
- The category at the given path
-
getCommands
Description copied from interface:CommandHandler
Returns an unmodifiable view of all the registered commands in this command handler.- Specified by:
getCommands
in interfaceCommandHandler
- Returns:
- The registered commands
-
getCategories
Description copied from interface:CommandHandler
Returns an unmodifiable view of all the registered categories in this command handler.- Specified by:
getCategories
in interfaceCommandHandler
- Returns:
- The registered categories
-
getResolver
-
getExceptionHandler
Description copied from interface:CommandHandler
Returns the command exception handler currently used by this command handler- Specified by:
getExceptionHandler
in interfaceCommandHandler
- Returns:
- The command exception handler
-
getMethodCallerFactory
Description copied from interface:CommandHandler
Returns theMethodCallerFactory
responsible for generating reflective calls.- Specified by:
getMethodCallerFactory
in interfaceCommandHandler
- Returns:
- The method caller factory
-
getHelpWriter
Description copied from interface:CommandHandler
Returns theCommandHelpWriter
of this command handler. This can be null if no writer is registered.- Specified by:
getHelpWriter
in interfaceCommandHandler
- Type Parameters:
T
- Command help entries type- Returns:
- The help writer of this handler
-
unregister
Description copied from interface:CommandHandler
Unregisters the given path and all the sub-paths that belong to it- Specified by:
unregister
in interfaceCommandHandler
- Parameters:
path
- Path to unregister- Returns:
- True if one or more elements were removed by this call.
-
unregister
Description copied from interface:CommandHandler
Unregisters the given path and all the sub-paths that belong to it- Specified by:
unregister
in interfaceCommandHandler
- Parameters:
commandPath
- Path to unregister- Returns:
- True if one or more elements were removed by this call.
-
unregisterAllCommands
public void unregisterAllCommands()Description copied from interface:CommandHandler
Unregisters all the command instances in this command handler.- Specified by:
unregisterAllCommands
in interfaceCommandHandler
-
getRootPaths
Description copied from interface:CommandHandler
Returns all the root commands or categories paths in this command handler.- Specified by:
getRootPaths
in interfaceCommandHandler
- Returns:
- All root command paths
-
getSwitchPrefix
Description copied from interface:CommandHandler
Returns the prefix that comes before allSwitch
parameters when they are fetched from the command.- Specified by:
getSwitchPrefix
in interfaceCommandHandler
- Returns:
- The switch prefix
-
getFlagPrefix
Description copied from interface:CommandHandler
Returns the prefix that comes before allFlag
parameters when they are fetched from the command.- Specified by:
getFlagPrefix
in interfaceCommandHandler
- Returns:
- The switch prefix
-
getMessagePrefix
Description copied from interface:CommandHandler
Returns the prefix that preceds all messages sent byCommandActor.reply(String)
andCommandActor.error(String)
.- Specified by:
getMessagePrefix
in interfaceCommandHandler
- Returns:
- The message prefix
-
dispatch
@NotNull public <T> @NotNull Optional<@Nullable T> dispatch(@NotNull @NotNull CommandActor actor, @NotNull @NotNull ArgumentStack arguments) Description copied from interface:CommandHandler
Evaluates the command from the given arguments- Specified by:
dispatch
in interfaceCommandHandler
- Parameters:
actor
- Actor to execute asarguments
- Arguments to invoke the command with- Returns:
- The result returned from invoking the command method. The optional value may be null if an exception was thrown.
-
dispatch
@NotNull public <T> @NotNull Optional<@Nullable T> dispatch(@NotNull @NotNull CommandActor actor, @NotNull @NotNull String commandInput) Description copied from interface:CommandHandler
Evaluates the command from the given input- Specified by:
dispatch
in interfaceCommandHandler
- Parameters:
actor
- Actor to execute ascommandInput
- Input to invoke with
-
getDependency
Description copied from interface:CommandHandler
Returns the dependency registered for the given type- Specified by:
getDependency
in interfaceCommandHandler
- Type Parameters:
T
- Dependency type- Parameters:
dependencyType
- Dependency type to look for- Returns:
- The dependency, or null if not found.
-
getDependency
Description copied from interface:CommandHandler
Returns the dependency registered for the given type, otherwise returns the givendef
value.- Specified by:
getDependency
in interfaceCommandHandler
- Type Parameters:
T
- Dependency type- Parameters:
dependencyType
- Dependency type to look fordef
- Default value if no dependency is registered for the given type.- Returns:
- The dependency, or null if not found.
-
setDependencies
-