From db6362444c8083f6d1634510f8996e395eee849d Mon Sep 17 00:00:00 2001 From: Hare Date: Thu, 4 Dec 2025 08:44:20 +0900 Subject: [PATCH] =?UTF-8?q?doc:=20=E4=BE=8B=E7=A4=BA=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E5=AE=9F=E8=A3=85=E3=81=AE=E8=AA=A4=E3=82=8A?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 58 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 04bd3d2..f18d8ae 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ dependencies { 1. プラグインの `onEnable` などで `kommand(plugin) { ... }` DSL を呼び出します。 2. `command("root", "alias") { ... }` でコマンドを宣言し、`literal` や `string`/`integer` 引数を追加します。 -3. `executes { ... }` 内で `string("player")` や `int("amount")` を使ってパース済みの値を取得します。 +3. `executes { ... }` は必ず対象のノード (`literal`, `player`, `integer` など) の中にネストします。これにより、そのノードまでに宣言した引数を `string("player")` や `int("amount")` のように取得できます。 ### サンプル: 経済コマンド @@ -49,45 +49,47 @@ class EconomyPlugin : JavaPlugin() { permission = "example.eco" literal("give") { - player("target") // プレイヤー名 or セレクター (@p 等) - integer("amount", min = 1) - - executes { - val target = player("target") - val amount = int("amount") - sender.sendMessage("Giving $amount to ${target.name}") + player("target") { // プレイヤー名 or セレクター (@p 等) + integer("amount", min = 1) { + executes { + val target = player("target") + val amount = int("amount") + sender.sendMessage("Giving $amount to ${target.name}") + } + } } } literal("speed") { - players("targets") // @a, プレイヤー名, などをまとめて取得 - float("value", min = 0.1, max = 5.0) - - executes { - val targets = players("targets") - val speed = float("value") - targets.forEach { it.walkSpeed = speed.toFloat() / 5.0f } - sender.sendMessage("Updated ${targets.size} players") + players("targets") { // @a, プレイヤー名, などをまとめて取得 + float("value", min = 0.1, max = 5.0) { + executes { + val targets = players("targets") + val speed = float("value") + targets.forEach { it.walkSpeed = speed.toFloat() / 5.0f } + sender.sendMessage("Updated ${targets.size} players") + } + } } } literal("setspawn") { - coordinates("point") // "~ ~1 ~-2" のような入力を受け付ける - - executes { - val base = (sender as? Player)?.location ?: return@executes - val target = location("point", base) - plugin.server.worlds.first().setSpawnLocation(target) - sender.sendMessage("Spawn set to ${target.x}, ${target.y}, ${target.z}") + coordinates("point") { // "~ ~1 ~-2" のような入力を受け付ける + executes { + val base = (sender as? Player)?.location ?: return@executes + val target = location("point", base) + plugin.server.worlds.first().setSpawnLocation(target) + sender.sendMessage("Spawn set to ${target.x}, ${target.y}, ${target.z}") + } } } literal("inspect") { - selector("entities") - - executes { - val entities = selector("entities") - sender.sendMessage("Selector resolved ${entities.size} entities") + selector("entities") { + executes { + val entities = selector("entities") + sender.sendMessage("Selector resolved ${entities.size} entities") + } } } }