mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
WorldManager: reduce code duplication for world path discovery
This commit is contained in:
parent
8d9759288c
commit
e2232dd8d4
@ -177,7 +177,7 @@ class WorldManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = $this->dataPath . "/" . $name . "/";
|
||||
$path = $this->getWorldPath($name);
|
||||
|
||||
$providers = WorldProviderManager::getMatchingProviders($path);
|
||||
if(count($providers) !== 1){
|
||||
@ -253,7 +253,7 @@ class WorldManager{
|
||||
|
||||
$providerClass = WorldProviderManager::getDefault();
|
||||
|
||||
$path = $this->dataPath . "/" . $name . "/";
|
||||
$path = $this->getWorldPath($name);
|
||||
/** @var WritableWorldProvider $providerClass */
|
||||
$providerClass::generate($path, $name, $seed, $generator, $options);
|
||||
|
||||
@ -297,11 +297,15 @@ class WorldManager{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function getWorldPath(string $name) : string{
|
||||
return $this->dataPath . "/" . $name . "/";
|
||||
}
|
||||
|
||||
public function isWorldGenerated(string $name) : bool{
|
||||
if(trim($name) === ""){
|
||||
return false;
|
||||
}
|
||||
$path = $this->dataPath . "/" . $name . "/";
|
||||
$path = $this->getWorldPath($name);
|
||||
if(!($this->getWorldByName($name) instanceof World)){
|
||||
return count(WorldProviderManager::getMatchingProviders($path)) > 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user