diff --git a/src/Server.php b/src/Server.php index ab75f901c..e691f5411 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1018,7 +1018,7 @@ class Server{ } GeneratorManager::registerDefaultGenerators(); - $this->worldManager = new WorldManager($this); + $this->worldManager = new WorldManager($this, $this->dataPath . "/worlds"); $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "update.pmmp.io")); diff --git a/src/world/WorldManager.php b/src/world/WorldManager.php index dd9853b1f..c504494fb 100644 --- a/src/world/WorldManager.php +++ b/src/world/WorldManager.php @@ -53,6 +53,9 @@ use function sprintf; use function trim; class WorldManager{ + /** @var string */ + private $dataPath; + /** @var World[] */ private $worlds = []; /** @var World|null */ @@ -69,8 +72,9 @@ class WorldManager{ /** @var int */ private $autoSaveTicker = 0; - public function __construct(Server $server){ + public function __construct(Server $server, string $dataPath){ $this->server = $server; + $this->dataPath = $dataPath; $this->autoSave = $this->server->getConfigBool("auto-save", $this->autoSave); $this->autoSaveTicks = (int) $this->server->getProperty("ticks-per.autosave", 6000); @@ -176,7 +180,7 @@ class WorldManager{ return false; } - $path = $this->server->getDataPath() . "worlds/" . $name . "/"; + $path = $this->dataPath . "/" . $name . "/"; $providers = WorldProviderManager::getMatchingProviders($path); if(count($providers) !== 1){ @@ -252,7 +256,7 @@ class WorldManager{ $providerClass = WorldProviderManager::getDefault(); - $path = $this->server->getDataPath() . "worlds/" . $name . "/"; + $path = $this->dataPath . "/" . $name . "/"; /** @var WritableWorldProvider $providerClass */ $providerClass::generate($path, $name, $seed, $generator, $options); @@ -300,7 +304,7 @@ class WorldManager{ if(trim($name) === ""){ return false; } - $path = $this->server->getDataPath() . "worlds/" . $name . "/"; + $path = $this->dataPath . "/" . $name . "/"; if(!($this->getWorldByName($name) instanceof World)){ return count(WorldProviderManager::getMatchingProviders($path)) > 0; }