PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
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)
 
 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 179 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 767 of file src/Server.php.

Member Function Documentation

◆ __debugInfo()

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

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

◆ addOnlinePlayer()

pocketmine\Server::addOnlinePlayer ( Player $player)

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

◆ addOp()

pocketmine\Server::addOp ( string $name)

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

◆ addWhitelist()

pocketmine\Server::addWhitelist ( string $name)

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

◆ broadcastMessage()

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

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

◆ broadcastPopup()

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

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

◆ broadcastTip()

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

Definition at line 1320 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 1349 of file src/Server.php.

◆ crashDump()

pocketmine\Server::crashDump ( )

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

◆ createPlayer()

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

@phpstan-return Promise<Player>

Definition at line 557 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 1422 of file src/Server.php.

◆ enablePlugins()

pocketmine\Server::enablePlugins ( PluginEnableOrder $type)

Definition at line 1402 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 1529 of file src/Server.php.

◆ forceShutdown()

pocketmine\Server::forceShutdown ( )

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

◆ getAllowedViewDistance()

pocketmine\Server::getAllowedViewDistance ( int $distance)

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

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

◆ getApiVersion()

pocketmine\Server::getApiVersion ( )

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

◆ getAsyncPool()

pocketmine\Server::getAsyncPool ( )

Definition at line 449 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 1286 of file src/Server.php.

◆ getCommandAliases()

pocketmine\Server::getCommandAliases ( )
Returns
string[][]

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

◆ getCommandMap()

pocketmine\Server::getCommandMap ( )

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

◆ getConfigGroup()

pocketmine\Server::getConfigGroup ( )

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

◆ getCraftingManager()

pocketmine\Server::getCraftingManager ( )

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

◆ getDataPath()

pocketmine\Server::getDataPath ( )

Definition at line 334 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 405 of file src/Server.php.

◆ getFilePath()

pocketmine\Server::getFilePath ( )

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

◆ getForceGamemode()

pocketmine\Server::getForceGamemode ( )

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

◆ getGamemode()

pocketmine\Server::getGamemode ( )

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

◆ getInstance()

static pocketmine\Server::getInstance ( )
static

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

◆ getIp()

pocketmine\Server::getIp ( )

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

◆ getIPBans()

pocketmine\Server::getIPBans ( )

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

◆ getIpV6()

pocketmine\Server::getIpV6 ( )

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

◆ getLanguage()

pocketmine\Server::getLanguage ( )

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

◆ getLoader()

pocketmine\Server::getLoader ( )

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

◆ getLogger()

pocketmine\Server::getLogger ( )

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

◆ getMaxPlayers()

pocketmine\Server::getMaxPlayers ( )

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

◆ getMemoryManager()

pocketmine\Server::getMemoryManager ( )

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

◆ getMotd()

pocketmine\Server::getMotd ( )

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

◆ getName()

pocketmine\Server::getName ( )

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

◆ getNameBans()

pocketmine\Server::getNameBans ( )

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

◆ getNetwork()

pocketmine\Server::getNetwork ( )

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

◆ getOfflinePlayer()

pocketmine\Server::getOfflinePlayer ( string $name)

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

◆ getOfflinePlayerData()

pocketmine\Server::getOfflinePlayerData ( string $name)

Definition at line 522 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 350 of file src/Server.php.

◆ getOnlinePlayers()

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

Definition at line 496 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 734 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 616 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 653 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 660 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 639 of file src/Server.php.

◆ getPluginCommand()

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

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

◆ getPluginManager()

pocketmine\Server::getPluginManager ( )

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

◆ getPluginPath()

pocketmine\Server::getPluginPath ( )

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

◆ getPocketMineVersion()

pocketmine\Server::getPocketMineVersion ( )

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

◆ getPort()

pocketmine\Server::getPort ( )

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

◆ getPortV6()

pocketmine\Server::getPortV6 ( )

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

◆ getQueryInformation()

pocketmine\Server::getQueryInformation ( )

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

◆ getResourcePackManager()

pocketmine\Server::getResourcePackManager ( )

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

◆ getResourcePath()

pocketmine\Server::getResourcePath ( )

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

◆ getServerUniqueId()

pocketmine\Server::getServerUniqueId ( )

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

◆ getStartTime()

pocketmine\Server::getStartTime ( )

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

◆ getTick()

pocketmine\Server::getTick ( )

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

◆ getTickSleeper()

pocketmine\Server::getTickSleeper ( )

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

◆ getTicksPerSecond()

pocketmine\Server::getTicksPerSecond ( )

Returns the last server TPS measure

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

◆ getTicksPerSecondAverage()

pocketmine\Server::getTicksPerSecondAverage ( )

Returns the last server TPS average measure

Definition at line 467 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 474 of file src/Server.php.

◆ getTickUsageAverage()

pocketmine\Server::getTickUsageAverage ( )

Returns the TPS usage/load average in %

Definition at line 481 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 429 of file src/Server.php.

◆ getVersion()

pocketmine\Server::getVersion ( )

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

◆ getViewDistance()

pocketmine\Server::getViewDistance ( )

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

◆ getWhitelisted()

pocketmine\Server::getWhitelisted ( )

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

◆ getWorldManager()

pocketmine\Server::getWorldManager ( )

Definition at line 445 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 518 of file src/Server.php.

◆ hasWhitelist()

pocketmine\Server::hasWhitelist ( )

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

◆ isHardcore()

pocketmine\Server::isHardcore ( )

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

◆ isLanguageForced()

pocketmine\Server::isLanguageForced ( )

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

◆ isOp()

pocketmine\Server::isOp ( string $name)

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

◆ isRunning()

pocketmine\Server::isRunning ( )

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

◆ isWhitelisted()

pocketmine\Server::isWhitelisted ( string $name)

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

◆ prepareBatch()

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

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

◆ removeOnlinePlayer()

pocketmine\Server::removeOnlinePlayer ( Player $player)

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

◆ removeOp()

pocketmine\Server::removeOp ( string $name)

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

◆ removeWhitelist()

pocketmine\Server::removeWhitelist ( string $name)

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

◆ requiresAuthentication()

pocketmine\Server::requiresAuthentication ( )

Alias of getOnlineMode().

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

◆ saveOfflinePlayerData()

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

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

◆ sendUsage()

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

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

◆ shouldSavePlayerData()

pocketmine\Server::shouldSavePlayerData ( )

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

◆ shutdown()

pocketmine\Server::shutdown ( )

Shuts the server down correctly

Definition at line 1439 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 1254 of file src/Server.php.

◆ unsubscribeFromAllBroadcastChannels()

pocketmine\Server::unsubscribeFromAllBroadcastChannels ( CommandSender $subscriber)

Unsubscribes from all broadcast channels.

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

◆ unsubscribeFromBroadcastChannel()

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

Unsubscribes from a particular message broadcast channel.

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

Member Data Documentation

◆ BROADCAST_CHANNEL_ADMINISTRATIVE

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

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

◆ BROADCAST_CHANNEL_USERS

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

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

◆ DEFAULT_MAX_PLAYERS

const pocketmine\Server::DEFAULT_MAX_PLAYERS = 20

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

◆ DEFAULT_MAX_VIEW_DISTANCE

const pocketmine\Server::DEFAULT_MAX_VIEW_DISTANCE = 16

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

◆ DEFAULT_PORT_IPV4

const pocketmine\Server::DEFAULT_PORT_IPV4 = 19132

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

◆ DEFAULT_PORT_IPV6

const pocketmine\Server::DEFAULT_PORT_IPV6 = 19133

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

◆ DEFAULT_SERVER_NAME

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

Definition at line 186 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 202 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 201 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 197 of file src/Server.php.


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