From 91d5a3ddfebbfb6824f5cb3faf3e55c6983a90cb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 10 Aug 2023 16:06:25 +0100 Subject: [PATCH] PotionCauldron: fixed setPotionItem() not validating the given item we should probably remove this API and have enums for potion container and type tbh... this API was a mistake --- src/block/PotionCauldron.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/block/PotionCauldron.php b/src/block/PotionCauldron.php index b8259fbc3..ca91664e4 100644 --- a/src/block/PotionCauldron.php +++ b/src/block/PotionCauldron.php @@ -63,6 +63,14 @@ final class PotionCauldron extends FillableCauldron{ /** @return $this */ public function setPotionItem(?Item $potionItem) : self{ + if($potionItem !== null && !match($potionItem->getTypeId()){ + ItemTypeIds::POTION, + ItemTypeIds::SPLASH_POTION, + ItemTypeIds::LINGERING_POTION => true, + default => false, + }){ + throw new \InvalidArgumentException("Item must be a POTION, SPLASH_POTION or LINGERING_POTION"); + } $this->potionItem = $potionItem !== null ? (clone $potionItem)->setCount(1) : null; return $this; }