Overview
The networking system manages all connected clients, handles player states (configuration and play), and provides utilities for sending packets.ConnectionManager
Manages all connected clients and player lifecycle.Player Queries
Gets the number of players in the play state (for query response)
Returns an unmodifiable collection of players currently in the play state
Returns an unmodifiable collection of players currently in the configuration state
Gets the Player linked to a PlayerConnectionReturns the player (regardless of state) or null
Gets the first player in play state matching the username (case-insensitive)Returns the player or null if not found
Gets the first player in play state matching the UUIDReturns the player or null if not found
Finds the closest matching player in play state (fuzzy search)Uses Jaro-Winkler distance for matching. Returns null if no close match.
Configuration
Changes the Player provider to use custom Player implementations
Player State Transitions
Creates a Player instance for a connection
Transitions a player from login to configuration stateFires
AsyncPlayerPreLoginEvent and handles compressionPerforms the configuration phase for a playerSends registry data, resource packs, and fires
AsyncPlayerConfigurationEventTransitions a player from play to configuration state (for reconfiguration)
Transitions a player from configuration to play state
Management
Removes a player from the connection managerUse
PlayerConnection.disconnect() instead of calling this directlyShuts down the connection manager by kicking all connected players
Ticks the connection manager (handles keep-alive, waiting players)
Registry & Tags
Sends the tags packet to a player
Invalidates the cached tags packet (called when registries change)
PlayerConnection
Represents a connection to a player. Implementations includePlayerSocketConnection for real network connections.
Packet Sending
Sends a packet to the player
Sends multiple packets
Connection Info
Gets the Player associated with this connection (may be null before login)
Gets the remote socket address
Checks if the connection is still active
Disconnects the player
Kicks the player with a reason
Player State Management
Players transition through different states:- Login - Initial handshake and authentication
- Configuration - Receiving registry data, resource packs, brand info
- Play - Actively playing in the world
- Configuration (reconfiguration) - Can transition back for updates
Custom Player Provider
Create custom Player implementations:Packet Utilities
Sending to Multiple Players
Configuration Events
Keep-Alive System
The ConnectionManager automatically sends keep-alive packets and kicks players who don’t respond:- Keep-alive sent every
ServerFlag.KEEP_ALIVE_DELAYmilliseconds (default: 10000) - Players kicked after
ServerFlag.KEEP_ALIVE_KICKmilliseconds (default: 30000)
Players are tracked separately during configuration and play states. The ConnectionManager handles state transitions automatically based on packet flow.
