Can't use more function modifiers than necessary

Fixes #2139
This commit is contained in:
TfT_02 2014-07-18 17:11:26 +02:00
parent 96fdf265d5
commit f77446919f
2 changed files with 6 additions and 8 deletions

View File

@ -13,10 +13,9 @@ import com.google.common.base.Functions;
* Called when mcMMO applies damage from an entity due to special abilities. * Called when mcMMO applies damage from an entity due to special abilities.
*/ */
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
private static final EnumMap<DamageModifier, Function<? super Double, Double>> functionModifiers = getFunctionModifiers();
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) { public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damager, damagee, cause, modifiers, functionModifiers); super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
} }
@Deprecated @Deprecated
@ -24,11 +23,11 @@ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
super(damager, damagee, cause, damage); super(damager, damagee, cause, damage);
} }
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers() { public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class); EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
Function<? super Double, Double> ZERO = Functions.constant(-0.0); Function<? super Double, Double> ZERO = Functions.constant(-0.0);
for (DamageModifier modifier : DamageModifier.values()) { for (DamageModifier modifier : modifiers.keySet()) {
modifierFunctions.put(modifier, ZERO); modifierFunctions.put(modifier, ZERO);
} }

View File

@ -13,10 +13,9 @@ import com.google.common.base.Functions;
* Called when mcMMO applies damage due to special abilities. * Called when mcMMO applies damage due to special abilities.
*/ */
public class FakeEntityDamageEvent extends EntityDamageEvent { public class FakeEntityDamageEvent extends EntityDamageEvent {
private static final EnumMap<DamageModifier, Function<? super Double, Double>> functionModifiers = getFunctionModifiers();
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) { public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damagee, cause, modifiers, functionModifiers); super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
} }
@Deprecated @Deprecated
@ -24,11 +23,11 @@ public class FakeEntityDamageEvent extends EntityDamageEvent {
super(damagee, cause, damage); super(damagee, cause, damage);
} }
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers() { public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class); EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
Function<? super Double, Double> ZERO = Functions.constant(-0.0); Function<? super Double, Double> ZERO = Functions.constant(-0.0);
for (DamageModifier modifier : DamageModifier.values()) { for (DamageModifier modifier : modifiers.keySet()) {
modifierFunctions.put(modifier, ZERO); modifierFunctions.put(modifier, ZERO);
} }