mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-05 03:31:09 +02:00
Fix last damage-tick by entity attack being reset while dead, renamings.
This commit is contained in:
parent
53756f7145
commit
333cffd0d5
|
@ -79,7 +79,7 @@ public class FightData extends ACheckData {
|
|||
public double reachVL;
|
||||
public double speedVL;
|
||||
|
||||
public long damageTakenTick;
|
||||
public long damageTakenByEntityTick;
|
||||
|
||||
// Shared
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ public class FightListener extends CheckListener {
|
|||
// Check for self hit exploits (mind that projectiles should be excluded)
|
||||
if (damaged instanceof Player){
|
||||
final Player damagedPlayer = (Player) damaged;
|
||||
if (cc.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
|
||||
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());
|
||||
}
|
||||
if (selfHit.isEnabled(player) && selfHit.check(player, damagedPlayer, data, cc))
|
||||
cancelled = true;
|
||||
}
|
||||
|
@ -99,7 +102,7 @@ public class FightListener extends CheckListener {
|
|||
if (cc.cancelDead){
|
||||
if (damaged.isDead()) cancelled = true;
|
||||
// Only allow damaging others if taken damage this tick.
|
||||
if (player.isDead() && data.damageTakenTick != TickTask.getTick()){
|
||||
if (player.isDead() && data.damageTakenByEntityTick != TickTask.getTick()){
|
||||
cancelled = true;
|
||||
}
|
||||
}
|
||||
|
@ -173,13 +176,22 @@ public class FightListener extends CheckListener {
|
|||
* |_____|_| |_|\__|_|\__|\__, | |____/ \__,_|_| |_| |_|\__,_|\__, |\___|
|
||||
* |___/ |___/
|
||||
*/
|
||||
// Filter some unwanted events right now.
|
||||
|
||||
final Entity damaged = event.getEntity();
|
||||
final boolean damagedIsPlayer = damaged instanceof Player;
|
||||
final boolean damagedIsDead = damaged.isDead();
|
||||
if (damagedIsPlayer && !damagedIsDead) {
|
||||
final Player player = (Player) event.getEntity();
|
||||
if (godMode.isEnabled(player) && godMode.check(player))
|
||||
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
||||
player.setNoDamageTicks(0);
|
||||
}
|
||||
// Attacking entities.
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
final EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
final Entity damaged = e.getEntity();
|
||||
if (damaged instanceof Player){
|
||||
if (damagedIsPlayer && !damagedIsDead){
|
||||
// TODO: check once more when to set this (!) in terms of order.
|
||||
FightData.getData((Player) damaged).damageTakenTick = TickTask.getTick();
|
||||
FightData.getData((Player) damaged).damageTakenByEntityTick = TickTask.getTick();
|
||||
}
|
||||
final Entity damager = e.getDamager();
|
||||
if (damager instanceof Player){
|
||||
|
@ -191,32 +203,6 @@ public class FightListener extends CheckListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We listen to EntityDamage events (again) for obvious reasons.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(
|
||||
ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
public void onEntityDamage_(final EntityDamageEvent event) {
|
||||
/*
|
||||
* _____ _ _ _ ____
|
||||
* | ____|_ __ | |_(_) |_ _ _ | _ \ __ _ _ __ ___ __ _ __ _ ___
|
||||
* | _| | '_ \| __| | __| | | | | | | |/ _` | '_ ` _ \ / _` |/ _` |/ _ \
|
||||
* | |___| | | | |_| | |_| |_| | | |_| | (_| | | | | | | (_| | (_| | __/
|
||||
* |_____|_| |_|\__|_|\__|\__, | |____/ \__,_|_| |_| |_|\__,_|\__, |\___|
|
||||
* |___/ |___/
|
||||
*/
|
||||
// Filter unwanted events right here.
|
||||
if (event.getEntity() instanceof Player && !event.getEntity().isDead()) {
|
||||
final Player player = (Player) event.getEntity();
|
||||
if (godMode.isEnabled(player) && godMode.check(player))
|
||||
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
||||
player.setNoDamageTicks(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We listen to death events to prevent a very specific method of doing godmode.
|
||||
*
|
||||
|
|
|
@ -93,6 +93,7 @@ public class GodMode extends Check {
|
|||
* the player
|
||||
*/
|
||||
public void death(final Player player) {
|
||||
// TODO: Is this still relevant ?
|
||||
// First check if the player is really dead (e.g. another plugin could have just fired an artificial event).
|
||||
if (player.getHealth() <= 0 && player.isDead())
|
||||
try {
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Vehicle;
|
|||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||
|
||||
|
@ -238,5 +239,8 @@ public class CheckUtils {
|
|||
// Somewhat check against tp showing something wrong (< 1.0).
|
||||
vehicle.setPassenger(player);
|
||||
}
|
||||
if (MovingConfig.getConfig(player).debug){
|
||||
System.out.println(player.getName() + " vehicle set back: " + location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user