PocketMine-MP 5.23.3 git-976fc63567edab7a6fb6aeae739f43cf9fe57de4
Loading...
Searching...
No Matches
pocketmine\Server Class Reference
+ Collaboration diagram for pocketmine\Server:

Public Member Functions

 __construct (private ThreadSafeClassLoader $autoloader, private AttachableThreadSafeLogger $logger, string $dataPath, string $pluginPath)
 
 __debugInfo ()
 
 addOnlinePlayer (Player $player)
 
 addOp (string $name)
 
 addWhitelist (string $name)
 
 broadcastMessage (Translatable|string $message, ?array $recipients=null)
 
 broadcastPopup (string $popup, ?array $recipients=null)
 
 broadcastTip (string $tip, ?array $recipients=null)
 
 broadcastTitle (string $title, string $subtitle="", int $fadeIn=-1, int $stay=-1, int $fadeOut=-1, ?array $recipients=null)
 
 crashDump ()
 
 createPlayer (NetworkSession $session, PlayerInfo $playerInfo, bool $authenticated, ?CompoundTag $offlinePlayerData)
 
 dispatchCommand (CommandSender $sender, string $commandLine, bool $internal=false)
 
 enablePlugins (PluginEnableOrder $type)
 
 exceptionHandler (\Throwable $e, ?array $trace=null)
 
 forceShutdown ()
 
 getAllowedViewDistance (int $distance)
 
 getApiVersion ()
 
 getAsyncPool ()
 
 getBroadcastChannelSubscribers (string $channelId)
 
 getCommandAliases ()
 
 getCommandMap ()
 
 getConfigGroup ()
 
 getCraftingManager ()
 
 getDataPath ()
 
 getDifficulty ()
 
 getFilePath ()
 
 getForceGamemode ()
 
 getGamemode ()
 
 getIp ()
 
 getIPBans ()
 
 getIpV6 ()
 
 getLanguage ()
 
 getLoader ()
 
 getLogger ()
 
 getMaxPlayers ()
 
 getMemoryManager ()
 
 getMotd ()
 
 getName ()
 
 getNameBans ()
 
 getNetwork ()
 
 getOfflinePlayer (string $name)
 
 getOfflinePlayerData (string $name)
 
 getOnlineMode ()
 
 getOnlinePlayers ()
 
 getOps ()
 
 getPlayerByPrefix (string $name)
 
 getPlayerByRawUUID (string $rawUUID)
 
 getPlayerByUUID (UuidInterface $uuid)
 
 getPlayerExact (string $name)
 
 getPluginCommand (string $name)
 
 getPluginManager ()
 
 getPluginPath ()
 
 getPocketMineVersion ()
 
 getPort ()
 
 getPortV6 ()
 
 getQueryInformation ()
 
 getResourcePackManager ()
 
 getResourcePath ()
 
 getServerUniqueId ()
 
 getStartTime ()
 
 getTick ()
 
 getTickSleeper ()
 
 getTicksPerSecond ()
 
 getTicksPerSecondAverage ()
 
 getTickUsage ()
 
 getTickUsageAverage ()
 
 getUpdater ()
 
 getVersion ()
 
 getViewDistance ()
 
 getWhitelisted ()
 
 getWorldManager ()
 
 hasOfflinePlayerData (string $name)
 
 hasWhitelist ()
 
 isHardcore ()
 
 isLanguageForced ()
 
 isOp (string $name)
 
 isRunning ()
 
 isWhitelisted (string $name)
 
 prepareBatch (string $buffer, Compressor $compressor, ?bool $sync=null, ?TimingsHandler $timings=null)
 
 removeOnlinePlayer (Player $player)
 
 removeOp (string $name)
 
 removeWhitelist (string $name)
 
 requiresAuthentication ()
 
 saveOfflinePlayerData (string $name, CompoundTag $nbtTag)
 
 sendUsage (int $type=SendUsageTask::TYPE_STATUS)
 
 setMaxPlayers (int $maxPlayers)
 
 shouldSavePlayerData ()
 
 shutdown ()
 
 subscribeToBroadcastChannel (string $channelId, CommandSender $subscriber)
 
 unsubscribeFromAllBroadcastChannels (CommandSender $subscriber)
 
 unsubscribeFromBroadcastChannel (string $channelId, CommandSender $subscriber)
 

Static Public Member Functions

static getInstance ()
 

Public Attributes

const BROADCAST_CHANNEL_ADMINISTRATIVE = "pocketmine.broadcast.admin"
 
const BROADCAST_CHANNEL_USERS = "pocketmine.broadcast.user"
 
const DEFAULT_MAX_PLAYERS = 20
 
const DEFAULT_MAX_VIEW_DISTANCE = 16
 
const DEFAULT_PORT_IPV4 = 19132
 
const DEFAULT_PORT_IPV6 = 19133
 
const DEFAULT_SERVER_NAME = VersionInfo::NAME . " Server"
 
const TARGET_NANOSECONDS_PER_TICK = 1_000_000_000 / self::TARGET_TICKS_PER_SECOND
 
const TARGET_SECONDS_PER_TICK = 1 / self::TARGET_TICKS_PER_SECOND
 
const TARGET_TICKS_PER_SECOND = 20
 

Detailed Description

The class that manages everything

Definition at line 182 of file src/Server.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\Server::__construct ( private ThreadSafeClassLoader $autoloader,
private AttachableThreadSafeLogger $logger,
string $dataPath,
string $pluginPath )

Definition at line 777 of file src/Server.php.

Member Function Documentation

◆ __debugInfo()

pocketmine\Server::__debugInfo ( )
Returns
mixed[]

Definition at line 1730 of file src/Server.php.

◆ addOnlinePlayer()

pocketmine\Server::addOnlinePlayer ( Player $player)

Definition at line 1749 of file src/Server.php.

◆ addOp()

pocketmine\Server::addOp ( string $name)

Definition at line 695 of file src/Server.php.

◆ addWhitelist()

pocketmine\Server::addWhitelist ( string $name)

Definition at line 719 of file src/Server.php.

◆ broadcastMessage()

pocketmine\Server::broadcastMessage ( Translatable|string $message,
?array $recipients = null )
Parameters
CommandSender[] | null$recipients

Definition at line 1338 of file src/Server.php.

◆ broadcastPopup()

pocketmine\Server::broadcastPopup ( string $popup,
?array $recipients = null )
Parameters
Player[] | null$recipients

Definition at line 1378 of file src/Server.php.

◆ broadcastTip()

pocketmine\Server::broadcastTip ( string $tip,
?array $recipients = null )
Parameters
Player[] | null$recipients

Definition at line 1365 of file src/Server.php.

◆ broadcastTitle()

pocketmine\Server::broadcastTitle ( string $title,
string $subtitle = "",
int $fadeIn = -1,
int $stay = -1,
int $fadeOut = -1,
?array $recipients = null )
Parameters
int$fadeInDuration in ticks for fade-in. If -1 is given, client-sided defaults will be used.
int$stayDuration in ticks to stay on screen for
int$fadeOutDuration in ticks for fade-out.
Player[] | null$recipients

Definition at line 1394 of file src/Server.php.

◆ crashDump()

pocketmine\Server::crashDump ( )

Definition at line 1640 of file src/Server.php.

◆ createPlayer()

pocketmine\Server::createPlayer ( NetworkSession $session,
PlayerInfo $playerInfo,
bool $authenticated,
?CompoundTag $offlinePlayerData )

@phpstan-return Promise<Player>

Definition at line 564 of file src/Server.php.

◆ dispatchCommand()

pocketmine\Server::dispatchCommand ( CommandSender $sender,
string $commandLine,
bool $internal = false )

Executes a command from a CommandSender

Definition at line 1467 of file src/Server.php.

◆ enablePlugins()

pocketmine\Server::enablePlugins ( PluginEnableOrder $type)

Definition at line 1447 of file src/Server.php.

◆ exceptionHandler()

pocketmine\Server::exceptionHandler ( \Throwable $e,
?array $trace = null )
Parameters
mixed[][] | null$trace@phpstan-param list<array<string, mixed>>|null $trace

Definition at line 1574 of file src/Server.php.

◆ forceShutdown()

pocketmine\Server::forceShutdown ( )

Definition at line 1496 of file src/Server.php.

◆ getAllowedViewDistance()

pocketmine\Server::getAllowedViewDistance ( int $distance)

Returns a view distance up to the currently-allowed limit.

Definition at line 383 of file src/Server.php.

◆ getApiVersion()

pocketmine\Server::getApiVersion ( )

Definition at line 325 of file src/Server.php.

◆ getAsyncPool()

pocketmine\Server::getAsyncPool ( )

Definition at line 456 of file src/Server.php.

◆ getBroadcastChannelSubscribers()

pocketmine\Server::getBroadcastChannelSubscribers ( string $channelId)

Returns a list of all the CommandSenders subscribed to the given broadcast channel.

Returns
CommandSender[] @phpstan-return array<int, CommandSender>

Definition at line 1331 of file src/Server.php.

◆ getCommandAliases()

pocketmine\Server::getCommandAliases ( )
Returns
string[][] @phpstan-return array<string, list<string>>

Definition at line 749 of file src/Server.php.

◆ getCommandMap()

pocketmine\Server::getCommandMap ( )

Definition at line 496 of file src/Server.php.

◆ getConfigGroup()

pocketmine\Server::getConfigGroup ( )

Definition at line 671 of file src/Server.php.

◆ getCraftingManager()

pocketmine\Server::getCraftingManager ( )

Definition at line 444 of file src/Server.php.

◆ getDataPath()

pocketmine\Server::getDataPath ( )

Definition at line 337 of file src/Server.php.

◆ getDifficulty()

pocketmine\Server::getDifficulty ( )

Returns Server global difficulty. Note that this may be overridden in individual worlds.

Definition at line 412 of file src/Server.php.

◆ getFilePath()

pocketmine\Server::getFilePath ( )

Definition at line 329 of file src/Server.php.

◆ getForceGamemode()

pocketmine\Server::getForceGamemode ( )

Definition at line 405 of file src/Server.php.

◆ getGamemode()

pocketmine\Server::getGamemode ( )

Definition at line 401 of file src/Server.php.

◆ getInstance()

static pocketmine\Server::getInstance ( )
static

Definition at line 770 of file src/Server.php.

◆ getIp()

pocketmine\Server::getIp ( )

Definition at line 387 of file src/Server.php.

◆ getIPBans()

pocketmine\Server::getIPBans ( )

Definition at line 691 of file src/Server.php.

◆ getIpV6()

pocketmine\Server::getIpV6 ( )

Definition at line 392 of file src/Server.php.

◆ getLanguage()

pocketmine\Server::getLanguage ( )

Definition at line 1800 of file src/Server.php.

◆ getLoader()

pocketmine\Server::getLoader ( )

Definition at line 428 of file src/Server.php.

◆ getLogger()

pocketmine\Server::getLogger ( )

Definition at line 432 of file src/Server.php.

◆ getMaxPlayers()

pocketmine\Server::getMaxPlayers ( )

Definition at line 345 of file src/Server.php.

◆ getMemoryManager()

pocketmine\Server::getMemoryManager ( )

Definition at line 1812 of file src/Server.php.

◆ getMotd()

pocketmine\Server::getMotd ( )

Definition at line 424 of file src/Server.php.

◆ getName()

pocketmine\Server::getName ( )

Definition at line 309 of file src/Server.php.

◆ getNameBans()

pocketmine\Server::getNameBans ( )

Definition at line 687 of file src/Server.php.

◆ getNetwork()

pocketmine\Server::getNetwork ( )

Definition at line 1808 of file src/Server.php.

◆ getOfflinePlayer()

pocketmine\Server::getOfflinePlayer ( string $name)

Definition at line 511 of file src/Server.php.

◆ getOfflinePlayerData()

pocketmine\Server::getOfflinePlayerData ( string $name)

Definition at line 529 of file src/Server.php.

◆ getOnlineMode()

pocketmine\Server::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.

Definition at line 357 of file src/Server.php.

◆ getOnlinePlayers()

pocketmine\Server::getOnlinePlayers ( )
Returns
Player[]

Definition at line 503 of file src/Server.php.

Referenced by pocketmine\stats\SendUsageTask\__construct().

+ Here is the caller graph for this function:

◆ getOps()

pocketmine\Server::getOps ( )

Definition at line 741 of file src/Server.php.

◆ getPlayerByPrefix()

pocketmine\Server::getPlayerByPrefix ( string $name)
Deprecated
This method's results are unpredictable. The string "Steve" will return the player named "SteveJobs", until another player named "SteveJ" joins the server, at which point it will return that player instead. Prefer filtering the results of Server::getOnlinePlayers() yourself.

Returns an online player whose name begins with or equals the given string (case insensitive). The closest match will be returned, or null if there are no online matches.

See also
Server::getPlayerExact()

Definition at line 623 of file src/Server.php.

◆ getPlayerByRawUUID()

pocketmine\Server::getPlayerByRawUUID ( string $rawUUID)

Returns the player online with the specified raw UUID, or null if not found

Definition at line 660 of file src/Server.php.

◆ getPlayerByUUID()

pocketmine\Server::getPlayerByUUID ( UuidInterface $uuid)

Returns the player online with a UUID equivalent to the specified UuidInterface object, or null if not found

Definition at line 667 of file src/Server.php.

◆ getPlayerExact()

pocketmine\Server::getPlayerExact ( string $name)

Returns an online player with the given name (case insensitive), or null if not found.

Definition at line 646 of file src/Server.php.

◆ getPluginCommand()

pocketmine\Server::getPluginCommand ( string $name)
Returns
Command|PluginOwned|null @phpstan-return (Command&PluginOwned)|null

Definition at line 679 of file src/Server.php.

◆ getPluginManager()

pocketmine\Server::getPluginManager ( )

Definition at line 440 of file src/Server.php.

◆ getPluginPath()

pocketmine\Server::getPluginPath ( )

Definition at line 341 of file src/Server.php.

◆ getPocketMineVersion()

pocketmine\Server::getPocketMineVersion ( )

Definition at line 317 of file src/Server.php.

◆ getPort()

pocketmine\Server::getPort ( )

Definition at line 368 of file src/Server.php.

◆ getPortV6()

pocketmine\Server::getPortV6 ( )

Definition at line 372 of file src/Server.php.

◆ getQueryInformation()

pocketmine\Server::getQueryInformation ( )

Definition at line 1566 of file src/Server.php.

◆ getResourcePackManager()

pocketmine\Server::getResourcePackManager ( )

Definition at line 448 of file src/Server.php.

◆ getResourcePath()

pocketmine\Server::getResourcePath ( )

Definition at line 333 of file src/Server.php.

◆ getServerUniqueId()

pocketmine\Server::getServerUniqueId ( )

Definition at line 397 of file src/Server.php.

◆ getStartTime()

pocketmine\Server::getStartTime ( )

Definition at line 492 of file src/Server.php.

◆ getTick()

pocketmine\Server::getTick ( )

Definition at line 460 of file src/Server.php.

◆ getTickSleeper()

pocketmine\Server::getTickSleeper ( )

Definition at line 1734 of file src/Server.php.

◆ getTicksPerSecond()

pocketmine\Server::getTicksPerSecond ( )

Returns the last server TPS measure

Definition at line 467 of file src/Server.php.

◆ getTicksPerSecondAverage()

pocketmine\Server::getTicksPerSecondAverage ( )

Returns the last server TPS average measure

Definition at line 474 of file src/Server.php.

Referenced by pocketmine\stats\SendUsageTask\__construct().

+ Here is the caller graph for this function:

◆ getTickUsage()

pocketmine\Server::getTickUsage ( )

Returns the TPS usage/load in %

Definition at line 481 of file src/Server.php.

◆ getTickUsageAverage()

pocketmine\Server::getTickUsageAverage ( )

Returns the TPS usage/load average in %

Definition at line 488 of file src/Server.php.

Referenced by pocketmine\stats\SendUsageTask\__construct().

+ Here is the caller graph for this function:

◆ getUpdater()

pocketmine\Server::getUpdater ( )

Definition at line 436 of file src/Server.php.

◆ getVersion()

pocketmine\Server::getVersion ( )

Definition at line 321 of file src/Server.php.

◆ getViewDistance()

pocketmine\Server::getViewDistance ( )

Definition at line 376 of file src/Server.php.

◆ getWhitelisted()

pocketmine\Server::getWhitelisted ( )

Definition at line 737 of file src/Server.php.

◆ getWorldManager()

pocketmine\Server::getWorldManager ( )

Definition at line 452 of file src/Server.php.

◆ hasOfflinePlayerData()

pocketmine\Server::hasOfflinePlayerData ( string $name)

Returns whether the server has stored any saved data for this player.

Definition at line 525 of file src/Server.php.

◆ hasWhitelist()

pocketmine\Server::hasWhitelist ( )

Definition at line 416 of file src/Server.php.

◆ isHardcore()

pocketmine\Server::isHardcore ( )

Definition at line 420 of file src/Server.php.

◆ isLanguageForced()

pocketmine\Server::isLanguageForced ( )

Definition at line 1804 of file src/Server.php.

◆ isOp()

pocketmine\Server::isOp ( string $name)

Definition at line 733 of file src/Server.php.

◆ isRunning()

pocketmine\Server::isRunning ( )

Definition at line 313 of file src/Server.php.

◆ isWhitelisted()

pocketmine\Server::isWhitelisted ( string $name)

Definition at line 729 of file src/Server.php.

◆ prepareBatch()

pocketmine\Server::prepareBatch ( string $buffer,
Compressor $compressor,
?bool $sync = null,
?TimingsHandler $timings = null )

Definition at line 1417 of file src/Server.php.

◆ removeOnlinePlayer()

pocketmine\Server::removeOnlinePlayer ( Player $player)

Definition at line 1784 of file src/Server.php.

◆ removeOp()

pocketmine\Server::removeOp ( string $name)

Definition at line 704 of file src/Server.php.

◆ removeWhitelist()

pocketmine\Server::removeWhitelist ( string $name)

Definition at line 724 of file src/Server.php.

◆ requiresAuthentication()

pocketmine\Server::requiresAuthentication ( )

Alias of getOnlineMode().

Definition at line 364 of file src/Server.php.

◆ saveOfflinePlayerData()

pocketmine\Server::saveOfflinePlayerData ( string $name,
CompoundTag $nbtTag )

Definition at line 541 of file src/Server.php.

◆ sendUsage()

pocketmine\Server::sendUsage ( int $type = SendUsageTask::TYPE_STATUS)

Definition at line 1793 of file src/Server.php.

◆ setMaxPlayers()

pocketmine\Server::setMaxPlayers ( int $maxPlayers)

Definition at line 349 of file src/Server.php.

◆ shouldSavePlayerData()

pocketmine\Server::shouldSavePlayerData ( )

Definition at line 507 of file src/Server.php.

◆ shutdown()

pocketmine\Server::shutdown ( )

Shuts the server down correctly

Definition at line 1484 of file src/Server.php.

◆ subscribeToBroadcastChannel()

pocketmine\Server::subscribeToBroadcastChannel ( string $channelId,
CommandSender $subscriber )

Subscribes to a particular message broadcast channel. The channel ID can be any arbitrary string.

Definition at line 1299 of file src/Server.php.

◆ unsubscribeFromAllBroadcastChannels()

pocketmine\Server::unsubscribeFromAllBroadcastChannels ( CommandSender $subscriber)

Unsubscribes from all broadcast channels.

Definition at line 1319 of file src/Server.php.

◆ unsubscribeFromBroadcastChannel()

pocketmine\Server::unsubscribeFromBroadcastChannel ( string $channelId,
CommandSender $subscriber )

Unsubscribes from a particular message broadcast channel.

Definition at line 1306 of file src/Server.php.

Member Data Documentation

◆ BROADCAST_CHANNEL_ADMINISTRATIVE

const pocketmine\Server::BROADCAST_CHANNEL_ADMINISTRATIVE = "pocketmine.broadcast.admin"

Definition at line 186 of file src/Server.php.

◆ BROADCAST_CHANNEL_USERS

const pocketmine\Server::BROADCAST_CHANNEL_USERS = "pocketmine.broadcast.user"

Definition at line 187 of file src/Server.php.

◆ DEFAULT_MAX_PLAYERS

const pocketmine\Server::DEFAULT_MAX_PLAYERS = 20

Definition at line 190 of file src/Server.php.

◆ DEFAULT_MAX_VIEW_DISTANCE

const pocketmine\Server::DEFAULT_MAX_VIEW_DISTANCE = 16

Definition at line 193 of file src/Server.php.

◆ DEFAULT_PORT_IPV4

const pocketmine\Server::DEFAULT_PORT_IPV4 = 19132

Definition at line 191 of file src/Server.php.

◆ DEFAULT_PORT_IPV6

const pocketmine\Server::DEFAULT_PORT_IPV6 = 19133

Definition at line 192 of file src/Server.php.

◆ DEFAULT_SERVER_NAME

const pocketmine\Server::DEFAULT_SERVER_NAME = VersionInfo::NAME . " Server"

Definition at line 189 of file src/Server.php.

◆ TARGET_NANOSECONDS_PER_TICK

const pocketmine\Server::TARGET_NANOSECONDS_PER_TICK = 1_000_000_000 / self::TARGET_TICKS_PER_SECOND

Definition at line 205 of file src/Server.php.

◆ TARGET_SECONDS_PER_TICK

const pocketmine\Server::TARGET_SECONDS_PER_TICK = 1 / self::TARGET_TICKS_PER_SECOND

The average time between ticks, in seconds.

Definition at line 204 of file src/Server.php.

◆ TARGET_TICKS_PER_SECOND

const pocketmine\Server::TARGET_TICKS_PER_SECOND = 20

Worlds, network, commands and most other things are polled this many times per second on average. Between ticks, the server will sleep to ensure that the average tick rate is maintained. It may wake up between ticks if a Snooze notification source is triggered (e.g. to process network packets).

Definition at line 200 of file src/Server.php.


The documentation for this class was generated from the following file: