The downloadable zip file for this resource contains a compiled plugin which uses the API in several example messages.
- Tested Minecraft Versions:
- Source Code:
It also contains the .java file containing the API with documentation.
I wanted to ensure it was as easy to add to your project as it is to use, so it's all contained within a single class.
To use the API, all you have to do is:
It's really that simple.Code (Java):new JsonMessage().append(ChatColor.GREEN + "Click me to fly!").setHoverAsTooltip("Seriously, just click!", "Zoom zoom!").setClickAsExecuteCmd("/fly").save().send(player);
With this API you can...
Or a combination of clicks and hover events at the same time!
- Create tooltips for when a player hovers over your chat message
- Redirect players to a URL, when a player clicks your chat message
- Suggest a command/message to a player's chat box when they click your chat message
- Force the player to run a command when they click your chat message
This API utilizes reflection in order to work on all server/plugin versions without the need for new imports, provided the class path files don't change.
(I have accounted for the IChatBaseComponent path change)
If class paths do change in future updates, be sure to notify me and I'll make an update.
The plugin version of this resource demonstrates the API with the commands:
Spigot does already come with a huge library for parsing json messages.
There are other massive libraries out there, as well.
Each of them using a lot of different classes, and a lot of unnecessary formatting methods (.color(Color).bold(true)).
BaseComponent TextComponent TranslateComponent ComponentBuilder....... All for a single message!
It becomes confusing, redundant, and tedious...
I aim to be able to replicate all of the neccesary functionality from these large libraries and keeping it contained in a single class file.
So only one class name ever needs to remembered.
No components, and NO ridiculous "color" or "bold" or "stylize" methods!
The builder is hidden in a static inner class.
The users of this API never have to deal with it.
Simply string what you want from the message, save and send.
On top of that, it supports all ChatColor formats straight from within the text, so you don't have to append a whole bunch of different strings and reset all the settings just get a new color on your character.
ChatColors directly supported without breaking on new lines.
Since I deal with the raw Json strings directly, speed is drastically increased.
For most users, including myself... This is perfect.
(That's the aim, at least)
This API is free for use provided the license is not removed, and I intend to keep it updated constantly.
Though, donations are always welcome. I don't make much.
All suggestions/feedback appreciated.
JsonMessage API 2.2.1
A single class API enabling full control over json messages to be sent in chat