Class CommandManager

java.lang.Object
net.apartium.cocoabeans.commands.CommandManager

@NonExtendable public abstract class CommandManager extends Object
  • Field Details

    • COMMON_PARSERS

      public static final Set<ArgumentParser<?>> COMMON_PARSERS
    • DEFAULT_KEYWORD_PRIORITY

      public static final int DEFAULT_KEYWORD_PRIORITY
      See Also:
    • commandMap

      protected final Map<String,net.apartium.cocoabeans.commands.RegisteredCommand> commandMap
  • Constructor Details

  • Method Details

    • registerArgumentTypeHandler

      public void registerArgumentTypeHandler(ArgumentParser<?> argumentTypeHandler)
    • registerArgumentTypeHandler

      public void registerArgumentTypeHandler(Set<ArgumentParser<?>> argumentTypeHandlers)
    • 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 override
      factory - the custom factory implementation to be registered
    • handleTabComplete

      public List<String> handleTabComplete(Sender sender, String commandName, String[] args)
    • handle

      public boolean handle(Sender sender, String commandName, String[] args) throws Throwable
      Throws:
      Throwable
    • addCommand

      public void addCommand(CommandNode commandNode)
    • mappingCommandInfo

      @AvailableSince("0.0.50") protected CommandInfo mappingCommandInfo(CommandInfo info, Collection<AnnotatedElement> nodes)
      Maps and processes a CommandInfo object based on the provided collection of GenericNode elements.
      Parameters:
      info - the original CommandInfo instance to be mapped or processed
      nodes - a collection of GenericNode elements that provide additional context or modifications
      Returns:
      the resulting CommandInfo instance after applying the mapping or processing logic
    • addMetadataHandler

      @AvailableSince("0.0.39") public void addMetadataHandler(Function<Map<String,Object>,Set<Requirement>> metaDataHandler)
    • 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 added
      callback - 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 added
      callback - function to be called each time the command has been run
      fallbackParser - fall back parser when couldn't find parser (will also log the missing parser as warning)
    • getCommandInfo

      public CommandInfo getCommandInfo(String commandName)
    • addCommand

      protected abstract void addCommand(CommandNode commandNode, Command command)
    • getArgumentMapper

      public ArgumentMapper getArgumentMapper()
    • getCommandLexer

      public CommandLexer 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

      @AvailableSince("0.0.41") public Logger getLogger()
      Get logger for command manager
      Returns:
      logger