🛖
Fox Hut
  • Introduction
    • Setting up
    • CommandActor, @Command and @Subcommand
    • Creating your first command
    • Improving our greet command
  • Platforms
    • Bukkit / Spigot / Paper
    • BungeeCord
    • Velocity
    • Sponge
    • Fabric
    • Brigadier
    • Minestom
    • JDA
    • Command line
  • How-to
    • Creating variants of /teleport
    • Custom parameter types
    • Suggestions and auto-completion
    • Context parameters
    • Command permissions
    • Parameter validators
    • Command conditions
    • Response handlers
    • Cooldowns
    • Help commands
    • Annotation replacers
    • Orphan command
    • Exception handling
    • Hooks
    • Dependency injection
    • Visitors
    • Customizing the dispatcher and failure behavior
Powered by GitBook
On this page
  • Notes on Brigadier
  • Setting up
  • Adding Lamp dependency
  • Bukkit-specific annotations
  • @CommandPermission
  • @FallbackPrefix
  • Supported Bukkit types
  • Example

Was this helpful?

Edit on GitHub
  1. Platforms

Bukkit / Spigot / Paper

This page describes how to integrate Lamp with Bukkit (Spigot) and Paper, as well as what to expect out of it.

Notes on Brigadier

Lamp allows for native integration with Brigadier, which is Minecraft's new command system introduced in 1.13 that comes with colorful suggestions, client-side validation, and space-aware auto-completion.

However, because Bukkit does not provide supported APIs for that, Lamp has to rely on hacks for injecting commands.

You may need to depend on the brigadier module if you would like to customize the Brigadier integration.

Lamp's Brigadier integration is enabled by default for 1.13+ but with some nuances. Here is a support table:

Version
Brigadier Supported

1.13 - 1.19

1.19.1+

Setting up

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>

  <!-- Bukkit module -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.bukkit</artifactId>
      <version>[VERSION]</version>
  </dependency>  
  
  <!-- Optional: Brigadier module -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.brigadier</artifactId>
      <version>[VERSION]</version>
  </dependency>
</dependencies>
dependencies {
    // Required for all platforms
    implementation 'io.github.revxrsal:lamp.common:[VERSION]'
   
    // Bukkit module
    implementation 'io.github.revxrsal:lamp.bukkit:[VERSION]'
   
    // Optional: Brigadier module
    implementation 'io.github.revxrsal:lamp.brigadier:[VERSION]'
}
dependencies {
    // Required for all platforms
    implementation("io.github.revxrsal:lamp.common:[VERSION]")
    
    // Bukkit module
    implementation("io.github.revxrsal:lamp.bukkit:[VERSION]")
    
    // Optional: Brigadier module
    implementation("io.github.revxrsal:lamp.brigadier:[VERSION]")
}

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>
compileJava { 
    // Preserve parameter names in the bytecode
    options.compilerArgs += ["-parameters"]
}

// optional: if you're using Kotlin
compileKotlin {
    kotlinOptions.javaParameters = true
}
tasks.withType<JavaCompile> {
    // Preserve parameter names in the bytecode
    options.compilerArgs.add("-parameters")
}

// optional: if you're using Kotlin
tasks.withType<KotlinJvmCompile> {
    compilerOptions {
        javaParameters = true
    }
}

Bukkit-specific annotations

@CommandPermission

Adds a command permission for the given command

@FallbackPrefix

Customizes the fallback prefix of a command

Bukkit uses this fallback prefix when two commands conflict with their main label, in which Bukkit would register it as /<fallback prefix>:command instead.

Supported Bukkit types

  • org.bukkit.command.CommandSender and its subclasses in place of CommandActor

  • org.bukkit.entity.Player

  • org.bukkit.OfflinePlayer

  • org.bukkit.World

  • org.bukkit.entity.Entity on 1.13+ (requires Brigadier)

Example

public final class MyPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        Lamp<BukkitCommandActor> lamp = BukkitLamp.builder(this).build();
        lamp.register(new MyCommand());
    }

    public class MyCommand {

        @Command("hello")
        @CommandPermission("myplugin.hello")
        public void hello(BukkitCommandActor actor) {
            // Command logic here
        }
    }
}
class MyPlugin : JavaPlugin() {

    override fun onEnable() {
      val lamp: Lamp<BukkitCommandActor> = BukkitLamp.builder(this)
          .build()
      lamp.register(MyCommand())
    }

    class MyCommand {

        @Command("hello")
        @CommandPermission("myplugin.hello")
        fun hello(actor: BukkitCommandActor) {
            // Command logic here
        }
    }
}
PreviousImproving our greet commandNextBungeeCord

Last updated 5 months ago

Was this helpful?

Paper only

Latest version:

✅
✔️