PocketMine-MP/src/world/format/io/WorldProvider.php
2020-12-03 21:59:30 +00:00

88 lines
2.5 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\world\format\io;
use pocketmine\world\format\Chunk;
use pocketmine\world\format\io\exception\CorruptedChunkException;
use pocketmine\world\format\io\exception\CorruptedWorldException;
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
interface WorldProvider{
/**
* @throws CorruptedWorldException
* @throws UnsupportedWorldFormatException
*/
public function __construct(string $path);
/**
* Gets the build height limit of this world
*/
public function getWorldHeight() : int;
public function getPath() : string;
/**
* Tells if the path is a valid world.
* This must tell if the current format supports opening the files in the directory
*/
public static function isValid(string $path) : bool;
/**
* Loads a chunk (usually from disk storage) and returns it. If the chunk does not exist, null is returned.
*
* @throws CorruptedChunkException
*/
public function loadChunk(int $chunkX, int $chunkZ) : ?Chunk;
/**
* Performs garbage collection in the world provider, such as cleaning up regions in Region-based worlds.
*/
public function doGarbageCollection() : void;
/**
* Returns information about the world
*/
public function getWorldData() : WorldData;
/**
* Performs cleanups necessary when the world provider is closed and no longer needed.
*/
public function close() : void;
/**
* Returns a generator which yields all the chunks in this world.
*
* @return \Generator|Chunk[]
* @phpstan-return \Generator<array{int, int}, Chunk, void, void>
* @throws CorruptedChunkException
*/
public function getAllChunks(bool $skipCorrupted = false, ?\Logger $logger = null) : \Generator;
/**
* Returns the number of chunks in the provider. Used for world conversion time estimations.
*/
public function calculateChunkCount() : int;
}