Allow plugins to disable background generation (#2613)

This commit is contained in:
Frago9876543210 2018-12-28 17:34:54 +03:00 committed by Dylan T
parent 78a80a6958
commit f06e67a792

View File

@ -1048,10 +1048,11 @@ class Server{
* @param int|null $seed * @param int|null $seed
* @param string|null $generator Class name that extends pocketmine\level\generator\Generator * @param string|null $generator Class name that extends pocketmine\level\generator\Generator
* @param array $options * @param array $options
* @param bool $backgroundGeneration
* *
* @return bool * @return bool
*/ */
public function generateLevel(string $name, int $seed = null, $generator = null, array $options = []) : bool{ public function generateLevel(string $name, int $seed = null, $generator = null, array $options = [], bool $backgroundGeneration = true) : bool{
if(trim($name) === "" or $this->isLevelGenerated($name)){ if(trim($name) === "" or $this->isLevelGenerated($name)){
return false; return false;
} }
@ -1082,6 +1083,10 @@ class Server{
(new LevelLoadEvent($level))->call(); (new LevelLoadEvent($level))->call();
if(!$backgroundGeneration){
return true;
}
$this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name])); $this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
$spawnLocation = $level->getSpawnLocation(); $spawnLocation = $level->getSpawnLocation();