Record Class CommandContext

java.lang.Object
java.lang.Record
com.marcusslover.plus.lib.command.CommandContext
All Implemented Interfaces:
ICommandContextHelper<CommandContext>

public record CommandContext(@NotNull Command commandData, @NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, @Nullable CommandContext parent) extends Record implements ICommandContextHelper<CommandContext>
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommandContext(@NotNull Command commandData, @NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args)
     
    CommandContext(@NotNull Command commandData, @NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, @Nullable CommandContext parent)
    Creates an instance of a CommandContext record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String[]
    Returns the value of the args record component.
    asConsole(@NotNull Consumer<org.bukkit.command.ConsoleCommandSender> console)
     
    asPlayer(@NotNull Consumer<@NotNull org.bukkit.entity.Player> player)
     
    child(int consumedArguments)
    Creates a child context.
    @NotNull Command
    Returns the value of the commandData record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NotNull String
    Returns the value of the label record component.
    @Nullable CommandContext
    Returns the value of the parent record component.
    @NotNull org.bukkit.command.CommandSender
    Returns the value of the sender record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CommandContext

      public CommandContext(@NotNull @NotNull Command commandData, @NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args)
    • CommandContext

      public CommandContext(@NotNull @NotNull Command commandData, @NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, @Nullable @Nullable CommandContext parent)
      Creates an instance of a CommandContext record class.
      Parameters:
      commandData - the value for the commandData record component
      sender - the value for the sender record component
      label - the value for the label record component
      args - the value for the args record component
      parent - the value for the parent record component
  • Method Details

    • asPlayer

      @NotNull public @NotNull CommandContext asPlayer(@NotNull @NotNull Consumer<@NotNull org.bukkit.entity.Player> player)
      Specified by:
      asPlayer in interface ICommandContextHelper<CommandContext>
    • asConsole

      @NotNull public @NotNull CommandContext asConsole(@NotNull @NotNull Consumer<org.bukkit.command.ConsoleCommandSender> console)
      Specified by:
      asConsole in interface ICommandContextHelper<CommandContext>
    • child

      @NotNull public @NotNull CommandContext child(int consumedArguments)
      Creates a child context.
      Parameters:
      consumedArguments - The amount of consumed arguments
      Returns:
      A child context with this context as the parent, the last consumed argument as the label, and all unconsumed arguments as args. Created by tecc
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • commandData

      @NotNull public @NotNull Command commandData()
      Returns the value of the commandData record component.
      Returns:
      the value of the commandData record component
    • sender

      @NotNull public @NotNull org.bukkit.command.CommandSender sender()
      Returns the value of the sender record component.
      Returns:
      the value of the sender record component
    • label

      @NotNull public @NotNull String label()
      Returns the value of the label record component.
      Returns:
      the value of the label record component
    • args

      @NotNull public @NotNull String[] args()
      Returns the value of the args record component.
      Returns:
      the value of the args record component
    • parent

      @Nullable public @Nullable CommandContext parent()
      Returns the value of the parent record component.
      Returns:
      the value of the parent record component