mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Use deprecated events for damage dealing for now
This commit is contained in:
parent
d2d70089ca
commit
8e3e1d5f11
@ -1,18 +1,23 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
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 {
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers, final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
|
||||
super(damager, damagee, cause, modifiers, modifierFunctions);
|
||||
private static final Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -1,18 +1,23 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
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 {
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers, final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
|
||||
super(damagee, cause, modifiers, modifierFunctions);
|
||||
private static final Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -602,7 +602,14 @@ public final class CombatUtils {
|
||||
|
||||
@Deprecated
|
||||
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
|
||||
return callFakeDamageEvent(attacker, target, damageCause, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
|
||||
if (damageEvent.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return damageEvent.getFinalDamage();
|
||||
}
|
||||
|
||||
public static double callFakeDamageEvent(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) {
|
||||
@ -614,7 +621,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
|
||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers, null) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers, null);
|
||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
|
||||
if (damageEvent.isCancelled()) {
|
||||
|
Loading…
Reference in New Issue
Block a user