From ff279bf63388788c0d6f684a4a2f6b5af212c80e Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 13 Nov 2012 22:17:34 +0100 Subject: [PATCH] Moved Salvage check to ItemChecks --- .../gmail/nossr50/skills/repair/Salvage.java | 130 +----------------- .../com/gmail/nossr50/util/ItemChecks.java | 126 +++++++++++++++++ 2 files changed, 128 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 2ab52d136..7a973e267 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 = getSalvagedAmount(inHand); - final int itemID = getSalvagedItemID(inHand); + final int salvagedAmount = ItemChecks.getSalvagedAmount(inHand); + final int itemID = ItemChecks.getSalvagedItemID(inHand); player.setItemInHand(new ItemStack(0)); location.setY(location.getY() + 1); @@ -51,132 +51,6 @@ public class Salvage { } } - 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; - } - /** * Handles notifications for placing an anvil. * diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 3e195b922..715088e74 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -474,4 +474,130 @@ 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; + } }