validators->add(new CallbackSlotValidator(self::validate(...))); } public function getHolder() : Living{ return $this->holder; } public function getHelmet() : Item{ return $this->getItem(self::SLOT_HEAD); } public function getChestplate() : Item{ return $this->getItem(self::SLOT_CHEST); } public function getLeggings() : Item{ return $this->getItem(self::SLOT_LEGS); } public function getBoots() : Item{ return $this->getItem(self::SLOT_FEET); } public function setHelmet(Item $helmet) : void{ $this->setItem(self::SLOT_HEAD, $helmet); } public function setChestplate(Item $chestplate) : void{ $this->setItem(self::SLOT_CHEST, $chestplate); } public function setLeggings(Item $leggings) : void{ $this->setItem(self::SLOT_LEGS, $leggings); } public function setBoots(Item $boots) : void{ $this->setItem(self::SLOT_FEET, $boots); } private static function validate(Inventory $inventory, Item $item, int $slot) : ?TransactionValidationException{ if($item instanceof Armor){ if($item->getArmorSlot() !== $slot){ return new TransactionValidationException("Armor item is in wrong slot"); } }else{ if(!($slot === ArmorInventory::SLOT_HEAD && $item instanceof ItemBlock && ( $item->getBlock()->getTypeId() === BlockTypeIds::CARVED_PUMPKIN || $item->getBlock()->getTypeId() === BlockTypeIds::MOB_HEAD ))){ return new TransactionValidationException("Item is not accepted in an armor slot"); } } return null; } }