From f77446919f4b0d0f50a29e1200263d7479eb0ca8 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Fri, 18 Jul 2014 17:11:26 +0200 Subject: [PATCH] Can't use more function modifiers than necessary Fixes #2139 --- .../nossr50/events/fake/FakeEntityDamageByEntityEvent.java | 7 +++---- .../gmail/nossr50/events/fake/FakeEntityDamageEvent.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) 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 45af0a0bf..3907096c5 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java @@ -13,10 +13,9 @@ import com.google.common.base.Functions; * Called when mcMMO applies damage from an entity due to special abilities. */ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { - private static final EnumMap> functionModifiers = getFunctionModifiers(); public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map modifiers) { - super(damager, damagee, cause, modifiers, functionModifiers); + super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers)); } @Deprecated @@ -24,11 +23,11 @@ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { super(damager, damagee, cause, damage); } - public static EnumMap> getFunctionModifiers() { + public static EnumMap> getFunctionModifiers(Map modifiers) { EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); - for (DamageModifier modifier : DamageModifier.values()) { + for (DamageModifier modifier : modifiers.keySet()) { modifierFunctions.put(modifier, ZERO); } 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 c74afe443..16cb42a9c 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java @@ -13,10 +13,9 @@ import com.google.common.base.Functions; * Called when mcMMO applies damage due to special abilities. */ public class FakeEntityDamageEvent extends EntityDamageEvent { - private static final EnumMap> functionModifiers = getFunctionModifiers(); public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map modifiers) { - super(damagee, cause, modifiers, functionModifiers); + super(damagee, cause, modifiers, getFunctionModifiers(modifiers)); } @Deprecated @@ -24,11 +23,11 @@ public class FakeEntityDamageEvent extends EntityDamageEvent { super(damagee, cause, damage); } - public static EnumMap> getFunctionModifiers() { + public static EnumMap> getFunctionModifiers(Map modifiers) { EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); - for (DamageModifier modifier : DamageModifier.values()) { + for (DamageModifier modifier : modifiers.keySet()) { modifierFunctions.put(modifier, ZERO); }