net.godlycow.org.essc.api

Interface ChatApi

public 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

boolean 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
Returns: boolean - true if chat formatting is active, false otherwise

hasColorPermission

boolean hasColorPermission(Player player)

Checks if the player has permission to use legacy color codes (&) in chat messages.

The permission node checked is essentialsc.chat.legacycodes.

ParameterDescription
playerthe player to check, must not be null
Returns: boolean - true if the player has color permission, false if null or no permission

hasRgbPermission

boolean hasRgbPermission(Player player)

Checks if the player has permission to use RGB hex color codes (&#RRGGBB) in chat messages.

The permission node checked is essentialsc.chat.rbgcodes.

ParameterDescription
playerthe player to check, must not be null
Returns: boolean - true if the player has RGB permission, false if null or no permission

colorize

String colorize(String message)

Translates alternate color codes (&) into Minecraft's internal color codes (§).

Example: "&cHello" becomes "§cHello" (red text).

ParameterDescription
messagethe message to colorize, null returns empty string
Returns: String - the colorized message with & codes replaced, or empty string if null

translateHexColorCodes

String translateHexColorCodes(String message)

Translates hex color codes (&#RRGGBB) into Minecraft's internal hex color format.

Example: "&#FF0000Red" becomes red colored text using the hex color code.

ParameterDescription
messagethe message containing hex codes, null returns empty string
Returns: String - the message with hex codes translated, or empty string if null

formatChatMessage

Component formatChatMessage(Player player, String message)

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.

ParameterDescription
playerthe player sending the message, must not be null
messagethe raw message content, null treated as empty string
Returns: Component - the formatted chat component, never null

reload

void 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