Interface CommandRegistrar<T>

    • Method Detail

      • register

        CommandMapping register​(org.spongepowered.plugin.PluginContainer container,
                                T command,
                                java.lang.String primaryAlias,
                                java.lang.String... secondaryAliases)
                         throws CommandFailedRegistrationException
        Registers a command.
        Parameters:
        container - The PluginContainer performing the registration
        command - The command to register
        primaryAlias - The primary alias
        secondaryAliases - Any secondary aliases. May be empty.
        Returns:
        The CommandMapping
        Throws:
        CommandFailedRegistrationException - if the registration failed
      • process

        CommandResult process​(CommandCause cause,
                              CommandMapping mapping,
                              java.lang.String command,
                              java.lang.String arguments)
                       throws CommandException
        Process the provided command.

        Note for implementors: the provided command will be the one registered as the primary alias when registering with the CommandManager.

        Parameters:
        cause - The CommandCause that caused the command to be executed
        mapping - The CommandMapping for the command being invoked
        command - The alias that was used to invoke the command
        arguments - The arguments of the command (that is, the raw string with the command alias removed, so if /sponge test test2 is invoked, arguments will contain test test2.)
        Returns:
        The CommandResult
        Throws:
        CommandException - if there is an error executing the command
      • complete

        java.util.List<CommandCompletion> complete​(CommandCause cause,
                                                   CommandMapping mapping,
                                                   java.lang.String command,
                                                   java.lang.String arguments)
                                            throws CommandException
        Provides a list of completions associated with the provided argument string.

        See process(CommandCause, CommandMapping, String, String) for any implementation notes.

        Parameters:
        cause - The CommandCause that caused the command to be executed
        mapping - The CommandMapping for the command being invoked
        command - The alias that was used to invoke the command
        arguments - The arguments of the command (that is, the raw string with the command alias removed, so if /sponge test test2 is invoked, arguments will contain test test2.)
        Returns:
        The completions
        Throws:
        CommandException - if there is an error providing the suggestions
      • shortDescription

        default java.util.Optional<Component> shortDescription​(CommandCause cause,
                                                               CommandMapping mapping)
        Returns a short description for the invoked command, if one is available.

        A good short description is not necessarily help, rather, it should be a short description of the command's function. This short description may also be part of the standard help for the function.

        It is recommended that any description here is kept very short as such a description may be used in a command listing.

        Parameters:
        cause - The CommandCause that caused the command to be executed
        mapping - The CommandMapping that is associated with the command
        Returns:
        The help, if any
      • help

        java.util.Optional<Component> help​(CommandCause cause,
                                           CommandMapping mapping)
        Returns help text for the invoked command, if one is available.
        Parameters:
        cause - The CommandCause that caused the command to be executed
        mapping - The CommandMapping that is associated with the command
        Returns:
        The help, if any