CommandMappublic class SimpleCommandMap extends Object implements CommandMap
| Modifier and Type | Field | Description |
|---|---|---|
protected Map<String,Command> |
knownCommands |
| Constructor | Description |
|---|---|
SimpleCommandMap(@NotNull Server server) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clearCommands() |
Clears all registered commands.
|
boolean |
dispatch(@NotNull CommandSender sender,
@NotNull String commandLine) |
Looks for the requested command and executes it if found.
|
@Nullable Command |
getCommand(@NotNull String name) |
Gets the command registered to the specified name
|
@NotNull Collection<Command> |
getCommands() |
|
boolean |
register(@NotNull String label,
@NotNull String fallbackPrefix,
@NotNull Command command) |
Registers a command.
|
boolean |
register(@NotNull String fallbackPrefix,
@NotNull Command command) |
Registers a command.
|
void |
registerAll(@NotNull String fallbackPrefix,
@NotNull List<Command> commands) |
Registers all the commands belonging to a certain plugin.
|
void |
registerServerAliases() |
|
void |
setFallbackCommands() |
|
@Nullable List<String> |
tabComplete(@NotNull CommandSender sender,
@NotNull String cmdLine) |
Looks for the requested command and executes an appropriate
tab-completer if found.
|
@Nullable List<String> |
tabComplete(@NotNull CommandSender sender,
@NotNull String cmdLine,
@Nullable Location location) |
Looks for the requested command and executes an appropriate
tab-completer if found.
|
public SimpleCommandMap(@NotNull
@NotNull Server server)
public void setFallbackCommands()
public void registerAll(@NotNull
@NotNull String fallbackPrefix,
@NotNull
@NotNull List<Command> commands)
Caller can use:-
registerAll in interface CommandMapfallbackPrefix - a prefix which is prepended to each command with
a ':' one or more times to make the command uniquecommands - a list of commands to registerpublic boolean register(@NotNull
@NotNull String fallbackPrefix,
@NotNull
@NotNull Command command)
Caller can use:-
register in interface CommandMapfallbackPrefix - a prefix which is prepended to the command with a
':' one or more times to make the command uniquecommand - the command to register, from which label is determined
from the command namepublic boolean register(@NotNull
@NotNull String label,
@NotNull
@NotNull String fallbackPrefix,
@NotNull
@NotNull Command command)
Caller can use:-
register in interface CommandMaplabel - the label of the command, without the '/'-prefix.fallbackPrefix - a prefix which is prepended to the command with a
':' one or more times to make the command uniquecommand - the command to registerpublic boolean dispatch(@NotNull
@NotNull CommandSender sender,
@NotNull
@NotNull String commandLine)
throws CommandException
dispatch in interface CommandMapsender - The command's sendercommandLine - command + arguments. Example: "/test abc 123"CommandException - Thrown when the executor for the given command
fails with an unhandled exceptionpublic void clearCommands()
CommandMapclearCommands in interface CommandMap@Nullable public @Nullable Command getCommand(@NotNull @NotNull String name)
CommandMapgetCommand in interface CommandMapname - Name of the command to retrieve@Nullable public @Nullable List<String> tabComplete(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String cmdLine)
CommandMaptabComplete in interface CommandMapsender - The command's sender.cmdLine - The entire command string to tab-complete, excluding
initial slash.@Nullable public @Nullable List<String> tabComplete(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String cmdLine, @Nullable @Nullable Location location)
CommandMaptabComplete in interface CommandMapsender - The command's sender.cmdLine - The entire command string to tab-complete, excluding
initial slash.location - The position looked at by the sender, or null if none@NotNull public @NotNull Collection<Command> getCommands()
public void registerServerAliases()
Copyright © 2020. All rights reserved.