unloadChunk() public method

public unloadChunk ( integer $X, integer $Z, boolean $safe = true ) : boolean
$X integer
$Z integer
$safe boolean
return boolean
Beispiel #1
0
 public function doChunkGarbageCollection()
 {
     $this->timings->doChunkGC->startTiming();
     $X = null;
     $Z = null;
     foreach ($this->chunks as $index => $chunk) {
         if (!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or count($this->usedChunks[$index]) === 0)) {
             if (PHP_INT_SIZE === 8) {
                 $X = $index >> 32 << 32 >> 32;
                 $Z = ($index & 4294967295.0) << 32 >> 32;
             } else {
                 list($X, $Z) = explode(":", $index);
                 $X = (int) $X;
                 $Z = (int) $Z;
             }
             if (!$this->isSpawnChunk($X, $Z)) {
                 $this->unloadChunkRequest($X, $Z, true);
             }
         }
     }
     foreach ($this->provider->getLoadedChunks() as $chunk) {
         if (!isset($this->chunks[PHP_INT_SIZE === 8 ? ($chunk->getX() & 4294967295.0) << 32 | $chunk->getZ() & 4294967295.0 : $chunk->getX() . ":" . $chunk->getZ()])) {
             $this->provider->unloadChunk($chunk->getX(), $chunk->getZ(), false);
         }
     }
     $this->provider->doGarbageCollection();
     $this->timings->doChunkGC->stopTiming();
 }
Beispiel #2
0
 public function doChunkGarbageCollection()
 {
     $this->timings->doChunkGC->startTiming();
     $X = null;
     $Z = null;
     foreach ($this->chunks as $index => $chunk) {
         if (!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or count($this->usedChunks[$index]) === 0)) {
             Level::getXZ($index, $X, $Z);
             if (!$this->isSpawnChunk($X, $Z)) {
                 $this->unloadChunkRequest($X, $Z, true);
             }
         }
     }
     foreach ($this->provider->getLoadedChunks() as $chunk) {
         if (!isset($this->chunks[Level::chunkHash($chunk->getX(), $chunk->getZ())])) {
             $this->provider->unloadChunk($chunk->getX(), $chunk->getZ(), false);
         }
     }
     $this->provider->doGarbageCollection();
     $this->timings->doChunkGC->stopTiming();
 }
 public function doChunkGarbageCollection()
 {
     $this->timings->doChunkGC->startTiming();
     $X = \null;
     $Z = \null;
     foreach ($this->chunks as $index => $chunk) {
         if (!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or \count($this->usedChunks[$index]) === 0)) {
             $X = $index >> 32 << 32 >> 32;
             $Z = ($index & 0xffffffff) << 32 >> 32;
             if (!$this->isSpawnChunk($X, $Z)) {
                 $this->unloadChunkRequest($X, $Z, \true);
             }
         }
     }
     foreach ($this->provider->getLoadedChunks() as $chunk) {
         if (!isset($this->chunks[($chunk->getX() & 0xffffffff) << 32 | $chunk->getZ() & 0xffffffff])) {
             $this->provider->unloadChunk($chunk->getX(), $chunk->getZ(), \false);
         }
     }
     $this->provider->doGarbageCollection();
     $this->timings->doChunkGC->stopTiming();
 }
Beispiel #4
0
 public function unloadChunk($x, $z, $safe = true)
 {
     if ($safe === true and $this->isChunkInUse($x, $z)) {
         return false;
     }
     $index = "{$x}:{$z}";
     $chunk = $this->getChunkAt($x, $z);
     if ($chunk instanceof FullChunk) {
         $this->server->getPluginManager()->callEvent($ev = new ChunkUnloadEvent($chunk));
         if ($ev->isCancelled()) {
             return false;
         }
     }
     $this->timings->doChunkUnload->startTiming();
     if ($this->getAutoSave()) {
         if (isset($this->chunks[$index])) {
             $this->provider->setChunk($x, $z, $this->chunks[$index]);
         }
         $this->provider->saveChunk($x, $z);
     }
     unset($this->chunks[$index]);
     $this->provider->unloadChunk($x, $z, $safe);
     unset($this->usedChunks[$index]);
     Cache::remove("world:" . $this->getID() . ":{$x}:{$z}");
     $this->timings->doChunkUnload->stopTiming();
     return true;
 }
 public function doChunkGarbageCollection()
 {
     $this->timings->doChunkGC->startTiming();
     $X = \null;
     $Z = \null;
     foreach ($this->chunks as $index => $chunk) {
         if (!isset($this->unloadQueue[$index]) and (!isset($this->usedChunks[$index]) or \count($this->usedChunks[$index]) === 0)) {
             list($X, $Z) = \explode(":", $index);
             $X = (int) $X;
             $Z = (int) $Z;
             if (!$this->isSpawnChunk($X, $Z)) {
                 $this->unloadChunkRequest($X, $Z, \true);
             }
         }
     }
     foreach ($this->provider->getLoadedChunks() as $chunk) {
         if (!isset($this->chunks[$chunk->getX() . ":" . $chunk->getZ()])) {
             $this->provider->unloadChunk($chunk->getX(), $chunk->getZ(), \false);
         }
     }
     $this->provider->doGarbageCollection();
     $this->timings->doChunkGC->stopTiming();
 }