• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

ChatControl Pro/WIKI/JSON

来自Minecraft插件百科
Qsefthuopq讨论 | 贡献2019年1月26日 (六) 19:33的版本 (创建页面,内容为“ JSON 全称为 JavaScript Object Notation. 当你与服务器间进行了数据交换或存储数据到数据库内时, 数据只能为文本. JSON 广泛用于存…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索


JSON 全称为 JavaScript Object Notation. 当你与服务器间进行了数据交换或存储数据到数据库内时, 数据只能为文本. JSON 广泛用于存储不同的信息,比如玩家或服务器事件.它可以便于人们读取和修改并且便于机器分析和生成.

Minecraft 在处理聊天时使用了 JSON. 为了增加聊天消息的功能, JSON 可以让其他玩家看到传输的数据. That way, you may view fancy chat components such as hover text or item specific information. ChatControl aims to fully support JSON and offers several way of using it.

JSON in .yml Files

Files such as settings.yml or messages.yml support JSON just where a normal message would be. There are two ways of using it.

a) Prepending the message with [JSON] and then write JSON code directly.

Warn_Message: '[JSON] {"text": "Hello World"}'

b) Using multiple lines with the '|-' line delimiter, placing the [JSON] prefix on one line and the JSON code itself on the rest. An example:

Example_Message: |-
  [JSON]
  {"text": "Hover Me","hoverEvent": {"action": "show_text","value": {"text": "Hey there!"}}}

JSON in Rules

For server's limitations, it's not possible to send JSON like you would do elsewhere in packet rules. You can use the 'then console' operator and send a 'tellraw' command to the player:

match ^This area is now protected.
dont verbose
then console tellraw {player} {"text": "This area is now protected."}

JSON in Timed Messages in messages.yml

The message broadcaster is a special case for users willing to take advantage of the JSON elements. You need to set the prefix merely to [JSON], and place the actual text message in JSON formatting on the lines separately, including the prefix on every line manually.

An example:

Broadcaster:
  [..]
  Prefix: '[JSON]'
  Messages:
    global:
    - '{"text":"这是条测试消息!"}'