Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
kangarko edited this page Apr 9, 2017 · 3 revisions

JSON stands for JavaScript Object Notation. When exchanging data between you and the server, or storing data in a database, the data can only be text. JSON is widely used for storing various information, for example about players or server events. It is easy for humans to read and write and easy for machines to parse and generate.

Minecraft uses JSON when handling chat. In addition to the plain chat message, JSON allows other (to you invisible) data to be transferred as well. 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.

To create JSON, you can use this JSON generator. It is a very handy tool that will produce interactive chat messages, for example with elements displaying on clicking or hovering on the message.

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.

Pay attention to brackets! If you use double brackets " " inside the JSON, use single brackets ' ' in the entire expression (see the example below).

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":"This is a test message!"}'