ChunkLoader is now a final class (#6730)

This commit is contained in:
Dylan T. 2025-06-11 21:02:31 +01:00 committed by GitHub
parent 950fb48bcb
commit 8229ee1812
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 6 deletions

View File

@ -342,7 +342,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->spawnThreshold = (int) (($this->server->getConfigGroup()->getPropertyInt(YmlServerProperties::CHUNK_SENDING_SPAWN_RADIUS, 4) ** 2) * M_PI);
$this->chunkSelector = new ChunkSelector();
$this->chunkLoader = new class implements ChunkLoader{};
$this->chunkLoader = new ChunkLoader();
$this->chunkTicker = new ChunkTicker();
$world = $spawnLocation->getWorld();
//load the spawn chunk so we can see the terrain

View File

@ -32,6 +32,6 @@ namespace pocketmine\world;
* WARNING: When moving this object around in the world or destroying it,
* be sure to unregister the loader from chunks you're not using, otherwise you'll leak memory.
*/
interface ChunkLoader{
final class ChunkLoader{
}

View File

@ -3321,7 +3321,7 @@ class World implements ChunkManager{
/** @phpstan-var PromiseResolver<Chunk> $resolver */
$resolver = $this->chunkPopulationRequestMap[$chunkHash] = new PromiseResolver();
if($associatedChunkLoader === null){
$temporaryLoader = new class implements ChunkLoader{};
$temporaryLoader = new ChunkLoader();
$this->registerChunkLoader($temporaryLoader, $chunkX, $chunkZ);
$resolver->getPromise()->onCompletion(
fn() => $this->unregisterChunkLoader($temporaryLoader, $chunkX, $chunkZ),
@ -3368,7 +3368,7 @@ class World implements ChunkManager{
return [$resolver, false];
}
$temporaryChunkLoader = new class implements ChunkLoader{};
$temporaryChunkLoader = new ChunkLoader();
$this->registerChunkLoader($temporaryChunkLoader, $chunkX, $chunkZ);
$chunk = $this->loadChunk($chunkX, $chunkZ);
$this->unregisterChunkLoader($temporaryChunkLoader, $chunkX, $chunkZ);
@ -3453,8 +3453,7 @@ class World implements ChunkManager{
$chunkPopulationLockId = new ChunkLockId();
$temporaryChunkLoader = new class implements ChunkLoader{
};
$temporaryChunkLoader = new ChunkLoader();
for($xx = -1; $xx <= 1; ++$xx){
for($zz = -1; $zz <= 1; ++$zz){
$this->lockChunk($chunkX + $xx, $chunkZ + $zz, $chunkPopulationLockId);