diff --git a/src/pocketmine/item/Armor.php b/src/pocketmine/item/Armor.php index e5852f163..8b2d641b9 100644 --- a/src/pocketmine/item/Armor.php +++ b/src/pocketmine/item/Armor.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace pocketmine\item; use pocketmine\event\entity\EntityDamageEvent; +use pocketmine\inventory\ArmorInventory; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\ProtectionEnchantment; use pocketmine\nbt\tag\IntTag; @@ -37,6 +38,28 @@ abstract class Armor extends Durable{ public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int + /** @var ArmorTypeInfo */ + private $armorInfo; + + public function __construct(int $id, int $variant, string $name, ArmorTypeInfo $info){ + parent::__construct($id, $variant, $name); + $this->armorInfo = $info; + } + + public function getMaxDurability() : int{ + return $this->armorInfo->getMaxDurability(); + } + + public function getDefensePoints() : int{ + return $this->armorInfo->getDefensePoints(); + } + + /** + * @see ArmorInventory + * @return int + */ + abstract public function getArmorSlot() : int; + public function getMaxStackSize() : int{ return 1; } diff --git a/src/pocketmine/item/ChainBoots.php b/src/pocketmine/item/ArmorTypeInfo.php similarity index 69% rename from src/pocketmine/item/ChainBoots.php rename to src/pocketmine/item/ArmorTypeInfo.php index 904891773..9a89a0c5d 100644 --- a/src/pocketmine/item/ChainBoots.php +++ b/src/pocketmine/item/ArmorTypeInfo.php @@ -23,17 +23,29 @@ declare(strict_types=1); namespace pocketmine\item; +class ArmorTypeInfo{ -class ChainBoots extends Armor{ - public function __construct(){ - parent::__construct(self::CHAIN_BOOTS, 0, "Chainmail Boots"); + /** @var int */ + private $defensePoints; + /** @var int */ + private $maxDurability; + + public function __construct(int $defensePoints, int $maxDurability){ + $this->defensePoints = $defensePoints; + $this->maxDurability = $maxDurability; } + /** + * @return int + */ public function getDefensePoints() : int{ - return 1; + return $this->defensePoints; } + /** + * @return int + */ public function getMaxDurability() : int{ - return 196; + return $this->maxDurability; } } diff --git a/src/pocketmine/item/GoldBoots.php b/src/pocketmine/item/Boots.php similarity index 76% rename from src/pocketmine/item/GoldBoots.php rename to src/pocketmine/item/Boots.php index 038639fa3..13753328d 100644 --- a/src/pocketmine/item/GoldBoots.php +++ b/src/pocketmine/item/Boots.php @@ -23,17 +23,11 @@ declare(strict_types=1); namespace pocketmine\item; +use pocketmine\inventory\ArmorInventory; -class GoldBoots extends Armor{ - public function __construct(){ - parent::__construct(self::GOLD_BOOTS, 0, "Gold Boots"); - } +class Boots extends Armor{ - public function getDefensePoints() : int{ - return 1; - } - - public function getMaxDurability() : int{ - return 92; + public function getArmorSlot() : int{ + return ArmorInventory::SLOT_FEET; } } diff --git a/src/pocketmine/item/ChainChestplate.php b/src/pocketmine/item/ChainChestplate.php deleted file mode 100644 index 0e1f90a1b..000000000 --- a/src/pocketmine/item/ChainChestplate.php +++ /dev/null @@ -1,39 +0,0 @@ -