### start Source: https://apidoc.pmmp.io/d8/d3c/classpocketmine_1_1network_1_1query_1_1_dedicated_query_network_interface Performs necessary actions to start the network interface after it has been registered. ```APIDOC ## start ### Description Performs actions needed to start the interface after it is registered. ### Method N/A (Method of the class) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Exceptions * NetworkInterfaceStartException - Thrown if the interface fails to start. ``` -------------------------------- ### Setup Wizard API Source: https://apidoc.pmmp.io/da/d58/deprecated API for accessing default configurations of the Setup Wizard. ```APIDOC ## GET /wizard/setup/defaults ### Description Retrieves the default configuration values for the Setup Wizard, including default name, player count, and port. ### Method GET ### Endpoint /wizard/setup/defaults ### Parameters None ### Request Example None ### Response #### Success Response (200) - **DEFAULT_NAME** (string) - The default name for the setup wizard. - **DEFAULT_PLAYERS** (int) - The default number of players. - **DEFAULT_PORT** (int) - The default port number. #### Response Example ```json { "DEFAULT_NAME": "PocketMine-MP", "DEFAULT_PLAYERS": 20, "DEFAULT_PORT": 19132 } ``` ``` -------------------------------- ### Packet Handler Setup (PHP) Source: https://apidoc.pmmp.io/d2/d47/classpocketmine_1_1network_1_1mcpe_1_1handler_1_1_login_packet_handler-members The setUp method is defined within the PacketHandler class. Its specific purpose is not detailed here but is typically used for initializing or configuring the packet handler before it starts processing network packets. This method is essential for ensuring the packet handling mechanism is ready to operate. ```PHP server->getLogger()->debug("Waiting for RakLib to start..."); try{ $this->rakLib->startAndWait(); }catch(SocketException $e){ throw new NetworkInterfaceStartException($e->getMessage(), 0, $e); } $this->server->getLogger()->debug("RakLib booted successfully"); } ``` -------------------------------- ### PacketHandler setUp Method Source: https://apidoc.pmmp.io/d5/d23/classpocketmine_1_1network_1_1mcpe_1_1handler_1_1_packet_handler The setUp method for the PacketHandler class. This is a placeholder method, and its specific implementation details are defined in the PacketHandler.php file. It's part of the packet handling mechanism for client sessions. ```php ``` -------------------------------- ### Setup Wizard Initialization Source: https://apidoc.pmmp.io/d3/dcd/_setup_wizard_8php_source Initializes the SetupWizard for PocketMine-MP, allowing users to configure server settings like language. It handles language selection and error checking for missing language files. The wizard requires the server's data path for configuration. ```php message(VersionInfo::NAME . " set-up wizard"); try{ $langs = Language::getLanguageList(); }catch(LanguageNotFoundException $e){ $this->error("No language files found, please use provided builds or clone the repository recursively."); return false; } $this->message("Please select a language"); foreach(Utils::stringifyKeys($langs) as $short => $native){ $this->writeLine(" $native => $short"); } do{ $lang = strtolower($this->getInput("Language", "eng")); if(!isset($langs[$lang])){ $this->error("Couldn't find the language"); } }while(!isset($langs[$lang])); $this->lang = $langs[$lang]; // ... rest of the wizard logic return true; // Placeholder } // Placeholder methods for demonstration private function message(string $message) : void { echo "[INFO] $message\n"; } private function error(string $message) : void { echo "[ERROR] $message\n"; } private function writeLine(string $line) : void { echo $line . PHP_EOL; } private function getInput(string $prompt, string $default = "") : string { $input = trim(fgets(STDIN) ?: ""); if ($input === "" && $default !== "") { return $default; } return $input; } } ``` -------------------------------- ### Get Network Start Translation (PHP) Source: https://apidoc.pmmp.io/d0/dc6/classpocketmine_1_1lang_1_1_known_translation_factory Retrieves the translation string indicating the start of the network process. This function can take two translatable string parameters. ```PHP getMessage(); ``` -------------------------------- ### SetupWizard Class run() Method in PHP Source: https://apidoc.pmmp.io/d7/dde/classpocketmine_1_1wizard_1_1_setup_wizard Documents the public run() method of the SetupWizard class in PHP. This method is responsible for executing the setup wizard. It takes no arguments and is defined in the SetupWizard.php file. ```php /** * pocketmine\wizard\SetupWizard::run */ public function run(): void ``` -------------------------------- ### POST setup() Source: https://apidoc.pmmp.io/dc/db6/namespacepocketmine_1_1utils Inserts default entries into the registry. ```APIDOC ## POST setup() ### Description Inserts default entries into the registry. ### Method POST ### Endpoint N/A (static abstract protected method) ### Parameters N/A ### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **void** - Setup successful. #### Response Example N/A ``` -------------------------------- ### Item Usage and Effects Source: https://apidoc.pmmp.io/dd/dc0/classpocketmine_1_1item_1_1_milk_bucket Methods related to item usage, such as starting to use an item or getting additional effects. ```APIDOC ## POST /item/use ### Description Handles the initiation of item usage by a player and retrieving any additional effects associated with the item. ### Method POST ### Endpoint /item/use ### Parameters #### Request Body - **player** (string) - Required - The identifier of the player using the item. - **action** (string) - Required - The action to perform (e.g., `canStartUsingItem`, `getAdditionalEffects`). ### Request Example ```json { "player": "playerName123", "action": "canStartUsingItem" } ``` ```json { "action": "getAdditionalEffects" } ``` ### Response #### Success Response (200) - **canStartUsingItem** (bool) - True if the player can start using the item, false otherwise. - **additionalEffects** (array) - An array of effect instances associated with the item. #### Response Example ```json { "canStartUsingItem": true } ``` ```json { "additionalEffects": [ { "effectId": 1, "amplifier": 0, "duration": 100 } ] } ``` ``` -------------------------------- ### Server Startup Initialization Source: https://apidoc.pmmp.io/d0/d05/src_2_server_8php_source Initializes server components, loads plugins, prepares worlds, and sets up network interfaces. It handles errors during these stages and logs the startup process. Usage statistics are sent if enabled. ```PHP 1060 $this->pluginManager->loadPlugins($this->pluginPath, $loadErrorCount); 1061 if($loadErrorCount > 0){ 1062 $this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_plugin_someLoadErrors())); 1063 $this->forceShutdownExit(); 1064 return; 1065 } 1066 if(!$this->enablePlugins(PluginEnableOrder::STARTUP)){ 1067 $this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_plugin_someEnableErrors())); 1068 $this->forceShutdownExit(); 1069 return; 1070 } 1071 1072 if(!$this->startupPrepareWorlds()){ 1073 $this->forceShutdownExit(); 1074 return; 1075 } 1076 1077 if(!$this->enablePlugins(PluginEnableOrder::POSTWORLD)){ 1078 $this->logger->emergency($this->language->translate(KnownTranslationFactory::pocketmine_plugin_someEnableErrors())); 1079 $this->forceShutdownExit(); 1080 return; 1081 } 1082 1083 if(!$this->startupPrepareNetworkInterfaces()){ 1084 $this->forceShutdownExit(); 1085 return; 1086 } 1087 1088 if($this->configGroup->getPropertyBool(Yml::ANONYMOUS_STATISTICS_ENABLED, true)){ 1089 $this->sendUsageTicker = self::TICKS_PER_STATS_REPORT; 1090 $this->sendUsage(SendUsageTask::TYPE_OPEN); 1091 } 1092 1093 $this->configGroup->save(); 1094 1095 $this->logger->info($this->language->translate(KnownTranslationFactory::pocketmine_server_defaultGameMode($this->getGamemode()->getTranslatableName()))); 1096 $highlight = TextFormat::AQUA; 1097 $reset = TextFormat::RESET; 1098 $github = VersionInfo::GITHUB_URL; 1099 $splash = "\n\n"; 1100 foreach([ 1101 KnownTranslationFactory::pocketmine_server_url_discord("{$highlight}https://discord.pmmp.io{$reset}"), 1102 KnownTranslationFactory::pocketmine_server_url_docs("{$highlight}https://doc.pmmp.io{$reset}"), 1103 KnownTranslationFactory::pocketmine_server_url_sourceCode("{$highlight}{$github}{$reset}"), 1104 KnownTranslationFactory::pocketmine_server_url_freePlugins("{$highlight}https://poggit.pmmp.io/plugins{$reset}"), 1105 KnownTranslationFactory::pocketmine_server_url_donations("{$highlight}https://patreon.com/pocketminemp{$reset}"), 1106 KnownTranslationFactory::pocketmine_server_url_translations("{$highlight}https://translate.pocketmine.net{$reset}"), 1107 KnownTranslationFactory::pocketmine_server_url_bugReporting("{$highlight}{$github}/issues{$reset}") 1108 ] as $link){ 1109 $splash .= "- " . $this->language->translate($link) . "\n"; 1110 } 1111 $this->logger->info($splash); 1112 1113 $this->logger->info($this->language->translate(KnownTranslationFactory::pocketmine_server_startFinished(strval(round(microtime(true) - $this->startTime, 3))))); 1114 1115 $forwarder = new BroadcastLoggerForwarder($this, $this->logger, $this->language); 1116 $this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_ADMINISTRATIVE, $forwarder); 1117 $this->subscribeToBroadcastChannel(self::BROADCAST_CHANNEL_USERS, $forwarder); 1118 1119 //TODO: move console parts to a separate component 1120 if($this->configGroup->getPropertyBool(Yml::CONSOLE_ENABLE_INPUT, true)){ 1121 $this->console = new ConsoleReaderChildProcessDaemon($this->logger); 1122 } 1123 1124 $this->tickProcessor(); 1125 $this->forceShutdown(); 1126 }catch(\Throwable $e){ 1127 $this->exceptionHandler($e); 1128 } 1129 } ``` -------------------------------- ### Get Relative Double Coordinate (PHP) Source: https://apidoc.pmmp.io/d1/d1c/classpocketmine_1_1command_1_1defaults_1_1_version_command Parses a coordinate input, handling relative coordinates (starting with ~) and validating against min/max bounds. Used in VanillaCommands. ```PHP ``` -------------------------------- ### Food Item Specific Methods Source: https://apidoc.pmmp.io/d2/dd2/classpocketmine_1_1item_1_1_beetroot This section details methods specifically for food items, such as getting additional effects or checking if an item can be used to start an action. ```APIDOC ## GET /food/{itemId}/getAdditionalEffects ### Description Gets the additional effects applied by consuming this food item. ### Method GET ### Endpoint `/food/{itemId}/getAdditionalEffects` ### Parameters #### Path Parameters - **itemId** (integer) - Required - The ID of the food item. ### Response #### Success Response (200) - **effects** (array) - An array of effect instances applied by the food. #### Response Example ```json { "effects": [ { "effectId": 10, "amplifier": 0, "duration": 100 } ] } ``` ## GET /food/{itemId}/canStartUsingItem/{playerId} ### Description Checks if the player can start using this food item. ### Method GET ### Endpoint `/food/{itemId}/canStartUsingItem/{playerId}` ### Parameters #### Path Parameters - **itemId** (integer) - Required - The ID of the food item. - **playerId** (string) - Required - The UUID of the player. ### Response #### Success Response (200) - **canStartUsing** (boolean) - True if the player can start using the item, false otherwise. #### Response Example ```json { "canStartUsing": true } ``` ``` -------------------------------- ### PocketMine-MP API - Function Documentation: checkInit() Source: https://apidoc.pmmp.io/dc/db6/namespacepocketmine_1_1utils Documentation for the checkInit() static method. ```APIDOC ## Function Documentation ## ◆ checkInit() | static pocketmine\utils\checkInit | ( | __| ) | --- staticprotected Definition at line 80 of file RegistryTrait.php. ``` -------------------------------- ### Get Spawn Location - PHP Source: https://apidoc.pmmp.io/d9/d88/_world_8php_source Retrieves the world's spawn location as a Vector3. This is the default starting point for players when they join the world. ```php public function getSpawnLocation() { // Implementation details omitted } ``` -------------------------------- ### POST /websites/apidoc_pmmp_io/RakLibInterface/start Source: https://apidoc.pmmp.io/d9/dc4/classpocketmine_1_1network_1_1mcpe_1_1raklib_1_1_rak_lib_interface Performs actions needed to start the interface after it is registered. This method is called automatically when the network interface is initialized. ```APIDOC ## POST /websites/apidoc_pmmp_io/RakLibInterface/start ### Description Performs actions needed to start the interface after it is registered. This method is called automatically when the network interface is initialized. ### Method POST ### Endpoint /websites/apidoc_pmmp_io/RakLibInterface/start ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) This method does not return specific data on success. It may throw a NetworkInterfaceStartException on failure. #### Response Example ```json { "message": "Network interface started successfully" } ``` ``` -------------------------------- ### Getting Command Information in PHP Source: https://apidoc.pmmp.io/d8/d45/classpocketmine_1_1command_1_1defaults_1_1_list_command-members Provides examples of getter methods for pocketmine\command\Command, including getName, getDescription, getUsage, getLabel, and getAliases. ```php public function getName() public function getDescription() public function getUsage() public function getLabel() public function getAliases() ``` -------------------------------- ### PrepareEncryptionTask Constructor Source: https://apidoc.pmmp.io/d7/d18/classpocketmine_1_1network_1_1mcpe_1_1encryption_1_1_prepare_encryption_task Initializes the PrepareEncryptionTask with a client public key and a completion callback. This is the entry point for starting the encryption task. ```PHP public function __construct(private string $clientPub, Closure $onCompletion) { // Constructor logic } ``` -------------------------------- ### Get Player by Prefix Source: https://apidoc.pmmp.io/d0/d05/src_2_server_8php_source Retrieves a player by a prefix of their name. It finds the player whose name starts with the given prefix and has the shortest difference in length. ```APIDOC ## GET /api/players/prefix/{name} ### Description Retrieves a player by a prefix of their name. It finds the player whose name starts with the given prefix and has the shortest difference in length. ### Method GET ### Endpoint /api/players/prefix/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The prefix of the player's name. ### Response #### Success Response (200) - **player** (Player) - The found Player object, or null if no player matches. #### Response Example ```json { "player": { "name": "ExamplePlayer", "uuid": "uuid_string" } } ``` ``` -------------------------------- ### Server Configuration and Management Source: https://apidoc.pmmp.io/d8/d02/classpocketmine_1_1network_1_1mcpe_1_1protocol_1_1types_1_1inventory_1_1stackrequest_1_1_item_stack_request_action-members Core components for server management, including server configuration, memory management, and version information. This section details how the server is initialized, configured, and how its resources are managed. ```php Server ServerConfigGroup ServerProperties VersionInfo YmlServerProperties GarbageCollectorManager MemoryDump MemoryManager TimeTrackingSleeperHandler ``` -------------------------------- ### Get Bow's Block Tool Type Source: https://apidoc.pmmp.io/d5/dbc/classpocketmine_1_1item_1_1_bow Returns the type of tool the bow represents for breaking blocks. For example, 'axe', 'pickaxe', etc. ```php public function getBlockToolType(): int ``` -------------------------------- ### PHP Hello World Example Source: https://apidoc.pmmp.io/d0/d0e/_mc_region_8php_source A basic 'Hello, World!' example in PHP, demonstrating simple output. This snippet is often used for initial testing and understanding of the language syntax. ```php run()){ $exitCode = -1; break; } } /* * We now use the Composer autoloader, but this autoloader is still for loading plugins. */ $autoloader = new ThreadSafeClassLoader(); $autoloader->register(false); ``` -------------------------------- ### Get Player by Prefix (Server) Source: https://apidoc.pmmp.io/functions_g Retrieves a player whose name starts with a given prefix. This method is part of the pocketmine\Server class and returns a Player object or null if no matching player is found. ```PHP getPlayerByPrefix($prefix); ?> ``` -------------------------------- ### Constructor Source: https://apidoc.pmmp.io/d6/dfa/classpocketmine_1_1world_1_1format_1_1io_1_1_base_world_provider Initializes the BaseWorldProvider with the specified path and logger. ```APIDOC ## __construct ### Description Initializes the BaseWorldProvider with the specified path and logger. ### Method __construct ### Parameters #### Path Parameters - **_path_** (string) - Required - The path to the world data. - **_logger_** (Logger) - Required - The logger instance for this provider. ### Request Example ```json { "_path_": "/path/to/world", "_logger_": "" } ``` ### Response #### Success Response (200) N/A (Constructor does not return a value directly visible to the caller in this format). #### Response Example N/A ``` -------------------------------- ### GET /getXpToReachLevel() Source: https://apidoc.pmmp.io/d2/d6a/classpocketmine_1_1entity_1_1utils_1_1_experience_utils This function calculates the total experience points (XP) required to reach a specific level, starting from level 0. It's useful for determining the XP needed for player progression. ```APIDOC ## GET /getXpToReachLevel() ### Description Calculates and returns the amount of XP needed to get from level 0 to level $level. ### Method GET ### Endpoint /getXpToReachLevel() ### Parameters #### Path Parameters - **level** (int) - Required - The target level to calculate XP for. #### Query Parameters - None #### Request Body - None ### Request Example { "level": 10 } ### Response #### Success Response (200) - **xp** (int) - The total XP required to reach the specified level. #### Response Example { "xp": 500 } ``` -------------------------------- ### Server Configuration and Player Limit Methods Source: https://apidoc.pmmp.io/d0/d05/src_2_server_8php_source Methods to get server configuration values like the maximum number of players and the online mode status. These are critical for server setup and security. ```php public function getMaxPlayers() : int{ return $this->maxPlayers; } public function getOnlineMode() : bool{ return $this->onlineMode; } public function requiresAuthentication() : bool{ return $this->getOnlineMode(); ``` -------------------------------- ### PocketMine-MP Server Core Components Source: https://apidoc.pmmp.io/da/d44/classpocketmine_1_1network_1_1mcpe_1_1protocol_1_1types_1_1login_1_1clientdata_1_1_client_data_persona_skin_piece-members Documentation for core server components, including bootstrap options, memory management, and server configuration. ```APIDOC ## Server Bootstrap and Management ### Description Details classes involved in the server's bootstrap process, memory management, and configuration handling. Includes garbage collection and timing utilities. ### Method Not applicable (Class definitions) ### Endpoint Not applicable (Class definitions) ### Parameters None ### Request Example ```json { "className": "Server" } ``` ### Response #### Success Response (N/A) These are class definitions, not API endpoints. #### Response Example ```json { "message": "Class definition" } ``` ``` -------------------------------- ### QueryHandler: Get Packet Pattern Source: https://apidoc.pmmp.io/db/dad/_query_handler_8php_source Returns a regular expression pattern used to identify and filter incoming query packets. This pattern ensures that only packets starting with specific byte sequences are processed. ```php public function getPattern() : string { return '/^\xfe\xfd.+$/s'; } ``` -------------------------------- ### handleSpawnExperienceOrb Source: https://apidoc.pmmp.io/d9/ded/classpocketmine_1_1network_1_1mcpe_1_1handler_1_1_in_game_packet_handler Processes the spawning of experience orbs using SpawnExperienceOrbPacket. ```APIDOC ## handleSpawnExperienceOrb() ### Description Processes the spawning of experience orbs using SpawnExperienceOrbPacket. ### Method POST (Assumed) ### Endpoint /handleSpawnExperienceOrb ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **_packet_** (SpawnExperienceOrbPacket) - The packet containing data for spawning an experience orb. ### Request Example ```json { "packet": { "type": "SpawnExperienceOrbPacket", "position": { "x": 15.5, "y": 65.0, "z": 25.5 }, "count": 5 } } ``` ### Response #### Success Response (200) Indicates successful experience orb spawn. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Block Light Filter (PHP) Source: https://apidoc.pmmp.io/d5/d56/classpocketmine_1_1block_1_1_mob_head Determines the amount of light a block filters when light passes through it, used in light propagation calculations. The value ranges from 0 to 15. Ice and Water are examples of blocks that reimplement this. ```php getLightFilter(); echo "Light Filter Level: " . $lightFilter; ?> ``` -------------------------------- ### Server Bootstrap Initialization Source: https://apidoc.pmmp.io/de/d55/_pocket_mine_8php_source The `server` function orchestrates the entire server startup process. It checks platform dependencies, sets INI entries, loads the Composer autoloader, verifies dependency synchronization, sets up error handling, parses command-line arguments for version display, configures paths for data and plugins, and creates necessary lock files. ```php function server(){ if(count($messages = check_platform_dependencies()) > 0){ echo PHP_EOL; $binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown"; critical_error("Selected PHP binary does not satisfy some requirements."); foreach($messages as $m){ echo " - $m" . PHP_EOL; } critical_error("PHP binary used: " . $binary); critical_error("Loaded php.ini: " . (($file = php_ini_loaded_file()) !== false ? $file : "none")); $phprc = getenv("PHPRC"); critical_error("Value of PHPRC environment variable: " . ($phprc === false ? "" : $phprc)); critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html."); echo PHP_EOL; exit(1); } unset($messages); error_reporting(-1); set_ini_entries(); $bootstrap = dirname(__FILE__, 2) . '/vendor/autoload.php'; if(!is_file($bootstrap)){ critical_error("Composer autoloader not found at " . $bootstrap); critical_error("Please install/update Composer dependencies or use provided builds."); exit(1); } require_once($bootstrap); $composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp'); if($composerGitHash !== null){ $currentGitHash = explode("-", VersionInfo::GIT_HASH(), 2)[0]; if($currentGitHash !== $composerGitHash){ critical_error("Composer dependencies and/or autoloader are out of sync."); critical_error("- Current revision is $currentGitHash"); critical_error("- Composer dependencies were last synchronized for revision $composerGitHash"); critical_error("Out-of-sync Composer dependencies may result in crashes and classes not being found."); critical_error("Please synchronize Composer dependencies before running the server."); exit(1); } } ErrorToExceptionHandler::set(); if(count(getopt("", [BootstrapOptions::VERSION])) > 0){ printf("%s %s (git hash %s) for Minecraft: Bedrock Edition %s\n", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true), VersionInfo::GIT_HASH(), ProtocolInfo::MINECRAFT_VERSION); exit(0); } if(defined('pocketmine\ORIGINAL_PHAR_PATH')){ Filesystem::addCleanedPath(ORIGINAL_PHAR_PATH, Filesystem::CLEAN_PATH_SRC_PREFIX); } $cwd = Utils::assumeNotFalse(realpath(Utils::assumeNotFalse(getcwd()))); $dataPath = getopt_string(BootstrapOptions::DATA) ?? $cwd; $pluginPath = getopt_string(BootstrapOptions::PLUGINS) ?? $cwd . DIRECTORY_SEPARATOR . "plugins"; Filesystem::addCleanedPath($pluginPath, Filesystem::CLEAN_PATH_PLUGINS_PREFIX); if(!@mkdir($dataPath, 0777, true) && !is_dir($dataPath)){ critical_error("Unable to create/access data directory at $dataPath. Check that the target location is accessible by the current user."); exit(1); } $dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR; $lockFilePath = Path::join($dataPath, 'server.lock'); try{ $pid = Filesystem::createLockFile($lockFilePath); }catch(InvalidArgumentException $e){ critical_error($e->getMessage()); critical_error("Please ensure that there is enough space on the disk and that the current user has read/write permissions to the selected data directory $dataPath."); exit(1); } if($pid !== null){ critical_error("Another " . VersionInfo::NAME . " instance (PID $pid) is already using this folder (" . realpath($dataPath) . ")."); critical_error("Please stop the other server first before running a new one."); exit(1); } if(!@mkdir($pluginPath, 0777, true) && !is_dir($pluginPath)){ critical_error("Unable to create plugin directory at $pluginPath. Check that the target location is accessible by the current user."); exit(1); } $pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR; Timezone::init(); } ``` -------------------------------- ### Getting Average Begin Frame Time (getAvgBeginFrameTimeMS) in PHP Source: https://apidoc.pmmp.io/d9/d0a/classpocketmine_1_1network_1_1mcpe_1_1protocol_1_1_serverbound_diagnostics_packet Details the `getAvgBeginFrameTimeMS` method of `ServerboundDiagnosticsPacket`, used to obtain the average time in milliseconds elapsed from the start of frame rendering until the beginning of the main rendering process. It returns a float. ```PHP getAvgBeginFrameTimeMS(); echo 'Average Begin Frame Time (ms): ' . $avgBeginFrame; ?> ``` -------------------------------- ### SetupWizard Class Constructor in PHP Source: https://apidoc.pmmp.io/d7/dde/classpocketmine_1_1wizard_1_1_setup_wizard Documents the constructor for the SetupWizard class in PHP. It is a private method that takes the server's data path as a string argument. This constructor is defined in the SetupWizard.php file. ```php /** * pocketmine\wizard\SetupWizard::__construct * * @param private string $dataPath */ public function __construct(private string $dataPath) ``` -------------------------------- ### Get Item Use Duration - PHP Source: https://apidoc.pmmp.io/d9/d76/_player_8php_source Calculates and returns the duration for which an item has been in use. If the player is not using an item, it returns -1. Otherwise, it returns the difference between the current server tick and the start of item usage. ```PHP public function getItemUseDuration() : int { return $this->startAction === -1 ? -1 : ($this->server->getTick() - $this->startAction); } ``` -------------------------------- ### Server Core Components Source: https://apidoc.pmmp.io/db/d8b/classpocketmine_1_1network_1_1mcpe_1_1protocol_1_1types_1_1recipe_1_1_furnace_recipe-members Documentation for core server components, including configuration, memory management, and timing. ```APIDOC ## Server Core Components ### Description This section details essential server components such as configuration handling, memory management, and timing utilities. ### Endpoints N/A (These are core components, not endpoints) ### Parameters N/A ### Request Example N/A ### Response N/A #### Core Component Classes - BootstrapOptions - GarbageCollectorManager - MemoryDump - MemoryManager - Server - ServerConfigGroup - ServerProperties - TimeTrackingSleeperHandler - VersionInfo - YmlServerProperties ``` -------------------------------- ### Get Item Representation (PHP) Source: https://apidoc.pmmp.io/df/d10/_cave_vines_8php_source This method returns an Item object representing the CaveVines block, specifically Glow Berries. This is used when the block itself is dropped, for example, due to the Silk Touch enchantment or when retrieving drops. ```php public function asItem() : Item{ return VanillaItems::GLOW_BERRIES(); } ``` -------------------------------- ### Get Region Entries as an Array Source: https://apidoc.pmmp.io/df/d90/_region_garbage_map_8php_source Returns the internal array of region entries. It sorts the entries numerically by their starting sector and merges adjacent entries if they form a contiguous block. This ensures a clean and optimized representation of the region map. ```PHP public function getArray() : array{ if(!$this->clean){ ksort($this->entries, SORT_NUMERIC); $prevIndex = null; foreach($this->entries as $k => $entry){ if($prevIndex !== null && $this->entries[$prevIndex]->getLastSector() + 1 === $entry->getFirstSector()){ //this SHOULD overwrite the previous index and not appear at the end $this->entries[$prevIndex] = new RegionLocationTableEntry( $this->entries[$prevIndex]->getFirstSector(), $this->entries[$prevIndex]->getSectorCount() + $entry->getSectorCount(), 0 ); unset($this->entries[$k]); }else{ $prevIndex = $k; } } $this->clean = true; } return $this->entries; } ``` -------------------------------- ### Utility and System Methods Source: https://apidoc.pmmp.io/functions_func_g General utility methods for configuration, timings, process information, and class loading. ```APIDOC ## GET /utils/system ### Description Access utility methods for system operations, including configuration, timings, and process management. ### Method GET ### Endpoint /utils/system ### Parameters None ### Request Example None ### Response #### Success Response (200) - **get** (pocketmine\utils\BinaryStream | pocketmine\errorhandler\ErrorTypeToStringMap | pocketmine\nbt\tag\ListTag | pocketmine\entity\effect\EffectCollection | pocketmine\world\generator\object\TreeFactory) - General getter method. - **getAll** (pocketmine\utils\Config | pocketmine\thread\ThreadManager | pocketmine\timings\TimingsRecord | pocketmine\lang\Language | pocketmine\block\VanillaBlocks | pocketmine\crafting\FurnaceRecipeManager | pocketmine\entity\AttributeMap | pocketmine\entity\effect\VanillaEffects | pocketmine\entity\object\PaintingMotive | pocketmine\event\HandlerListManager | pocketmine\inventory\CreativeInventory | pocketmine\item\enchantment\AvailableEnchantmentRegistry | pocketmine\item\enchantment\VanillaEnchantments | pocketmine\item\VanillaArmorMaterials | pocketmine\item\VanillaItems | pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection) - Retrieves all configurations, managers, or collections. - **getAdvancedMemoryUsage** (pocketmine\utils\Process) - Gets advanced memory usage information for the process. - **getAsyncTaskErrorTimings** (pocketmine\timings\Timings) - Retrieves timings for asynchronous task errors. - **getAndRemoveLookupEntries** (pocketmine\thread\ThreadSafeClassLoader) - Gets and removes lookup entries from the class loader. - **getAddress** (raklib\protocol\PacketSerializer | pocketmine\event\player\PlayerTransferEvent) - Retrieves address information. #### Response Example { "get": "pocketmine\\utils\\BinaryStream", "getAll": "pocketmine\\utils\\Config", "getAdvancedMemoryUsage": "pocketmine\\utils\\Process", "getAsyncTaskErrorTimings": "pocketmine\\timings\\Timings", "getAndRemoveLookupEntries": "pocketmine\\thread\\ThreadSafeClassLoader", "getAddress": "raklib\\protocol\\PacketSerializer" } ``` -------------------------------- ### Server Management Source: https://apidoc.pmmp.io/df/d59/classpocketmine_1_1world_1_1sound_1_1_barrel_open_sound-members Documentation for server configuration, memory management, and version information. ```APIDOC ## Server Management Documentation for server configuration, memory management, and version details. ### Classes: - **BootstrapOptions**: Options for server bootstrap process. - **GarbageCollectorManager**: Manages garbage collection. - **MemoryDump**: Represents a memory dump. - **MemoryManager**: Manages server memory. - **Server**: Represents the game server. - **ServerConfigGroup**: Groups server configuration settings. - **ServerProperties**: Stores server properties. - **TimeTrackingSleeperHandler**: Handles timing for server sleeping. - **VersionInfo**: Provides information about the server version. - **YmlServerProperties**: Server properties loaded from a YML file. ### Method N/A (List of classes) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Get Model Position Offset (PHP) Source: https://apidoc.pmmp.io/d9/dc4/classpocketmine_1_1block_1_1_item_frame Returns a fractional vector used to shift the block model's position, allowing for randomization of certain block appearances like bamboo. This method is inherited and reimplemented, for example, in the Bamboo block. ```php getModelPositionOffset(); // Example of accessing offset components (actual properties may vary) // echo "Model offset: X = ". $offset->getX() . ", Y = " . $offset->getY() . ", Z = " . $offset->getZ() . "\n"; ``` -------------------------------- ### Get Worker Entry Source: https://apidoc.pmmp.io/d9/d27/_async_pool_8php_source Retrieves the internal entry for a specific worker ID. If the worker does not exist, it initializes a new worker, sets up event loop notifiers, registers necessary class loaders, and executes any registered worker start hooks. ```php 124 private function getWorker(int $workerId) : AsyncPoolWorkerEntry{ 125 if(!isset($this->workers[$workerId])){ 126 $sleeperEntry = $this->eventLoop->addNotifier(function() use ($workerId) : void{ 127 $this->collectTasksFromWorker($workerId); 128 }); 129 $this->workers[$workerId] = new AsyncPoolWorkerEntry(new AsyncWorker($this->logger, $workerId, $this->workerMemoryLimit, $sleeperEntry), $sleeperEntry->getNotifierId()); 130 $this->workers[$workerId]->worker->setClassLoaders([$this->classLoader]); 131 $this->workers[$workerId]->worker->start(self::WORKER_START_OPTIONS); 132 133 foreach($this->workerStartHooks as $hook){ 134 $hook($workerId); 135 } 136 }else{ 137 $this->checkCrashedWorker($workerId, null); 138 } 139 140 return $this->workers[$workerId]; 141 } ``` -------------------------------- ### PacketHandler - setUp Source: https://apidoc.pmmp.io/d0/dda/classpocketmine_1_1network_1_1mcpe_1_1handler_1_1_spawn_response_packet_handler-members Initializes the PacketHandler, setting up necessary configurations. ```APIDOC ## POST /setUp ### Description Initializes the PacketHandler, setting up necessary configurations. ### Method POST ### Endpoint /setUp ### Parameters #### Request Body - **None** ### Request Example {} ### Response #### Success Response (200) - **status** (string) - Indicates the success of the setup operation. #### Response Example { "status": "setup_complete" } ``` -------------------------------- ### Instantiate Plugin (PHP) Source: https://apidoc.pmmp.io/db/d3b/_plugin_manager_8php_source This code illustrates the instantiation of a plugin class. It takes several arguments including the plugin loader, server instance, plugin description, data folder, prefix status, and a resource provider. This is a core part of the plugin loading mechanism. ```php $plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed, new DiskResourceProvider($prefixed . "/resources/")); $this->plugins[$plugin->getDescription()->getName()] = $plugin; ``` -------------------------------- ### Generate Miscellaneous Translatable Strings Source: https://apidoc.pmmp.io/d6/d12/_known_translation_factory_8php_source This snippet includes methods for generating Translatable strings for various other game elements and actions, such as server setup, installer skipping, and a specific record-now-playing function that accepts a parameter. They all rely on the Translatable class and KnownTranslationKeys. ```php public static function record_nowPlaying(Translatable|string $param0) : Translatable{ return new Translatable(KnownTranslationKeys::RECORD_NOWPLAYING, [ 0 => $param0, ]); } public static function setting_up_server_now() : Translatable{ return new Translatable(KnownTranslationKeys::SETTING_UP_SERVER_NOW, []); } public static function skip_installer() : Translatable{ return new Translatable(KnownTranslationKeys::SKIP_INSTALLER, []); } ``` -------------------------------- ### CraftingGrid Constructor Source: https://apidoc.pmmp.io/de/d7a/classpocketmine_1_1crafting_1_1_crafting_grid Initializes a new instance of the CraftingGrid class. ```APIDOC ## Constructor ### `__construct(private int $_gridWidth)` - **Description**: Constructs a new CraftingGrid instance. - **Parameters**: - `_gridWidth` (int) - The width of the crafting grid. ``` -------------------------------- ### Get Player by Name Prefix Source: https://apidoc.pmmp.io/d0/d05/src_2_server_8php_source Retrieves an online player whose name starts with the given prefix. It performs a case-insensitive comparison and returns the player with the closest name match if multiple players share the same prefix. Returns null if no matching player is found. ```php public function getPlayerByPrefix(string $name) : ?Player{ $found = null; $name = strtolower($name); $delta = PHP_INT_MAX; foreach($this->getOnlinePlayers() as $player){ if(stripos($player->getName(), $name) === 0){ $curDelta = strlen($player->getName()) - strlen($name); if($curDelta < $delta){ $found = $player; $delta = $curDelta; } if($curDelta === 0){ break; } } } return $found; ``` -------------------------------- ### Handle Block Post-Placement Event (PHP) Source: https://apidoc.pmmp.io/d0/dff/classpocketmine_1_1block_1_1_sea_pickle This method is invoked immediately after a block has been successfully placed in the world. It's useful for blocks that require post-placement initialization or setup that cannot be done during the block transaction itself. Base Rails, Base Signs, and Chests are examples of blocks that reimplement this. ```PHP /** * Called immediately after the block has been placed in the world. * Since placement uses a block transaction, some things may not be possible * until after the transaction has been executed. */ abstract public function onPostPlace(): void; ``` -------------------------------- ### PocketMine-MP Core Functionality - PHP Source: https://apidoc.pmmp.io/d0/d05/src_2_server_8php_source This PHP code snippet demonstrates the core initialization and setup of the PocketMine-MP server. It includes namespaces, use statements for various components like commands, entities, events, and network functionalities. This forms the foundation for server operations. ```php