mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 02:09:42 +00:00
Fixed entity visibility Player object memory leak, close #416
This commit is contained in:
parent
217f66e180
commit
2079e2fd88
@ -3100,6 +3100,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
foreach($this->usedChunks as $index => $d){
|
foreach($this->usedChunks as $index => $d){
|
||||||
Level::getXZ($index, $chunkX, $chunkZ);
|
Level::getXZ($index, $chunkX, $chunkZ);
|
||||||
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
|
$this->level->unregisterChunkLoader($this, $chunkX, $chunkZ);
|
||||||
|
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
|
||||||
|
$entity->despawnFrom($this, false);
|
||||||
|
}
|
||||||
unset($this->usedChunks[$index]);
|
unset($this->usedChunks[$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,11 +708,13 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
/**
|
/**
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function despawnFrom(Player $player){
|
public function despawnFrom(Player $player, bool $send = true){
|
||||||
if(isset($this->hasSpawned[$player->getLoaderId()])){
|
if(isset($this->hasSpawned[$player->getLoaderId()])){
|
||||||
|
if($send){
|
||||||
$pk = new RemoveEntityPacket();
|
$pk = new RemoveEntityPacket();
|
||||||
$pk->eid = $this->id;
|
$pk->eid = $this->id;
|
||||||
$player->dataPacket($pk);
|
$player->dataPacket($pk);
|
||||||
|
}
|
||||||
unset($this->hasSpawned[$player->getLoaderId()]);
|
unset($this->hasSpawned[$player->getLoaderId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user