Skip to content

Velocity Implementation

mario edited this page Mar 29, 2026 · 6 revisions

Velocity

Registering Commands

Unlike Bukkit and BungeeCord, Velocity plugins do not extend a base class, so both the plugin instance and the ProxyServer must be passed explicitly.

@Plugin(id = "myplugin", name = "MyPlugin", version = "1.0")
public class MyPlugin {
    private final ProxyServer server;

    @Inject
    public MyPlugin(ProxyServer server) {
        this.server = server;
    }

    @Subscribe
    public void onProxyInitialize(ProxyInitializeEvent event) {
        // Recommended — scans the entire package
        VelocityCommandHandler.registerCommands("me.myplugin.commands", this, server);
        // Register a single class
        VelocityCommandHandler.registerCommands(MyCommands.class, this, server);
        // Register multiple classes at once
        VelocityCommandHandler.registerCommands(this, server, MyCommands.class, AdminCommands.class);
    }
}

Differences from Bukkit

Bukkit Velocity
Sender type org.bukkit.command.CommandSender com.velocitypowered.api.command.CommandSource
Processor base class Processor<T> VelocityProcessor<T>
Handler BukkitCommandHandler VelocityCommandHandler
Messages Legacy ChatColor Adventure Component API

Error Messages

Velocity uses the Adventure API, so error messages accept Component instead of plain strings.

VelocityCommandHandler.setNoPermissionMessage(
    Component.text("You don't have permission.", NamedTextColor.RED));
VelocityCommandHandler.setPlayerOnlyMessage(
    Component.text("Only players can use this.", NamedTextColor.RED));
VelocityCommandHandler.setConsoleOnlyMessage(
    Component.text("Only console can use this.", NamedTextColor.RED));
VelocityCommandHandler.setInternalErrorMessage(
    Component.text("Internal error occurred.", NamedTextColor.RED));

Further Reading

Clone this wiki locally