mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 04:00:29 +00:00
Inventory: reduce API duplication by using a Set for viewers
This commit is contained in:
@@ -221,8 +221,8 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
|
||||
$inventoryTag = $nbt->getListTag("Inventory");
|
||||
if($inventoryTag !== null){
|
||||
$armorListeners = $this->armorInventory->getListeners();
|
||||
$this->armorInventory->removeListeners(...$armorListeners);
|
||||
$armorListeners = $this->armorInventory->getListeners()->toArray();
|
||||
$this->armorInventory->getListeners()->clear();
|
||||
|
||||
/** @var CompoundTag $item */
|
||||
foreach($inventoryTag as $i => $item){
|
||||
@@ -236,7 +236,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
$this->armorInventory->addListeners(...$armorListeners);
|
||||
$this->armorInventory->getListeners()->add(...$armorListeners);
|
||||
}
|
||||
|
||||
$enderChestInventoryTag = $nbt->getListTag("EnderChestInventory");
|
||||
|
@@ -110,7 +110,7 @@ abstract class Living extends Entity{
|
||||
|
||||
$this->armorInventory = new ArmorInventory($this);
|
||||
//TODO: load/save armor inventory contents
|
||||
$this->armorInventory->addListeners(CallbackInventoryListener::onAnyChange(
|
||||
$this->armorInventory->getListeners()->add(CallbackInventoryListener::onAnyChange(
|
||||
function(Inventory $unused) : void{
|
||||
foreach($this->getViewers() as $viewer){
|
||||
$viewer->getNetworkSession()->onMobArmorChange($this);
|
||||
|
Reference in New Issue
Block a user