Package me.efekos.simpler.commands
Class CommandExecuteContext
java.lang.Object
me.efekos.simpler.commands.CommandExecuteContext
A context class that contains some information about a command execution.
-
Constructor Summary
ConstructorDescriptionCommandExecuteContext
(org.bukkit.command.CommandSender sender, List<String> args) Creates a new context to use for runningCommandExecutive
s ofCommandNode
s. -
Method Summary
Modifier and TypeMethodDescriptiongetArgs()
Returns a list of the arguments that sender gave.org.bukkit.command.CommandSender
Returns the sender that ran this command.org.bukkit.command.ConsoleCommandSender
Casts the sender to aConsoleCommandSender
, then returns it.org.bukkit.entity.Player
Casts the sender to aPlayer
, then returns it.boolean
Checks what sender is, and returns whether the sender is the console or not.boolean
Checks what sender is, and returns whether the sender is a player or not.
-
Constructor Details
-
CommandExecuteContext
Creates a new context to use for runningCommandExecutive
s ofCommandNode
s.- Parameters:
sender
- Sender that ran this command.args
- List of the arguments sender gave.
-
-
Method Details
-
isSenderPlayer
public boolean isSenderPlayer()Checks what sender is, and returns whether the sender is a player or not.- Returns:
true
if sender is a player.
-
isSenderConsole
public boolean isSenderConsole()Checks what sender is, and returns whether the sender is the console or not.- Returns:
true
if sender is the console.
-
getSender
public org.bukkit.command.CommandSender getSender()Returns the sender that ran this command.- Returns:
- Sender of this context.
-
getSenderAsPlayer
public org.bukkit.entity.Player getSenderAsPlayer()Casts the sender to aPlayer
, then returns it. Make sure to use this only whenisSenderPlayer()
istrue
.- Returns:
- Sender of this context as
Player
.
-
getSenderAsConsole
public org.bukkit.command.ConsoleCommandSender getSenderAsConsole()Casts the sender to aConsoleCommandSender
, then returns it. Make sure to use this only whenisSenderConsole()
istrue
.- Returns:
- Sender of this context as
ConsoleCommandSender
.
-
getArgs
Returns a list of the arguments that sender gave. Keep in mind thatLabelNode
s are filtered out from this list. You'll only get the arguments.- Returns:
- Argument list of this context.
-