Velocity

This page describes how to integrate Lamp with Velocity 3+, as well as what to expect out of it.

Setting up

Prerequisites

  • Java 17 or newer

Adding Lamp dependency

To add Lamp to your project, add the following (depending on your project structure):

<dependencies>
  <!-- Required for all platforms -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.common</artifactId> 
      <version>[VERSION]</version>
  </dependency>

  <!-- Velocity module -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.velocity</artifactId>
      <version>[VERSION]</version>
  </dependency>  
  
  <!-- Optional: Brigadier module -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.brigadier</artifactId>
      <version>[VERSION]</version>
  </dependency>
</dependencies>

Optional: Preserve parameter names

Lamp identifies parameters by their names and uses them to generate relevant command metadata. By default, Java does not preserve parameter names reflectively. You need to add the following to your project:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
      <compilerArgs>
        <!-- Preserves parameter names -->
        <arg>-parameters</arg>
      </compilerArgs>
    </configuration>
  </plugin>
</plugins>

Velocity-specific annotations

@CommandPermission

Adds a command permission for the given command

Supported Velocity types

  • com.velocitypowered.api.command.CommandSource and its subclasses in place of CommandActor

  • com.velocitypowered.api.proxy.Player

Example

@Plugin(
    id = "myplugin",
    name = "MyPlugin",
    version = "1.0",
    description = "A simple Velocity plugin",
    authors = {"YourName"}
)
public class MyPlugin {

    private final ProxyServer server;
    private final Lamp<VelocityCommandActor> lamp;

    @Inject
    public MyPlugin(ProxyServer server, @DataDirectory Path dataDirectory) {
        this.server = server;
        this.lamp = VelocityLamp.builder(this, server).build();
        lamp.register(new MyCommand());
    }

    public static class MyCommand {

        @Command("hello")
        @CommandPermission("myplugin.hello")
        public void hello(VelocityCommandActor actor) {
            ...
        }
    }
}

Last updated