🛖
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
  • Adding Lamp dependency
  • Optional: Preserve parameter names

Was this helpful?

Edit on GitHub
  1. Introduction

Setting up

This page describes how you can add Lamp to your own projects, using Gradle or Maven.

NextCommandActor, @Command and @Subcommand

Last updated 7 months ago

Was this helpful?

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>

  <!-- Add your specific platform module here -->
  <dependency>
      <groupId>io.github.revxrsal</groupId>
      <artifactId>lamp.[PLATFORM]</artifactId>
      <version>[VERSION]</version>
  </dependency>  
</dependencies>
dependencies {
   implementation 'io.github.revxrsal:lamp.common:[VERSION]'
   implementation 'io.github.revxrsal:lamp.[PLATFORM]:[VERSION]'
}
dependencies {
   implementation("io.github.revxrsal:lamp.common:[VERSION]")
   implementation("io.github.revxrsal:lamp.[PLATFORM]:[VERSION]")
}

Latest version:

Where [PLATFORM] is any of the following:

  • cli: A minimal implementation of the Lamp APIs for command-line applications

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
    }
}

For Kotlin

Here’s how you can set the Kotlin compiler option javaParameters = true in three different build systems, using the tab format you specified:

<build>
    <plugins>
        <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <!-- ... your configuration here ... -->
            <configuration>
                <args>
                    <arg>-java-parameters</arg>
                </args>
            </configuration>
        </plugin>
    </plugins>
</build>
kotlin {
    compilerOptions {
        javaParameters = true
    }
}
kotlin {
    compilerOptions {
        javaParameters = true
    }
}

bukkit: Contains integrations for the platform

bungee: Contains integrations for the API

brigadier: Contains integrations for API

sponge: Contains integrations for the platform (version 8+)

paper: Contains extra features for the API

velocity: Contains integrations for the API

minestom: Contains integrations for the platform

fabric: Contains integrations for the modding API

jda: Contains integrations for the

Bukkit
BungeeCord
Mojang's Brigadier
Sponge
PaperMC
VelocityPowered
Minestom
Fabric
Java Discord API