Class BukkitActor

java.lang.Object
revxrsal.commands.bukkit.core.BukkitActor
All Implemented Interfaces:
BukkitCommandActor, CommandActor

@Internal public final class BukkitActor extends Object implements BukkitCommandActor
  • Constructor Details

    • BukkitActor

      public BukkitActor(org.bukkit.command.CommandSender sender, CommandHandler handler)
  • Method Details

    • getSender

      @NotNull public @NotNull org.bukkit.command.CommandSender getSender()
      Description copied from interface: BukkitCommandActor
      Returns the underlying CommandSender of this actor
      Specified by:
      getSender in interface BukkitCommandActor
      Returns:
      The sender
    • isPlayer

      public boolean isPlayer()
      Description copied from interface: BukkitCommandActor
      Tests whether is this actor a player or not
      Specified by:
      isPlayer in interface BukkitCommandActor
      Returns:
      Is this a player or not
    • isConsole

      public boolean isConsole()
      Description copied from interface: BukkitCommandActor
      Tests whether is this actor the console or not
      Specified by:
      isConsole in interface BukkitCommandActor
      Returns:
      Is this the console or not
    • getAsPlayer

      @Nullable public @Nullable org.bukkit.entity.Player getAsPlayer()
      Description copied from interface: BukkitCommandActor
      Returns this actor as a Player if it is a player, otherwise returns null.
      Specified by:
      getAsPlayer in interface BukkitCommandActor
      Returns:
      The sender as a player, or null.
    • requirePlayer

      @NotNull public @NotNull org.bukkit.entity.Player requirePlayer()
      Description copied from interface: BukkitCommandActor
      Returns this actor as a Player if it is a player, otherwise throws a SenderNotPlayerException.
      Specified by:
      requirePlayer in interface BukkitCommandActor
      Returns:
      The actor as a player
    • requireConsole

      @NotNull public @NotNull org.bukkit.command.ConsoleCommandSender requireConsole()
      Description copied from interface: BukkitCommandActor
      Returns this actor as a ConsoleCommandSender if it is a player, otherwise throws a SenderNotConsoleException.
      Specified by:
      requireConsole in interface BukkitCommandActor
      Returns:
      The actor as console
    • audience

      @NotNull public @NotNull net.kyori.adventure.audience.Audience audience()
      Description copied from interface: BukkitCommandActor
      Returns the Audience of this sender.

      NOTE: This requires calling BukkitCommandHandler.enableAdventure() or BukkitCommandHandler.enableAdventure(BukkitAudiences).

      Specified by:
      audience in interface BukkitCommandActor
      Returns:
      The audience of this sender
    • reply

      public void reply(@NotNull @NotNull net.kyori.adventure.text.ComponentLike component)
      Description copied from interface: BukkitCommandActor
      Sends the given component to this actor.

      NOTE: This requires calling BukkitCommandHandler.enableAdventure() or BukkitCommandHandler.enableAdventure(BukkitAudiences).

      Specified by:
      reply in interface BukkitCommandActor
      Parameters:
      component - Component to send
    • getName

      @NotNull public @NotNull String getName()
      Description copied from interface: CommandActor
      Returns the name of this actor. Varies depending on the platform.
      Specified by:
      getName in interface CommandActor
      Returns:
      The actor name
    • getUniqueId

      @NotNull public @NotNull UUID getUniqueId()
      Description copied from interface: CommandActor
      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.

      Specified by:
      getUniqueId in interface CommandActor
      Returns:
      The UUID of this subject.
    • reply

      public void reply(@NotNull @NotNull String message)
      Description copied from interface: CommandActor
      Replies to the sender with the specified message.

      Varies depending on the platform.

      Specified by:
      reply in interface CommandActor
      Parameters:
      message - Message to reply with.
    • error

      public void error(@NotNull @NotNull String message)
      Description copied from interface: CommandActor
      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 CommandActor.reply(String).

      This method should not throw any exceptions.

      Specified by:
      error in interface CommandActor
      Parameters:
      message - Message to reply with
    • getCommandHandler

      public BukkitCommandHandler getCommandHandler()
      Description copied from interface: BukkitCommandActor
      Returns the command handler that constructed this actor
      Specified by:
      getCommandHandler in interface BukkitCommandActor
      Specified by:
      getCommandHandler in interface CommandActor
      Returns:
      The command handler
    • getLocale

      @NotNull public @NotNull Locale getLocale()
      Description copied from interface: CommandActor
      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.

      Specified by:
      getLocale in interface CommandActor
      Returns:
      The actor's locale