Make protection enchantments actually protect wearer from damage (Fixes PC-311)

This commit is contained in:
AlexTheCoder 2016-06-28 22:31:08 -04:00 committed by cnr
parent 36bb0b9ae8
commit 9c4b787436

View File

@ -282,25 +282,25 @@ public class DamageManager extends MiniPlugin
for (Enchantment e : enchants.keySet())
{
if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL))
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
event.AddMod("Ench Prot", damagee.getName(), -0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FIRE) &&
event.GetCause() == DamageCause.FIRE &&
event.GetCause() == DamageCause.FIRE_TICK &&
event.GetCause() == DamageCause.LAVA)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
event.AddMod("Ench Prot", damagee.getName(), -0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_FALL) &&
event.GetCause() == DamageCause.FALL)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
event.AddMod("Ench Prot", damagee.getName(), -0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) &&
event.GetCause() == DamageCause.ENTITY_EXPLOSION)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
event.AddMod("Ench Prot", damagee.getName(), -0.5 * (double)enchants.get(e), false);
else if (e.equals(Enchantment.PROTECTION_PROJECTILE) &&
event.GetCause() == DamageCause.PROJECTILE)
event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false);
event.AddMod("Ench Prot", damagee.getName(), -0.5 * (double)enchants.get(e), false);
}
}
}