Package studio.mevera.imperat
Class VelocitySource
java.lang.Object
studio.mevera.imperat.VelocitySource
- All Implemented Interfaces:
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 TypeMethodDescriptioncom.velocitypowered.api.proxy.ConsoleCommandSourceCasts this command source to a ConsoleCommandSource.com.velocitypowered.api.proxy.PlayerasPlayer()Casts this command source to a Player.voidSends an error message to this command source.booleanChecks if this command source is the console.name()Gets the name of this command source.com.velocitypowered.api.command.CommandSourceorigin()Gets the original Velocity CommandSource that this VelocitySource wraps.voidSends a rich message to this command source using Velocity's rich message format.voidreply(net.kyori.adventure.text.ComponentLike component) Sends an Adventure Component to this command source.uuid()Gets the UUID of this command source.voidSends a warning message to this command source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.imperat.context.Source
as
-
Method Details
-
name
Gets the name of this command source.- Specified by:
namein interfacestudio.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:
originin interfacestudio.mevera.imperat.context.Source- Returns:
- the underlying Velocity CommandSource
-
reply
Sends a rich message to this command source using Velocity's rich message format. Supports MiniMessage format for styling and colors.- Specified by:
replyin interfacestudio.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
Sends a warning message to this command source. The message will be formatted in yellow.- Specified by:
warnin interfacestudio.mevera.imperat.context.Source- Parameters:
message- the warning message to send
-
error
Sends an error message to this command source. The message will be formatted in red.- Specified by:
errorin interfacestudio.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:
isConsolein interfacestudio.mevera.imperat.context.Source- Returns:
- true if this is the console, false otherwise
-
uuid
Gets the UUID of this command source. For the console, a predefined constant UUID is returned.- Specified by:
uuidin interfacestudio.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 ifisConsole()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 ifisConsole()returns false.- Returns:
- this command source as a Player
- Throws:
ClassCastException- if this is the console
-