java.lang.Object
com.github.cyberryan1.cybercore.spigot.command.sent.SentSubCommand

public class SentSubCommand extends Object
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 Details

    • SentSubCommand

      public SentSubCommand(org.bukkit.command.CommandSender sender, String subcommand, String[] subcommandArgs)
  • Method Details

    • getSubcommand

      public String 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

      public String[] 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

      public String getArg(int index)
      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 at getSubcommandArgs() 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 an OfflinePlayer
      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 at getSubcommandArgs() for more information)
      Returns:
      The OfflinePlayer at the provided index
      Throws:
      IndexOutOfBoundsException - If the index is out of bounds
      ClassCastException - 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 a Player
      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 at getSubcommandArgs() for more information)
      Returns:
      The Player at the provided index
      Throws:
      IndexOutOfBoundsException - If the index is out of bounds
      ClassCastException - 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 at getSubcommandArgs() for more information)
      Returns:
      The integer at the provided index
      Throws:
      IndexOutOfBoundsException - If the index is out of bounds
      ClassCastException - 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 at getSubcommandArgs() for more information)
      Returns:
      The double at the provided index
      Throws:
      IndexOutOfBoundsException - If the index is out of bounds
      ClassCastException - If the argument at the provided index isn't a valid double