Fixed bug where non-default generators are ignored in pocketmine\Server.php #2751

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@alejandroliu
Contributor

Setting FLAT on server.properties or pocketmine.yml does not work, i.e. it is ignored by LevelProvider::generator.

The issue is that Server.php will create a new $generator instance, while LevelProvide::generate expects a string with the class name and an options array.

@alejandroliu alejandroliu Fixed $generator so that Non default generator works
d965a44
@alejandroliu alejandroliu changed the title from PR:BugFix Fixed bug where non-default generators are ignored to Fixed bug where non-default generators are ignored in pocketmine\Server.php Mar 10, 2015
@alejandroliu
Contributor

The issue is that Server.php in line 1,143, it is creating a new $generator instance which is then used to call the selected LevelProvider::generate in line 1,156. The signature for LevelProvider::generate is:

 * Generate the needed files in the path given
 *
 * @param string  $path
 * @param string  $name
 * @param int     $seed
 * @param string  $generator
 * @param array[] $options
 */
public static function generate($path, $name, $seed, $generator, array $options = []);

So $generator shouldn't be a class instance but a string. Indeed McRegion::generate does:

 "generatorName" => new String("generatorName", Generator::getGeneratorName($generator))

Which uses Generator::getGeneratorName which takes a string containing a full class name.

@shoghicp shoghicp added a commit that closed this pull request Mar 17, 2015
@shoghicp shoghicp Changed generator choosing logic, add proper preset if needed, fixes #… 7c76c1e
@shoghicp shoghicp closed this in 7c76c1e Mar 17, 2015
@alejandroliu alejandroliu deleted the unknown repository branch Mar 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment