Skip to content
Austin edited this page Aug 25, 2015 · 5 revisions

MCMarkupLanguage

MCMarkupLanguage on its own is not a Bukkit plugin, so don't try running it as one. In order to use MCML in your plugin, you must either:

  • Copy all of the classes into your plugin.
  • Shade it into your plugin's jar using Maven. (preferred)
  • Depend on FlexCore, which has MCML included.

MCML is built on Fanciful, so you can use Fanciful's FancyMessage class once you create a message using MCML.

Adding MCML as a dependency

If you are using Maven, you can add MCML as a dependency by adding my personal repository to your pom.xml.

<repository>    
    <id>stealthyone-repo</id> 
    <url>http://repo.stealthyone.com/content/groups/public</url>
</repository>
<dependency>
    <groupId>com.stealthyone.mcb</groupId>
    <artifactId>mcml</artifactId>
    <version>LATEST</version>
</dependency>

Usage

Using MCML is simple. All you need to do is create a new MCMLBuilder instance with an existing String.

MCMLBuilder builder = new MCMLBuilder(String);

Then to send it to a player, you simply do:

builder.getFancyMessage().send(Player);

builder.getFancyMessage() returns an instance of Fanciful's FancyMessage class, so you can use methods from there if you want to.

MCML Syntax

Color codes are identified by ampersands ('&' symbol) and a list of valid codes can be found here.

In order to use an event, you must first group text using square brackets ([]). Then, simply add a hover event, click event, or both events immediately following it.

Hover Events

You can include hover events by doing the following:
[Displayed text];(txt:Text to show when hovered over); - Show text when the mouse hovers over the displayed text.
[Displayed text];(ach:Achievement name); - Show achievement when the mouse hovers over the displayed text.
[Displayed text];(itm:{REPLACEMENT KEY or JSON}); - Show item when the mouse hovers over the displayed text.

You can either use an item's JSON directly, or you can put an ItemStack into the MCMLBuilder's replacement map to automatically convert it to JSON.

Map<String, Object> map = new HashMap<>();
map.put("{REPLACEMENT KEY}", new ItemStack(Material.STONE));

new MCMLBuilder("[Displayed text];(itm:{REPLACEMENT KEY});", map);

Click Events

You can also include click events by doing the following:
[Displayed text];(cmd:/command to run); - Run a command when the displayed text is clicked.
[Displayed text];(url:http://urlToSuggest.com/); - Suggest a URL when the displayed text is clicked.
[Displayed text];(scmd:/command to suggest); - Suggest a command when the displayed text is clicked.

Examples

You can combine both click and hover events for a single group of text.

  • [Visit our website!];(txt:Click to open our website in your browser);(url:http://google.com/);

The possibilities are endless!

  • &aWelcome to the server! [&6Click here to read the rules];(cmd:/rules); &abefore you play. If you need help, just [&6run the help command!];(cmd:/help); &aWe hope you enjoy your stay!

Questions?

If you still have questions about MCML, feel free to contact me for more information.
You can find various ways of contacting me via my website.