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
ConstructorsConstructorDescriptionCommandContext(@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 aCommandContextrecord class. -
Method Summary
Modifier and TypeMethodDescription@NotNull String[]args()Returns the value of theargsrecord component.@NotNull CommandContext@NotNull CommandContext@NotNull CommandContextchild(int consumedArguments) Creates a child context.@NotNull CommandReturns the value of thecommandDatarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Stringlabel()Returns the value of thelabelrecord component.@Nullable CommandContextparent()Returns the value of theparentrecord component.@NotNull org.bukkit.command.CommandSendersender()Returns the value of thesenderrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CommandContext
-
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 aCommandContextrecord class.- Parameters:
commandData- the value for thecommandDatarecord componentsender- the value for thesenderrecord componentlabel- the value for thelabelrecord componentargs- the value for theargsrecord componentparent- the value for theparentrecord component
-
-
Method Details
-
asPlayer
@NotNull public @NotNull CommandContext asPlayer(@NotNull @NotNull Consumer<@NotNull org.bukkit.entity.Player> player) - Specified by:
asPlayerin interfaceICommandContextHelper<CommandContext>
-
asConsole
@NotNull public @NotNull CommandContext asConsole(@NotNull @NotNull Consumer<org.bukkit.command.ConsoleCommandSender> console) - Specified by:
asConsolein interfaceICommandContextHelper<CommandContext>
-
child
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
commandData
Returns the value of thecommandDatarecord component.- Returns:
- the value of the
commandDatarecord component
-
sender
@NotNull public @NotNull org.bukkit.command.CommandSender sender()Returns the value of thesenderrecord component.- Returns:
- the value of the
senderrecord component
-
label
Returns the value of thelabelrecord component.- Returns:
- the value of the
labelrecord component
-
args
Returns the value of theargsrecord component.- Returns:
- the value of the
argsrecord component
-
parent
Returns the value of theparentrecord component.- Returns:
- the value of the
parentrecord component
-