<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 分項與數組 **extra-分項** 以及 **JSON array-JSON數組** 提供了讓多個不同的JSON文本同時存在的可能性 例如想讓一條`tellraw`命令中使用多個不同樣式的對象,或者是組合多個JSON結構時使用 同時它們在**告示牌**和**成書**之中也有重要的角色 并且**繼承**的特性有時能讓一些樣式上的設定變得方便 ## 基礎 extra-分項是一個附加在JSON文本中的數組對象 其格式為 ``` extra:[{[JSON文本1]},{[JSON文本2]},......] ``` JSON文本1、JSON文本2...等等的文本會被放在當前對象之后。 ---- 而JSON array則是由`[]`包圍的JSON文本,在需求JSON文本的命令/NBT中,可以直接使用`[]`輸入一個JSON數組,取代使用`{}`來輸入單一對象 使用一個簡單的例子: ``` /tellraw @a {"text":"Hello World"} ``` ![1](https://box.kancloud.cn/1b5b72c53fb3af46db42fe8a2d1d613e_648x18.png) 最基礎的一條`tellraw`命令也可以分別以`extra`和`array`的形式重寫 array: ``` /tellraw @a [{"text":"Hello"},{"text":" World"}] ``` 或者 ``` /tellraw @a ["Hello"," World"] ``` (在array中,可以用雙引號直接取代簡單的`text`對象,可以和完整的JSON文本混合使用) ![1](https://box.kancloud.cn/1b5b72c53fb3af46db42fe8a2d1d613e_648x18.png) extra: ``` /tellraw @a {"text":"Hello","extra":[{"text":" World"}]} ``` ![1](https://box.kancloud.cn/1b5b72c53fb3af46db42fe8a2d1d613e_648x18.png) 三者效果是完全一樣的 --- extra內也可以添加多個JSON文本 例如: ``` /tellraw @a {"text":"Hello","extra":[{"text":" Minecraft"},{"text":" World"}]} ``` ![41](https://box.kancloud.cn/6981dfe3fa22128f408ff2f0483626ea_648x18.png) --- 不過由于`extra`和`array`的效果和特性基本一致,出于`array`比`extra`使用上方便一點,以及格式上比較方便閱讀和美觀,個人推薦盡量使用`array` ## 應用 extra及array最大的應用,就是可以分別設置每一個JSON文本的屬性 例如: array: ``` /tellraw @a [{"text":"Hello","color":"red"},{"text":" Minecraft","color":"green"},{"text":" World","color":"blue"}] ``` extra: ``` /tellraw @a {"text":"Hello","color":"red","extra":[{"text":" Minecraft","color":"green"},{"text":" World","color":"blue"}]} ``` ![42](https://box.kancloud.cn/a407dd384412b4572ae5aaaf976547ee_648x18.png) 不僅僅是顏色之類的樣式代碼,還可以是CE和HE 例如: array: ``` /tellraw @a [{"text":"Hello","color":"red"},{"text":" Minecraft","color":"green","clickEvent":{"action":"run_command","value":"/say Minecraft"}},{"text":" World","color":"blue","hoverEvent":{"action":"show_text","value":"World"}}] ``` extra: ``` /tellraw @a {"text":"Hello","color":"red","extra":[{"text":" Minecraft","color":"green","clickEvent":{"action":"run_command","value":"/say Minecraft"}},{"text":" World","color":"blue","hoverEvent":{"action":"show_text","value":"World"}}]} ``` 由于命令比較長,下面將會把命令分解出來說明 這條`/tellraw`命令分別有3個JSON文本: - 第一個JSON文本(array內首個對象,或者是帶有extra列表的那個對象),我們可稱之為主項: ``` {"text":"Hello","color":red} ``` 其設定為紅色的"Hello" - 第二個對象: ``` {"text":" Minecraft","color":"green","clickEvent":{"action":"run_command","value":"/say Minecraft"}} ``` 其設定為綠色的" Minecraft",點擊執行**/say Minecraft** - 第三個對象: ``` {"text":" World","color":"blue","hoverEvent":{"action":"show_text","value":"World"}} ``` 其設定為藍色的" World",懸浮時顯示"World" 效果就會是: ![43](https://box.kancloud.cn/831d38aaf8be218c963e6b98ca889692_648x59.png) --- 不僅如此,它們還可以設置不同結構的JSON(例如組合text,score和selector) 例如: array: ``` /tellraw @a [{"text":"Nearest Player:"},{"selector":"@p"}] ``` extra: ``` /tellraw @a {"text":"Nearest Player:","extra":[{"selector":"@p"}]} ``` 這里有兩個對象: - 主項的文本:**"Nearest Player:"** - 和第二項的`@p`選擇符 效果就是: ![44](https://box.kancloud.cn/d911cc3f37271fde499362837cf34cda_648x19.png) ## 繼承 `extra`和`array`都擁有繼承的特性 所有`分項`(array里面首個之后的對象/extra列表里面的所有對象)都會繼承到`主項`(array里面首個對象/帶有extra列表的那個對象)的設定 舉個例子幫助理解: array: ``` /tellraw @a [{"text":"Hello","bold":true},{"text":" World"}] ``` extra: ``` /tellraw @a {"text":"Hello","bold":true,"extra":[{"text":" World"}]} ``` ![45](https://box.kancloud.cn/c3720339a59caf9fea9340c7a9d49ff6_648x18.png) 在本例中,只有主項設置了`bold`屬性,但是由于繼承的特性,分項也同時擁有了粗體的樣式 但是反之,分項的設定并不會影響主項,例如: array: ``` /tellraw @a [{"text":"Hello"},{"text":" World","bold":true}] ``` extra: ``` /tellraw @a {"text":"Hello","bold":true,"extra":[{"text":" World","bold":true}]} ``` ![46](https://box.kancloud.cn/aa0dd90ed6c4c02f300431f8d69eab6d_648x18.png) 同時,分項之間并不會互相影響,并且繼承而來的屬性可以被覆蓋 例如: array: ``` /tellraw @a [{"text":"Hello","bold":true},{"text":" Minecraft","color":"green"},{"text":" World","bold":false}] ``` extra: ``` /tellraw @a {"text":"Hello","bold":true,"extra":[{"text":" Minecraft","color":"green"},{"text":" World","bold":false}]} ``` ![47](https://box.kancloud.cn/2f4cf57ac60017fd8a4508c220bd5681_648x18.png) 詳細分析一下以上的命令,以上的`/tellraw`擁有三個對象 - 主項為"Hello",擁有`bold`屬性 - 第二項" Minecraft",繼承了`bold`屬性,并且設定了顏色為綠色 - 第三項" World",雖然應該繼承主項的`bold`屬性,但是`bold:false`設定覆蓋了繼承而來的屬性,同時也不受第二項的顏色屬性影響 雖然本節沒有使用CE/HE作為例子,但它們也是可以如同`樣式代碼`一樣被繼承的,規則相同 --- 如果有時需要設定一段格式差異較大的JSON文本,例如只想將第一段文字設定為粗體,其他都不要,那么后面的文本是不是都要設定`bold:false`這么麻煩? 一個方便的做法為,將主項設置為空項,例如: array: ``` /tellraw @a ["",{"text":"Hello","bold":true},{"text":" Minecraft","color":"green"},{"text":" World","italic":true}] ``` extra: ``` /tellraw @a {"text":"","extra":[{"text":"Hello","bold":true},{"text":" Minecraft","color":"green"},{"text":" World","italic":true}]} ``` ![48](https://box.kancloud.cn/8691917e4aa0e2f8ad9b44797fa65231_648x18.png) 這樣即可確保每一個JSON文本的獨立性,減少互相干擾
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看