mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fix flight detection issues when being damaged by an explosion
This commit is contained in:
1 parent
3a226aa9e3
commit
c647bb4b6a
2 files changed
+33
-9
No files matched your search
@@ -24,7 +24,10 @@ import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Distance;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
@@ -114,8 +117,9 @@ public class EntityListener extends EventListener
|
||||
if (e.getDamager() instanceof Player)
|
||||
{
|
||||
Player p = (Player) e.getDamager();
|
||||
backend.logDamage(p);
|
||||
backend.logDamage(player);
|
||||
backend.logDamage(p, 1);
|
||||
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
||||
backend.logDamage(player, value);
|
||||
if (checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||
@@ -129,7 +133,14 @@ public class EntityListener extends EventListener
|
||||
}
|
||||
else
|
||||
{
|
||||
backend.logDamage(player);
|
||||
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper)
|
||||
{
|
||||
backend.logDamage(player, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
backend.logDamage(player, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getDamager() instanceof Player)
|
||||
|
||||
@@ -46,7 +46,8 @@ public class Backend
|
||||
private static final int JOIN_TIME = 40;
|
||||
private static final int DROPPED_ITEM_TIME = 2;
|
||||
private static final int DAMAGE_TIME = 50;
|
||||
private static final int KNOCKBACK_DAMAGE_TIME = 50;
|
||||
private static final int KNOCKBACK_DAMAGE_TIME = 70;
|
||||
private static final int EXPLOSION_DAMAGE_TIME = 100;
|
||||
private static final int PROJECTILE_TIME = 20;
|
||||
private static final long PROJECTILE_HOLD = 20L * 10L;
|
||||
private static final int TIME_MIN = 700;
|
||||
@@ -641,7 +642,7 @@ public class Backend
|
||||
String name = player.getName();
|
||||
int y1 = (int)distance.fromY();
|
||||
int y2 = (int)distance.toY();
|
||||
if((y1 == y2 || y1 < y2) && !Utilities.isInWater(player) && !Utilities.canStand(player.getLocation().getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -1, 0).getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -2, 0).getBlock()))
|
||||
if(!isMovingExempt(player) && (y1 == y2 || y1 < y2) && !Utilities.isInWater(player) && !Utilities.canStand(player.getLocation().getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -1, 0).getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -2, 0).getBlock()))
|
||||
{
|
||||
int violation = flightViolation.containsKey(name) ? flightViolation.get(name) + 1 : 1;
|
||||
increment(player, flightViolation, violation);
|
||||
@@ -1069,12 +1070,24 @@ public class Backend
|
||||
}
|
||||
}
|
||||
|
||||
public void logDamage(final Player player)
|
||||
public void logDamage(final Player player, int type)
|
||||
{
|
||||
int time = DAMAGE_TIME;
|
||||
if (player.getInventory().getItemInHand().getEnchantments().containsKey(Enchantment.KNOCKBACK))
|
||||
int time;
|
||||
switch(type)
|
||||
{
|
||||
time = KNOCKBACK_DAMAGE_TIME;
|
||||
case 1:
|
||||
time = DAMAGE_TIME;
|
||||
break;
|
||||
case 2:
|
||||
time = KNOCKBACK_DAMAGE_TIME;
|
||||
break;
|
||||
case 3:
|
||||
time = EXPLOSION_DAMAGE_TIME;
|
||||
break;
|
||||
default:
|
||||
time = DAMAGE_TIME;
|
||||
break;
|
||||
|
||||
}
|
||||
logEvent(movingExempt, player, time);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user