public function unloadChunks(bool $force = false)
{
if (count($this->unloadQueue) > 0) {
$maxUnload = 96;
$now = microtime(true);
foreach ($this->unloadQueue as $index => $time) {
Level::getXZ($index, $X, $Z);
if (!$force) {
if ($maxUnload <= 0) {
break;
} elseif ($time > $now - 30) {
continue;
}
}
//If the chunk can't be unloaded, it stays on the queue
if ($this->unloadChunk($X, $Z, true)) {
unset($this->unloadQueue[$index]);
--$maxUnload;
}
}
}
}