mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
World::unregisterChunkListenerFromAll(): go through unregisterChunkListener()
this ensures that everything gets cleaned up properly (e.g. player chunk listeners).
This commit is contained in:
parent
3dc75644d9
commit
fbb91d123d
@ -731,14 +731,9 @@ class World implements ChunkManager{
|
|||||||
* Unregisters a chunk listener from all chunks it is listening on in this World.
|
* Unregisters a chunk listener from all chunks it is listening on in this World.
|
||||||
*/
|
*/
|
||||||
public function unregisterChunkListenerFromAll(ChunkListener $listener) : void{
|
public function unregisterChunkListenerFromAll(ChunkListener $listener) : void{
|
||||||
$id = spl_object_id($listener);
|
|
||||||
foreach($this->chunkListeners as $hash => $listeners){
|
foreach($this->chunkListeners as $hash => $listeners){
|
||||||
if(isset($listeners[$id])){
|
World::getXZ($hash, $chunkX, $chunkZ);
|
||||||
unset($this->chunkListeners[$hash][$id]);
|
$this->unregisterChunkListener($listener, $chunkX, $chunkZ);
|
||||||
if(count($this->chunkListeners[$hash]) === 0){
|
|
||||||
unset($this->chunkListeners[$hash]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user