WorldCreationOptions are now mandatory during creation of worlds

This commit is contained in:
Dylan K. Taylor 2021-04-15 13:54:58 +01:00
parent 203cc7fcef
commit 7b21fc8e9d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
6 changed files with 6 additions and 8 deletions

View File

@ -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;
} }

View File

@ -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).

View File

@ -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;

View File

@ -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())

View File

@ -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")){

View File

@ -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);
} }