PacketLimiter
all projectsA PocketMine-MP plugin that tracks player packet rates and disconnects repeat offenders.
Limiting packet spam in PocketMine
PacketLimiter is an open-source PHP plugin for PocketMine-MP that tracks how many packets each player sends. Repeatedly exceeding the configured limit adds warnings and eventually disconnects the player, helping curb excessive client packet traffic.
Configuration
The repository targets PocketMine-MP API 4.0.0. Its YAML configuration controls the packet limit, warning threshold, and kick message:
packet_per_second: 250
maximum_warning: 5
kick_message: 'You sending too many packets!'
Technical implementation
The plugin listens for PocketMine's packet-receive events and counts packets associated with connected players. Each player has an independent session, so packet counts and warnings are tracked separately.
A repeating scheduler task checks the counters roughly once per second. When the interval stretches beyond 1.2 seconds, the limit scales with elapsed time to account for a delayed check.
Exceeding the limit adds a warning, and repeated violations trigger a disconnect with the configured message. Packet counters reset after each check, while warnings remain associated with the player's session.
The session manager creates tracking state when a player first sends a packet and removes it when that player quits. The implementation uses PocketMine's event and scheduler APIs without a separate database or service.
Source
Explore the source code and configuration guide. PacketLimiter is available under the MIT license.