Skip to main content
The SystemChatListener processes all system chat messages sent by the server, including player messages, announcements, and system notifications. It also handles action bar messages and filters unwanted notifications.

Packet Type

Intercepts: PacketType.Play.Server.SYSTEM_CHAT_MESSAGE This packet is sent whenever the server needs to display a chat message to the player.

Configuration

listeners:
  system-messages: true
When disabled, system chat messages are sent unmodified to the client.

Class Structure

public class SystemChatListener extends AbstractListener {
    private final MiniMessage mm = MiniMessage.miniMessage();

    public SystemChatListener(ProcessHandler processHandler, ConfigManager configManager) {
        super(processHandler, configManager);
    }

    @Override
    public void onPacketPlaySend(PacketPlaySendEvent e) {
        // Implementation
    }
}
Source: SystemChatListener.java:11-40

Implementation Details

1. Packet Type Validation

if (!config.getOrDefault("listeners.system-messages", true) ||
    e.getPacketType() != PacketType.Play.Server.SYSTEM_CHAT_MESSAGE) return;
Source: SystemChatListener.java:20-21 The listener exits early if:
  • The listener is disabled in the configuration
  • The packet type doesn’t match SYSTEM_CHAT_MESSAGE

2. Message Extraction

Player player = e.getPlayer();
WrapperPlayServerSystemChatMessage packet = new WrapperPlayServerSystemChatMessage(e);
String message = mm.serialize(packet.getMessage());
Source: SystemChatListener.java:23-25 The message is serialized from an Adventure Component to a MiniMessage string for processing.

3. Message Filtering

if (message.startsWith("<lang:multiplayer.message_not_delivered:")) {
    e.setCancelled(true);
    return;
}
Source: SystemChatListener.java:27-30 Cancels packets containing the “message not delivered” notification, which appears when chat reporting fails. This prevents unwanted system messages from appearing to players.

4. Action Bar Handling

if (message.contains("[actionbar]")) {
    message = message.replace("[actionbar]", "");
    e.setCancelled(true);
    player.sendActionBar(handler.processComponent(message, player));
}
Source: SystemChatListener.java:32-35 Messages containing the [actionbar] tag are:
  1. Stripped of the tag
  2. Cancelled from appearing in chat
  3. Redirected to the action bar with formatting applied
This allows servers to send action bar messages through the chat system.

5. Standard Message Processing

else {
    packet.setMessage(handler.processComponent(message, player));
}
Source: SystemChatListener.java:36-38 For regular messages, the text is processed through ProcessHandler.processComponent(), which:
  • Resolves PlaceholderAPI placeholders
  • Resolves MiniPlaceholders
  • Parses MiniMessage formatting
  • Returns a formatted Adventure Component

Usage Example

When a plugin sends:
player.sendMessage("<gradient:red:blue>Welcome %player_name%!</gradient> [actionbar]");
The listener:
  1. Detects the [actionbar] tag
  2. Removes the tag from the message
  3. Processes placeholders: %player_name%Steve
  4. Applies MiniMessage gradient formatting
  5. Sends the result to the action bar instead of chat

Dependencies

  • PacketEvents: For packet interception
  • WrapperPlayServerSystemChatMessage: Packet wrapper for reading/modifying system chat
  • MiniMessage: For serializing Adventure components to strings
  • ProcessHandler: For placeholder resolution and formatting

Build docs developers (and LLMs) love