From eca0e88471767f2ef503e768d99f0354f4253461 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 5 Dec 2020 01:11:30 +0000 Subject: [PATCH] BaseInventory: fixed passing NULL slots to InventoryListener->onContentChange() as per the documentation, InventoryListener->onContentChange() does not expect to receive NULL in the given array. --- src/inventory/BaseInventory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index 0e6a190de..70c03f2b0 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -27,6 +27,7 @@ use Ds\Set; use pocketmine\item\Item; use pocketmine\item\ItemFactory; use pocketmine\player\Player; +use function array_map; use function array_slice; use function count; use function max; @@ -95,7 +96,9 @@ abstract class BaseInventory implements Inventory{ $items = array_slice($items, 0, $this->getSize(), true); } - $oldContents = $this->slots->toArray(); + $oldContents = array_map(function(?Item $item) : Item{ + return $item ?? ItemFactory::air(); + }, $this->slots->toArray()); $listeners = $this->listeners->toArray(); $this->listeners->clear();