mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-09 23:39:43 +00:00
don't spam listeners with slot-change notifications when doing a content change
This commit is contained in:
parent
c13b352b76
commit
04d0b6c054
@ -108,6 +108,9 @@ abstract class BaseInventory implements Inventory{
|
|||||||
$items = array_slice($items, 0, $this->getSize(), true);
|
$items = array_slice($items, 0, $this->getSize(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$listeners = $this->listeners;
|
||||||
|
$this->listeners = [];
|
||||||
|
|
||||||
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||||
if(!isset($items[$i])){
|
if(!isset($items[$i])){
|
||||||
if($this->slots[$i] !== null){
|
if($this->slots[$i] !== null){
|
||||||
@ -120,6 +123,8 @@ abstract class BaseInventory implements Inventory{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->addChangeListeners(...$listeners); //don't directly write, in case listeners were added while operation was in progress
|
||||||
|
|
||||||
foreach($this->listeners as $listener){
|
foreach($this->listeners as $listener){
|
||||||
$listener->onContentChange($this);
|
$listener->onContentChange($this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user