Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

マイクラ25w20aで追加されたダイアログのタグ解説

Posted at

ダイアログの記述形式

共通のダイアログのタグ

type

ダイアログのタイプを指定

title

画面のタイトル
特定のタイプに関係なく、常に画面に表示する

external_title

このダイアログへ移動するボタンに使用する名前
省略した場合はtitleが使用される

body

オプションの body 要素のリストまたは単一の要素

can_close_with_escape

ダイアログをEscキーで閉じることができるか
デフォルトはtrue

共通するボタンのタグ

label

ボタンに表示するテキスト

tooltip

ボタンがハイライトされたり、ホバーされたときに表示されるテキスト

width

ボタンの幅
デフォルトは150

on_click

オプションのクリックイベント(テキストのclick_eventと同じ形式)
存在しない場合は、画面を閉じる

ダイアログのタイプ

notice

フッターに1つのボタンがあるシンプルな画面

  • action
    デフォルトは{label:gui.ok}のアクション無し
noticeテンプレート
{
    "type":"notice",
    "title": "画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "body":[],
    "action":{
        "label":{
            "translate":"gui.ok"
        }
    },
    "can_close_with_escape":true
}

confirmation

フッターに2つのボタンがあるシンプルな画面

  • yes
    左側のボタン
  • no
    右側のボタン
confirmationテンプレート
{
    "type":"confirmation",
    "title": "画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "body":[],
    "action":[],
    "yes":{
        "label":"YES!"
    },
    "no":{
        "label":"NO!"
    },
    "can_close_with_escape":true
}

multi_action

スクロール可能なボタンのリストを表示
画面のフッターに終了アクションを実行して閉じるボタンがある(終了アクションがある場合は"gui.cancel"、ない場合は"gui.back")
終了時にオプションでon_cancelのアクションが実行

  • on_cancel
    テキストのclick_eventと同じ形式
  • columns
    ボタンの列数を指定
    デフォルトは2(横に2個ずつボタンが並ぶ)
  • button_width
    リスト内のボタンの幅
    デフォルトは150
multi_actionテンプレート
{
    "type":"multi_action",
    "title": "画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "body":[],
    "actions":[
        {
            "label":"ダイヤモンドを得る",
            "on_click":{
                "action":"run_command",
                "command":"give @s diamond"
            }
        },
        {
            "label":"エメラルドを得る",
            "on_click":{
                "action":"run_command",
                "command":"give @s emerald"
            }
        },
        {
            "label":"キャンセル",
            "width":302
        }
    ],
    "can_close_with_escape":true,
    "on_cancel":{
        "action":"run_command",
        "command":"say ここに実行できるコマンド入れると戻れない"
    },
    "columns":2,
    "button_width":150
}

server_links

パケット内のサーバーから受信したリンクのスクロール可能なリストを表示
画面のフッターに終了アクションを実行して閉じるボタンがある(終了アクションがある場合は"gui.cancel"、ない場合は"gui.back")
終了時にオプションでon_cancelのアクションが実行
注: これは本文が追加された以前のサーバーリンク画面の代わり

  • on_cancel
    テキストのclick_eventと同じ形式
  • columns
    ボタンの列数を指定
    デフォルトは2(横に2個ずつボタンが並ぶ)
  • button_width
    リスト内のボタンの幅
    デフォルトは150
server_linksテンプレート
{
    "type":"server_links",
    "title": "画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "body":[
        {
            "type":"plain_message",
            "contents":[
                {"text":"テキストを"},
                {"text":"表示","color":"green"},
                {"text":"できる!"}
            ]
        }
    ],
    "action":[
        {
            "label":"サーバーから送れるのかな?"
        }
    ],
    "can_close_with_escape":true,
    "columns":1,
    "button_width":150
}

dialog_list

他のダイアログに直接移動するボタンのリストを表示
ボタンのタイトルは、移動先ダイアログのexternal_title(ない場合はtitle)になる
画面のフッターに終了アクションを実行して閉じるボタンがある(終了アクションがある場合は"gui.cancel"、ない場合は"gui.back")
終了時にオプションでon_cancelのアクションが実行

  • dialogs
    ダイアログ、ダイアログのリスト、またはダイアログタグ
  • on_cancel
    テキストのclick_eventと同じ形式
  • columns
    ボタンの列数を指定
    デフォルトは2(横に2個ずつボタンが並ぶ)
  • button_width
    リスト内のボタンの幅
    デフォルトは150
dialog_listテンプレート
{
    "type":"dialog_list",
    "title": "画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "dialogs":[
        {
            "type":"confirmation",
            "title": "ダイアログ1",
            "external_title":"ボタン1",
            "body":[
                {
                    "type":"plain_message",
                    "contents":[
                        {"text":"これにしますか?"}
                    ]
                }
            ],
            "yes":{
                "label":"YES!"
            },
            "no":{
                "label":"NO!"
            }
        },
        {
            "type":"confirmation",
            "title": "ダイアログ2",
            "external_title":"ボタン2",
            "body":[
                {
                    "type":"plain_message",
                    "contents":[
                        {"text":"これにしますか?"}
                    ]
                }
            ],
            "yes":{
                "label":"YES!"
            },
            "no":{
                "label":"NO!"
            }
        }
    ]
}

simple_input_form

ユーザー入力を受け付ける画面
フッター内に単一の送信アクションがある
終了アクションなし

simple_input_formのテンプレート
{
    "type":"simple_input_form",
    "title":"画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "inputs":[
        {
            "type":"text",
            "key":"text_input",
            "label":"ここにテキストを入力",
            "initial":"",
            "width":200,
            "label_visible":true
        }
    ],
    "action":{
        "label":"決定",
        "id":"submit",
        "on_submit":{
            "type":"command_template",
            "template":"title @a title '$(text_input)'"
        }
    }
}

multi_action_input_form

ユーザー入力を受け付ける画面
複数の送信アクションを持つことができる
フッターなし、送信アクションは本文に追加される
終了アクションなし

multi_action_input_formのテンプレート
{
    "type":"multi_action_input_form",
    "title":"画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "inputs":[
        {
            "type":"text",
            "key":"text_input1",
            "label":"タイトルに表示する文字",
            "initial":"",
            "width":200,
            "label_visible":true
        },
        {
            "type":"text",
            "key":"text_input2",
            "label":"テキストに表示する文字",
            "initial":"",
            "width":200,
            "label_visible":true
        }
    ],
    "actions":[
        {
            "label":"タイトル!",
            "id":"submit",
            "on_submit":{
                "type":"command_template",
                "template":"title @a title '$(text_input1)'"
            }
        },
        {
            "label":"チャット!",
            "id":"submit",
            "on_submit":{
                "type":"command_template",
                "template":"tellraw @a '$(text_input2)'"
            }
        }
    ]
}

ダイアログbodyのタイプ

plain_message

テキストを表示

  • contents
    テキストコンポーネント
  • width
    メッセージの最大幅
    デフォルトは200

item

オプションの説明付きのアイテムを表示(説明がある場合アイテムの右側に表示)
インベントリスロットにあるかのようにレンダリングされる
widthおよびheightがデフォルト以外の値に設定されていても、アイテムは拡大縮小されない

  • item
    アイテムスタックとカウント
  • description (オプション)
    • contents
      テキストコンポーネント
    • width
      コンテンツの最大幅
      デフォルトは200
      テキストコンポーネントのみにすることもできる
  • show_decorations
    trueの場合、カウントとダメージバーがアイテム上にレンダリングされる
    デフォルトはtrue
  • show_tooltip
    trueの場合、アイテムにマウスを置いたときにアイテムのツールチップが表示され
    デフォルトはtrue
  • width
    要素の水平サイズ
    デフォルト16
  • height
    要素の垂直サイズ
    デフォルト16
bodyテンプレート
{
    "type":"confirmation",
    "title": "ダイアログ1",
    "external_title":"ボタン1",
    "body":[
        {
            "type":"plain_message",
            "contents":[
                {"text":"これにしますか?"}
            ]
        },
        {
            "type":"item",
            "item":{
                "id":"golden_apple",
                "count":1,
                "components":{"item_name":"輝くリンゴ"}
            },
            "description":{
                "contents":[{"text":"幸運になれるよ"}],
                "width":100
            },
            "show_decorations":true,
            "show_tooltip":true,
            "width":16,
            "height":16
        }
    ],
    "yes":{
        "label":"はい"
    },
    "no":{
        "label":"いいえ"
    }
}

共通する入力コントロールのタグ

入力コントロールのタイプ

text

シンプルなテキスト入力

  • width
    入力の幅
    デフォルトは200
  • label
    コントロールの左側に表示されるテキストコンポーネント
  • label_visible
    ラベルの表示を制御。デフォルトはtrue
  • initial
    初期内容

boolean

シンプルなチェックボックス

  • label
    コントロールの右側に表示されるテキストコンポーネント
  • initial
    初期値を指定
    デフォルトはfalse
  • on_true
    コントロールがチェックされたときに送信される文字列値
    デフォルトはtrue
  • on_false
    コントロールがチェックされていないときに送信される文字列値
    デフォルトはfalse

single_option

クリックすると一連のオプションが切り替わるボタン
現在選択されているプリセットに関連付けられた値を送信する

  • label
    ボタンに表示されるテキストコンポーネント
  • label_visible
    trueの場合、ラベルはボタンのテキストに組み込まれます。デフォルト:true
  • width
    ボタンの幅
    デフォルトは正の整数:200
  • options
    フィールドを持つオブジェクトのリスト:
    • id
      送信時に送信される文字列値
    • display(オプション)
      ボタンに表示するテキストコンポーネント(存在しない場合はidが表示)
    • initial(オプション)
      初期値をboolで選択する(設定できるのは1つのみ)

number_range

数値を範囲から選択するためのスライダー
現在選択されている小数点なしの整数値を送信する

  • label
    スライダーのラベルとして表示されるテキストコンポーネント
  • label_format
    ラベルの構築に使用される翻訳キー
    最初の引数はlabelタグのテキスト、2番目の引数は現在の値
    デフォルトはoptions.generic_value
  • width
    入力の幅
    デフォルトは200
  • start
    開始値 float(スライダーが左端の位置の数値)
  • end
    終了値 float(スライダーが右端の位置)
  • steps
    スライダーの増分数
  • initial
    スライダーの初期値
    値はスライダーの範囲内である必要がある
    デフォルトは最小値
入力コントロールのテンプレート
{
    "type":"simple_input_form",
    "title":"画面タイトル",
    "external_title":"このダイアログへ移動するボタンの名前",
    "inputs":[
        {
            "type":"text",
            "key":"text_input",
            "label":"ここにテキストを入力",
            "initial":"",
            "width":200,
            "label_visible":true
        },
        {
            "type":"boolean",
            "key":"boolean",
            "label":"チェックボックス",
            "initial":false,
            "on_true":"真!",
            "onfalse":"偽!"
        },
        {
            "type":"single_option",
            "key":"options",
            "label":"切り替え",
            "options":[
                {
                    "id":"一個目!",
                    "display":"display1"
                },
                {
                    "id":"二個目!",
                    "display":"display2",
                    "initial":true
                },
                {
                    "id":"三個目!",
                    "display":"display3"
                }
            ]
        },
        {
            "type":"number_range",
            "key":"number",
            "label":"ナンバー指定",
            "start":30,
            "end":110,
            "steps":80,
            "initial":70
        }
    ],
    "action":{
        "label":"決定",
        "id":"submit",
        "on_submit":{
            "type":"command_template",
            "template":"tellraw @a 'テキスト:\"$(text_input)\"\\nチェックボックス:\"$(boolean)\"\\n切り替え:\"$(options)\"\\nナンバー指定:\"$(number)\"'"
        }
    }
}

アクションの送信

actionボタンクリック時に使用する送信アクション

アクション共通タグ

アクションの種類

バニラで使うのは基本command_templateだけ

command_template

マクロを使用してコマンドを実行する
クリックイベントのrun_commandと同じ
オペレータ権限1以上必要なコマンドは確認ダイアログが表示される

  • template
    コマンドとして解釈されるマクロテンプレートを持つ文字列

custom_template

マクロを使用してアクションをサーバーに送信する
クリックイベントのcustomと同じ(新しく追加された)
(よくわかんないけどカスタムイベントをマクロで生成できるんだと思う)

  • template
    ペイロードとして使用されるマクロテンプレートを含む文字列
  • id
    名前空間ID

custom_form

アクションをサーバーに送信し実行する
クリックイベントのcustomと同じ
(よくわかんないけど全入力値をまとめてデータとして送信できるんだと思う)

  • id
    名前空間ID

組み込みダイアログ

クライアントが使用する特定の画面をカスタマイズするためのカスタムダイアログ

server_links

PaperやMODサーバー用
よくわかんないけどサーバーがプレイヤーに対して外部リンクを安全に表示させるためのUIだと思う

custom_options

よくわかんないけどサーバーが用意した複数のダイアログを選択形式で表示できるんだと思う

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?