Interface CommandSource<C,R>

Type Parameters:
C - the underlying type representing the source (e.g., CommandSender)
R - the player-specific type related to the platform (e.g., Player)

public interface CommandSource<C,R>
Represents a source implementation that abstracts interactions with various platforms.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the number of arguments associated with the source.
    @Nullable Player<R>
    Attempts to retrieve the source as a Player.
    Retrieves the arguments associated with the source.
    default Operator
    Retrieves the operator associated with this source implementation.
    Retrieves the source entity that this implementation represents.
    boolean
    hasPermission(String permission)
    Checks if the entity associated with this source has the specified permission.
    default boolean
    Determines if the entity associated with this source is a Bedrock player.
    boolean
    Determines if the entity represented by this source is a player.
    @Nullable Locale
    Retrieves the locale associated with this source, identifying the language and regional preferences set for the source.
    void
    sendMessage(@NotNull net.kyori.adventure.text.Component message)
    Sends a message to the source.
    void
    Sends a message to the source.
  • Method Details

    • getOperator

      default Operator getOperator()
      Retrieves the operator associated with this source implementation.

      The operator typically represents the entity that executes administrative or management tasks.

      Returns:
      the operator, defaulting to the system console operator.
    • getSource

      C getSource()
      Retrieves the source entity that this implementation represents.
      Returns:
      the source entity of type C
    • isBedrockPlayer

      default boolean isBedrockPlayer()
      Determines if the entity associated with this source is a Bedrock player.
      Returns:
      true if the source entity is a Bedrock player, otherwise false
    • isPlayer

      boolean isPlayer()
      Determines if the entity represented by this source is a player.
      Returns:
      true if the source is a player, otherwise false
    • getArgs

      String[] getArgs()
      Retrieves the arguments associated with the source. The arguments are typically used to provide additional information or parameters related to a command or action.
      Returns:
      an array of strings representing the arguments associated with the source
    • argSize

      int argSize()
      Retrieves the number of arguments associated with the source.
      Returns:
      the number of arguments as an integer.
    • locale

      @Nullable @Nullable Locale locale()
      Retrieves the locale associated with this source, identifying the language and regional preferences set for the source.
      Returns:
      the locale representing the language and region preferences, or null if the client is not connected to any server.

      If the source is not a player, it returns the environment's default locale.

    • hasPermission

      boolean hasPermission(String permission)
      Checks if the entity associated with this source has the specified permission.
      Parameters:
      permission - the permission node to check for
      Returns:
      true if the entity has the specified permission, otherwise false
    • sendMessage

      void sendMessage(String message)
      Sends a message to the source.
      Parameters:
      message - the message to be sent
    • sendMessage

      void sendMessage(@NotNull @NotNull net.kyori.adventure.text.Component message)
      Sends a message to the source.
      Parameters:
      message - the message to be sent; must not be null
    • asPlayer

      @Nullable @Nullable Player<R> asPlayer()
      Attempts to retrieve the source as a Player. If the source does not represent a player, this method will return null.
      Returns:
      a Player<R> instance if the source is a player, or null if the source is not a player.