mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
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
This commit is contained in:
parent
f03e708f64
commit
91d5a3ddfe
@ -63,6 +63,14 @@ final class PotionCauldron extends FillableCauldron{
|
|||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function setPotionItem(?Item $potionItem) : self{
|
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;
|
$this->potionItem = $potionItem !== null ? (clone $potionItem)->setCount(1) : null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user