Package net.apartium.cocoabeans.commands
Class CommandManager
java.lang.Object
net.apartium.cocoabeans.commands.CommandManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCommandManager(Logger logger, ArgumentMapper argumentMapper, CommandLexer commandLexer) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(CommandNode commandNode) protected abstract voidaddCommand(CommandNode commandNode, Command command) voidaddMetadataHandler(Function<Map<String, Object>, Set<Requirement>> metaDataHandler) voidaddVirtualCommand(VirtualCommandDefinition virtualCommandDefinition, Function<CommandContext, Boolean> callback) Add Virtual command with consumer that get called every time someone is running that commandvoidaddVirtualCommand(VirtualCommandDefinition virtualCommandDefinition, Function<CommandContext, Boolean> callback, ArgumentParser<?> fallbackParser) Add Virtual command with consumer that get called every time someone is running that commandgetCommandInfo(String commandName) intGet the priority of the keyword.Get logger for command managerbooleanhandleTabComplete(Sender sender, String commandName, String[] args) protected CommandInfomappingCommandInfo(CommandInfo info, Collection<AnnotatedElement> nodes) Maps and processes aCommandInfoobject based on the provided collection ofGenericNodeelements.voidregisterArgumentTypeHandler(Set<ArgumentParser<?>> argumentTypeHandlers) voidregisterArgumentTypeHandler(ArgumentParser<?> argumentTypeHandler) voidregisterRequirementFactory(Class<? extends Annotation> annotation, RequirementFactory factory) Registers an external requirement factory for a specific annotation.voidsetKeywordPriority(int keywordPriority) Set the priority of the keyword.
-
Field Details
-
COMMON_PARSERS
-
DEFAULT_KEYWORD_PRIORITY
public static final int DEFAULT_KEYWORD_PRIORITY- See Also:
-
commandMap
-
-
Constructor Details
-
CommandManager
-
-
Method Details
-
registerArgumentTypeHandler
-
registerArgumentTypeHandler
-
registerRequirementFactory
@AvailableSince("0.0.38") public void registerRequirementFactory(Class<? extends Annotation> annotation, RequirementFactory factory) Registers an external requirement factory for a specific annotation.This allows overriding the default behavior of the annotation with a custom factory implementation. Note that this registration only affects commands registered after the factory is set. Commands registered prior to this change will continue to use their previously assigned implementation.
- Parameters:
annotation- the annotation class to overridefactory- the custom factory implementation to be registered
-
handleTabComplete
-
handle
- Throws:
Throwable
-
addCommand
-
mappingCommandInfo
@AvailableSince("0.0.50") protected CommandInfo mappingCommandInfo(CommandInfo info, Collection<AnnotatedElement> nodes) Maps and processes aCommandInfoobject based on the provided collection ofGenericNodeelements.- Parameters:
info- the originalCommandInfoinstance to be mapped or processednodes- a collection ofGenericNodeelements that provide additional context or modifications- Returns:
- the resulting
CommandInfoinstance after applying the mapping or processing logic
-
addMetadataHandler
-
addVirtualCommand
@AvailableSince("0.0.39") public void addVirtualCommand(VirtualCommandDefinition virtualCommandDefinition, Function<CommandContext, Boolean> callback) Add Virtual command with consumer that get called every time someone is running that command- Parameters:
virtualCommandDefinition- virtual command to be addedcallback- function to be called each time the command has been run
-
addVirtualCommand
@AvailableSince("0.0.41") public void addVirtualCommand(VirtualCommandDefinition virtualCommandDefinition, Function<CommandContext, Boolean> callback, ArgumentParser<?> fallbackParser) Add Virtual command with consumer that get called every time someone is running that command- Parameters:
virtualCommandDefinition- virtual command to be addedcallback- function to be called each time the command has been runfallbackParser- fall back parser when couldn't find parser (will also log the missing parser as warning)
-
getCommandInfo
-
addCommand
-
getArgumentMapper
-
getCommandLexer
-
getKeywordPriority
@AvailableSince("0.0.51") public int getKeywordPriority()Get the priority of the keyword.- Returns:
- priority of the keyword
-
setKeywordPriority
@AvailableSince("0.0.51") public void setKeywordPriority(int keywordPriority) Set the priority of the keyword.- Parameters:
keywordPriority- priority of the keyword
-
getLogger
Get logger for command manager- Returns:
- logger
-