mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-01 16:20:26 +01:00
Attempt to fix issues with player-ignited TNT (1).
This commit is contained in:
parent
ee5c86bb4f
commit
b43fa259dc
@ -136,6 +136,14 @@ public class FightData extends ACheckData {
|
|||||||
public final ActionFrequency speedBuckets;
|
public final ActionFrequency speedBuckets;
|
||||||
public int speedShortTermCount;
|
public int speedShortTermCount;
|
||||||
public int speedShortTermTick;
|
public int speedShortTermTick;
|
||||||
|
|
||||||
|
// TNT workaround: Allow ENTITY_ATTACK if these attributes match.
|
||||||
|
/** Amount of damage dealt by the last explosion. */
|
||||||
|
public double lastExplosionDamage = Double.MAX_VALUE;
|
||||||
|
/** Tick the last explosion damage was dealt at. */
|
||||||
|
public int lastExplosionDamageTick = -1 ;
|
||||||
|
/** Last explosion damage causing player (damager). */
|
||||||
|
public String lastExplosionDamagePlayer = null;
|
||||||
|
|
||||||
|
|
||||||
public FightData(final FightConfig cc){
|
public FightData(final FightConfig cc){
|
||||||
|
@ -92,7 +92,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
* The EntityDamageByEntityEvent
|
* The EntityDamageByEntityEvent
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean handleNormalDamage(final Player player, final Entity damaged, double damage) {
|
private boolean handleNormalDamage(final Player player, final Entity damaged, final double damage, final int tick) {
|
||||||
final FightConfig cc = FightConfig.getConfig(player);
|
final FightConfig cc = FightConfig.getConfig(player);
|
||||||
final FightData data = FightData.getData(player);
|
final FightData data = FightData.getData(player);
|
||||||
|
|
||||||
@ -105,7 +105,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
|
||||||
final String worldName = player.getWorld().getName();
|
final String worldName = player.getWorld().getName();
|
||||||
final int tick = TickTask.getTick();
|
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
final boolean worldChanged = !worldName.equals(data.lastWorld);
|
final boolean worldChanged = !worldName.equals(data.lastWorld);
|
||||||
|
|
||||||
@ -321,9 +320,26 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
}
|
}
|
||||||
if (damager instanceof Player){
|
if (damager instanceof Player){
|
||||||
final Player player = (Player) damager;
|
final Player player = (Player) damager;
|
||||||
if (e.getCause() == DamageCause.ENTITY_ATTACK){
|
final DamageCause damageCause = event.getCause();
|
||||||
|
final double damage = BridgeHealth.getDamage(e);
|
||||||
if (handleNormalDamage(player, damaged, BridgeHealth.getDamage(e))){
|
final int tick = TickTask.getTick();
|
||||||
|
if (damageCause == DamageCause.BLOCK_EXPLOSION || damageCause == DamageCause.ENTITY_EXPLOSION) {
|
||||||
|
if (damagedData != null) {
|
||||||
|
damagedData.lastExplosionDamagePlayer = player.getName();
|
||||||
|
damagedData.lastExplosionDamageTick = tick;
|
||||||
|
damagedData.lastExplosionDamage = BridgeHealth.getDamage(event);
|
||||||
|
}
|
||||||
|
} else if (e.getCause() == DamageCause.ENTITY_ATTACK){
|
||||||
|
if (damagedData != null) {
|
||||||
|
// TODO: Might/should skip the damage comparison, though checking on lowest priority.
|
||||||
|
if (damage == damagedData.lastExplosionDamage && player.getName().equals(damagedData.lastExplosionDamagePlayer) && tick == damagedData.lastExplosionDamageTick) {
|
||||||
|
damagedData.lastExplosionDamage = Double.MAX_VALUE;
|
||||||
|
damagedData.lastExplosionDamageTick = -1;
|
||||||
|
damagedData.lastExplosionDamagePlayer = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handleNormalDamage(player, damaged, damage, tick)){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user