The MessageVariables API allows you to create your own custom message variable for others to use. It is a very simple implementation that doesn't require much effort to use.

To start off, you need add CustomMessages to your softdepend list or depend list in your plugin.yml:

name: ExamplePlugin
main: me.psyco.ExamplePlugin
version: 1.0
softdepend: [CustomMessages]

After that, you need to create a class that extends MessageVariable then import and implement the methods:

package me.psyco;

import com.psyco.tplmc.CustomMessages.MessageTypes;
import com.psyco.tplmc.CustomMessages.configuration.MessageVariable;
import org.bukkit.entity.Player;

public class ExampleVariable extends MessageVariable {
    public String getReplacement(Player player, MessageTypes messageTypes) {
        return null;

The getReplacement() method added in is what allows you to chose what to display on a per person and per message basis. Just replace the 'return null;' with whatever logic you want to add in to CustomMessages and return said variable. After that, you need to create an instance of said MessageVariable class and register it with CustomMessages:

package me.psyco;

import org.bukkit.plugin.java.JavaPlugin;

public class ExamplePlugin extends JavaPlugin {
    public void onEnable() {
        new ExampleVariable().register("/example");

This code registers the MessageVariable class "ExampleVariable" to /example in any message. You are now done!


Posts Quoted:
Clear All Quotes