Server events are fired for server-level operations like networking, commands, and server management. All server events extend theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pmmp/PocketMine-MP/llms.txt
Use this file to discover all available pages before exploring further.
ServerEvent base class.
ServerEvent Base Class
All server events inherit from this abstract class. It has no additional methods beyond the baseEvent class.
Command Events
CommandEvent
CommandEvent
Cancellable: YesCalled when any CommandSender runs a command, before it is parsed.Warning: Do NOT use this to block commands. Use permissions instead. Many commands have aliases (e.g., Note: The command string does NOT begin with a slash.Methods:
/version, /ver, /about).getSender()- Returns the CommandSender executing the commandgetCommand()- Returns the command string (without leading slash)setCommand(string $command)- Modifies the command string
Network Events
DataPacketReceiveEvent
DataPacketReceiveEvent
Cancellable: YesCalled when the server receives a packet from a client.Methods:
getPacket()- Returns the ClientboundPacketgetOrigin()- Returns the NetworkSession that sent the packet
DataPacketSendEvent
DataPacketSendEvent
Cancellable: YesCalled when the server sends a packet to a client.Methods:
getPackets()- Returns array of ServerboundPacketsgetTargets()- Returns array of NetworkSessions receiving packetssetTargets(array $targets)- Sets which sessions receive the packets
DataPacketDecodeEvent
DataPacketDecodeEvent
Cancellable: YesCalled after a packet is decoded but before it’s handled.Methods:
getPacket()- Returns the decoded packetgetOrigin()- Returns the NetworkSession
Network Interface Events
NetworkInterfaceRegisterEvent
NetworkInterfaceRegisterEvent
Cancellable: NoCalled when a network interface is registered.Methods:
getInterface()- Returns the NetworkInterface being registered
NetworkInterfaceUnregisterEvent
NetworkInterfaceUnregisterEvent
Cancellable: NoCalled when a network interface is unregistered.Methods:
getInterface()- Returns the NetworkInterface being unregistered
Server Management Events
QueryRegenerateEvent
QueryRegenerateEvent
Cancellable: NoCalled when server query information is regenerated. Allows customization of query response.Methods:
getServer()- Returns the Server instancegetServerName()- Returns server name in querysetServerName(string $name)- Sets server namegetListPlugins()- Returns whether plugins are listedsetListPlugins(bool $list)- Sets whether to list pluginsgetPlugins()- Returns plugin arraysetPlugins(array $plugins)- Sets plugin listgetPlayerCount()- Returns player countsetPlayerCount(int $count)- Sets player countgetMaxPlayerCount()- Returns max playerssetMaxPlayerCount(int $count)- Sets max playersgetPlayerList()- Returns player name arraysetPlayerList(array $players)- Sets player listgetWorld()- Returns default world namesetWorld(string $world)- Sets world name
UpdateNotifyEvent
UpdateNotifyEvent
Cancellable: NoCalled when a PocketMine-MP update is available.Methods:
getUpdateInfo()- Returns UpdateInfo object with update details
LowMemoryEvent
LowMemoryEvent
Cancellable: NoCalled when the server detects low memory.Methods:
getMemory()- Returns current memory usage in bytesgetMemoryLimit()- Returns memory limit in bytesgetTriggerCount()- Returns how many times this has been triggeredisGlobal()- Returns whether this is a global memory issue
Usage Examples
Command Logger
Custom Query Response
Packet Anti-Spam
Memory Management
Update Notification System
Complete Server Event List
All server-related events:CommandEvent- Command is executedDataPacketDecodeEvent- Packet is decodedDataPacketReceiveEvent- Packet is received from clientDataPacketSendEvent- Packet is sent to clientLowMemoryEvent- Low memory detectedNetworkInterfaceEvent- Base for network interface eventsNetworkInterfaceRegisterEvent- Network interface registeredNetworkInterfaceUnregisterEvent- Network interface unregisteredQueryRegenerateEvent- Server query info regeneratedServerEvent- Base class for server eventsUpdateNotifyEvent- Update is available