Interface CommandSource

All Superinterfaces:
PermissionSubject
All Known Subinterfaces:
Player

public interface CommandSource extends PermissionSubject
Represents a source that can execute commands.

This can be a player, the console, or another command source. All command sources are permission subjects and can be checked for permissions.

The Player interface extends this interface, so all players are also command sources.

  • Method Details

    • sendMessage

      void sendMessage(@Nonnull String message)
      Send a message to this command source.
      Parameters:
      message - the message to send
    • sendMessage

      default void sendMessage(@Nonnull ChatMessageBuilder builder)
      Send a formatted message to this command source.

      If this source is a player, the message is sent with colors. If this source is the console, colors are stripped automatically.

      Parameters:
      builder - the message builder
    • asPlayer

      @Nonnull default Optional<Player> asPlayer()
      Get this source as a player, if applicable.
      Returns:
      the player, or empty if this is not a player
    • isPlayer

      default boolean isPlayer()
      Check if this source is a player.
      Returns:
      true if this is a player
    • isConsole

      default boolean isConsole()
      Check if this source is the console.
      Returns:
      true if this is the console