Documentation

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

$broadcastSubscribers

private array<string|int, mixed> $broadcastSubscribers = []
Tags
phpstan-var

array<string, array<int, CommandSender>>

$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

$isRunning

private bool $isRunning = true

$maxPlayers

private int $maxPlayers

$networkCompressionAsync

private bool $networkCompressionAsync = true

$nextTick

private float $nextTick = 0

$onlineMode

private bool $onlineMode = true

$playerList

private array<string|int, mixed> $playerList = []

$pluginPath

private string $pluginPath

$profilingTickRate

private float $profilingTickRate = 20

$sendUsageTicker

private int $sendUsageTicker = 0

$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

$uniquePlayers

private array<string|int, mixed> $uniquePlayers = []
Tags
phpstan-var

array<string, string>

$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]

Methods

__clone()

public final __clone() : mixed
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

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

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

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
phpstan-param

list<array<string, mixed>>|null $trace

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

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
phpstan-return

array<int, CommandSender>

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>>

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

getIp()

public getIp() : string
Return values
string

getIpV6()

public getIpV6() : string
Return values
string

getMaxPlayers()

public getMaxPlayers() : int
Return values
int

getMotd()

public getMotd() : string
Return values
string

getName()

public getName() : string
Return values
string

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>

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
see
Server::getPlayerExact()
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

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

getResourcePath()

public getResourcePath() : string
Return values
string

getStartTime()

public getStartTime() : float
Return values
float

getTick()

public getTick() : int
Return values
int

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

getVersion()

public getVersion() : string
Return values
string

getViewDistance()

public getViewDistance() : int
Return values
int

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

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
Return values
string

Search results