From e2232dd8d494836f93ffaa610cdd58a1ba6ddee3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 23 May 2020 09:50:25 +0100 Subject: [PATCH] WorldManager: reduce code duplication for world path discovery --- src/world/WorldManager.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/world/WorldManager.php b/src/world/WorldManager.php index 6d0689a38..5aa991ceb 100644 --- a/src/world/WorldManager.php +++ b/src/world/WorldManager.php @@ -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; }