mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Level: add unregisterChunkListenerFromAll()
it's not expected for chunk listeners to have to track all the chunks they are listening to under normal circumstances.
This commit is contained in:
parent
f9da0f3ece
commit
fd4a441f3a
@ -713,6 +713,23 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters a chunk listener from all chunks it is listening on in this Level.
|
||||||
|
*
|
||||||
|
* @param ChunkListener $listener
|
||||||
|
*/
|
||||||
|
public function unregisterChunkListenerFromAll(ChunkListener $listener) : void{
|
||||||
|
$id = spl_object_id($listener);
|
||||||
|
foreach($this->chunkListeners as $hash => $listeners){
|
||||||
|
if(isset($listeners[$id])){
|
||||||
|
unset($this->chunkListeners[$hash][$id]);
|
||||||
|
if(empty($this->chunkListeners[$hash])){
|
||||||
|
unset($this->chunkListeners[$hash]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the listeners attached to this chunk.
|
* Returns all the listeners attached to this chunk.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user