public interface CommandManager extends Dispatcher
Modifier and Type | Method and Description |
---|---|
Set<CommandMapping> |
getOwnedBy(Object instance)
Gets a set of commands owned by the given plugin instance.
|
Optional<PluginContainer> |
getOwner(CommandMapping mapping)
Gets the owner of a CommandMapping, if any is present.
|
Set<PluginContainer> |
getPluginContainers()
Gets a set of plugin containers that have commands registered.
|
List<String> |
getSuggestions(CommandSource source,
String arguments,
Location<World> targetPosition)
Gets a list of suggestions based on input.
|
CommandResult |
process(CommandSource source,
String arguments)
Execute the command based on input arguments.
|
Optional<CommandMapping> |
register(Object plugin,
CommandCallable callable,
List<String> aliases)
Register a given command using the given list of aliases.
|
Optional<CommandMapping> |
register(Object plugin,
CommandCallable callable,
List<String> aliases,
Function<List<String>,List<String>> callback)
Register a given command using a given list of aliases.
|
Optional<CommandMapping> |
register(Object plugin,
CommandCallable callable,
String... alias)
Register a given command using the given list of aliases.
|
Optional<CommandMapping> |
removeMapping(CommandMapping mapping)
Remove a command identified by the given mapping.
|
int |
size()
Gets the number of registered aliases.
|
containsAlias, containsMapping, get, get, getAliases, getAll, getAll, getCommands, getPrimaryAliases
getHelp, getShortDescription, getUsage, testPermission
Optional<CommandMapping> register(Object plugin, CommandCallable callable, String... alias)
If there is a conflict with one of the aliases (i.e. that alias is already assigned to another command), then the alias will be skipped. It is possible for there to be no alias to be available out of the provided list of aliases, which would mean that the command would not be assigned to any aliases.
The first non-conflicted alias becomes the "primary alias."
plugin
- A plugin instancecallable
- The commandalias
- An array of aliasesIllegalArgumentException
- Thrown if plugin
is not a
plugin instanceOptional<CommandMapping> register(Object plugin, CommandCallable callable, List<String> aliases)
If there is a conflict with one of the aliases (i.e. that alias is already assigned to another command), then the alias will be skipped. It is possible for there to be no alias to be available out of the provided list of aliases, which would mean that the command would not be assigned to any aliases.
The first non-conflicted alias becomes the "primary alias."
plugin
- A plugin instancecallable
- The commandaliases
- A list of aliasesIllegalArgumentException
- Thrown if plugin
is not a
plugin instanceOptional<CommandMapping> register(Object plugin, CommandCallable callable, List<String> aliases, Function<List<String>,List<String>> callback)
The provided callback function will be called with a list of aliases
that are not taken (from the list of aliases that were requested) and
it should return a list of aliases to actually register. Aliases may be
removed, and if no aliases remain, then the command will not be
registered. It may be possible that no aliases are available, and thus
the callback would receive an empty list. New aliases should not be added
to the list in the callback as this may cause
IllegalArgumentException
to be thrown.
The first non-conflicted alias becomes the "primary alias."
plugin
- A plugin instancecallable
- The commandaliases
- A list of aliasescallback
- The callbackIllegalArgumentException
- Thrown if new conflicting aliases are
added in the callbackIllegalArgumentException
- Thrown if plugin
is not a
plugin instanceOptional<CommandMapping> removeMapping(CommandMapping mapping)
mapping
- The mappingSet<PluginContainer> getPluginContainers()
Set<CommandMapping> getOwnedBy(Object instance)
instance
- The plugin instanceOptional<PluginContainer> getOwner(CommandMapping mapping)
mapping
- The mapping to get an owner forint size()
CommandResult process(CommandSource source, String arguments)
The implementing class must perform the necessary permission checks.
process
in interface CommandCallable
source
- The caller of the commandarguments
- The raw arguments for this commandList<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition)
If a suggestion is chosen by the user, it will replace the last word.
getSuggestions
in interface CommandCallable
source
- The command sourcearguments
- The arguments entered up to this pointtargetPosition
- The position the source is looking at when
performing tab completion