From 58e9728710ff945dd7c5705a66668c95143463a2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 2 Aug 2019 16:17:04 +0100 Subject: [PATCH] Removing useless armour descendent classes, move armour slot to ArmorTypeInfo --- changelogs/4.0-snapshot.md | 4 ---- src/item/Armor.php | 6 ++++-- src/item/ArmorTypeInfo.php | 12 ++++++++++- src/item/Boots.php | 33 ------------------------------ src/item/Chestplate.php | 33 ------------------------------ src/item/Helmet.php | 33 ------------------------------ src/item/ItemFactory.php | 41 +++++++++++++++++++------------------- src/item/Leggings.php | 33 ------------------------------ src/item/VanillaItems.php | 40 ++++++++++++++++++------------------- 9 files changed, 56 insertions(+), 179 deletions(-) delete mode 100644 src/item/Boots.php delete mode 100644 src/item/Chestplate.php delete mode 100644 src/item/Helmet.php delete mode 100644 src/item/Leggings.php diff --git a/changelogs/4.0-snapshot.md b/changelogs/4.0-snapshot.md index 602f1d501..4299cf210 100644 --- a/changelogs/4.0-snapshot.md +++ b/changelogs/4.0-snapshot.md @@ -434,11 +434,7 @@ This version features substantial changes to the network system, improving coher - `Item::removeCreativeItem()` -> `CreativeInventory::remove()` - The following classes have been added: - `ArmorTypeInfo` - - `Boots` - - `Chestplate` - `Fertilizer` - - `Helmet` - - `Leggings` - `LiquidBucket` - `MilkBucket` - `WritableBookBase` diff --git a/src/item/Armor.php b/src/item/Armor.php index afd880e04..d2b5759ea 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -38,7 +38,7 @@ use pocketmine\utils\Color; use function lcg_value; use function mt_rand; -abstract class Armor extends Durable{ +class Armor extends Durable{ public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int @@ -65,7 +65,9 @@ abstract class Armor extends Durable{ * @see ArmorInventory * @return int */ - abstract public function getArmorSlot() : int; + public function getArmorSlot() : int{ + return $this->armorInfo->getArmorSlot(); + } public function getMaxStackSize() : int{ return 1; diff --git a/src/item/ArmorTypeInfo.php b/src/item/ArmorTypeInfo.php index 9a89a0c5d..172a590b8 100644 --- a/src/item/ArmorTypeInfo.php +++ b/src/item/ArmorTypeInfo.php @@ -29,10 +29,13 @@ class ArmorTypeInfo{ private $defensePoints; /** @var int */ private $maxDurability; + /** @var int */ + private $armorSlot; - public function __construct(int $defensePoints, int $maxDurability){ + public function __construct(int $defensePoints, int $maxDurability, int $armorSlot){ $this->defensePoints = $defensePoints; $this->maxDurability = $maxDurability; + $this->armorSlot = $armorSlot; } /** @@ -48,4 +51,11 @@ class ArmorTypeInfo{ public function getMaxDurability() : int{ return $this->maxDurability; } + + /** + * @return int + */ + public function getArmorSlot() : int{ + return $this->armorSlot; + } } diff --git a/src/item/Boots.php b/src/item/Boots.php deleted file mode 100644 index 13753328d..000000000 --- a/src/item/Boots.php +++ /dev/null @@ -1,33 +0,0 @@ -