Fixed crash on /stop

This commit is contained in:
Shoghi Cervantes 2014-07-14 14:41:19 +02:00
parent cb879977d2
commit 304524f6d8
2 changed files with 19 additions and 18 deletions

View File

@ -1643,7 +1643,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
]; ];
$damage = [ $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){ if($this->distance($target) > 8){

View File

@ -131,26 +131,27 @@ class Anvil extends BaseLevelProvider{
public function unloadChunk($x, $z, $safe = true){ public function unloadChunk($x, $z, $safe = true){
$chunk = $this->getChunk($x, $z, false); $chunk = $this->getChunk($x, $z, false);
if($safe === true and $this->isChunkLoaded($x, $z)){ if($chunk instanceof Chunk){
foreach($chunk->getEntities() as $entity){ if($safe === true and $this->isChunkLoaded($x, $z)){
if($entity instanceof Player){ foreach($chunk->getEntities() as $entity){
return false; 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; return true;
} }