mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
WorldManager: allow dataPath to be injected via constructor
This commit is contained in:
parent
6257f717b1
commit
fcea7da183
@ -1018,7 +1018,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
GeneratorManager::registerDefaultGenerators();
|
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"));
|
$this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "update.pmmp.io"));
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ use function sprintf;
|
|||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
class WorldManager{
|
class WorldManager{
|
||||||
|
/** @var string */
|
||||||
|
private $dataPath;
|
||||||
|
|
||||||
/** @var World[] */
|
/** @var World[] */
|
||||||
private $worlds = [];
|
private $worlds = [];
|
||||||
/** @var World|null */
|
/** @var World|null */
|
||||||
@ -69,8 +72,9 @@ class WorldManager{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $autoSaveTicker = 0;
|
private $autoSaveTicker = 0;
|
||||||
|
|
||||||
public function __construct(Server $server){
|
public function __construct(Server $server, string $dataPath){
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
$this->dataPath = $dataPath;
|
||||||
|
|
||||||
$this->autoSave = $this->server->getConfigBool("auto-save", $this->autoSave);
|
$this->autoSave = $this->server->getConfigBool("auto-save", $this->autoSave);
|
||||||
$this->autoSaveTicks = (int) $this->server->getProperty("ticks-per.autosave", 6000);
|
$this->autoSaveTicks = (int) $this->server->getProperty("ticks-per.autosave", 6000);
|
||||||
@ -176,7 +180,7 @@ class WorldManager{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->server->getDataPath() . "worlds/" . $name . "/";
|
$path = $this->dataPath . "/" . $name . "/";
|
||||||
|
|
||||||
$providers = WorldProviderManager::getMatchingProviders($path);
|
$providers = WorldProviderManager::getMatchingProviders($path);
|
||||||
if(count($providers) !== 1){
|
if(count($providers) !== 1){
|
||||||
@ -252,7 +256,7 @@ class WorldManager{
|
|||||||
|
|
||||||
$providerClass = WorldProviderManager::getDefault();
|
$providerClass = WorldProviderManager::getDefault();
|
||||||
|
|
||||||
$path = $this->server->getDataPath() . "worlds/" . $name . "/";
|
$path = $this->dataPath . "/" . $name . "/";
|
||||||
/** @var WritableWorldProvider $providerClass */
|
/** @var WritableWorldProvider $providerClass */
|
||||||
$providerClass::generate($path, $name, $seed, $generator, $options);
|
$providerClass::generate($path, $name, $seed, $generator, $options);
|
||||||
|
|
||||||
@ -300,7 +304,7 @@ class WorldManager{
|
|||||||
if(trim($name) === ""){
|
if(trim($name) === ""){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$path = $this->server->getDataPath() . "worlds/" . $name . "/";
|
$path = $this->dataPath . "/" . $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