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)
All Known Implementing Classes:
SystemCommandSource

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.
    void
    Clears all boss bars currently shown to the source.
    void
    Clears any currently displayed title for the associated entity or source.
    Retrieves the arguments associated with the source.
    @Nullable Locale
    Retrieves the locale associated with this source, identifying the language and regional preferences set for 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.
    void
    hideBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bossBar)
    Hides the specified boss bar from the associated source.
    boolean
    Determines if the entity represented by this source is a player.
    void
    sendMessage(@NotNull net.kyori.adventure.text.Component message)
    Sends a message to the source.
    void
    Sends a message to the source.
    void
    showBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bossBar)
    Displays the specified BossBar to the source.
    void
    showTitle(@NotNull net.kyori.adventure.title.Title title)
    Displays the specified title to the command 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
    • 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.
    • getLocale

      @Nullable @Nullable Locale getLocale()
      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
    • showBossBar

      void showBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bossBar)
      Displays the specified BossBar to the source. The BossBar provides visual feedback typically used to represent progress, health, or timed events in a graphical interface.
      Parameters:
      bossBar - the BossBar to be displayed; must not be null
    • hideBossBar

      void hideBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bossBar)
      Hides the specified boss bar from the associated source.
      Parameters:
      bossBar - the boss bar to be hidden; must not be null
    • clearBossBars

      void clearBossBars()
      Clears all boss bars currently shown to the source.

      This method removes all active boss bar instances displayed to the command source, ensuring a clean slate without any remaining visual indicators associated with boss bars.

    • showTitle

      void showTitle(@NotNull @NotNull net.kyori.adventure.title.Title title)
      Displays the specified title to the command source.
      Parameters:
      title - the title to be shown; must not be null
    • clearTitle

      void clearTitle()
      Clears any currently displayed title for the associated entity or source. This method is intended to remove any active on-screen title graphics, including subtitles, from the user's view.
    • 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.