mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Level generators can be set in server.properties
This commit is contained in:
parent
d298adabad
commit
83eb9f778a
@ -1061,12 +1061,8 @@ class Server{
|
||||
if($generator !== null and class_exists($generator) and is_subclass_of($generator, "pocketmine\\level\\generator\\Generator")){
|
||||
$generator = new $generator($options);
|
||||
}else{
|
||||
if(strtoupper($this->getLevelType()) == "FLAT"){
|
||||
$generator = Generator::getGenerator("flat");
|
||||
$options["preset"] = $this->getConfigString("generator-settings", "");
|
||||
}else{
|
||||
$generator = Generator::getGenerator("normal");
|
||||
}
|
||||
$generator = Generator::getGenerator($this->getLevelType());
|
||||
}
|
||||
|
||||
if(($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null){
|
||||
@ -2051,6 +2047,8 @@ class Server{
|
||||
foreach($this->interfaces as $interface){
|
||||
$interface->process();
|
||||
}
|
||||
|
||||
|
||||
Timings::$connectionTimer->stopTiming();
|
||||
|
||||
Timings::$schedulerTimer->startTiming();
|
||||
|
@ -44,14 +44,13 @@ class GenerationChunkManager implements ChunkManager{
|
||||
protected $changes = [];
|
||||
|
||||
public function __construct(GenerationManager $manager, $levelID, $seed, $class, array $options){
|
||||
if(!is_subclass_of($class, "pocketmine\\level\\generator\\Generator")){
|
||||
throw new \Exception("Class is not a subclass of Generator");
|
||||
if(!class_exists($class, true) or !is_subclass_of($class, "pocketmine\\level\\generator\\Generator")){
|
||||
throw new \Exception("Class $class does not exists or is not a subclass of Generator");
|
||||
}
|
||||
|
||||
$this->levelID = $levelID;
|
||||
$this->seed = $seed;
|
||||
$this->manager = $manager;
|
||||
|
||||
$this->generator = new $class($options);
|
||||
$this->generator->init($this, new Random($seed));
|
||||
}
|
||||
@ -116,9 +115,11 @@ class GenerationChunkManager implements ChunkManager{
|
||||
}
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
try{
|
||||
$this->getChunk($chunkX, $chunkZ);
|
||||
$this->generator->generateChunk($chunkX, $chunkZ);
|
||||
$this->setChunkGenerated($chunkX, $chunkZ);
|
||||
}catch(\Exception $e){}
|
||||
}
|
||||
|
||||
public function populateChunk($chunkX, $chunkZ){
|
||||
|
@ -122,6 +122,7 @@ class GenerationManager{
|
||||
$chunkX = $chunkZ = null;
|
||||
|
||||
while($this->shutdown !== true){
|
||||
try{
|
||||
if(count($this->requestQueue) > 0){
|
||||
foreach($this->requestQueue as $levelID => $chunks){
|
||||
if(count($chunks) === 0){
|
||||
@ -135,6 +136,9 @@ class GenerationManager{
|
||||
}else{
|
||||
$this->readPacket();
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
$this->logger->warning("[Generator Thread] Exception: ".$e->getMessage() . " on file \"".$e->getFile()."\" line ".$e->getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user