From 3495c79c0cd334944d936af7e01ed911dcbd855f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 9 Aug 2014 10:42:03 +0200 Subject: [PATCH] Fixed crashes related to ChunkEvent --- src/pocketmine/level/Level.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index a3af82c6f..ba7f0620b 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -1300,9 +1300,11 @@ class Level implements ChunkManager, Metadatable{ $oldChunk = $this->getChunkAt($x, $z); unset($this->chunkGenerationQueue["$x:$z"]); $this->setChunk($x, $z, $chunk); - - if(!($oldChunk instanceof FullChunk) or ($oldChunk->isPopulated() === false and $chunk->isPopulated())){ - $this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this->getChunkAt($x, $z))); + $chunk = $this->getChunkAt($x, $z); + if($chunk instanceof FullChunk){ + if(!($oldChunk instanceof FullChunk) or ($oldChunk->isPopulated() === false and $chunk->isPopulated())){ + $this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk)); + } } } @@ -1569,9 +1571,13 @@ class Level implements ChunkManager, Metadatable{ return false; } - $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($this->getChunkAt($x, $z))); - if($ev->isCancelled()){ - return false; + $chunk = $this->getChunkAt($x, $z); + + if($chunk instanceof FullChunk){ + $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk)); + if($ev->isCancelled()){ + return false; + } } $this->timings->doChunkUnload->startTiming();