Moved Salvage check to ItemChecks

This commit is contained in:
TfT_02 2012-11-13 22:17:34 +01:00
parent a582b07549
commit ff279bf633
2 changed files with 128 additions and 128 deletions

View File

@ -36,8 +36,8 @@ public class Salvage {
final float currentdura = inHand.getDurability(); final float currentdura = inHand.getDurability();
if (currentdura == 0) { if (currentdura == 0) {
final int salvagedAmount = getSalvagedAmount(inHand); final int salvagedAmount = ItemChecks.getSalvagedAmount(inHand);
final int itemID = getSalvagedItemID(inHand); final int itemID = ItemChecks.getSalvagedItemID(inHand);
player.setItemInHand(new ItemStack(0)); player.setItemInHand(new ItemStack(0));
location.setY(location.getY() + 1); 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. * Handles notifications for placing an anvil.
* *

View File

@ -474,4 +474,130 @@ public class ItemChecks {
public static boolean isEnchantable(ItemStack is) { public static boolean isEnchantable(ItemStack is) {
return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW); 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;
}
} }