From 304524f6d80b77b2261cea704126ea117c053b08 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 14 Jul 2014 14:41:19 +0200 Subject: [PATCH] Fixed crash on /stop --- src/pocketmine/Player.php | 2 +- src/pocketmine/level/format/anvil/Anvil.php | 35 +++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 7947e7c52..d85ae1a66 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1643,7 +1643,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ ]; $damage = [ - EntityDamageByEntityEvent::MODIFIER_BASE => isset($damageTable[$item->getID()]) ? $damageTable[$item->getID()] : 1, + EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getID()]) ? $damageTable[$item->getID()] : 1, ]; if($this->distance($target) > 8){ diff --git a/src/pocketmine/level/format/anvil/Anvil.php b/src/pocketmine/level/format/anvil/Anvil.php index f866c6c96..9754d2a38 100644 --- a/src/pocketmine/level/format/anvil/Anvil.php +++ b/src/pocketmine/level/format/anvil/Anvil.php @@ -131,26 +131,27 @@ class Anvil extends BaseLevelProvider{ public function unloadChunk($x, $z, $safe = true){ $chunk = $this->getChunk($x, $z, false); - if($safe === true and $this->isChunkLoaded($x, $z)){ - foreach($chunk->getEntities() as $entity){ - if($entity instanceof Player){ - return false; + if($chunk instanceof Chunk){ + if($safe === true and $this->isChunkLoaded($x, $z)){ + foreach($chunk->getEntities() as $entity){ + if($entity instanceof Player){ + return false; + } } } + + foreach($chunk->getEntities() as $entity){ + $entity->close(); + } + + foreach($chunk->getTiles() as $tile){ + $tile->close(); + } + + $this->chunks[$index = Level::chunkHash($x, $z)] = null; + + unset($this->chunks[$index]); } - - foreach($chunk->getEntities() as $entity){ - $entity->close(); - } - - foreach($chunk->getTiles() as $tile){ - $tile->close(); - } - - $this->chunks[$index = Level::chunkHash($x, $z)] = null; - - unset($this->chunks[$index]); - return true; }