Check vanilla's maxDurability here as well, just to be safe.

Fixes #1504
This commit is contained in:
GJ 2013-10-02 08:55:56 -04:00
parent 2e2abcd645
commit a0ef0d5708

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.axes; package com.gmail.nossr50.skills.axes;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -97,9 +98,10 @@ public class AxesManager extends SkillManager {
for (ItemStack armor : target.getEquipment().getArmorContents()) { for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) { if (ItemUtils.isArmor(armor) && Axes.impactChance > Misc.getRandom().nextInt(getActivationChance())) {
Material armorType = armor.getType();
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier; double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
short maxDurability = mcMMO.getRepairableManager().getRepairable(armor.getType()).getMaximumDurability(); short maxDurability = (short) Math.max(armorType.getMaxDurability(), mcMMO.getRepairableManager().getRepairable(armorType).getMaximumDurability());
double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier; double maxDurabilityDamage = maxDurability * Axes.impactMaxDurabilityModifier;
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability())); armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));