mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Added worlds directive to pocketmine.yml to load extra worlds or use a plugin-provided generator
This commit is contained in:
parent
d10274ca7c
commit
26ec562fbf
@ -1034,7 +1034,7 @@ class Server{
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function generateLevel($name, $seed = null, $generator = null, array $options = []){
|
||||
public function generateLevel($name, $seed = null, $generator = null, $options = []){
|
||||
if(trim($name) === "" or $this->isLevelGenerated($name)){
|
||||
return false;
|
||||
}
|
||||
@ -1509,6 +1509,23 @@ class Server{
|
||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal");
|
||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default");
|
||||
|
||||
foreach($this->getProperty("worlds", []) as $name => $worldSetting){
|
||||
if($this->loadLevel($name) === false){
|
||||
$seed = $this->getProperty("worlds.$name.seed", time());
|
||||
$options = explode(":", $this->getProperty("worlds.$name.generator", Generator::getGenerator("default")));
|
||||
$generator = Generator::getGenerator(array_shift($options));
|
||||
if(count($options) > 0){
|
||||
$options = [
|
||||
"preset" => implode(":", $options),
|
||||
];
|
||||
}else{
|
||||
$options = [];
|
||||
}
|
||||
|
||||
$this->generateLevel($name, $seed, $generator, $options);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getDefaultLevel() === null){
|
||||
$default = $this->getConfigString("level-name", "world");
|
||||
if(trim($default) == ""){
|
||||
|
@ -30,7 +30,7 @@ abstract class Generator{
|
||||
private static $list = [];
|
||||
|
||||
public static function addGenerator($object, $name){
|
||||
if(is_subclass_of($object, "pocketmine\\level\\generator\\Generator") and !isset(Generator::$list[$name])){
|
||||
if(is_subclass_of($object, "pocketmine\\level\\generator\\Generator") and !isset(Generator::$list[$name = strtolower($name)])){
|
||||
Generator::$list[$name] = $object;
|
||||
|
||||
return true;
|
||||
@ -40,7 +40,7 @@ abstract class Generator{
|
||||
}
|
||||
|
||||
public static function getGenerator($name){
|
||||
if(isset(Generator::$list[$name])){
|
||||
if(isset(Generator::$list[$name = strtolower($name)])){
|
||||
return Generator::$list[$name];
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,13 @@ auto-updater:
|
||||
host: www.pocketmine.net
|
||||
|
||||
aliases:
|
||||
#Examples
|
||||
#Examples:
|
||||
#showtheversion: version
|
||||
#savestop: [save-all, stop]
|
||||
#savestop: [save-all, stop]
|
||||
|
||||
worlds:
|
||||
#These settings will override the generator set in server.properties and allows loading multiple levels
|
||||
#Example:
|
||||
#world:
|
||||
# seed: 404
|
||||
# generator: FLAT:2;7,59x1,3x3,2;1;decoration(treecount=80 grasscount=45)
|
Loading…
x
Reference in New Issue
Block a user