3.7 KiB
3.7 KiB
GhostDisplays
Paper 1.21.10 向けの不可視ディスプレイ制御ライブラリです。TextDisplay / BlockDisplay / ItemDisplay をプレイヤー単位で表示・クリック検知できるようにし、ゴースト化した UI やガイドラインをサーバー側で柔軟に提供できます。
提供機能
DisplayServiceによる Text/Block/Item Display の生成 APIDisplayControllerを介したPlayer#showEntity/hideEntityの参照カウント管理AudiencePredicate/AudiencePredicatesによる可視対象の自動同期(ログイン・ワールド移動・リスポーンで再評価)- Interaction エンティティを用いたクリック判定サポートと、優先度付きクリックハンドラー
- まとめて
destroyAll()できるリソース管理
スタンドアロンでの使い方
プラグインを plugins/ に配置して起動すると /ghostdisplay コマンドが利用できます。デフォルトで OP のみ実行可能ですが、ghostdisplays.command.* を付与すると通常権限でも操作できます。
| コマンド | 説明 |
|---|---|
/ghostdisplay create text <id> |
プレイヤー視点の約 1.5 ブロック先に TextDisplay を生成し、即座にチャット編集モードへ。次に送信したメッセージ(または cancel)が内容になります。 |
/ghostdisplay create block <id> <blockstate> |
BlockDisplay を生成します。oak_planks[facing=north] のような BlockData 文字列を指定してください。 |
/ghostdisplay create item <id> <material> |
ItemDisplay を生成します。minecraft:stick などのアイテム ID を受け付けます。 |
/ghostdisplay text edit <id> |
既存の TextDisplay をチャット入力で編集。cancel で破棄。単語のみで良い場合は /ghostdisplay text set <id> Hello_World のように _ をスペースに変換して即時更新できます。 |
| `/ghostdisplay viewer add | remove player/@a` |
/ghostdisplay audience permission add <id> <permission> |
指定パーミッションを持つプレイヤーに自動表示 (remove で解除)。 |
/ghostdisplay audience near set <id> <radius> |
Display 周囲の半径プレイヤーへ自動表示 (audience clear で全自動表示を解除)。 |
/ghostdisplay list / /ghostdisplay info <id> |
登録済み Display の一覧、情報(座標 / Viewers / Audiences / 内容)を表示。 |
/ghostdisplay delete <id> |
Display を完全に削除します。 |
技術的ポイント
- Paper 標準 API の
setVisibleByDefault(false)+showEntity/hideEntityを採用し、ProtocolLib に依存しない設計 - Display / Interaction は
setPersistent(false)でスポーンし、サーバーリロードやチャンクアンロードに強い - Predicate ごとにアクティブなプレイヤー集合を持つため、複数条件での重複表示にも対応
- クリック検知は
PlayerInteractEntityEventを介して Display/Interaction 双方から観測し、ハンドラーは Kotlin DSL で登録可能 - Kotlin 2.2 + ShadowJar + plugin-yml 生成を使い、
./gradlew buildでそのまま Paper に投入可能なJarを生成
同梱ライブラリ
- コマンド定義は
kommand-lib(Kotlin DSL)を使用し、permits-libと連携してghostdisplays.command.*のパーミッションツリーを自動生成しています。 - どちらも本リポジトリの
kommand-lib/以下にサブモジュールとして含まれており、./gradlew build時に一緒にコンパイルされます。