CallbackInventoryListener: fix crash when any of the callbacks isn't provided

This commit is contained in:
Dylan K. Taylor 2020-05-03 21:48:32 +01:00
parent 6e6fffa461
commit f34753c496

View File

@ -72,13 +72,17 @@ class CallbackInventoryListener implements InventoryListener{
}
public function onSlotChange(Inventory $inventory, int $slot, Item $oldItem) : void{
($this->onSlotChangeCallback)($inventory, $slot, $oldItem);
if($this->onSlotChangeCallback !== null){
($this->onSlotChangeCallback)($inventory, $slot, $oldItem);
}
}
/**
* @param Item[] $oldContents
*/
public function onContentChange(Inventory $inventory, array $oldContents) : void{
($this->onContentChangeCallback)($inventory, $oldContents);
if($this->onContentChangeCallback !== null){
($this->onContentChangeCallback)($inventory, $oldContents);
}
}
}