mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Level: __construct() now accepts a LevelProvider object instead of string, string
This is made possible by the removal of LevelProvider dependence on their Levels, and furthers the goal of #2024.
This commit is contained in:
@ -317,27 +317,18 @@ class Level implements ChunkManager, Metadatable{
|
||||
/**
|
||||
* Init the default level data
|
||||
*
|
||||
* @param Server $server
|
||||
* @param string $name
|
||||
* @param string $path
|
||||
* @param string $provider Class that extends LevelProvider
|
||||
*
|
||||
* @throws \Exception
|
||||
* @param Server $server
|
||||
* @param string $name
|
||||
* @param LevelProvider $provider
|
||||
*/
|
||||
public function __construct(Server $server, string $name, string $path, string $provider){
|
||||
public function __construct(Server $server, string $name, LevelProvider $provider){
|
||||
$this->blockStates = BlockFactory::getBlockStatesArray();
|
||||
$this->levelId = static::$levelIdCounter++;
|
||||
$this->blockMetadata = new BlockMetadataStore($this);
|
||||
$this->server = $server;
|
||||
$this->autoSave = $server->getAutoSave();
|
||||
|
||||
/** @var LevelProvider $provider */
|
||||
|
||||
if(is_subclass_of($provider, LevelProvider::class, true)){
|
||||
$this->provider = new $provider($path);
|
||||
}else{
|
||||
throw new LevelException("Provider is not a subclass of LevelProvider");
|
||||
}
|
||||
$this->provider = $provider;
|
||||
|
||||
$this->displayName = $this->provider->getName();
|
||||
$this->worldHeight = $this->provider->getWorldHeight();
|
||||
|
Reference in New Issue
Block a user