TitleListener intercepts and formats title and subtitle packets, allowing servers to display formatted large text messages on the player’s screen with MiniMessage formatting and placeholder support.
Packet Types
Intercepts two packet types:PacketType.Play.Server.SET_TITLE_TEXT- Main title textPacketType.Play.Server.SET_TITLE_SUBTITLE- Subtitle text below the title
Configuration
Class Structure
Implementation Details
1. Packet Type Validation
- The listener is disabled in the configuration
- The packet type is neither
SET_TITLE_TEXTnorSET_TITLE_SUBTITLE
2. Title Text Processing
- Creates a
WrapperPlayServerSetTitleTextwrapper - Extracts the title component
- Processes it through
ProcessHandler - Sets the formatted title back to the packet
3. Subtitle Text Processing
- Creates a
WrapperPlayServerSetTitleSubtitlewrapper - Extracts the subtitle component
- Processes it through
ProcessHandler - Sets the formatted subtitle back to the packet
Usage Example
When a plugin sends a title:- Intercept both the title and subtitle packets
- Process the gradient formatting in the title
- Resolve the
%player_points%placeholder in the subtitle - Send the formatted components to the client
- Title: “VICTORY!” displayed with a red-to-gold gradient
- Subtitle: “You earned 150 points” (with the placeholder resolved)
Processing Flow
Component Processing
Extracts the text component and processes it:
- Resolves placeholders
- Parses MiniMessage formatting
Per-Player Customization
Because processing includes the player parameter, titles can display personalized content:Dependencies
- PacketEvents: For packet interception
- WrapperPlayServerSetTitleText: Packet wrapper for title text
- WrapperPlayServerSetTitleSubtitle: Packet wrapper for subtitle text
- ProcessHandler: For placeholder resolution and formatting
Related Components
- ProcessHandler - Handles text processing
- ConfigManager - Manages listener configuration
Common Use Cases
-
Welcome Messages
- Greet players when they join the server
- Display personalized welcome back messages
-
Game Events
- Announce game starts, wins, or defeats
- Show achievement notifications
- Display round countdowns
-
Broadcasts
- Server-wide announcements
- Event notifications
- Important alerts
-
Player Notifications
- Level up messages
- Reward notifications
- Quest completions