diff --git a/src/material/Item.php b/src/material/Item.php index 448c30c7..31c06148 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -247,20 +247,17 @@ class Item{ BOW => 385 //x3 ]; - if(($type = $this->getPickaxeLevel()) === false){ - if(($type = $this->isAxe()) === false){ - if(($type = $this->isSword()) === false){ - if(($type = $this->isShovel()) === false){ - if(($type = $this->isHoe()) === false){ - $type = $this->id; - } - } - } - } + if(($type = $this->getLevel()) === false){ + $type = $this->id; } return $levels[$type]; } - + + public function getLevel(){ + return false; + } + + //TODO remove? public function getPickaxeLevel(){ //Returns false or level of the pickaxe switch($this->id){ case WOODEN_PICKAXE: diff --git a/src/material/item/base/ItemAxe.php b/src/material/item/base/ItemAxe.php index be8d41f6..6bbc3060 100644 --- a/src/material/item/base/ItemAxe.php +++ b/src/material/item/base/ItemAxe.php @@ -6,6 +6,21 @@ abstract class ItemAxe extends ItemTool return true; } - + public function getLevel(){ + switch($this->id){ + case WOODEN_AXE: + return 1; + case GOLDEN_AXE: + return 2; + case STONE_AXE: + return 3; + case IRON_AXE: + return 4; + case DIAMOND_AXE: + return 5; + default: + return false; + } + } } diff --git a/src/material/item/base/ItemHoe.php b/src/material/item/base/ItemHoe.php index b9ea33be..b239b9cf 100644 --- a/src/material/item/base/ItemHoe.php +++ b/src/material/item/base/ItemHoe.php @@ -14,5 +14,22 @@ abstract class ItemHoe extends ItemTool return parent::useOn($object, $force); } } + + public function getLevel(){ + switch($this->id){ + case WOODEN_HOE: + return 1; + case GOLDEN_HOE: + return 2; + case STONE_HOE: + return 3; + case IRON_HOE: + return 4; + case DIAMOND_HOE: + return 5; + default: + return false; + } + } } diff --git a/src/material/item/base/ItemPickaxe.php b/src/material/item/base/ItemPickaxe.php index ad5c05ae..c501aa99 100644 --- a/src/material/item/base/ItemPickaxe.php +++ b/src/material/item/base/ItemPickaxe.php @@ -5,9 +5,26 @@ abstract class ItemPickaxe extends ItemTool public function isTool(){ return true; } - + public function isPickaxe(){ return true; } + + public function getLevel(){ + switch($this->id){ + case WOODEN_PICKAXE: + return 1; + case GOLDEN_PICKAXE: + return 2; + case STONE_PICKAXE: + return 3; + case IRON_PICKAXE: + return 4; + case DIAMOND_PICKAXE: + return 5; + default: + return false; + } + } } diff --git a/src/material/item/base/ItemShovel.php b/src/material/item/base/ItemShovel.php index 225f4fa3..08c20b8f 100644 --- a/src/material/item/base/ItemShovel.php +++ b/src/material/item/base/ItemShovel.php @@ -5,5 +5,22 @@ class ItemShovel extends ItemTool public function isShovel(){ return true; } + + public function getLevel(){ + switch($this->id){ + case WOODEN_SHOVEL: + return 1; + case GOLDEN_SHOVEL: + return 2; + case STONE_SHOVEL: + return 3; + case IRON_SHOVEL: + return 4; + case DIAMOND_SHOVEL: + return 5; + default: + return false; + } + } } diff --git a/src/material/item/base/ItemSword.php b/src/material/item/base/ItemSword.php index ab2ddc0a..37f54b4d 100644 --- a/src/material/item/base/ItemSword.php +++ b/src/material/item/base/ItemSword.php @@ -6,5 +6,22 @@ abstract class ItemSword extends ItemTool public function isSword(){ return true; } + + public function getLevel(){ + switch($this->id){ + case WOODEN_SWORD: + return 1; + case GOLDEN_SWORD: + return 2; + case STONE_SWORD: + return 3; + case IRON_SWORD: + return 4; + case DIAMOND_SWORD: + return 5; + default: + return false; + } + } }