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 be null.
runAs - the execution context defining which identity and permissions are used; must not be null. See RunAs for available modes.
player - the UUID of the player to execute the command as, or null when runAs is RunAs.CONSOLE. Required when runAs is RunAs.PLAYER or RunAs.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 Details

    • CommandPayload

      public CommandPayload(String command, RunAs runAs)
      Creates a payload with no player context, equivalent to new CommandPayload(command, runAs, null).

      Use this constructor when runAs is RunAs.CONSOLE, as no player UUID is required.

      Parameters:
      command - the command string to execute; must not include a leading slash
      runAs - the execution context; must not be null
    • CommandPayload

      public CommandPayload(String command, RunAs runAs, UUID player)
      Creates an instance of a CommandPayload record class.
      Parameters:
      command - the value for the command record component
      runAs - the value for the runAs record component
      player - the value for the player record component
  • Method Details

    • 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.
    • command

      public String command()
      Returns the value of the command record component.
      Returns:
      the value of the command record component
    • runAs

      public RunAs runAs()
      Returns the value of the runAs record component.
      Returns:
      the value of the runAs record component
    • player

      public UUID player()
      Returns the value of the player record component.
      Returns:
      the value of the player record component