mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 08:09:39 +01:00
Add a modifier function for each DamageModifier
Must have a modifier function for each DamageModifier Fixes #2139
This commit is contained in:
parent
6b9f6c29ec
commit
d93c83f775
@ -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<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
private static final EnumMap<DamageModifier, Function<? super Double, Double>> functionModifiers = getFunctionModifiers();
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
super(damager, damagee, cause, modifiers, new EnumMap<DamageModifier, Function<? super Double, Double>>(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<DamageModifier, Function<? super Double, Double>> getFunctionModifiers() {
|
||||
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);
|
||||
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
@ -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<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
private static final EnumMap<DamageModifier, Function<? super Double, Double>> functionModifiers = getFunctionModifiers();
|
||||
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
super(damagee, cause, modifiers, new EnumMap<DamageModifier, Function<? super Double, Double>>(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<DamageModifier, Function<? super Double, Double>> getFunctionModifiers() {
|
||||
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);
|
||||
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user