Server
in package
Uses
NotCloneable, NotSerializable
The class that manages everything
Table of Contents
- BROADCAST_CHANNEL_ADMINISTRATIVE = "pocketmine.broadcast.admin"
- BROADCAST_CHANNEL_USERS = "pocketmine.broadcast.user"
- $asyncPool : AsyncPool
- $autoloader : DynamicClassLoader
- $banByIP : BanList
- $banByName : BanList
- $broadcastSubscribers : array<string|int, mixed>
- $commandMap : SimpleCommandMap
- $configGroup : ServerConfigGroup
- $console : ConsoleReaderThread
- $craftingManager : CraftingManager
- $currentTPS : float
- $currentUse : float
- $dataPath : string
- $doTitleTick : bool
- $forceLanguage : bool
- $hasStopped : bool
- $instance : Server|null
- $isRunning : bool
- $language : Language
- $logger : AttachableThreadedLogger
- $maxPlayers : int
- $memoryManager : MemoryManager
- $network : Network
- $networkCompressionAsync : bool
- $nextTick : float
- $onlineMode : bool
- $operators : Config
- $playerList : array<string|int, mixed>
- $pluginManager : PluginManager
- $pluginPath : string
- $profilingTickRate : float
- $queryInfo : QueryInfo
- $resourceManager : ResourcePackManager
- $sendUsageTicker : int
- $serverID : UuidInterface
- $signalHandler : SignalHandler
- $startTime : float
- $tickAverage : array<string|int, mixed>
- $tickCounter : int
- Counts the ticks since the server start
- $tickSleeper : SleeperHandler
- $uniquePlayers : array<string|int, mixed>
- $updater : UpdateChecker
- $useAverage : array<string|int, mixed>
- $whitelist : Config
- $worldManager : WorldManager
- __clone() : mixed
- __construct() : mixed
- __debugInfo() : array<string|int, mixed>
- __serialize() : array<string|int, mixed>
- __unserialize() : void
- addOnlinePlayer() : bool
- addOp() : void
- addWhitelist() : void
- broadcastMessage() : int
- broadcastPackets() : bool
- broadcastPopup() : int
- broadcastTip() : int
- broadcastTitle() : int
- crashDump() : void
- createPlayer() : Promise
- dispatchCommand() : bool
- Executes a command from a CommandSender
- enablePlugins() : void
- exceptionHandler() : void
- forceShutdown() : void
- getAllowedViewDistance() : int
- Returns a view distance up to the currently-allowed limit.
- getApiVersion() : string
- getAsyncPool() : AsyncPool
- getBroadcastChannelSubscribers() : array<string|int, CommandSender>
- Returns a list of all the CommandSenders subscribed to the given broadcast channel.
- getCommandAliases() : array<string|int, array<string|int, string>>
- getCommandMap() : SimpleCommandMap
- getConfigGroup() : ServerConfigGroup
- getCraftingManager() : CraftingManager
- getDataPath() : string
- getDifficulty() : int
- Returns Server global difficulty. Note that this may be overridden in individual worlds.
- getFilePath() : string
- getForceGamemode() : bool
- getGamemode() : GameMode
- getInstance() : Server
- getIp() : string
- getIPBans() : BanList
- getIpV6() : string
- getLanguage() : Language
- getLoader() : DynamicClassLoader
- getLogger() : AttachableThreadedLogger
- getMaxPlayers() : int
- getMemoryManager() : MemoryManager
- getMotd() : string
- getName() : string
- getNameBans() : BanList
- getNetwork() : Network
- getOfflinePlayer() : OfflinePlayer|Player
- getOfflinePlayerData() : CompoundTag|null
- getOnlineMode() : bool
- Returns whether the server requires that players be authenticated to Xbox Live. If true, connecting players who are not logged into Xbox Live will be disconnected.
- getOnlinePlayers() : array<string|int, Player>
- getOps() : Config
- getPlayerByPrefix() : Player|null
- Returns an online player whose name begins with or equals the given string (case insensitive).
- getPlayerByRawUUID() : Player|null
- Returns the player online with the specified raw UUID, or null if not found
- getPlayerByUUID() : Player|null
- Returns the player online with a UUID equivalent to the specified UuidInterface object, or null if not found
- getPlayerExact() : Player|null
- Returns an online player with the given name (case insensitive), or null if not found.
- getPluginCommand() : Command|PluginOwned|null
- getPluginManager() : PluginManager
- getPluginPath() : string
- getPocketMineVersion() : string
- getPort() : int
- getPortV6() : int
- getQueryInformation() : QueryInfo
- getResourcePackManager() : ResourcePackManager
- getResourcePath() : string
- getServerUniqueId() : UuidInterface
- getStartTime() : float
- getTick() : int
- getTickSleeper() : SleeperHandler
- getTicksPerSecond() : float
- Returns the last server TPS measure
- getTicksPerSecondAverage() : float
- Returns the last server TPS average measure
- getTickUsage() : float
- Returns the TPS usage/load in %
- getTickUsageAverage() : float
- Returns the TPS usage/load average in %
- getUpdater() : UpdateChecker
- getVersion() : string
- getViewDistance() : int
- getWhitelisted() : Config
- getWorldManager() : WorldManager
- hasOfflinePlayerData() : bool
- Returns whether the server has stored any saved data for this player.
- hasWhitelist() : bool
- isHardcore() : bool
- isLanguageForced() : bool
- isOp() : bool
- isRunning() : bool
- isWhitelisted() : bool
- prepareBatch() : CompressBatchPromise
- Broadcasts a list of packets in a batch to a list of players
- removeOnlinePlayer() : void
- removeOp() : void
- removeWhitelist() : void
- requiresAuthentication() : bool
- Alias of {@link #getOnlineMode()}.
- saveOfflinePlayerData() : void
- sendUsage() : void
- shouldSavePlayerData() : bool
- shutdown() : void
- Shuts the server down correctly
- subscribeToBroadcastChannel() : void
- Subscribes to a particular message broadcast channel.
- unsubscribeFromAllBroadcastChannels() : void
- Unsubscribes from all broadcast channels.
- unsubscribeFromBroadcastChannel() : void
- Unsubscribes from a particular message broadcast channel.
- getPlayerBroadcastSubscribers() : array<string|int, Player>
- getPlayerDataPath() : string
- handleCorruptedPlayerData() : void
- startupPrepareConnectableNetworkInterfaces() : bool
- startupPrepareNetworkInterfaces() : bool
- startupPrepareWorlds() : bool
- tick() : void
- Tries to execute a server tick
- tickProcessor() : void
- titleTick() : void
- writeCrashDumpFile() : string
Constants
BROADCAST_CHANNEL_ADMINISTRATIVE
public
mixed
BROADCAST_CHANNEL_ADMINISTRATIVE
= "pocketmine.broadcast.admin"
BROADCAST_CHANNEL_USERS
public
mixed
BROADCAST_CHANNEL_USERS
= "pocketmine.broadcast.user"
Properties
$asyncPool
private
AsyncPool
$asyncPool
$autoloader
private
DynamicClassLoader
$autoloader
$banByIP
private
BanList
$banByIP
$banByName
private
BanList
$banByName
$broadcastSubscribers
private
array<string|int, mixed>
$broadcastSubscribers
= []
Tags
$commandMap
private
SimpleCommandMap
$commandMap
$configGroup
private
ServerConfigGroup
$configGroup
$console
private
ConsoleReaderThread
$console
$craftingManager
private
CraftingManager
$craftingManager
$currentTPS
private
float
$currentTPS
= 20
$currentUse
private
float
$currentUse
= 0
$dataPath
private
string
$dataPath
$doTitleTick
private
bool
$doTitleTick
= true
$forceLanguage
private
bool
$forceLanguage
= false
$hasStopped
private
bool
$hasStopped
= false
$instance
private
static Server|null
$instance
= null
$isRunning
private
bool
$isRunning
= true
$language
private
Language
$language
$logger
private
AttachableThreadedLogger
$logger
$maxPlayers
private
int
$maxPlayers
$memoryManager
private
MemoryManager
$memoryManager
$network
private
Network
$network
$networkCompressionAsync
private
bool
$networkCompressionAsync
= true
$nextTick
private
float
$nextTick
= 0
$onlineMode
private
bool
$onlineMode
= true
$operators
private
Config
$operators
$playerList
private
array<string|int, mixed>
$playerList
= []
$pluginManager
private
PluginManager
$pluginManager
$pluginPath
private
string
$pluginPath
$profilingTickRate
private
float
$profilingTickRate
= 20
$queryInfo
private
QueryInfo
$queryInfo
$resourceManager
private
ResourcePackManager
$resourceManager
$sendUsageTicker
private
int
$sendUsageTicker
= 0
$serverID
private
UuidInterface
$serverID
$signalHandler
private
SignalHandler
$signalHandler
$startTime
private
float
$startTime
$tickAverage
private
array<string|int, mixed>
$tickAverage
= [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]
$tickCounter
Counts the ticks since the server start
private
int
$tickCounter
= 0
$tickSleeper
private
SleeperHandler
$tickSleeper
$uniquePlayers
private
array<string|int, mixed>
$uniquePlayers
= []
Tags
$updater
private
UpdateChecker
$updater
$useAverage
private
array<string|int, mixed>
$useAverage
= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
$whitelist
private
Config
$whitelist
$worldManager
private
WorldManager
$worldManager
Methods
__clone()
public
final __clone() : mixed
Return values
mixed —__construct()
public
__construct(DynamicClassLoader $autoloader, AttachableThreadedLogger $logger, string $dataPath, string $pluginPath) : mixed
Parameters
- $autoloader : DynamicClassLoader
- $logger : AttachableThreadedLogger
- $dataPath : string
- $pluginPath : string
Return values
mixed —__debugInfo()
public
__debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —__serialize()
public
final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —addOnlinePlayer()
public
addOnlinePlayer(Player $player) : bool
Parameters
- $player : Player
Return values
bool —addOp()
public
addOp(string $name) : void
Parameters
- $name : string
Return values
void —addWhitelist()
public
addWhitelist(string $name) : void
Parameters
- $name : string
Return values
void —broadcastMessage()
public
broadcastMessage(Translatable|string $message[, array<string|int, CommandSender>|null $recipients = null ]) : int
Parameters
- $message : Translatable|string
- $recipients : array<string|int, CommandSender>|null = null
Return values
int —broadcastPackets()
public
broadcastPackets(array<string|int, Player> $players, array<string|int, ClientboundPacket> $packets) : bool
Parameters
- $players : array<string|int, Player>
- $packets : array<string|int, ClientboundPacket>
Return values
bool —broadcastPopup()
public
broadcastPopup(string $popup[, array<string|int, Player>|null $recipients = null ]) : int
Parameters
- $popup : string
- $recipients : array<string|int, Player>|null = null
Return values
int —broadcastTip()
public
broadcastTip(string $tip[, array<string|int, Player>|null $recipients = null ]) : int
Parameters
- $tip : string
- $recipients : array<string|int, Player>|null = null
Return values
int —broadcastTitle()
public
broadcastTitle(string $title[, string $subtitle = "" ][, int $fadeIn = -1 ][, int $stay = -1 ][, int $fadeOut = -1 ][, array<string|int, Player>|null $recipients = null ]) : int
Parameters
- $title : string
- $subtitle : string = ""
- $fadeIn : int = -1
-
Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
- $stay : int = -1
-
Duration in ticks to stay on screen for
- $fadeOut : int = -1
-
Duration in ticks for fade-out.
- $recipients : array<string|int, Player>|null = null
Return values
int —crashDump()
public
crashDump() : void
Return values
void —createPlayer()
public
createPlayer(NetworkSession $session, PlayerInfo $playerInfo, bool $authenticated, CompoundTag|null $offlinePlayerData) : Promise
Parameters
- $session : NetworkSession
- $playerInfo : PlayerInfo
- $authenticated : bool
- $offlinePlayerData : CompoundTag|null
Tags
Return values
Promise —dispatchCommand()
Executes a command from a CommandSender
public
dispatchCommand(CommandSender $sender, string $commandLine[, bool $internal = false ]) : bool
Parameters
- $sender : CommandSender
- $commandLine : string
- $internal : bool = false
Return values
bool —enablePlugins()
public
enablePlugins(PluginEnableOrder $type) : void
Parameters
- $type : PluginEnableOrder
Return values
void —exceptionHandler()
public
exceptionHandler(Throwable $e[, array<string|int, array<string|int, mixed>>|null $trace = null ]) : void
Parameters
- $e : Throwable
- $trace : array<string|int, array<string|int, mixed>>|null = null
Tags
Return values
void —forceShutdown()
public
forceShutdown() : void
Return values
void —getAllowedViewDistance()
Returns a view distance up to the currently-allowed limit.
public
getAllowedViewDistance(int $distance) : int
Parameters
- $distance : int
Return values
int —getApiVersion()
public
getApiVersion() : string
Return values
string —getAsyncPool()
public
getAsyncPool() : AsyncPool
Return values
AsyncPool —getBroadcastChannelSubscribers()
Returns a list of all the CommandSenders subscribed to the given broadcast channel.
public
getBroadcastChannelSubscribers(string $channelId) : array<string|int, CommandSender>
Parameters
- $channelId : string
Tags
Return values
array<string|int, CommandSender> —getCommandAliases()
public
getCommandAliases() : array<string|int, array<string|int, string>>
Return values
array<string|int, array<string|int, string>> —getCommandMap()
public
getCommandMap() : SimpleCommandMap
Return values
SimpleCommandMap —getConfigGroup()
public
getConfigGroup() : ServerConfigGroup
Return values
ServerConfigGroup —getCraftingManager()
public
getCraftingManager() : CraftingManager
Return values
CraftingManager —getDataPath()
public
getDataPath() : string
Return values
string —getDifficulty()
Returns Server global difficulty. Note that this may be overridden in individual worlds.
public
getDifficulty() : int
Return values
int —getFilePath()
public
getFilePath() : string
Return values
string —getForceGamemode()
public
getForceGamemode() : bool
Return values
bool —getGamemode()
public
getGamemode() : GameMode
Return values
GameMode —getInstance()
public
static getInstance() : Server
Return values
Server —getIp()
public
getIp() : string
Return values
string —getIPBans()
public
getIPBans() : BanList
Return values
BanList —getIpV6()
public
getIpV6() : string
Return values
string —getLanguage()
public
getLanguage() : Language
Return values
Language —getLoader()
public
getLoader() : DynamicClassLoader
Return values
DynamicClassLoader —getLogger()
public
getLogger() : AttachableThreadedLogger
Return values
AttachableThreadedLogger —getMaxPlayers()
public
getMaxPlayers() : int
Return values
int —getMemoryManager()
public
getMemoryManager() : MemoryManager
Return values
MemoryManager —getMotd()
public
getMotd() : string
Return values
string —getName()
public
getName() : string
Return values
string —getNameBans()
public
getNameBans() : BanList
Return values
BanList —getNetwork()
public
getNetwork() : Network
Return values
Network —getOfflinePlayer()
public
getOfflinePlayer(string $name) : OfflinePlayer|Player
Parameters
- $name : string
Return values
OfflinePlayer|Player —getOfflinePlayerData()
public
getOfflinePlayerData(string $name) : CompoundTag|null
Parameters
- $name : string
Return values
CompoundTag|null —getOnlineMode()
Returns whether the server requires that players be authenticated to Xbox Live. If true, connecting players who are not logged into Xbox Live will be disconnected.
public
getOnlineMode() : bool
Return values
bool —getOnlinePlayers()
public
getOnlinePlayers() : array<string|int, Player>
Return values
array<string|int, Player> —getOps()
public
getOps() : Config
Return values
Config —getPlayerByPrefix()
Returns an online player whose name begins with or equals the given string (case insensitive).
public
getPlayerByPrefix(string $name) : Player|null
The closest match will be returned, or null if there are no online matches.
Parameters
- $name : string
Tags
Return values
Player|null —getPlayerByRawUUID()
Returns the player online with the specified raw UUID, or null if not found
public
getPlayerByRawUUID(string $rawUUID) : Player|null
Parameters
- $rawUUID : string
Return values
Player|null —getPlayerByUUID()
Returns the player online with a UUID equivalent to the specified UuidInterface object, or null if not found
public
getPlayerByUUID(UuidInterface $uuid) : Player|null
Parameters
- $uuid : UuidInterface
Return values
Player|null —getPlayerExact()
Returns an online player with the given name (case insensitive), or null if not found.
public
getPlayerExact(string $name) : Player|null
Parameters
- $name : string
Return values
Player|null —getPluginCommand()
public
getPluginCommand(string $name) : Command|PluginOwned|null
Parameters
- $name : string
Tags
Return values
Command|PluginOwned|null —getPluginManager()
public
getPluginManager() : PluginManager
Return values
PluginManager —getPluginPath()
public
getPluginPath() : string
Return values
string —getPocketMineVersion()
public
getPocketMineVersion() : string
Return values
string —getPort()
public
getPort() : int
Return values
int —getPortV6()
public
getPortV6() : int
Return values
int —getQueryInformation()
public
getQueryInformation() : QueryInfo
Return values
QueryInfo —getResourcePackManager()
public
getResourcePackManager() : ResourcePackManager
Return values
ResourcePackManager —getResourcePath()
public
getResourcePath() : string
Return values
string —getServerUniqueId()
public
getServerUniqueId() : UuidInterface
Return values
UuidInterface —getStartTime()
public
getStartTime() : float
Return values
float —getTick()
public
getTick() : int
Return values
int —getTickSleeper()
public
getTickSleeper() : SleeperHandler
Return values
SleeperHandler —getTicksPerSecond()
Returns the last server TPS measure
public
getTicksPerSecond() : float
Return values
float —getTicksPerSecondAverage()
Returns the last server TPS average measure
public
getTicksPerSecondAverage() : float
Return values
float —getTickUsage()
Returns the TPS usage/load in %
public
getTickUsage() : float
Return values
float —getTickUsageAverage()
Returns the TPS usage/load average in %
public
getTickUsageAverage() : float
Return values
float —getUpdater()
public
getUpdater() : UpdateChecker
Return values
UpdateChecker —getVersion()
public
getVersion() : string
Return values
string —getViewDistance()
public
getViewDistance() : int
Return values
int —getWhitelisted()
public
getWhitelisted() : Config
Return values
Config —getWorldManager()
public
getWorldManager() : WorldManager
Return values
WorldManager —hasOfflinePlayerData()
Returns whether the server has stored any saved data for this player.
public
hasOfflinePlayerData(string $name) : bool
Parameters
- $name : string
Return values
bool —hasWhitelist()
public
hasWhitelist() : bool
Return values
bool —isHardcore()
public
isHardcore() : bool
Return values
bool —isLanguageForced()
public
isLanguageForced() : bool
Return values
bool —isOp()
public
isOp(string $name) : bool
Parameters
- $name : string
Return values
bool —isRunning()
public
isRunning() : bool
Return values
bool —isWhitelisted()
public
isWhitelisted(string $name) : bool
Parameters
- $name : string
Return values
bool —prepareBatch()
Broadcasts a list of packets in a batch to a list of players
public
prepareBatch(PacketBatch $stream, Compressor $compressor[, bool|null $sync = null ]) : CompressBatchPromise
Parameters
- $stream : PacketBatch
- $compressor : Compressor
- $sync : bool|null = null
-
Compression on the main thread (true) or workers (false). Default is automatic (null).
Return values
CompressBatchPromise —removeOnlinePlayer()
public
removeOnlinePlayer(Player $player) : void
Parameters
- $player : Player
Return values
void —removeOp()
public
removeOp(string $name) : void
Parameters
- $name : string
Return values
void —removeWhitelist()
public
removeWhitelist(string $name) : void
Parameters
- $name : string
Return values
void —requiresAuthentication()
Alias of {@link #getOnlineMode()}.
public
requiresAuthentication() : bool
Return values
bool —saveOfflinePlayerData()
public
saveOfflinePlayerData(string $name, CompoundTag $nbtTag) : void
Parameters
- $name : string
- $nbtTag : CompoundTag
Return values
void —sendUsage()
public
sendUsage([int $type = SendUsageTask::TYPE_STATUS ]) : void
Parameters
- $type : int = SendUsageTask::TYPE_STATUS
Return values
void —shouldSavePlayerData()
public
shouldSavePlayerData() : bool
Return values
bool —shutdown()
Shuts the server down correctly
public
shutdown() : void
Return values
void —subscribeToBroadcastChannel()
Subscribes to a particular message broadcast channel.
public
subscribeToBroadcastChannel(string $channelId, CommandSender $subscriber) : void
The channel ID can be any arbitrary string.
Parameters
- $channelId : string
- $subscriber : CommandSender
Return values
void —unsubscribeFromAllBroadcastChannels()
Unsubscribes from all broadcast channels.
public
unsubscribeFromAllBroadcastChannels(CommandSender $subscriber) : void
Parameters
- $subscriber : CommandSender
Return values
void —unsubscribeFromBroadcastChannel()
Unsubscribes from a particular message broadcast channel.
public
unsubscribeFromBroadcastChannel(string $channelId, CommandSender $subscriber) : void
Parameters
- $channelId : string
- $subscriber : CommandSender
Return values
void —getPlayerBroadcastSubscribers()
private
getPlayerBroadcastSubscribers(string $channelId) : array<string|int, Player>
Parameters
- $channelId : string
Return values
array<string|int, Player> —getPlayerDataPath()
private
getPlayerDataPath(string $username) : string
Parameters
- $username : string
Return values
string —handleCorruptedPlayerData()
private
handleCorruptedPlayerData(string $name) : void
Parameters
- $name : string
Return values
void —startupPrepareConnectableNetworkInterfaces()
private
startupPrepareConnectableNetworkInterfaces(string $ip, int $port, bool $ipV6, bool $useQuery) : bool
Parameters
- $ip : string
- $port : int
- $ipV6 : bool
- $useQuery : bool
Return values
bool —startupPrepareNetworkInterfaces()
private
startupPrepareNetworkInterfaces() : bool
Return values
bool —startupPrepareWorlds()
private
startupPrepareWorlds() : bool
Return values
bool —tick()
Tries to execute a server tick
private
tick() : void
Return values
void —tickProcessor()
private
tickProcessor() : void
Return values
void —titleTick()
private
titleTick() : void
Return values
void —writeCrashDumpFile()
private
writeCrashDumpFile(CrashDump $dump) : string
Parameters
- $dump : CrashDump