Developer API
Add ChatColor as a dependency in your project to interact with player color data programmatically.
Getting Started
To use the API, you first need to obtain an instance of the ChatColorAPI.
ChatColor plugin = (ChatColor) Bukkit.getPluginManager().getPlugin("ChatColor");
if (plugin != null) {
ChatColorAPI api = plugin.getChatColorAPI();
// Your API calls here
}
API Methods
Set a Player's Color
// Set a solid color by key
api.setColor(player, "red");
// Set a gradient by key
api.setGradient(player, "sunset");
// Set a pattern by key
api.setPattern(player, "rainbow");
Reset a Player's Color
// Remove all active color settings for a player
api.resetColor(player);
Get Player Data
// Get data by UUID
PlayerColorData data = api.getPlayerData(player.getUniqueId());
String type = data.getColorType(); // "SOLID", "GRADIENT", "PATTERN", or "NONE"
String key = data.getColorKey();
String tag = data.getColorTag();
Apply Color to Text
Apply a player's active color/gradient/pattern to a string and return it as a Kyori Adventure Component.
Component coloredText = api.applyColorToText(player, "Hello, world!");