A modern annotations-driven commands framework for Java and Kotlin
MIT License
Welcome to Lamp, the versatile and powerful command framework designed for modern Java and Kotlin applications. Whether you're building plugins for Minecraft servers, integrating with Discord, or creating command-line tools, Lamp provides a robust solution with a clean, idiomatic API.
@Optional
and @Default
--switch
and -s
) and flags (--value <value>
or -v <value>
)-s -p -r
as -spr
ResponseHandlers
.@Command("greet user")
@Description("Sends a greeting message")
public void greet(CommandActor actor, @Optional("World") String name) {
actor.reply("Hello, " + name + "!");
}
@Command("teleport <target> here")
public void teleportHere(Player sender, EntitySelector<LivingEntity> target) {
for (LivingEntity entity : target)
entity.teleport(sender);
}
@Command("teleport")
public void teleport(Player sender, double x, double y, double z) {
sender.teleport(new Location(sender.getWorld(), x, y, z));
}
@Command({"gamemode creative", "gmc"})
public void creative(@Default("me") Player sender) {
sender.setGameMode(GameMode.CREATIVE);
}
@Command({"gamemode adventure", "gma"})
public void adventure(@Default("me") Player sender) {
sender.setGameMode(GameMode.ADVENTURE);
}
@Command("world")
fun teleportToWorld(
sender: Player,
@Optional target: Player = sender,
@Optional world: World = sender.world
) {
}
@CommandPermission("quests.command")
@Command("quest")
class QuestCommands {
@Dependency
private lateinit var questManager: QuestManager
@Subcommand("create")
fun createQuest(sender: CommandSender, name: String, description: String) {
}
@Subcommand("<quest> delete")
fun deleteQuest(sender: CommandSender, quest: Quest) {
}
@Subcommand("<quest> start")
fun startQuest(sender: Player, quest: Quest) {
}
@Subcommand("clear")
fun clearQuests(sender: CommandSender) {
}
}
@RequiresGroup("admin")
@Command("admin command")
public void adminCommand(BukkitCommandActor actor) {
actor.reply("You are authorized to use this command!")
}
@Command("ban")
@Description("Bans the given user")
@CommandPermission(Permission.BAN_MEMBERS)
public void ban(
SlashCommandActor actor,
Member target,
@Range(min = 1) int days
) {
actor.replyToInteraction("User **" + target.getEffectiveName() + "** has been banned!").queue();
}
Lamp supports the following platforms out of the box:
To get started with Lamp, follow the instructions in our setup guide. Whether you're using Gradle or Maven, integrating Lamp into your project is straightforward.
For more detailed documentation on each feature, please refer to our detailed book that outlines all features and APIs in Lamp
Happy coding with Lamp! π
If Lamp has made your life significantly easier or you're feeling particularly generous, consider sponsoring the project! It's a great way to support the many hours I've spent maintaining this library and keeps me motivated. Please don't sponsor if you can't afford it.
Huge thanks to those who donated! π
If I missed you, or you would like to remain anonymous, feel free to shoot me a DM on Discord)