NetworkSession: Fixed InventoryManager nullability disaster

fixes #4277
fixes #4275
fixes #3139
This commit is contained in:
Dylan K. Taylor
2021-06-26 17:44:42 +01:00
parent e43bca95bf
commit 0910054c41
8 changed files with 74 additions and 48 deletions

View File

@ -136,7 +136,11 @@ abstract class BaseInventory implements Inventory{
$listener->onSlotChange($this, $index, $before);
}
foreach($this->viewers as $viewer){
$viewer->getNetworkSession()->getInvManager()->syncSlot($this, $index);
$invManager = $viewer->getNetworkSession()->getInvManager();
if($invManager === null){
continue;
}
$invManager->syncSlot($this, $index);
}
}
@ -150,7 +154,11 @@ abstract class BaseInventory implements Inventory{
}
foreach($this->getViewers() as $viewer){
$viewer->getNetworkSession()->getInvManager()->syncContents($this);
$invManager = $viewer->getNetworkSession()->getInvManager();
if($invManager === null){
continue;
}
$invManager->syncContents($this);
}
}