dependencies {
// Required for all platforms
implementation("io.github.revxrsal:lamp.common:[VERSION]")
// Velocity module
implementation("io.github.revxrsal:lamp.fabric:[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:
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
}
}
Fabric-specific annotations
@CommandPermission
Adds a command permission level for the given command
Supported Fabric types
net.minecraft.server.command.ServerCommandSource and its subclasses in place of CommandActor
net.minecraft.server.network.ServerPlayerEntity
net.minecraft.world.World
Example
public class MyMod implements ModInitializer {
@Override
public void onInitialize() {
var lamp = FabricLamp.builder(this).build();
lamp.register(new MyCommand());
}
public class MyCommand {
@Command("hello")
@Description("Sends a hello message")
@CommandPermission(4)
public void hello(FabricCommandActor actor) {
actor.reply("Hello from Fabric mod!");
}
}
}
class MyMod : ModInitializer {
override fun onInitialize() {
val lamp = FabricLamp.builder(this).build()
lamp.register(MyCommand())
}
inner class MyCommand {
@Command("hello")
@Description("Sends a hello message")
@CommandPermission(4)
fun hello(actor: FabricCommandActor) {
actor.reply("Hello from Fabric mod!")
}
}
}