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 parent and name, 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(String id, Command<?> command) throws IllegalArgumentException
      Registers a command into this registry.
      Parameters:
      id - The ID to register the command under. This is different from the command name and display name in that it is not used for command handling or any user-facing functionality, but rather only as a way to internally identify the command.
      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.
    • 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.