Interface Registry

All Known Implementing Classes:
SimpleRegistry

public interface Registry
A registry that stores commands that may be invoked by users.
Since:
1.0
Version:
1.0
  • Method Details

    • findCommand

      @Pure <H extends Handlers> @Nullable Command<? extends H> findCommand(Invocation invocation, Class<H> type)
      Retrieves the best command known to this registry that has the given invocation, and is compatible with the given type.
      Type Parameters:
      H - The handler type that must be supported.
      Parameters:
      invocation - The invocation of the command.
      type - The handler type.
      Returns:
      The best matching command known to this registry, or null if none were found.
    • getCommands

      @SideEffectFree <H extends Handlers> Collection<Command<? extends H>> getCommands(Class<H> type)
      Retrieves all commands known to this registry that are compatible with the given type.
      Type Parameters:
      H - The handler type that must be supported.
      Parameters:
      type - The handler type.
      Returns:
      The compatible commands known to this registry.
    • getCommand

      @Pure @Nullable Command<?> getCommand(String id)
      Retrieves the command with the given ID that is registered to this registry.
      Parameters:
      id - The ID of the command to retrieve.
      Returns:
      The command that was registered with the given ID, or null if there is no such command in this registry.
    • registerCommand

      boolean registerCommand(Command<?> command) throws IllegalArgumentException
      Registers a command into this registry.
      Parameters:
      command - The command to register.
      Returns:
      true if the command was registered successfully. false if there is already a command in this registry with the given ID, or if there is already a command known to this registry with the given signature and this registry does not allow overriding. If false, the registration failed and the call had no effect.
      Throws:
      IllegalArgumentException - if the given command has an invalid configuration.
    • registerCommands

      default void registerCommands(Collection<? extends Command<?>> commands)
      Registers the given commands into this registry.

      For each of the commands that cannot be added (due to being invalid or using an ID that is already used by another command), if any, an error will be logged but otherwise it will be silently ignored. If handling of those cases is necessary, use registerCommand(Command) directly.

      Parameters:
      commands - The commands to add.
    • registerCommands

      default void registerCommands(CommandGroup commands)
      Registers the given commands into this registry.

      For each of the commands that cannot be added (due to being invalid or using an ID that is already used by another command), if any, an error will be logged but otherwise it will be silently ignored. If handling of those cases is necessary, use registerCommand(Command) directly.

      Parameters:
      commands - The commands to add.
    • registerCommands

      default void registerCommands(Command<?>... commands)
      Registers the given commands into this registry.

      For each of the commands that cannot be added (due to being invalid or using an ID that is already used by another command), if any, an error will be logged but otherwise it will be silently ignored. If handling of those cases is necessary, use registerCommand(Command) directly.

      Parameters:
      commands - The commands to add.
    • removeCommand

      @Nullable Command<?> removeCommand(String id)
      Removes a command from this registry that was registered with the given ID.
      Parameters:
      id - The ID of the command to remove.
      Returns:
      The removed command, or null if there was no command in this registry registered with the given ID.