mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->dataPath . "/" . $name . "/";
|
$path = $this->getWorldPath($name);
|
||||||
|
|
||||||
$providers = WorldProviderManager::getMatchingProviders($path);
|
$providers = WorldProviderManager::getMatchingProviders($path);
|
||||||
if(count($providers) !== 1){
|
if(count($providers) !== 1){
|
||||||
@ -253,7 +253,7 @@ class WorldManager{
|
|||||||
|
|
||||||
$providerClass = WorldProviderManager::getDefault();
|
$providerClass = WorldProviderManager::getDefault();
|
||||||
|
|
||||||
$path = $this->dataPath . "/" . $name . "/";
|
$path = $this->getWorldPath($name);
|
||||||
/** @var WritableWorldProvider $providerClass */
|
/** @var WritableWorldProvider $providerClass */
|
||||||
$providerClass::generate($path, $name, $seed, $generator, $options);
|
$providerClass::generate($path, $name, $seed, $generator, $options);
|
||||||
|
|
||||||
@ -297,11 +297,15 @@ class WorldManager{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getWorldPath(string $name) : string{
|
||||||
|
return $this->dataPath . "/" . $name . "/";
|
||||||
|
}
|
||||||
|
|
||||||
public function isWorldGenerated(string $name) : bool{
|
public function isWorldGenerated(string $name) : bool{
|
||||||
if(trim($name) === ""){
|
if(trim($name) === ""){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$path = $this->dataPath . "/" . $name . "/";
|
$path = $this->getWorldPath($name);
|
||||||
if(!($this->getWorldByName($name) instanceof World)){
|
if(!($this->getWorldByName($name) instanceof World)){
|
||||||
return count(WorldProviderManager::getMatchingProviders($path)) > 0;
|
return count(WorldProviderManager::getMatchingProviders($path)) > 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user