-
- All Implemented Interfaces:
public final class CommandContext<T extends Object>
The context when the command is executed. It is passed as an argument or receiver when executing a command or completing a tab. This class holds information when executing a command or completing a tab, which can be retrieved by the plug-in that registered the command, the command itself, the sender of the command, etc. It can also send a message to the executor of the command, display usage instructions, etc.
-
-
Field Summary
Fields Modifier and Type Field Description private final JavaPlugin
plugin
private final Player
player
private final List<String>
args
private final FlyLib<T>
flyLib
private final T
config
private final Command<T>
command
private final CommandSender
sender
private final World
world
private final Server
server
private final String
message
private final List<Object>
typedArgs
-
Method Summary
Modifier and Type Method Description final JavaPlugin
getPlugin()
final Player
getPlayer()
Executed command sender. final List<String>
getArgs()
Command arguments. final FlyLib<T>
getFlyLib()
final T
getConfig()
final Command<T>
getCommand()
The command that has been executed or is about to be executed. final CommandSender
getSender()
The executor of the command or the entity that is about to execute it (may not be the player). final World
getWorld()
The world where the command was executed final Server
getServer()
The server on which the plugin was run final String
getMessage()
Command input message. final List<Object>
getTypedArgs()
final Unit
message(String text)
send string message final Unit
message(String text, Color color)
send string colored message final Unit
message(Component component)
send component final Unit
message(ComponentBuilderAction builder)
send component via builder final Unit
success(String text)
send green string final Unit
warn(String text)
send yellow string final Unit
fail(String text)
send red string final Unit
pluginMessage(String text)
send string with plugin name final Unit
pluginMessage(String text, Color color)
send colored string with plugin name final Unit
pluginMessage(Component component)
send component with plugin name final Unit
pluginMessage(ComponentBuilderAction builder)
send component via builder with plugin name final Unit
pluginMessageSuccess(String text)
send green string with plugin name final Unit
pluginMessageWarn(String text)
send yellow string with plugin name final Unit
pluginMessageFail(String text)
send red string with plugin name final Unit
updateConfig(Function1<T, Unit> action)
final Unit
sendHelp()
Display the information of the command in this context in the sender of this context. -
-
Method Detail
-
getPlugin
final JavaPlugin getPlugin()
-
getPlayer
final Player getPlayer()
Executed command sender. (Limited to the player, but null if executed by someone other than the player.)
-
getArgs
final List<String> getArgs()
Command arguments. The remaining arguments except the beginning of the command are assigned. These are all returned as strings. If you need parsed values, see typedArgs.
/command <number> args: <number>
/parent children <arg1><arg2> args: <arg1>, <arg2>
/command <literal><text><number><entity> args: <literal>, <text>, <number>, <entity>
-
getCommand
final Command<T> getCommand()
The command that has been executed or is about to be executed.
-
getSender
final CommandSender getSender()
The executor of the command or the entity that is about to execute it (may not be the player).
-
getWorld
final World getWorld()
The world where the command was executed
-
getServer
final Server getServer()
The server on which the plugin was run
-
getMessage
final String getMessage()
Command input message. (includes slash)
-
getTypedArgs
final List<Object> getTypedArgs()
-
message
final Unit message(ComponentBuilderAction builder)
send component via builder
-
pluginMessage
final Unit pluginMessage(String text)
send string with plugin name
-
pluginMessage
final Unit pluginMessage(String text, Color color)
send colored string with plugin name
-
pluginMessage
final Unit pluginMessage(Component component)
send component with plugin name
-
pluginMessage
final Unit pluginMessage(ComponentBuilderAction builder)
send component via builder with plugin name
-
pluginMessageSuccess
final Unit pluginMessageSuccess(String text)
send green string with plugin name
-
pluginMessageWarn
final Unit pluginMessageWarn(String text)
send yellow string with plugin name
-
pluginMessageFail
final Unit pluginMessageFail(String text)
send red string with plugin name
-
updateConfig
final Unit updateConfig(Function1<T, Unit> action)
-
-
-
-