Class VelocitySource

java.lang.Object
studio.mevera.imperat.VelocitySource
All Implemented Interfaces:
studio.mevera.imperat.context.Source

public class VelocitySource extends Object implements studio.mevera.imperat.context.Source
A Velocity-specific implementation of Source that wraps a Velocity CommandSource. This class provides a bridge between Velocity's command system and the Imperat framework, allowing commands to work seamlessly with Velocity's player and console command sources.

Features:

  • Support for both player and console command sources
  • Adventure text component support for rich messaging
  • Type-safe casting to Player or ConsoleCommandSource
  • UUID-based identification for players
Since:
1.0
  • Field Summary

    Fields inherited from interface studio.mevera.imperat.context.Source

    CONSOLE_UUID
  • Method Summary

    Modifier and Type
    Method
    Description
    com.velocitypowered.api.proxy.ConsoleCommandSource
    Casts this command source to a ConsoleCommandSource.
    com.velocitypowered.api.proxy.Player
    Casts this command source to a Player.
    void
    error(String message)
    Sends an error message to this command source.
    boolean
    Checks if this command source is the console.
    Gets the name of this command source.
    com.velocitypowered.api.command.CommandSource
    Gets the original Velocity CommandSource that this VelocitySource wraps.
    void
    reply(String message)
    Sends a rich message to this command source using Velocity's rich message format.
    void
    reply(net.kyori.adventure.text.ComponentLike component)
    Sends an Adventure Component to this command source.
    Gets the UUID of this command source.
    void
    warn(String message)
    Sends a warning message to this command source.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface studio.mevera.imperat.context.Source

    as
  • Method Details

    • name

      public String name()
      Gets the name of this command source.
      Specified by:
      name in interface studio.mevera.imperat.context.Source
      Returns:
      the username if this is a player, or "CONSOLE" if this is the console
    • origin

      public com.velocitypowered.api.command.CommandSource origin()
      Gets the original Velocity CommandSource that this VelocitySource wraps.
      Specified by:
      origin in interface studio.mevera.imperat.context.Source
      Returns:
      the underlying Velocity CommandSource
    • reply

      public void reply(String message)
      Sends a rich message to this command source using Velocity's rich message format. Supports MiniMessage format for styling and colors.
      Specified by:
      reply in interface studio.mevera.imperat.context.Source
      Parameters:
      message - the message to send, can include MiniMessage formatting
    • reply

      public void reply(net.kyori.adventure.text.ComponentLike component)
      Sends an Adventure Component to this command source.
      Parameters:
      component - the Adventure component to send
    • warn

      public void warn(String message)
      Sends a warning message to this command source. The message will be formatted in yellow.
      Specified by:
      warn in interface studio.mevera.imperat.context.Source
      Parameters:
      message - the warning message to send
    • error

      public void error(String message)
      Sends an error message to this command source. The message will be formatted in red.
      Specified by:
      error in interface studio.mevera.imperat.context.Source
      Parameters:
      message - the error message to send
    • isConsole

      public boolean isConsole()
      Checks if this command source is the console.
      Specified by:
      isConsole in interface studio.mevera.imperat.context.Source
      Returns:
      true if this is the console, false otherwise
    • uuid

      public UUID uuid()
      Gets the UUID of this command source. For the console, a predefined constant UUID is returned.
      Specified by:
      uuid in interface studio.mevera.imperat.context.Source
      Returns:
      the UUID of the command source
    • asConsole

      public com.velocitypowered.api.proxy.ConsoleCommandSource asConsole()
      Casts this command source to a ConsoleCommandSource. This is only safe if isConsole() returns true.
      Returns:
      this command source as a ConsoleCommandSource
      Throws:
      ClassCastException - if this is not the console
    • asPlayer

      public com.velocitypowered.api.proxy.Player asPlayer()
      Casts this command source to a Player. This is only safe if isConsole() returns false.
      Returns:
      this command source as a Player
      Throws:
      ClassCastException - if this is the console