Overview | EssentialsC | ChatApi
net.godlycow.org.essc.api

Interface ChatApi

public interface ChatApi

API interface for interacting with EssentialsC's chat formatting system. The chat system processes outgoing player messages through LuckPerms group formats and PlaceholderAPI placeholders when both are available and enabled. This API lets you query the current state of the system and run a message through the same formatting pipeline manually.

Retrieve an instance via EssentialsCAPI.getChatApi().

ChatApi chat = APIProvider.getAPI().getChatApi();

if (chat.isActive()) {
    Component formatted = chat.formatMessage(player, "Hello world");
    player.getServer().broadcast(formatted);
}

Method Summary

boolean isLuckPermsChatEnabled()
Returns whether LuckPerms chat formatting is enabled in the config.
boolean isLuckPermsAvailable()
Returns whether the LuckPerms API is currently loaded and available.
boolean isActive()
Returns whether the chat system is fully active — config enabled and LuckPerms available.
boolean canUseColorCodes(Player player)
Returns whether the player can use legacy color codes in chat.
boolean canUseRgbCodes(Player player)
Returns whether the player can use hex/RGB color codes in chat.
Component formatMessage(Player player, String message)
Formats a raw chat message through the full EssentialsC pipeline and returns a Component.
Method Detail
public boolean isLuckPermsChatEnabled()

Returns whether LuckPerms-based chat formatting is enabled in the plugin config.

This reflects the config value only — the LuckPerms plugin may still be unavailable at runtime even if this returns true. Use isActive() to check both conditions at once.

Returns:
booleantrue if LuckPerms chat formatting is switched on in the config
public boolean isLuckPermsAvailable()

Returns whether the LuckPerms API is currently loaded and available.

This can return false even when LuckPerms is installed if the plugin loaded before LuckPerms finished registering its service provider.

Returns:
booleantrue if the LuckPerms API was successfully obtained at startup or last reload
public boolean isActive()

Returns whether chat formatting is fully active — that is, both the config option is enabled and the LuckPerms API is available.

Equivalent to isLuckPermsChatEnabled() && isLuckPermsAvailable().

Returns:
booleantrue if the chat system will process outgoing messages
public boolean canUseColorCodes(Player player)

Returns whether the given player is allowed to use legacy color codes (e.g. &c, &l) in chat.

Checks for the essentialsc.chat.legacycodes permission.

Parameters:
playerthe player to check; must not be null
Returns:
booleantrue if the player has the essentialsc.chat.legacycodes permission
public boolean canUseRgbCodes(Player player)

Returns whether the given player is allowed to use hex/RGB color codes (e.g. &#FF5500) in chat.

Checks for the essentialsc.chat.rbgcodes permission.

Parameters:
playerthe player to check; must not be null
Returns:
booleantrue if the player has the essentialsc.chat.rbgcodes permission
public Component formatMessage(Player player, String message)

Formats a raw chat message for the given player through the full EssentialsC chat pipeline and returns the result as an Adventure Component.

The pipeline applies, in order:

  • Hex color translation (&#RRGGBB) if the player has essentialsc.chat.rbgcodes
  • Legacy color code translation (&c, etc.) if the player has essentialsc.chat.legacycodes
  • LuckPerms group format lookup (group-formats.<group> in config, falling back to chat-format)
  • PlaceholderAPI placeholder expansion if PlaceholderAPI is present
  • Prefix, suffix, and name substitution from LuckPerms metadata

If the chat system is not active (see isActive()), this method returns the raw message deserialized as a plain Component with no LuckPerms formatting applied.

Parameters:
playerthe player whose format and permissions are used; must not be null
messagethe raw message string as typed by the player; must not be null
Returns:
Componentthe fully formatted Adventure Component; never null