diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 1e7c334..1c36fe9 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -197,6 +197,31 @@ public class PlayerListener extends EventListener } log("tried to fly.",player,CheckType.FLY); } + if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkDoomsOfTheYHeckers(player)) { + from.setX(from.getX()-1); + from.setY(from.getY()-1); + from.setZ(from.getZ()-1); + if(from.getBlock().getTypeId() == 0) + event.setTo(from); + for(int i= 5;i>0;i--) + { + Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ()); + Block lower = newLocation.getBlock(); + if(lower.getTypeId() == 0) + { + player.teleport(newLocation); + break; + } + } + //Lets really give this flyer a real pushdown. + Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ()); + Block newBlock = newLocation.getBlock(); + if(newBlock.getTypeId() != 0) + { + event.setTo(newLocation); + } + log("tried to fly on y-axis", player, CheckType.FLY); //cause he's poor. + } if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY)) { if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y)) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 03c9dee..9895d90 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -56,6 +56,10 @@ public class Backend private static final int CHAT_BAN_LEVEL = 3; public static final int FLIGHT_LIMIT = 4; + public static final int FLIGHT_MINIMUM = 1; + public static final int FLIGHT_TIMELIMIT = 5000; + public static final int Y_MAXVIOLATIONS = 1; + public static final int Y_MAXVIOTIME = 5000; public static final int NOFALL_LIMIT = 5; public static final int SPRINT_FOOD_MIN = 6; @@ -75,6 +79,8 @@ public class Backend public static final double LADDER_Y_MIN = 0.11759; public static final double Y_SPEED_MAX = 0.5; + public static final double Y_MAXDIFF = 5; + public static final double Y_TIME = 1000; public static final double XZ_SPEED_MAX = 0.4; public static final double XZ_SPEED_MAX_SPRINT = 0.65; public static final double XZ_SPEED_MAX_SNEAK = 0.2; @@ -99,6 +105,10 @@ public class Backend private Map chatKicks = new HashMap(); private Map nofallViolation = new HashMap(); private Map fastBreakViolation = new HashMap(); + private Map YaxisViolations = new HashMap(); + private Map YaxisLastVio = new HashMap(); + private Map lastYcoord = new HashMap(); + private Map lastYtime = new HashMap(); private Map blocksBroken = new HashMap(); private Map lastBlockBroken = new HashMap(); private Map fastPlaceViolation = new HashMap(); @@ -235,6 +245,63 @@ public class Backend return false; } + public boolean checkDoomsOfTheYHeckers(Player player) { + double y1 = player.getLocation().getY(); + String name = player.getName(); + //Fix Y axis spam. + if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) + || !YaxisViolations.containsKey(name) || !YaxisLastVio.containsKey(name)) + { + lastYcoord.put(name, y1); + YaxisViolations.put(name, 0); + YaxisLastVio.put(name, 0L); + lastYtime.put(name, System.currentTimeMillis()); + } + else + { + 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)); + player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage."); + YaxisViolations.put(name, YaxisViolations.get(name)+1); + YaxisLastVio.put(name, System.currentTimeMillis()); + if(g.getBlock().getTypeId() == 0) + player.teleport(g); + return true; + } + else + { + if(YaxisViolations.get(name) > Y_MAXVIOLATIONS + && (System.currentTimeMillis() - YaxisLastVio.get(name)) > Y_MAXVIOTIME) { + YaxisViolations.put(name, 0); + YaxisLastVio.put(name, 0L); + } + } + if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME) + { + Location g = player.getLocation(); + g.setY(lastYcoord.get(name)); + YaxisViolations.put(name, YaxisViolations.get(name)+1); + YaxisLastVio.put(name, System.currentTimeMillis()); + if(g.getBlock().getTypeId() == 0) + player.teleport(g); + return true; + } + 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 + return false; + } + public boolean checkFlight(Player player, double y1, double y2) { Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);