Class SentSubCommand
java.lang.Object
com.github.cyberryan1.cybercore.spigot.command.sent.SentSubCommand
Used to represent an executed subcommand, with the sender and arguments of the subcommand.
Allows for one to easily get the arguments of the executed subcommand into a specified
type.
-
Constructor Summary
ConstructorsConstructorDescriptionSentSubCommand
(org.bukkit.command.CommandSender sender, String subcommand, String[] subcommandArgs) -
Method Summary
Modifier and TypeMethodDescriptiongetArg
(int index) double
getDoubleAtArg
(int index) Tries to convert the argument at the provided index to a doubleint
getIntegerAtArg
(int index) Tries to convert the argument at the provided index to an integerorg.bukkit.OfflinePlayer
getOfflinePlayerAtArg
(int index) Tries to convert the argument at the provided index to anOfflinePlayer
org.bukkit.entity.Player
org.bukkit.entity.Player
getPlayerAtArg
(int index) Tries to convert the argument at the provided index to aPlayer
org.bukkit.command.CommandSender
String[]
-
Constructor Details
-
SentSubCommand
-
-
Method Details
-
getSubcommand
- Returns:
- The name of the subcommand that was executed
-
getSender
public org.bukkit.command.CommandSender getSender()- Returns:
- The
CommandSender
that executed the subcommand
-
getPlayer
public org.bukkit.entity.Player getPlayer()- Returns:
- The
Player
who executed the subcommand - Throws:
ClassCastException
- If the sender isn't a player
-
getSubcommandArgs
- Returns:
- The arguments that were provided to the subcommand
IMPORTANT: The index of each argument is relative to the index of the subcommand in the command. Example: if/numbergen random 1 10
was executed, and the subcommand was "random", then the argument at index 0 would be "1" and the argument at index 1 would be "10".
-
getArg
- Parameters:
index
- The index of the argument to get.
IMPORTANT: The index of the argument is relative to the subcommand, not the command
(see the comments atgetSubcommandArgs()
for more information)- Returns:
- The argument at the provided index
- Throws:
IndexOutOfBoundsException
- If the index is out of bounds
-
getOfflinePlayerAtArg
public org.bukkit.OfflinePlayer getOfflinePlayerAtArg(int index) Tries to convert the argument at the provided index to anOfflinePlayer
- Parameters:
index
- The index of the argument to convert
IMPORTANT: The index of the argument is relative to the subcommand, not the command
(see the comments atgetSubcommandArgs()
for more information)- Returns:
- The
OfflinePlayer
at the provided index - Throws:
IndexOutOfBoundsException
- If the index is out of boundsClassCastException
- If the argument at the provided index isn't a valid username
-
getPlayerAtArg
public org.bukkit.entity.Player getPlayerAtArg(int index) Tries to convert the argument at the provided index to aPlayer
- Parameters:
index
- The index of the argument to convert
IMPORTANT: The index of the argument is relative to the subcommand, not the command
(see the comments atgetSubcommandArgs()
for more information)- Returns:
- The
Player
at the provided index - Throws:
IndexOutOfBoundsException
- If the index is out of boundsClassCastException
- If the argument at the provided index isn't a valid username
-
getIntegerAtArg
public int getIntegerAtArg(int index) Tries to convert the argument at the provided index to an integer- Parameters:
index
- The index of the argument to convert
IMPORTANT: The index of the argument is relative to the subcommand, not the command
(see the comments atgetSubcommandArgs()
for more information)- Returns:
- The integer at the provided index
- Throws:
IndexOutOfBoundsException
- If the index is out of boundsClassCastException
- If the argument at the provided index isn't a valid integer
-
getDoubleAtArg
public double getDoubleAtArg(int index) Tries to convert the argument at the provided index to a double- Parameters:
index
- The index of the argument to convert
IMPORTANT: The index of the argument is relative to the subcommand, not the command
(see the comments atgetSubcommandArgs()
for more information)- Returns:
- The double at the provided index
- Throws:
IndexOutOfBoundsException
- If the index is out of boundsClassCastException
- If the argument at the provided index isn't a valid double
-