-
- 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 JavaPluginpluginprivate final Playerplayerprivate final List<String>argsprivate final FlyLib<T>flyLibprivate final Tconfigprivate final Command<T>commandprivate final CommandSendersenderprivate final Worldworldprivate final Serverserverprivate final Stringmessageprivate final List<Object>typedArgs
-
Method Summary
Modifier and Type Method Description final JavaPlugingetPlugin()final PlayergetPlayer()Executed command sender. final List<String>getArgs()Command arguments. final FlyLib<T>getFlyLib()final TgetConfig()final Command<T>getCommand()The command that has been executed or is about to be executed. final CommandSendergetSender()The executor of the command or the entity that is about to execute it (may not be the player). final WorldgetWorld()The world where the command was executed final ServergetServer()The server on which the plugin was run final StringgetMessage()Command input message. final List<Object>getTypedArgs()final Unitmessage(String text)send string message final Unitmessage(String text, Color color)send string colored message final Unitmessage(Component component)send component final Unitmessage(ComponentBuilderAction builder)send component via builder final Unitsuccess(String text)send green string final Unitwarn(String text)send yellow string final Unitfail(String text)send red string final UnitpluginMessage(String text)send string with plugin name final UnitpluginMessage(String text, Color color)send colored string with plugin name final UnitpluginMessage(Component component)send component with plugin name final UnitpluginMessage(ComponentBuilderAction builder)send component via builder with plugin name final UnitpluginMessageSuccess(String text)send green string with plugin name final UnitpluginMessageWarn(String text)send yellow string with plugin name final UnitpluginMessageFail(String text)send red string with plugin name final UnitupdateConfig(Function1<T, Unit> action)final UnitsendHelp()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)
-
-
-
-