Interface RegisterCommandEvent<C>
-
- Type Parameters:
C
- The type of command that is being registered.
- All Superinterfaces:
Event
,GenericEvent<C>
,LifecycleEvent
public interface RegisterCommandEvent<C> extends GenericEvent<C>, LifecycleEvent
Lifecycle event to indicate when commands should be registered.This event is generic and the type parameter is required. This type parameter (
C
) will correspond to the base class or interface that your command inherits from.There are two types of command that Sponge will always call an event for:
- Where
C
isCommand.Raw
; and - Where
C
isCommand.Parameterized
.
Commands that have been generated using
Command.builder()
should be registered during theRegisterCommandEvent<Command.Parameterized>
event.Other plugins and platforms may provide a
CommandRegistrar
that allows for other types to be registered as commands. These types will be provided by these other plugins, consult their documentation for more details.This event will be called whenever the game re-initializes commands, and does not guarantee that any specific engine is running.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
RegisterCommandEvent.Result<C>
TheRegisterCommandEvent.Result
of a command registration, allowing for the chaining of other command registrations, or the retrival of theCommandMapping
generated from the registration that returned this result.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RegisterCommandEvent.Result<C>
register(org.spongepowered.plugin.PluginContainer container, C command, String alias, String... aliases)
Registers a command with the appropriateCommandRegistrar
.-
Methods inherited from interface org.spongepowered.api.event.GenericEvent
paramType
-
Methods inherited from interface org.spongepowered.api.event.lifecycle.LifecycleEvent
game
-
-
-
-
Method Detail
-
register
RegisterCommandEvent.Result<C> register(org.spongepowered.plugin.PluginContainer container, C command, String alias, String... aliases) throws CommandFailedRegistrationException
Registers a command with the appropriateCommandRegistrar
.- Parameters:
container
- ThePluginContainer
command
- The command to registeralias
- The first alias to register for this commandaliases
- Any other aliases to register- Returns:
- The
RegisterCommandEvent.Result
, which contains theCommandMapping
for this registration, while also allowing for chaining of other command registrations. - Throws:
CommandFailedRegistrationException
- if registration failed
-
-