Getting started

Message

To get started first you need to create a BukkitMessage.
1
final BukkitMessage message = BukkitMessage.create();
Copied!
This will be the base of every message you parse.

Message Options

You can also specify some message options to the message creator, this allows you to control how the message will be parsed.
The base of the message options is the MessageOptions builder:
1
MessageOptions.builder();
Copied!
With it you can remove some formats:
1
final MessageOptions messageOptions = MessageOptions.builder().removeFormat(Format.BOLD).build();
Copied!
In this example, the BOLD format will be removed and it'll not parse the bold portion of the message.
You can also set a default color to be used in the messages:
1
final MessageOptions messageOptions = MessageOptions.builder().setDefaultColor(new FlatColor("#38ef7d")).build();
Copied!
Available color types are
  • FlatColor - Takes in a String with a color, can be hex or just the name, for example: FlatColor("red");
  • GradientColor - Takes in a List of Color objects.
  • RainbowColor - Takes two values, a saturation level and a brightness level.
Finally you can pass the format options to the message creator:
1
final BukkitMessage message = Message.create(messageOptions);
Copied!

Parsing

Finally all there is left to do is parsing the message:
1
final MessageComponent component = message.parse("**Hello** __everyone__!");
Copied!
The MessageComponent holds the parsed values that you can use for anything you want.
1
// Sends JSON message
2
component.sendMessage(player);
3
4
component.sendActionBar(player, fadeIn, stay, fadeOut);
5
component.sendSubTitle(player, fadeIn, stay, fadeOut);
6
component.sendTitle(player, fadeIn, stay, fadeOut);
7
8
// Parsed String to use in items, etc
9
final String parsed = component.toString();
10
// Raw JSON String
11
final String json = component.toJson();
Copied!
Last modified 2mo ago