Tweak a few more things with Salvage.

This commit is contained in:
GJ 2013-02-06 10:28:28 -05:00
parent 2799bab206
commit 7a0f8ea2dd
3 changed files with 60 additions and 28 deletions

View File

@ -27,7 +27,7 @@ Version 1.4.00-dev
+ Added methods to check if a player is in party or admin chat to the ChatAPI
+ Added /mcpurge functionality for Flatfile users
+ Added basic support for Mo' Creatures (and other entity mods) - specify mob info in entities.yml
+ Added Shears, Buckets, Fishing rods and Bows to the list of items that can be Salvaged
+ Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged
= Fixed multiple commands not working properly on offline players
= Fixed /mmoedit not giving feedback when modifying another players stats
= Fixed the guide usage string showing up every time /skillname was called

View File

@ -37,15 +37,13 @@ public class Salvage {
return;
}
final float currentdura = item.getDurability();
if (currentdura == 0) {
final int salvagedAmount = getSalvagedAmount(item);
final int itemID = getSalvagedItemID(item);
final float currentDurability = item.getDurability();
if (currentDurability == 0) {
player.setItemInHand(new ItemStack(Material.AIR));
location.setY(location.getY() + 1);
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
Misc.dropItems(location, new ItemStack(getSalvagedItem(item)), getSalvagedAmount(item));
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
@ -73,7 +71,8 @@ public class Salvage {
if (spoutPlayer.isSpoutCraftEnabled()) {
spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to salvage!", Material.getMaterial(anvilID));
}
} else {
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil2"));
}
@ -82,28 +81,58 @@ 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) || inHand.getType() == Material.BUCKET) salvagedItem = 265;
else if (ItemChecks.isStoneTool(inHand)) salvagedItem = 4;
else if (ItemChecks.isWoodTool(inHand)) salvagedItem = 5;
else if (ItemChecks.isLeatherArmor(inHand)) salvagedItem = 334;
else if (ItemChecks.isStringTool(inHand)) salvagedItem = 287;
return salvagedItem;
private static Material getSalvagedItem(final ItemStack inHand) {
if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) {
return Material.DIAMOND;
}
else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) {
return Material.GOLD_INGOT;
}
else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)) {
return Material.IRON_INGOT;
}
else if (ItemChecks.isStoneTool(inHand)) {
return Material.COBBLESTONE;
}
else if (ItemChecks.isWoodTool(inHand)) {
return Material.WOOD;
}
else if (ItemChecks.isLeatherArmor(inHand)) {
return Material.LEATHER;
}
else if (ItemChecks.isStringTool(inHand)) {
return Material.STRING;
}
else {
return null;
}
}
public static int getSalvagedAmount(final ItemStack inHand) {
int salvagedAmount = 0;
if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) salvagedAmount = 3;
else if (ItemChecks.isShovel(inHand)) salvagedAmount = 1;
else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) 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;
private static int getSalvagedAmount(final ItemStack inHand) {
if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
return 3;
}
else if (ItemChecks.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1;
}
else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
return 2;
}
else if (ItemChecks.isHelmet(inHand)) {
return 5;
}
else if (ItemChecks.isChestplate(inHand)) {
return 8;
}
else if (ItemChecks.isPants(inHand)) {
return 7;
}
else if (ItemChecks.isBoots(inHand)) {
return 4;
}
else {
return 0;
}
}
/**
* Checks if the item is salvageable.

View File

@ -392,6 +392,7 @@ public class ItemChecks {
public static boolean isStringTool(ItemStack is) {
switch (is.getType()) {
case BOW:
case CARROT_STICK:
case FISHING_ROD:
return true;
@ -429,6 +430,8 @@ public class ItemChecks {
*/
public static boolean isIronTool(ItemStack is) {
switch (is.getType()) {
case BUCKET:
case FLINT_AND_STEEL:
case IRON_AXE:
case IRON_HOE:
case IRON_PICKAXE: