Check inventory slot is in range in SlotChangeAction

This commit is contained in:
Dylan K. Taylor 2017-11-28 16:56:02 +00:00
parent 88318d740a
commit 98ac6fc7be

View File

@ -75,8 +75,11 @@ class SlotChangeAction extends InventoryAction{
* @return bool
*/
public function isValid(Player $source) : bool{
$check = $this->inventory->getItem($this->inventorySlot);
return $check->equalsExact($this->sourceItem);
return (
$this->inventorySlot >= 0 and
$this->inventorySlot < $this->inventory->getSize() and
$this->inventory->getItem($this->inventorySlot)->equalsExact($this->sourceItem)
);
}
/**