mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 10:57:47 +01:00
Use a utility for getting the damage of damage-events as well.
This commit is contained in:
parent
9edfb14103
commit
4035719597
@ -278,7 +278,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
|
final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
|
||||||
final boolean damagedIsDead = damaged.isDead();
|
final boolean damagedIsDead = damaged.isDead();
|
||||||
if (damagedPlayer != null && !damagedIsDead) {
|
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.
|
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
||||||
damagedPlayer.setNoDamageTicks(0);
|
damagedPlayer.setNoDamageTicks(0);
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
final Player player = (Player) damager;
|
final Player player = (Player) damager;
|
||||||
if (e.getCause() == DamageCause.ENTITY_ATTACK){
|
if (e.getCause() == DamageCause.ENTITY_ATTACK){
|
||||||
|
|
||||||
if (handleNormalDamage(player, damaged, e.getDamage())){
|
if (handleNormalDamage(player, damaged, BridgeHealth.getDamage(e))){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ import fr.neatmonster.nocheatplus.checks.combined.BedLeave;
|
|||||||
import fr.neatmonster.nocheatplus.checks.combined.Combined;
|
import fr.neatmonster.nocheatplus.checks.combined.Combined;
|
||||||
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
|
import fr.neatmonster.nocheatplus.checks.combined.CombinedConfig;
|
||||||
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
||||||
import fr.neatmonster.nocheatplus.components.IData;
|
import fr.neatmonster.nocheatplus.components.IData;
|
||||||
import fr.neatmonster.nocheatplus.components.IHaveCheckType;
|
import fr.neatmonster.nocheatplus.components.IHaveCheckType;
|
||||||
import fr.neatmonster.nocheatplus.components.INeedConfig;
|
import fr.neatmonster.nocheatplus.components.INeedConfig;
|
||||||
@ -1199,7 +1200,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
parkedInfo.add(moveInfo);
|
parkedInfo.add(moveInfo);
|
||||||
}
|
}
|
||||||
final float fallDistance = player.getFallDistance();
|
final float fallDistance = player.getFallDistance();
|
||||||
final double damage = event.getDamage();
|
final double damage = BridgeHealth.getDamage(event);
|
||||||
final float yDiff = (float) (data.noFallMaxY - loc.getY());
|
final float yDiff = (float) (data.noFallMaxY - loc.getY());
|
||||||
if (cc.debug){
|
if (cc.debug){
|
||||||
System.out.println(player.getName() + " damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff);
|
System.out.println(player.getName() + " damage(FALL): " + damage + " / dist=" + player.getFallDistance() + " nf=" + data.noFallFallDistance + " yDiff=" + yDiff);
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
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).
|
* Get the health for an entity (LivingEntity).
|
||||||
* @param entity
|
* @param entity
|
||||||
|
Loading…
Reference in New Issue
Block a user