mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Fixed a false-positive when running and jumping into water
This commit is contained in:
1 parent
be4bd0cdcc
commit
2fae1a4d27
2 files changed
+90
-62
No files matched your search
@@ -199,7 +199,8 @@ public class PlayerListener extends EventListener
|
|||||||
}
|
}
|
||||||
log("tried to fly.",player,CheckType.FLY);
|
log("tried to fly.",player,CheckType.FLY);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkDoomsOfTheYHeckers(player)) {
|
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkYAxis(player))
|
||||||
|
{
|
||||||
from.setX(from.getX()-1);
|
from.setX(from.getX()-1);
|
||||||
from.setY(from.getY()-1);
|
from.setY(from.getY()-1);
|
||||||
from.setZ(from.getZ()-1);
|
from.setZ(from.getZ()-1);
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public class Backend
|
|||||||
private List<String> startEat = new ArrayList<String>();
|
private List<String> startEat = new ArrayList<String>();
|
||||||
private List<String> healed = new ArrayList<String>();
|
private List<String> healed = new ArrayList<String>();
|
||||||
private List<String> sprinted = new ArrayList<String>();
|
private List<String> sprinted = new ArrayList<String>();
|
||||||
|
private List<String> isInWater = new ArrayList<String>();
|
||||||
|
private List<String> isInWaterCache = new ArrayList<String>();
|
||||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||||
@@ -235,73 +237,98 @@ public class Backend
|
|||||||
public boolean checkWaterWalk(Player player, double x, double z)
|
public boolean checkWaterWalk(Player player, double x, double z)
|
||||||
{
|
{
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
if(block.isLiquid() && player.getVehicle() == null)
|
if(block.isLiquid() && player.getVehicle() == null)
|
||||||
{
|
{
|
||||||
if(x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER && !Utilities.sprintFly(player) && player.getNearbyEntities(1, 1, 1).isEmpty())
|
if(isInWater.contains(player.getName()))
|
||||||
{
|
{
|
||||||
return true;
|
if(isInWaterCache.contains(player.getName()))
|
||||||
|
{
|
||||||
|
if(x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER && !Utilities.sprintFly(player) && player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isInWaterCache.add(player.getName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
else
|
||||||
{
|
{
|
||||||
return true;
|
isInWater.add(player.getName());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
}
|
||||||
|
isInWater.remove(player.getName());
|
||||||
|
isInWaterCache.remove(player.getName());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkDoomsOfTheYHeckers(Player player) {
|
public boolean checkYAxis(Player player)
|
||||||
double y1 = player.getLocation().getY();
|
{
|
||||||
String name = player.getName();
|
if(!player.isFlying())
|
||||||
//Fix Y axis spam.
|
{
|
||||||
if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name)
|
double y1 = player.getLocation().getY();
|
||||||
|| !YaxisViolations.containsKey(name) || !YaxisLastVio.containsKey(name))
|
String name = player.getName();
|
||||||
{
|
//Fix Y axis spam.
|
||||||
lastYcoord.put(name, y1);
|
if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) || !YaxisViolations.containsKey(name) || !YaxisLastVio.containsKey(name))
|
||||||
YaxisViolations.put(name, 0);
|
{
|
||||||
YaxisLastVio.put(name, 0L);
|
lastYcoord.put(name, y1);
|
||||||
lastYtime.put(name, System.currentTimeMillis());
|
YaxisViolations.put(name, 0);
|
||||||
}
|
YaxisLastVio.put(name, 0L);
|
||||||
else
|
lastYtime.put(name, System.currentTimeMillis());
|
||||||
{
|
}
|
||||||
if(y1 > lastYcoord.get(name) && YaxisViolations.get(name) > Y_MAXVIOLATIONS
|
else
|
||||||
&& (System.currentTimeMillis() - YaxisLastVio.get(name)) < Y_MAXVIOTIME)
|
{
|
||||||
{
|
if(y1 > lastYcoord.get(name) && YaxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - YaxisLastVio.get(name)) < Y_MAXVIOTIME)
|
||||||
Location g = player.getLocation();
|
{
|
||||||
g.setY(lastYcoord.get(name));
|
Location g = player.getLocation();
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
|
g.setY(lastYcoord.get(name));
|
||||||
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
|
||||||
YaxisLastVio.put(name, System.currentTimeMillis());
|
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
||||||
if(g.getBlock().getTypeId() == 0)
|
YaxisLastVio.put(name, System.currentTimeMillis());
|
||||||
player.teleport(g);
|
if(g.getBlock().getTypeId() == 0)
|
||||||
return true;
|
{
|
||||||
}
|
player.teleport(g);
|
||||||
else
|
}
|
||||||
{
|
return true;
|
||||||
if(YaxisViolations.get(name) > Y_MAXVIOLATIONS
|
}
|
||||||
&& (System.currentTimeMillis() - YaxisLastVio.get(name)) > Y_MAXVIOTIME) {
|
else
|
||||||
YaxisViolations.put(name, 0);
|
{
|
||||||
YaxisLastVio.put(name, 0L);
|
if(YaxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - YaxisLastVio.get(name)) > Y_MAXVIOTIME)
|
||||||
}
|
{
|
||||||
}
|
YaxisViolations.put(name, 0);
|
||||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
|
YaxisLastVio.put(name, 0L);
|
||||||
{
|
}
|
||||||
Location g = player.getLocation();
|
}
|
||||||
g.setY(lastYcoord.get(name));
|
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
|
||||||
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
{
|
||||||
YaxisLastVio.put(name, System.currentTimeMillis());
|
Location g = player.getLocation();
|
||||||
if(g.getBlock().getTypeId() == 0)
|
g.setY(lastYcoord.get(name));
|
||||||
player.teleport(g);
|
YaxisViolations.put(name, YaxisViolations.get(name)+1);
|
||||||
return true;
|
YaxisLastVio.put(name, System.currentTimeMillis());
|
||||||
}
|
if(g.getBlock().getTypeId() == 0)
|
||||||
else
|
{
|
||||||
{
|
player.teleport(g);
|
||||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
|
}
|
||||||
{
|
return true;
|
||||||
lastYtime.put(name, System.currentTimeMillis());
|
}
|
||||||
lastYcoord.put(name, y1);
|
else
|
||||||
}
|
{
|
||||||
}
|
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
|
||||||
}
|
{
|
||||||
|
lastYtime.put(name, System.currentTimeMillis());
|
||||||
|
lastYcoord.put(name, y1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//Fix Y axis spam
|
//Fix Y axis spam
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user