ALB Studio

Commands

A Kotlin builder on Paper's command API: typed arguments, subcommands, validators and tab completion.

Docs updated · What changed

On this page

Register commands in onEnable. They go through Paper's command system, so no plugin.yml entry is needed. Arguments are parsed first; the next word then picks a subcommand.

Registering a commandLink to this section

Kotlin
CommandUtil.registerCommand(this, "island") {
    aliases = mutableListOf("is")
    description = "Island commands"
    playerOnly = true
    action { sender, _ -> openIslandMenu(sender as Player) }   // "/island" with no subcommand

    subcommand("invite") {
        arg("player", ArgType.PLAYER)
        action { sender, args -> invite(sender as Player, args.player("player")) }
    }
    subcommand("setsize") {
        permission = "island.admin"                           // hidden from tab completion without it
        arg("owner", ArgType.OFFLINE_PLAYER)
        arg("size", ArgType.INT) {
            validate({ _, v -> v in 50..500 }) { MessageUtil.send(it, "&cSize must be 50-500") }
        }
        arg("reason", ArgType.TEXT) { optional = true }      // rest of the line
        action { sender, args ->
            setSize(args.offlinePlayer("owner"), args.int("size"), args.stringOrNull("reason"))
        }
    }
}

Argument typesLink to this section

Arg typeValue
STRINGone word
TEXTthe rest of the line; must be the last argument
INT, LONG, DOUBLEnumbers
BOOLEANtrue/false, yes/no, on/off
PLAYERan online player by exact name (Bedrock names include the Floodgate prefix)
OFFLINE_PLAYERanyone who joined before; never blocks on a web lookup

Custom typesLink to this section

Extend ArgType and read the value with args.get<T>(name).

Kotlin
object SkillArg : ArgType<Skill>("skill") {
    override fun parse(raw: String) = Skill.byId(raw)
    override fun suggestions() = Skill.ids
}

OptionsLink to this section

  • Per argument: optional, validate(check, onFail), suggest { }, onInvalid { sender, raw -> }.
  • Per command: permission, playerOnly, noPermissionMessage, playerOnlyMessage, onMissingArgs, onUnknownSubcommand.

Type a class, method, config key or topic. Use the arrow keys and Enter to open a result.