Player: clean up refs when forced chunk unload is detected

this might happen because of a plugin, or low memory condition.
This commit is contained in:
Dylan K. Taylor 2020-10-13 18:17:12 +01:00
parent cc91cbd8c5
commit 3aca03d262

View File

@ -2348,6 +2348,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
use ChunkListenerNoOpTrait {
onChunkChanged as private;
onChunkUnloaded as private;
}
public function onChunkChanged(Chunk $chunk) : void{
@ -2356,4 +2357,11 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->nextChunkOrderRun = 0;
}
}
public function onChunkUnloaded(Chunk $chunk) : void{
if($this->isUsingChunk($chunk->getX(), $chunk->getZ())){
$this->logger->debug("Detected forced unload of chunk " . $chunk->getX() . " " . $chunk->getZ());
$this->unloadChunk($chunk->getX(), $chunk->getZ());
}
}
}