diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java index 3f66088fe..45af0a0bf 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java @@ -8,20 +8,30 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import com.google.common.base.Function; import com.google.common.base.Functions; -import com.google.common.collect.ImmutableMap; /** * Called when mcMMO applies damage from an entity due to special abilities. */ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { - private static final Function ZERO = Functions.constant(-0.0); + private static final EnumMap> functionModifiers = getFunctionModifiers(); public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map modifiers) { - super(damager, damagee, cause, modifiers, new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); + super(damager, damagee, cause, modifiers, functionModifiers); } @Deprecated public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) { super(damager, damagee, cause, damage); } + + public static EnumMap> getFunctionModifiers() { + EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + Function ZERO = Functions.constant(-0.0); + + for (DamageModifier modifier : DamageModifier.values()) { + modifierFunctions.put(modifier, ZERO); + } + + return modifierFunctions; + } } diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java index 0c3f89edb..c74afe443 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java @@ -8,20 +8,30 @@ import org.bukkit.event.entity.EntityDamageEvent; import com.google.common.base.Function; import com.google.common.base.Functions; -import com.google.common.collect.ImmutableMap; /** * Called when mcMMO applies damage due to special abilities. */ public class FakeEntityDamageEvent extends EntityDamageEvent { - private static final Function ZERO = Functions.constant(-0.0); + private static final EnumMap> functionModifiers = getFunctionModifiers(); public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map modifiers) { - super(damagee, cause, modifiers, new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); + super(damagee, cause, modifiers, functionModifiers); } @Deprecated public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) { super(damagee, cause, damage); } + + public static EnumMap> getFunctionModifiers() { + EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + Function ZERO = Functions.constant(-0.0); + + for (DamageModifier modifier : DamageModifier.values()) { + modifierFunctions.put(modifier, ZERO); + } + + return modifierFunctions; + } }