Minor cleanup

This commit is contained in:
TfT_02 2013-02-06 15:29:21 +01:00
parent ba4d0451ff
commit 2799bab206

View File

@ -23,7 +23,7 @@ public class Salvage {
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel(); public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
public static int anvilID = Config.getInstance().getSalvageAnvilId(); public static int anvilID = Config.getInstance().getSalvageAnvilId();
public static void handleSalvage(final Player player, final Location location, final ItemStack inHand) { public static void handleSalvage(final Player player, final Location location, final ItemStack item) {
if (!configInstance.getSalvageEnabled()) { if (!configInstance.getSalvageEnabled()) {
return; return;
} }
@ -32,28 +32,29 @@ public class Salvage {
final int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR); final int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
final int unlockLevel = configInstance.getSalvageUnlockLevel(); final int unlockLevel = configInstance.getSalvageUnlockLevel();
if (skillLevel >= unlockLevel) { if (skillLevel < unlockLevel) {
final float currentdura = inHand.getDurability(); player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
return;
}
if (currentdura == 0) { final float currentdura = item.getDurability();
final int salvagedAmount = getSalvagedAmount(inHand);
final int itemID = getSalvagedItemID(inHand);
player.setItemInHand(new ItemStack(Material.AIR)); if (currentdura == 0) {
location.setY(location.getY() + 1); final int salvagedAmount = getSalvagedAmount(item);
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount)); final int itemID = getSalvagedItemID(item);
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); player.setItemInHand(new ItemStack(Material.AIR));
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess")); location.setY(location.getY() + 1);
} Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability")); player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
} player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage")); player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
} }
} }
} }
/** /**