Interface CommandActor

All Known Subinterfaces:
BukkitCommandActor, BungeeCommandActor, ConsoleActor, JDAActor, SpongeCommandActor, VelocityCommandActor
All Known Implementing Classes:
BaseActorJDA, BukkitActor, BungeeActor, CommandLineActor, SpongeActor, VelocityActor

public interface CommandActor
Represents a command sender, responsible for performing a command-related action.
  • Method Details

    • getName

      @NotNull @NotNull String getName()
      Returns the name of this actor. Varies depending on the platform.
      Returns:
      The actor name
    • getUniqueId

      @NotNull @NotNull UUID getUniqueId()
      Returns the unique UID of this subject. Varies depending on the platform.

      Although some platforms explicitly have their underlying senders have UUIDs, some platforms may have to generate this UUID based on other available data.

      Returns:
      The UUID of this subject.
    • reply

      void reply(@NotNull @NotNull String message)
      Replies to the sender with the specified message.

      Varies depending on the platform.

      Parameters:
      message - Message to reply with.
    • error

      void error(@NotNull @NotNull String message)
      Replies to the sender with the specified message, and marks it as an error depending on the platform.

      Note that, in certain platforms where no "error" mode is available, this may effectively be equivilent to calling reply(String).

      This method should not throw any exceptions.

      Parameters:
      message - Message to reply with
    • getCommandHandler

      CommandHandler getCommandHandler()
      Returns the command handler that constructed this actor
      Returns:
      The command handler
    • getTranslator

      default Translator getTranslator()
      Returns:
      The command handler translator
    • getLocale

      @NotNull default @NotNull Locale getLocale()
      Returns the locale of this command actor. This can be used by translation tools to provide specialized messages.

      Note that platforms that do not support per-actor locales will return a default locale, mostly Locale.ENGLISH.

      Returns:
      The actor's locale
    • replyLocalized

      default void replyLocalized(@NotNull @NotNull String key, Object... args)
      Replies with the given message
      Parameters:
      key - Key of the message
      args - The arguments to format with
    • errorLocalized

      default void errorLocalized(@NotNull @NotNull String key, Object... args)
      Replies with the given message
      Parameters:
      key - Key of the message
      args - The arguments to format with
    • as

      default <T extends CommandActor> T as(@NotNull @NotNull Class<T> type)
      Returns this actor as the specified type. This is effectively casting this actor to the given type.
      Type Parameters:
      T - The actor type
      Parameters:
      type - Type to cast to
      Returns:
      This actor but casted.