Brigadier
This page describes how to integrate Lamp with Brigadier, as well as what to expect out of it.
Because Lamp and Brigadier share a lot in common in structure and organization, Lamp provides a brigadier module that allows for creating 1-to-1 mappings between the two frameworks easily.
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>
<!-- 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]'
// Brigadier module
implementation 'io.github.revxrsal:lamp.brigadier:[VERSION]'
}dependencies {
// Required for all platforms
implementation("io.github.revxrsal:lamp.common:[VERSION]")
// Brigadier module
implementation("io.github.revxrsal:lamp.brigadier:[VERSION]")
}Latest 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
}
}Brigadier-specific annotations
@BType
@BTypeSpecifies what ArgumentType a parameter should be mapped to
Lamp to Brigadier conversion
All Lamp to Brigadier conversions are done using two main classes:
BrigadierConverter: An interface that specifies how certain Brigadier or Lamp types should be converted.createActor: Specifies how to convert Brigadier's sender S to Lamp's CommandActor AgetArgumentType: Specifies how to convert Lamp's ParameterType to Brigadier's ArgumentType. It's recommended to use the registry Lamp provides, using theArgumentTypesclass.
BrigadierParser: Contains functions that accept Lamp objects and aBrigadierConverterto convert into respective Brigadier types.createNode(ExecutableCommand): Creates aLiteralCommandNodefrom a LampExecutableCommandcreateNode(CommandNode node): Creates a BrigadierCommandNodefrom a LampCommandNode.createRequirement: Creates aPredicatefor Brigadier from Lamp's CommandPermissioncreateAction: Creates aCommand<S>from Lamp'sCommandActioncreateSuggestionProvider: Creates a BrigadierSuggestionProviderfrom Lamp'sSuggestionProvider.toParameterType: Converts a BrigadierArgumentTypeto Lamp'sParameterNode
Last updated
Was this helpful?