Simon_Flash / TeslaPowered

The unlimited power of Tesla!

Message Library

| GitHub |

The Message Library (or generally Message Service, after the class), is a simple utility for loading configurable messages. Due to it’s use of Java’s ResourceBundle class, this makes it incredibly easy to support translations in your plugin.

This was the first library in TeslaLibs and added by Simon_Flash.


The namesake MessageService [link] class is used to retrieve ResourceBundles [link] from a ClassLoader. For ease of access, static methods exist to create a MessageService using the loader for the plugin’s asset folder as well as a specified path in the server files.

MessageService messages = MessageService.of(container, "messages"); //asset folder

Files used by the class must be .properties files (being a ResourceBundle), such as, and files for a specific local such as French would be (research ResourceBundles for more info). An example file is shown below. value
message.two=With &4<arg>

To retrieve a message, use MessageService#get with the message key (such as and a Locale. The class uses an Caffeine LoadingCache to handle requests for new ResourceBundles as necessary. The value of the message (or the key if absent) is returned in a Message to handle arguments.


The Message class is a utility class that works with a String message to apply arguments in the form <arg>. The class contains methods for applying these arguments as well as retrieving the raw String or converting it to a Text object.

Message message = messages.get("messages.two", Locales.DEFAULT);
message.arg("arg", "fire!"); // message is now "With &4fire!"
Text text = message.toText();

Category: Developer Tools

Published on Mar 18, 2018


390 total downloads