Interface ChatApi
Interface for managing chat formatting and color processing.
This API provides access to EssentialsC's chat formatting system, including LuckPerms integration, color code translation, and permission-based formatting.
To obtain an instance of this API:
ChatApi chatApi = APIProvider.getAPI().getChatApi();
Example usage:
// Check if player can use colors
if (chatApi.hasColorPermission(player)) {
String colored = chatApi.colorize("&cRed &aGreen");
}
// Format a chat message
Component formatted = chatApi.formatChatMessage(player, "Hello world");
Method Summary
| Return Type | Method | Description |
|---|---|---|
| boolean | isFormattingEnabled() | Checks if LuckPerms chat formatting is currently enabled and available. |
| boolean | hasColorPermission(Player player) | Checks if the player has permission to use legacy color codes in chat. |
| boolean | hasRgbPermission(Player player) | Checks if the player has permission to use RGB hex color codes in chat. |
| String | colorize(String message) | Translates alternate color codes (&) into Minecraft color codes. |
| String | translateHexColorCodes(String message) | Translates hex color codes (&#RRGGBB) into Minecraft color codes. |
| Component | formatChatMessage(Player player, String message) | Formats a chat message using the configured format for the player's LuckPerms group. |
| void | reload() | Reloads the chat configuration and re-initializes LuckPerms integration. |
Method Detail
isFormattingEnabled
Checks if LuckPerms chat formatting is currently enabled and available.
Returns true only if:
- LuckPerms formatting is enabled in config
- The LuckPerms plugin is installed and enabled
- The LuckPerms API is successfully loaded
hasColorPermission
Checks if the player has permission to use legacy color codes (&) in chat messages.
The permission node checked is essentialsc.chat.legacycodes.
| Parameter | Description |
|---|---|
| player | the player to check, must not be null |
hasRgbPermission
Checks if the player has permission to use RGB hex color codes (&#RRGGBB) in chat messages.
The permission node checked is essentialsc.chat.rbgcodes.
| Parameter | Description |
|---|---|
| player | the player to check, must not be null |
colorize
Translates alternate color codes (&) into Minecraft's internal color codes (§).
Example: "&cHello" becomes "§cHello" (red text).
| Parameter | Description |
|---|---|
| message | the message to colorize, null returns empty string |
& codes replaced, or empty string if null
translateHexColorCodes
Translates hex color codes (&#RRGGBB) into Minecraft's internal hex color format.
Example: "&#FF0000Red" becomes red colored text using the hex color code.
| Parameter | Description |
|---|---|
| message | the message containing hex codes, null returns empty string |
formatChatMessage
Formats a chat message using the configured format for the player's LuckPerms group.
This applies the full chat formatting including:
- LuckPerms prefix and suffix
- Group-specific format strings from config
- PlaceholderAPI placeholders (if PlaceholderAPI is installed)
- Message replacement in the format template
If LuckPerms formatting is not enabled, returns a simple component with the raw message.
| Parameter | Description |
|---|---|
| player | the player sending the message, must not be null |
| message | the raw message content, null treated as empty string |
reload
Reloads the chat configuration and re-initializes LuckPerms integration.
This reloads:
- LuckPerms enable/disable status from config
- Group format strings from config
- LuckPerms API provider connection