diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java index 49395b13..357e1ee7 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java @@ -278,7 +278,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{ final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer); final boolean damagedIsDead = damaged.isDead(); if (damagedPlayer != null && !damagedIsDead) { - if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, event.getDamage(), damagedData)){ + if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, BridgeHealth.getDamage(event), damagedData)){ // It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0. damagedPlayer.setNoDamageTicks(0); } @@ -312,7 +312,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{ final Player player = (Player) damager; if (e.getCause() == DamageCause.ENTITY_ATTACK){ - if (handleNormalDamage(player, damaged, e.getDamage())){ + if (handleNormalDamage(player, damaged, BridgeHealth.getDamage(e))){ e.setCancelled(true); } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java index 3c820330..a5eda9a2 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java @@ -49,6 +49,7 @@ import fr.neatmonster.nocheatplus.checks.combined.BedLeave; import fr.neatmonster.nocheatplus.checks.combined.Combined; import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig; import fr.neatmonster.nocheatplus.checks.combined.CombinedData; +import fr.neatmonster.nocheatplus.compat.BridgeHealth; import fr.neatmonster.nocheatplus.components.IData; import fr.neatmonster.nocheatplus.components.IHaveCheckType; import fr.neatmonster.nocheatplus.components.INeedConfig; @@ -1199,7 +1200,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo parkedInfo.add(moveInfo); } final float fallDistance = player.getFallDistance(); - final double damage = event.getDamage(); + final double damage = BridgeHealth.getDamage(event); final float yDiff = (float) (data.noFallMaxY - loc.getY()); if (cc.debug){ System.out.println(player.getName() + " damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java index e0cbd7f1..48155476 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeHealth.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.Set; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import fr.neatmonster.nocheatplus.logging.LogUtil; @@ -65,6 +66,21 @@ public class BridgeHealth { } } + /** + * Get the damage from an EntityDamageEvent. + * @param event + * @return + * @throws RuntimeException, in case of an AbstractMethodError without success on recovery attempts. + */ + public static double getDamage(final EntityDamageEvent event){ + try{ + return event.getDamage(); + } + catch(AbstractMethodError e){ + return getDoubleOrInt(event, "getDamage", e); + } + } + /** * Get the health for an entity (LivingEntity). * @param entity