if (skillLevel < minimumRepairableLevel) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", minimumRepairableLevel, StringUtils.getPrettyItemString(item.getType())));
return;
}
PlayerInventory inventory = player.getInventory();
Material repairMaterial = repairable.getRepairMaterial();
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
short startDurability = item.getDurability();
// Do not repair if at full durability
if (startDurability <= 0) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
return;
}
// Check if they have the proper material to repair with
if (!inventory.contains(repairMaterial)) {
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
String message = LocaleLoader.getString("Skills.NeedMore", prettyName);
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
message += ":" + repairMaterialMetadata;
}
player.sendMessage(message);
return;
}
// Do not repair stacked items
if (item.getAmount() != 1) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
return;
}
// Clear ability buffs before trying to repair.
SkillUtils.removeAbilityBuff(item);
// Lets get down to business,
// To defeat, the huns.
int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters?
short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?
// Call event
if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
return;
}
// Handle the enchants
if (ArcaneForging.arcaneForgingEnchantLoss) {
addEnchants(item);
}
// Remove the item
if (repairMaterialMetadata == -1) {
toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
toRemove.setAmount(1);
}
inventory.removeItem(toRemove);
// Give out XP like candy
applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE);
// BWONG BWONG BWONG