From 8e3320ad72070a601d05a8babc1889aa3b2b3ec6 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 13 Nov 2012 22:28:56 +0100 Subject: [PATCH] Hehe, you were soo right. This is MUCH cleaner to look at. :) --- .../gmail/nossr50/skills/repair/Salvage.java | 26 +++- .../com/gmail/nossr50/util/ItemChecks.java | 126 ------------------ 2 files changed, 24 insertions(+), 128 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index 7a973e267..e67ae5ea7 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -36,8 +36,8 @@ public class Salvage { final float currentdura = inHand.getDurability(); if (currentdura == 0) { - final int salvagedAmount = ItemChecks.getSalvagedAmount(inHand); - final int itemID = ItemChecks.getSalvagedItemID(inHand); + final int salvagedAmount = getSalvagedAmount(inHand); + final int itemID = getSalvagedItemID(inHand); player.setItemInHand(new ItemStack(0)); location.setY(location.getY() + 1); @@ -75,6 +75,28 @@ public class Salvage { } } + public static int getSalvagedItemID(final ItemStack inHand) { + int salvagedItem = 0; + if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) { salvagedItem = 264; } + else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) { salvagedItem = 266; } + else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)){ salvagedItem = 265; } + else if (ItemChecks.isStoneTool(inHand)){ salvagedItem = 4; } + else if (ItemChecks.isWoodTool(inHand)){ salvagedItem = 5; } + else if ( ItemChecks.isLeatherArmor(inHand)){ salvagedItem = 334; } + return salvagedItem; + } + + public static int getSalvagedAmount(final ItemStack inHand) { + int salvagedAmount = 0; + if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand)) { salvagedAmount = 3; } + else if (ItemChecks.isShovel(inHand)) { salvagedAmount = 1; } + else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand)) { salvagedAmount = 2; } + else if (ItemChecks.isHelmet(inHand)) { salvagedAmount = 5; } + else if (ItemChecks.isChestplate(inHand)) { salvagedAmount = 8; } + else if (ItemChecks.isPants(inHand)) { salvagedAmount = 7; } + else if (ItemChecks.isBoots(inHand)) { salvagedAmount = 4; } + return salvagedAmount; + } /** * Checks if the item is salvageable. * diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 715088e74..3e195b922 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -474,130 +474,4 @@ public class ItemChecks { public static boolean isEnchantable(ItemStack is) { return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW); } - - public static int getSalvagedItemID(final ItemStack inHand) { - int salvagedItem = 0; - switch (inHand.getType()) { - case DIAMOND_PICKAXE: - case DIAMOND_SPADE: - case DIAMOND_AXE: - case DIAMOND_SWORD: - case DIAMOND_HOE: - case DIAMOND_HELMET: - case DIAMOND_CHESTPLATE: - case DIAMOND_LEGGINGS: - case DIAMOND_BOOTS: - salvagedItem = 264; - break; - case GOLD_PICKAXE: - case GOLD_SPADE: - case GOLD_AXE: - case GOLD_SWORD: - case GOLD_HOE: - case GOLD_HELMET: - case GOLD_CHESTPLATE: - case GOLD_LEGGINGS: - case GOLD_BOOTS: - salvagedItem = 266; - break; - case IRON_PICKAXE: - case IRON_SPADE: - case IRON_AXE: - case IRON_SWORD: - case IRON_HOE: - case IRON_HELMET: - case IRON_CHESTPLATE: - case IRON_LEGGINGS: - case IRON_BOOTS: - salvagedItem = 265; - break; - case STONE_PICKAXE: - case STONE_SPADE: - case STONE_AXE: - case STONE_SWORD: - case STONE_HOE: - salvagedItem = 4; - break; - case WOOD_PICKAXE: - case WOOD_SPADE: - case WOOD_AXE: - case WOOD_SWORD: - case WOOD_HOE: - salvagedItem = 5; - break; - case LEATHER_HELMET: - case LEATHER_CHESTPLATE: - case LEATHER_LEGGINGS: - case LEATHER_BOOTS: - salvagedItem = 334; - break; - default: - break; - } - return salvagedItem; - } - - public static int getSalvagedAmount(final ItemStack inHand) { - int salvagedAmount = 0; - switch (inHand.getType()) { - case DIAMOND_PICKAXE: - case GOLD_PICKAXE: - case IRON_PICKAXE: - case STONE_PICKAXE: - case WOOD_PICKAXE: - case DIAMOND_AXE: - case GOLD_AXE: - case IRON_AXE: - case STONE_AXE: - case WOOD_AXE: - salvagedAmount = 3; - break; - case DIAMOND_SPADE: - case GOLD_SPADE: - case IRON_SPADE: - case STONE_SPADE: - case WOOD_SPADE: - salvagedAmount = 1; - break; - case DIAMOND_SWORD: - case GOLD_SWORD: - case IRON_SWORD: - case STONE_SWORD: - case WOOD_SWORD: - case DIAMOND_HOE: - case GOLD_HOE: - case IRON_HOE: - case STONE_HOE: - case WOOD_HOE: - salvagedAmount = 2; - break; - case DIAMOND_HELMET: - case GOLD_HELMET: - case IRON_HELMET: - case LEATHER_HELMET: - salvagedAmount = 5; - break; - case DIAMOND_CHESTPLATE: - case GOLD_CHESTPLATE: - case IRON_CHESTPLATE: - case LEATHER_CHESTPLATE: - salvagedAmount = 8; - break; - case DIAMOND_LEGGINGS: - case GOLD_LEGGINGS: - case IRON_LEGGINGS: - case LEATHER_LEGGINGS: - salvagedAmount = 7; - break; - case DIAMOND_BOOTS: - case GOLD_BOOTS: - case IRON_BOOTS: - case LEATHER_BOOTS: - salvagedAmount = 4; - break; - default: - break; - } - return salvagedAmount; - } }