Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
/ cmdlib Public archive

Paper用のBrigadierのKotlinラッパー

Notifications You must be signed in to change notification settings

uTen2c/cmdlib

Repository files navigation

cmdlib

BrigadierのKotlin用ラッパー

Maven metadata URL

Groovy DSL

repositories {
  maven { url 'https://uten2c.github.io/repo/' }
}

dependencies {
  implementation 'dev.uten2c:cmdlib:VERSION'
}

Kotlin DSL

repositories {
  maven("https://uten2c.github.io/repo/")
}

dependencies {
  implementation("dev.uten2c:cmdlib:VERSION")
}

Example

val cmdLib = CmdLib(Plugin)

cmdLib.register("example") {
    requires("permission.name") // Bukkit permission name
    // requires(2) // or Minecraft op level
    // or custom
    // requires { sender ->
    //     sender is Player && sender.gameMode == GameMode.CREATIVE
    // }

    literal("echo") {
        executes {
            sender.sendMessage("Hello")
        }
    }

    literal("getDiamond") {
        integer("amount", 0, 64) {
            executes {
                val itemStack = ItemStack(Material.DIAMOND).apply {
                    amount = getInteger("amount")
                }
                player.inventory.addItem(itemStack)
            }
        }
    }

    literal("tp") {
        entity("target") {
            executes {
                val target = getEntity("target")
                player.teleport(target.location)
            }
        }
    }
}

引数

  • boolean
  • double
  • float
  • integer
  • long
  • string
  • blockPos
  • entity
  • entities
  • message
  • player
  • players
  • itemStack
  • uuid
  • vector

Tips

  • executes内でplayerを使用するときコマンドの実行者がプレイヤーでない場合実行に失敗するのでsenderがプレイヤーであるかの検証をする必要はない

About

Paper用のBrigadierのKotlinラッパー

Resources

Stars

Watchers

Forks

Packages

No packages published