Record Class CommandPayload
java.lang.Object
java.lang.Record
dev.objz.commandbridge.api.channel.command.CommandPayload
- Record Components:
command- the command string to execute on the target server; must not include a leading slash. Must not benull.runAs- the execution context defining which identity and permissions are used; must not benull. SeeRunAsfor available modes.player- the UUID of the player to execute the command as, ornullwhenrunAsisRunAs.CONSOLE. Required whenrunAsisRunAs.PLAYERorRunAs.OPERATOR.
- All Implemented Interfaces:
ChannelPayload
public record CommandPayload(String command, RunAs runAs, UUID player)
extends Record
implements ChannelPayload
Payload carrying a command to be executed on a remote server via the
CommandBridge network.
The three components define what to run and how. command is the
command string without a leading slash. runAs defines the execution
context; see RunAs for available modes. player is the
optional player UUID required when runAs is RunAs.PLAYER
or RunAs.OPERATOR; pass null for RunAs.CONSOLE.
Instances are sent through a
MessageChannel obtained from
CommandBridgeAPI.channel(Class).
To create a console command with no player context:
new CommandPayload("say hello", RunAs.CONSOLE)
To create a command that runs as a specific player:
new CommandPayload("home", RunAs.PLAYER, playerUUID)
To create a command with temporary operator permissions:
new CommandPayload("gamemode creative", RunAs.OPERATOR, playerUUID)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCommandPayload(String command, RunAs runAs) Creates a payload with no player context, equivalent tonew CommandPayload(command, runAs, null).CommandPayload(String command, RunAs runAs, UUID player) Creates an instance of aCommandPayloadrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncommand()Returns the value of thecommandrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.player()Returns the value of theplayerrecord component.runAs()Returns the value of therunAsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CommandPayload
Creates a payload with no player context, equivalent tonew CommandPayload(command, runAs, null).Use this constructor when
runAsisRunAs.CONSOLE, as no player UUID is required.- Parameters:
command- the command string to execute; must not include a leading slashrunAs- the execution context; must not benull
-
CommandPayload
Creates an instance of aCommandPayloadrecord class.
-
-
Method Details
-
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). -
command
Returns the value of thecommandrecord component.- Returns:
- the value of the
commandrecord component
-
runAs
Returns the value of therunAsrecord component.- Returns:
- the value of the
runAsrecord component
-
player
Returns the value of theplayerrecord component.- Returns:
- the value of the
playerrecord component
-