Class VelocityActor

java.lang.Object
revxrsal.commands.velocity.core.VelocityActor
All Implemented Interfaces:
CommandActor, VelocityCommandActor

public final class VelocityActor extends Object implements VelocityCommandActor
  • Constructor Summary

    Constructors
    Constructor
    Description
    VelocityActor(com.velocitypowered.api.command.CommandSource source, com.velocitypowered.api.proxy.ProxyServer server, CommandHandler handler)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    error(@NotNull String message)
    Replies to the sender with the specified message, and marks it as an error depending on the platform.
    @Nullable com.velocitypowered.api.proxy.Player
    Returns this actor as a Player if it is a player, otherwise returns null.
    Returns the command handler that constructed this actor
    @NotNull Locale
    Returns the locale of this command actor.
    @NotNull String
    Returns the name of this actor.
    @NotNull com.velocitypowered.api.proxy.ProxyServer
    Returns the ProxyServer of this actor
    @NotNull com.velocitypowered.api.command.CommandSource
    Returns the underlying CommandSource being wrapped by this actor.
    @NotNull UUID
    Returns the unique UID of this subject.
    boolean
    Tests whether is this actor the console or not
    boolean
    Tests whether is this actor a player or not
    void
    reply(@NotNull String message)
    Replies to the sender with the specified message.
    void
    reply(@NotNull net.kyori.adventure.text.Component component)
    Sends the given component message to this actor
    void
    reply(@NotNull net.kyori.adventure.text.ComponentLike component)
    Sends the given component message to this actor
    @NotNull com.velocitypowered.api.proxy.ConsoleCommandSource
    Returns this actor as a ConsoleCommandSource if it is a player, otherwise throws a SenderNotConsoleException.
    @NotNull com.velocitypowered.api.proxy.Player
    Returns this actor as a Player if it is a player, otherwise throws a SenderNotPlayerException.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface revxrsal.commands.command.CommandActor

    as, errorLocalized, getTranslator, replyLocalized
  • Constructor Details

    • VelocityActor

      public VelocityActor(com.velocitypowered.api.command.CommandSource source, com.velocitypowered.api.proxy.ProxyServer server, CommandHandler handler)
  • Method Details

    • 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 CommandHandler getCommandHandler()
      Description copied from interface: CommandActor
      Returns the command handler that constructed this actor
      Specified by:
      getCommandHandler in interface CommandActor
      Returns:
      The command handler
    • getSource

      @NotNull public @NotNull com.velocitypowered.api.command.CommandSource getSource()
      Description copied from interface: VelocityCommandActor
      Returns the underlying CommandSource being wrapped by this actor.
      Specified by:
      getSource in interface VelocityCommandActor
      Returns:
      Velocity's command source.
    • reply

      public void reply(@NotNull @NotNull net.kyori.adventure.text.Component component)
      Description copied from interface: VelocityCommandActor
      Sends the given component message to this actor
      Specified by:
      reply in interface VelocityCommandActor
      Parameters:
      component - Component to send
    • reply

      public void reply(@NotNull @NotNull net.kyori.adventure.text.ComponentLike component)
      Description copied from interface: VelocityCommandActor
      Sends the given component message to this actor
      Specified by:
      reply in interface VelocityCommandActor
      Parameters:
      component - Component to send
    • 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
    • getServer

      @NotNull public @NotNull com.velocitypowered.api.proxy.ProxyServer getServer()
      Description copied from interface: VelocityCommandActor
      Returns the ProxyServer of this actor
      Specified by:
      getServer in interface VelocityCommandActor
      Returns:
      The proxy server
    • isPlayer

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

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

      @Nullable public @Nullable com.velocitypowered.api.proxy.Player getAsPlayer()
      Description copied from interface: VelocityCommandActor
      Returns this actor as a Player if it is a player, otherwise returns null.
      Specified by:
      getAsPlayer in interface VelocityCommandActor
      Returns:
      The sender as a player, or null.
    • requirePlayer

      @NotNull public @NotNull com.velocitypowered.api.proxy.Player requirePlayer() throws SenderNotPlayerException
      Description copied from interface: VelocityCommandActor
      Returns this actor as a Player if it is a player, otherwise throws a SenderNotPlayerException.
      Specified by:
      requirePlayer in interface VelocityCommandActor
      Returns:
      The actor as a player
      Throws:
      SenderNotPlayerException - if not a player
    • requireConsole

      @NotNull public @NotNull com.velocitypowered.api.proxy.ConsoleCommandSource requireConsole() throws SenderNotConsoleException
      Description copied from interface: VelocityCommandActor
      Returns this actor as a ConsoleCommandSource if it is a player, otherwise throws a SenderNotConsoleException.
      Specified by:
      requireConsole in interface VelocityCommandActor
      Returns:
      The actor as console
      Throws:
      SenderNotConsoleException - if not a player