mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Throw exception on invalid parameters on Inventory addItem() and removeItem()
This commit is contained in:
parent
cf3f32fdae
commit
e5f28e0f7a
@ -236,6 +236,9 @@ abstract class BaseInventory implements Inventory{
|
||||
/** @var Item[] $slots */
|
||||
$itemSlots = [];
|
||||
foreach($slots as $slot){
|
||||
if(!($slot instanceof Item)){
|
||||
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
|
||||
}
|
||||
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
||||
$itemSlots[] = clone $slot;
|
||||
}
|
||||
@ -293,6 +296,9 @@ abstract class BaseInventory implements Inventory{
|
||||
/** @var Item[] $slots */
|
||||
$itemSlots = [];
|
||||
foreach($slots as $slot){
|
||||
if(!($slot instanceof Item)){
|
||||
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
|
||||
}
|
||||
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
||||
$itemSlots[] = clone $slot;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user