commit 4d2e9f65005599d77fdcd25bfe8c45848650f9ca Author: Hare Date: Tue Dec 9 11:01:03 2025 +0900 init diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..de927d2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "Faction"] + path = Faction + url = git@gitea.hareworks.net:hcu/Faction.git + branch = master +[submodule "Economy"] + path = Economy + url = git@gitea.hareworks.net:hcu/Economy.git + branch = master +[submodule "hcu-core"] + path = hcu-core + url = git@gitea.hareworks.net:hcu/hcu-core.git + branch = master diff --git a/Economy b/Economy new file mode 160000 index 0000000..7a9067e --- /dev/null +++ b/Economy @@ -0,0 +1 @@ +Subproject commit 7a9067e9e494a278f0b08e5da4a0096ca7dafa76 diff --git a/Faction b/Faction new file mode 160000 index 0000000..ac72167 --- /dev/null +++ b/Faction @@ -0,0 +1 @@ +Subproject commit ac7216788c98dcdd35392e4c9aeb8e04b0b82cb1 diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..5cb43fa --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,63 @@ +import net.minecrell.pluginyml.bukkit.BukkitPluginDescription +import net.minecrell.pluginyml.paper.PaperPluginDescription + +group = "net.hareworks.hcu" +version = "1.0-SNAPSHOT" + +plugins { + kotlin("jvm") version "2.2.21" + id("de.eldoria.plugin-yml.paper") version "0.8.0" + id("com.gradleup.shadow") version "9.2.2" +} + +repositories { + + mavenCentral() + maven("https://repo.papermc.io/repository/maven-public/") +} + +dependencies { + compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") + compileOnly("org.jetbrains.kotlin:kotlin-stdlib") + + // Component Dependencies + compileOnly("net.hareworks.hcu:hcu-core:1.3") + compileOnly("net.hareworks.hcu:economy:1.0") + compileOnly("net.hareworks.hcu:faction:1.0") + + // Libs + compileOnly("com.michael-bull.kotlin-result:kotlin-result:2.1.0") +} + +tasks { + withType { + archiveBaseName.set("shop") + } + shadowJar { + archiveClassifier.set("min") + minimize() + } +} + +paper { + main = "net.hareworks.hcu.shop.ShopPlugin" + name = "shop" + description = "Shop plugin for HCU server" + version = getVersion().toString() + apiVersion = "1.21.10" + serverDependencies { + register("hcu-core") { + required = true + load = PaperPluginDescription.RelativeLoadOrder.BEFORE + } + register("economy") { + required = true + load = PaperPluginDescription.RelativeLoadOrder.BEFORE + } + register("faction") { + required = true + load = PaperPluginDescription.RelativeLoadOrder.BEFORE + } + } + authors = listOf("Hare-K02") +} diff --git a/dialog_texh.md b/dialog_texh.md new file mode 100644 index 0000000..a37ce9c --- /dev/null +++ b/dialog_texh.md @@ -0,0 +1,97 @@ +# Paper における Dialog(ダイアログ)機能の使用 — ドキュメント + +## 🎯 概要 + +* Dialog 機能は、Minecraft Java Edition 1.21.6 で導入された「画面中央に出すモーダル UI(メニュー/入力フォーム/確認ダイアログなど)」をサーバー/プラグイン側から出せる仕組み。([PaperMC Docs][1]) +* Paper は 1.21.7 から **Dialog API** を提供し、プラグインから動的にダイアログを生成・表示できるようになっている。([PaperMC Docs][1]) +* これは実験的機能(Experimental)扱い。今後仕様変更の可能性があることに注意。([PaperMC][2]) + +--- + +## ✅ Dialog API の主要機能 + +* サーバー/プラグインから任意のダイアログを生成・表示可能。([PaperMC Docs][1]) +* 標準で「通知/確認ダイアログ」「複数アクション付きダイアログ」「リスト型ダイアログ」「サーバーリンクダイアログ」などが提供されている。([PaperMC][2]) +* プレイヤーに表示する方法は主に二通り: + + 1. コマンド経由 — `/dialog show ` ([PaperMC Docs][1]) + 2. API 経由 — `Audience#showDialog(Dialog)` を使った直接呼び出し ([PaperMC Docs][1]) +* 動的生成も可能:`Dialog.create(...)` を通じて、コードでダイアログ内容を構築 → 表示。([PaperMC][5]) + +--- + +## 🧩 API の構成 — 主なクラス/インターフェース + +| パッケージ / クラス | 概要 | +| ----------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `io.papermc.paper.dialog.Dialog` | ダイアログ本体を表すクラス/インターフェース。Registry に登録されたダイアログも、動的生成ダイアログも扱える。([PaperMC][5]) | +| `io.papermc.paper.registry.data.dialog.type.DialogType` | ダイアログの「型」を示す (例: notice, confirmation, multi-action, list など) ([PaperMC][2]) | +| `io.papermc.paper.registry.data.dialog.body.DialogBody` | ダイアログ本体に表示する内容(テキスト、アイテム表示など) | +| `io.papermc.paper.registry.data.dialog.input.DialogInput` | 入力コントロール (テキスト入力、選択肢、トグルなど) を定義可能。([PaperMC][6]) | +| `io.papermc.paper.registry.data.dialog.action.DialogAction` | ダイアログのボタン押下等で実行されるアクション (コマンド実行、カスタムコード、別ダイアログ呼び出し etc.) を定義。([Daydream][7]) | +| `DialogBase` / `DialogBase.Builder` | ダイアログの基本情報(タイトル、外部タイトル、閉じられるか、表示後の動作など)を構築する。([PaperMC][6]) | + +--- + +## 🔧 サンプルコード(Java) — シンプルな Notice ダイアログ + +```java +import io.papermc.paper.dialog.Dialog; +import io.papermc.paper.dialog.DialogResponseView; +import io.papermc.paper.registry.data.dialog.type.DialogType; +import net.kyori.adventure.text.Component; +import org.bukkit.entity.Player; + +public void showNotice(Player player) { + Dialog dialog = Dialog.create(builder -> builder + .empty() + .base(DialogBase.builder(Component.text("重要なお知らせ")).build()) + .type(DialogType.notice()) + ); + + player.showDialog(dialog); +} +``` + +このコードは、タイトルだけの「OK ボタン付き通知ダイアログ」をプレイヤーに表示します。([PaperMC Docs][1]) + +--- + +## ⚠️ 注意点・既知の制限 + +* Dialog API は現時点で実験的 (`@Experimental`)。仕様や挙動が今後変わる可能性あり。([PaperMC][2]) +* click イベントでダイアログを開く機能 (`ClickEvent.openDialog`) や、クリック時のカスタムアクション (`DialogAction.customClick`) を使えるが、後者は **メモリリークの恐れ** が指摘されている。特にコールバックを登録したままプレイヤーが離脱したりダイアログを閉じても無効化されず、リソースが解放されない可能性。([GitHub][8]) +* クライアント側も Minecraft 1.21.6 以降である必要がある。古いクライアントではダイアログが正しく表示されない。これは、そもそも Dialog 機能自体がバニラ 1.21.6 からの新仕様。([PaperMC Docs][1]) + +--- + +## ✅ 利用例・応用用途 + +Paper サーバー + Dialog API を利用すると、以下のような用途に適している: + +* サーバー参加時の規約同意画面、ウェルカム画面 +* ミニゲームやワールド生成時の設定フォーム(オプション選択など) +* サーバー内メニュー、クイックアクション、サーバーリンク一覧 +* NPC/テレポート/ワールド選択など、インタラクティブなメニュー +* 入力フォーム(テキスト、選択肢、トグルなど)を用いたカスタムフォーム + +また、既存のプラグインライブラリとして FancyDialogs のようなものもあり、JSON 形式やコードでダイアログを定義できる。([Hangar][9]) + +--- + +## 📚 参考リソース + +* Paper Dialog API ドキュメント — 「Dialog API」セクション (docs.papermc.io) ([PaperMC Docs][1]) +* Javadoc — `io.papermc.paper.dialog`, `io.papermc.paper.registry.data.dialog.*` パッケージ群 ([PaperMC][5]) +* 使用例プラグイン FancyDialogs (GitHub / Hangar) ([Hangar][9]) +* 警告: callback 系 API のメモリリーク問題に関する issue #13236 ([GitHub][8]) + +[1]: https://docs.papermc.io/paper/dev/dialogs/?utm_source=chatgpt.com "Dialog API" +[2]: https://jd.papermc.io/paper/1.21.8/io/papermc/paper/registry/data/dialog/type/package-summary.html?utm_source=chatgpt.com "Package io.papermc.paper.registry.data.dialog.type - Javadocs" +[3]: https://papermc.io/news/1-21-7/?utm_source=chatgpt.com "1.21.7" +[4]: https://github.com/PaperMC/Paper?utm_source=chatgpt.com "PaperMC/Paper: The most widely used, high performance ..." +[5]: https://jd.papermc.io/paper/1.21.7/io/papermc/paper/dialog/class-use/Dialog.html?utm_source=chatgpt.com "Uses of Interface io.papermc.paper.dialog.Dialog - Javadocs" +[6]: https://jd.papermc.io/paper/1.21.10/io/papermc/paper/registry/data/dialog/DialogBase.html?utm_source=chatgpt.com "DialogBase (paper-api 1.21.10-R0.1-SNAPSHOT API)" +[7]: https://daydream.caramel.moe/io/papermc/paper/registry/data/dialog/action/package-summary.html?utm_source=chatgpt.com "Package io.papermc.paper.registry.data.dialog.action" +[8]: https://github.com/PaperMC/Paper/issues/13236?utm_source=chatgpt.com "Callback API can quickly lead to memory leaks #13236" +[9]: https://hangar.papermc.io/Oliver/FancyDialogs?utm_source=chatgpt.com "FancyDialogs - Minecraft Plugin - Hangar" diff --git a/hcu-core b/hcu-core new file mode 160000 index 0000000..520a378 --- /dev/null +++ b/hcu-core @@ -0,0 +1 @@ +Subproject commit 520a378cd5c3da6321305d07cc0b402b73292add diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..ad97463 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,5 @@ +rootProject.name = "shop" + +includeBuild("hcu-core") +includeBuild("Faction") +includeBuild("Economy") diff --git a/src/main/kotlin/net/hareworks/hcu/shop/ShopPlugin.kt b/src/main/kotlin/net/hareworks/hcu/shop/ShopPlugin.kt new file mode 100644 index 0000000..f041c36 --- /dev/null +++ b/src/main/kotlin/net/hareworks/hcu/shop/ShopPlugin.kt @@ -0,0 +1,13 @@ +package net.hareworks.hcu.shop + +import org.bukkit.plugin.java.JavaPlugin + +class ShopPlugin : JavaPlugin() { + override fun onEnable() { + logger.info("Shop plugin enabled!") + } + + override fun onDisable() { + logger.info("Shop plugin disabled!") + } +}