-
Notifications
You must be signed in to change notification settings - Fork 8
JSON
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.
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!"}}}
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."}
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!"}'
© MineAcademy | Code Unique Minecraft Plugins & Servers In 20 Days
About
Free version
Basics
Understanding
- Channels
- Formatting
- Rules / Filters
- Handlers
- Groups
- JSON
- Discord
- Toggle ignoring swears
- Variables
- JavaScript Variables
Tweaking
Solving Issues
Miscellaneous