Skip to content
ブログに戻る
Java code editor showing Lamp command annotations for a Minecraft server plugin

Lamp: Building Minecraft Commands Without the Boilerplate

ice
ice
@ice
Updated
94 閲覧
TL;DR:Lamp is a modern Java command framework that simplifies building Minecraft server commands, Discord bots, and plugins. Using annotations and smart parameter handling, it eliminates boilerplate code and supports multiple platforms from a single codebase.

"A modern annotations-driven commands framework for Java and Kotlin "

Revxrsal/Lamp · github.com
⭐ 335 stars💻 Java📜 MIT

If you've ever written a custom Minecraft server command, you know the pain. Parsing arguments, handling subcommands, validating permissions - it's repetitive, error-prone, and every plugin does it differently. Lamp cuts through that mess by letting you define commands with annotations and letting the framework handle the complexity.

What Lamp Is

Lamp isn't a mod or a plugin. It's a command framework for Java and Kotlin developers building plugins, bots, and server tools. Think of it like a Swiss Army knife for command handling. With 335 stars on GitHub, it's built by the community for the community.

The core idea is dead simple: annotate your command methods with @Command, define your parameters, and Lamp handles the rest. No parsing boilerplate. No manual validation. No arguments array spaghetti code.

What makes it different from rolling your own command handler is the thoughtfulness. The project explicitly avoids the gotchas that plague other frameworks. So it uses immutable builders, strong typing, and compiler annotations to catch mistakes before runtime.


Who Needs This

Three groups benefit from Lamp: server administrators building custom commands, plugin developers tired of writing boilerplate, and Discord bot developers who want clean command definitions.

If you're running a Minecraft server and want custom commands for admin tasks without wrestling with argument parsing, you need a plugin developer who uses Lamp. If you're that developer, Lamp saves you hours per project. And if you're building Discord bots, Lamp's multi-platform approach means you get consistent command syntax across platforms.

You don't need this if you're a casual player. This is pure developer tooling.


How Multi-Platform Works

One of Lamp's best features is platform abstraction. A single codebase can target Bukkit, Velocity, Minestom, JDA (Discord), and other platforms using the same annotation-based command syntax.

Minecraft Lamp (torch)
Minecraft Lamp (torch)

In practice, this means if you write a command once, you can compile it for multiple platforms without rewriting the command logic. The framework handles platform-specific details like how responses are sent, who "actors" are, and how permissions map to each platform's system.

This isn't perfect - some features are platform-specific - but it's a massive time saver for developers maintaining multiple server implementations or bots across different services.


Features That Matter

Lamp handles several things that make developers' lives easier. Here's what stands out.

Parameter handling with context resolvers. Need to turn a player name into a LivingEntity? Or parse a location from three arguments? Lamp can resolve custom types automatically. You define the resolver once, and it applies everywhere that type appears in a command parameter.

Optional parameters and defaults. The @Optional and @Default annotations let you skip the ugly null checks and manual defaulting. If a parameter isn't provided, Lamp fills it with the default value you specified.

Flags and switches. Unix-style options like - switch and -s are built in. You can combine short flags (-spr) and mix flags throughout commands. This is genuinely nice for admin commands where you might want multiple modifiers.

Multiple command variants. Need the same logical command to work with different signatures? @Command lets you define several methods with the same base command but different parameters. Lamp picks the right one based on what the user provides.

Custom annotations. You can extend Lamp's behavior with your own annotations and define how they work. And this means you can add framework-aware validation specific to your server without hacking the parser.


Getting Started (Simple)

Installation depends on your platform. For a Bukkit plugin, add Lamp to your build system and register it in your plugin's onEnable method.

gradle
dependencies {
 implementation 'io.github.revxrsal:lamp.bukkit:4.0.0-rc.16'
}

Then create a command class. Here's the bare minimum:

java
@Command("greet user")
@Description("Sends a greeting")
public void greet(CommandActor actor, @Default("World") String name) {
 actor.reply("Hello, " + name + "!");
}

Register it with Lamp's command manager, and you're done. The framework handles parsing, validation, and dispatch.

For Discord bots or other platforms, the process is similar but you'd use the JDA or Minestom implementations instead. The command definitions stay almost identical.


Real-World Use Cases

Here's where Lamp shines: actual problems it solves.

Server admins often need quick utilities like teleporting players, managing whitelist entries, or tweaking server settings. A developer using Lamp can build a clean admin command panel in a fraction of the time it'd take with manual argument parsing. Better yet, if you're checking your server status externally, you might want commands that integrate with external APIs. Lamp's context resolvers let you fetch player data from your database and inject it cleanly into commands.

For large networks, you might have a Discord bot that mirrors in-game commands (like checking who's online). Lamp supports that use case directly. Write the command once, register it on multiple platforms, and they all behave identically.

And if you're building something like a public server list with admin tools, custom commands for server owners to manage their listings are way cleaner with Lamp than with hand-rolled parsers.


Common Pitfalls (Things That Trip People Up)

Lamp reduces errors, but there are still gotchas.

First: parameter order matters. If you have optional parameters followed by required ones, Lamp won't know how to parse. The framework is designed to be fool-proof, but you still need to think about your command structure. Optional parameters should come after required ones.

Second: context resolvers need to be registered before the command is registered. If you define a custom type but forget to add the resolver, you'll get a compile-time error (which is actually good). But you need to know where to add it.

Third: multi-platform doesn't mean "identical everywhere." Some features are Bukkit-only or Discord-only. You'll need to understand your target platform's limitations. Lamp documents this clearly, but it's worth reading the platform-specific guides before assuming your command will work everywhere.


Alternatives Worth Knowing

Lamp isn't the only command framework, though it's probably the most polished for multi-platform use.

Cloud is another popular option, especially for Discord bots. It's more heavyweight and has different design goals. If you're building exclusively for one platform, Cloud might be worth comparing.

Some developers just write their own command parser. This works fine for small projects, but it scales badly. By the time you've added optional parameters, flags, and multi-platform support, you've basically rebuilt Lamp from scratch.

For simple one-off scripts, rolling your own is fine. For anything you'll maintain for more than a few months, a framework beats reinventing the wheel.

Frequently Asked Questions

Is Lamp free to use?
Yes, Lamp is completely free and open source under the MIT license. You can use it in commercial and personal projects without restrictions. The source code is available on GitHub, and the latest stable release is distributed through Maven Central for easy integration into your build system.
What Minecraft versions does Lamp support?
Lamp is a framework, not a mod or plugin, so it works with any Minecraft server software that runs Java. It supports Bukkit, Spigot, Paper, Velocity, Minestom, and other platforms. Compatibility depends on which Lamp module you use, but modern versions of Minecraft server software are all compatible.
Can I use Lamp for a Discord bot instead of Minecraft?
Yes, Lamp has dedicated support for Discord bots via the JDA (Java Discord API) module. The annotation-based command syntax works the same across platforms, so you can define commands that work identically on both Minecraft servers and Discord without duplicating code.
Do I need to be an expert Java developer to use Lamp?
You should be comfortable with Java basics and build tools like Gradle or Maven. Lamp handles the complex parts of command parsing, but you still need to understand how to structure a project and register commands. If you've built a simple plugin before, Lamp is easier than your previous approach.
What's the difference between Lamp and writing my own argument parser?
Lamp eliminates hundreds of lines of boilerplate: argument parsing, type validation, permission checking, and platform-specific handling. Hand-rolled parsers work for tiny projects but become a maintenance nightmare as your command library grows. Lamp handles these concerns robustly and lets you focus on command logic instead.