Overview
TheServer class is the central component that manages everything in PocketMine-MP. It provides access to worlds, players, plugins, commands, and all other core functionality.
Getting the Server Instance
Core Methods
getName()
Returns the server software name.getName() : string
string - Server software name (e.g., “PocketMine-MP”)
Example:
isRunning()
Checks if the server is currently running.isRunning() : bool
bool - True if server is running
getVersion()
Returns the Minecraft version the server supports.getVersion() : string
string - Minecraft protocol version (e.g., “1.20.0”)
getApiVersion()
Returns the PocketMine-MP API version.getApiVersion() : string
string - API version string
Player Management
getOnlinePlayers()
Gets all currently online players.getOnlinePlayers() : array
Player[] - Array of online Player objects
Example:
getPlayerExact()
Finds an online player by exact name (case insensitive).getPlayerExact(string $name) : ?Player
The exact player name to search for
Player|null - Player object if found, null otherwise
Example:
getPlayerByUUID()
Finds an online player by their UUID.getPlayerByUUID(UuidInterface $uuid) : ?Player
The player’s UUID
Player|null - Player object if found, null otherwise
getMaxPlayers()
Gets the maximum number of players allowed.getMaxPlayers() : int
int - Maximum player count
getOfflinePlayer()
Gets offline player data by name.getOfflinePlayer(string $name) : Player|OfflinePlayer|null
Player name to look up
Player|OfflinePlayer|null - Online player, offline player data, or null
World Management
getWorldManager()
Gets the world manager instance.getWorldManager() : WorldManager
WorldManager - The world manager
Example:
Plugin Management
getPluginManager()
Gets the plugin manager instance.getPluginManager() : PluginManager
PluginManager - The plugin manager
Example:
Command Management
getCommandMap()
Gets the command map for registering commands.getCommandMap() : SimpleCommandMap
SimpleCommandMap - The command map
Example:
getPluginCommand()
Gets a plugin command by name.getPluginCommand(string $name) : Command|PluginOwned|null
Command name to search for
Command|null - Command if found and owned by a plugin
Scheduler
getAsyncPool()
Gets the async task pool for background operations.getAsyncPool() : AsyncPool
AsyncPool - The async pool
Server Information
getMotd()
Gets the server’s Message of the Day.getMotd() : string
string - The server MOTD
getIp()
Gets the server’s IPv4 address.getIp() : string
string - IPv4 address
getPort()
Gets the server’s IPv4 port.getPort() : int
int - Port number
getTick()
Gets the current server tick count.getTick() : int
int - Current tick number since server start
getTicksPerSecond()
Gets the current TPS (ticks per second).getTicksPerSecond() : float
float - Current TPS value
getTicksPerSecondAverage()
Gets the average TPS.getTicksPerSecondAverage() : float
float - Average TPS
Broadcasting
broadcastMessage()
Broadcasts a message to all players.broadcastMessage(Translatable|string $message, ?array $recipients = null) : int
Message to broadcast
Optional array of specific recipients. Defaults to all players.
int - Number of recipients who received the message
Example:
broadcastTitle()
Broadcasts a title to all players.broadcastTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1, ?array $recipients = null) : int
Title text
Subtitle text (default: "")
Fade in duration in ticks (default: -1 for client default)
Stay duration in ticks (default: -1 for client default)
Fade out duration in ticks (default: -1 for client default)
Optional array of specific recipients
int - Number of recipients
Example:
Permissions
isOp()
Checks if a player name is an operator.isOp(string $name) : bool
Player name to check
bool - True if player is an operator
addOp()
Adds a player as an operator.addOp(string $name) : void
Player name to make operator
removeOp()
Removes operator status from a player.removeOp(string $name) : void
Player name to remove operator from
isWhitelisted()
Checks if a player is whitelisted.isWhitelisted(string $name) : bool
Player name to check
bool - True if whitelisted or whitelist is disabled
addWhitelist()
Adds a player to the whitelist.addWhitelist(string $name) : void
Player name to whitelist
removeWhitelist()
Removes a player from the whitelist.removeWhitelist(string $name) : void
Player name to remove from whitelist
Constants
Target server tick rate (20 TPS = 1 tick per 50ms)
Broadcast channel for administrative messages
Broadcast channel for user messages