Hehe, you were soo right. This is MUCH cleaner to look at. :)

This commit is contained in:
TfT_02 2012-11-13 22:28:56 +01:00
parent ff279bf633
commit 8e3320ad72
2 changed files with 24 additions and 128 deletions

View File

@ -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.
*

View File

@ -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;
}
}