mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
WorldCreationOptions are now mandatory during creation of worlds
This commit is contained in:
parent
203cc7fcef
commit
7b21fc8e9d
@ -244,7 +244,7 @@ class WorldManager{
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function generateWorld(string $name, ?WorldCreationOptions $options = null, bool $backgroundGeneration = true) : bool{
|
public function generateWorld(string $name, WorldCreationOptions $options, bool $backgroundGeneration = true) : bool{
|
||||||
if(trim($name) === "" or $this->isWorldGenerated($name)){
|
if(trim($name) === "" or $this->isWorldGenerated($name)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ interface WritableWorldProvider extends WorldProvider{
|
|||||||
/**
|
/**
|
||||||
* Generate the needed files in the path given
|
* Generate the needed files in the path given
|
||||||
*/
|
*/
|
||||||
public static function generate(string $path, string $name, ?WorldCreationOptions $options = null) : void;
|
public static function generate(string $path, string $name, WorldCreationOptions $options) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a chunk (usually to disk).
|
* Saves a chunk (usually to disk).
|
||||||
|
@ -53,8 +53,7 @@ class BedrockWorldData extends BaseNbtWorldData{
|
|||||||
public const GENERATOR_INFINITE = 1;
|
public const GENERATOR_INFINITE = 1;
|
||||||
public const GENERATOR_FLAT = 2;
|
public const GENERATOR_FLAT = 2;
|
||||||
|
|
||||||
public static function generate(string $path, string $name, ?WorldCreationOptions $options = null) : void{
|
public static function generate(string $path, string $name, WorldCreationOptions $options) : void{
|
||||||
$options ??= WorldCreationOptions::create();
|
|
||||||
switch($options->getGeneratorClass()){
|
switch($options->getGeneratorClass()){
|
||||||
case Flat::class:
|
case Flat::class:
|
||||||
$generatorType = self::GENERATOR_FLAT;
|
$generatorType = self::GENERATOR_FLAT;
|
||||||
|
@ -43,10 +43,9 @@ use const ZLIB_ENCODING_GZIP;
|
|||||||
|
|
||||||
class JavaWorldData extends BaseNbtWorldData{
|
class JavaWorldData extends BaseNbtWorldData{
|
||||||
|
|
||||||
public static function generate(string $path, string $name, ?WorldCreationOptions $options = null, int $version = 19133) : void{
|
public static function generate(string $path, string $name, WorldCreationOptions $options, int $version = 19133) : void{
|
||||||
//TODO, add extra details
|
//TODO, add extra details
|
||||||
|
|
||||||
$options ??= WorldCreationOptions::create();
|
|
||||||
$worldData = CompoundTag::create()
|
$worldData = CompoundTag::create()
|
||||||
->setByte("hardcore", 0)
|
->setByte("hardcore", 0)
|
||||||
->setByte("Difficulty", $options->getDifficulty())
|
->setByte("Difficulty", $options->getDifficulty())
|
||||||
|
@ -143,7 +143,7 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
|
|||||||
return file_exists($path . "/level.dat") and is_dir($path . "/db/");
|
return file_exists($path . "/level.dat") and is_dir($path . "/db/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generate(string $path, string $name, ?WorldCreationOptions $options = null) : void{
|
public static function generate(string $path, string $name, WorldCreationOptions $options) : void{
|
||||||
self::checkForLevelDBExtension();
|
self::checkForLevelDBExtension();
|
||||||
|
|
||||||
if(!file_exists($path . "/db")){
|
if(!file_exists($path . "/db")){
|
||||||
|
@ -74,7 +74,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generate(string $path, string $name, ?WorldCreationOptions $options = null) : void{
|
public static function generate(string $path, string $name, WorldCreationOptions $options) : void{
|
||||||
if(!file_exists($path)){
|
if(!file_exists($path)){
|
||||||
mkdir($path, 0777, true);
|
mkdir($path, 0777, true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user