diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 69a45c7..e4b9fef 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -51,7 +51,6 @@ import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.providers.Lang; import com.rammelkast.anticheatreloaded.config.providers.Magic; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager; -import com.rammelkast.anticheatreloaded.manage.UserManager; import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; @@ -162,6 +161,7 @@ public class Backend { VelocityCheck.VIOLATIONS.remove(uuid); MorePacketsCheck.LAST_PACKET_TIME.remove(uuid); MorePacketsCheck.PACKET_BALANCE.remove(uuid); + MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid); GlideCheck.LAST_MOTION_Y.remove(uuid); GlideCheck.LAST_FALL_DISTANCE.remove(uuid); GlideCheck.VIOLATIONS.remove(uuid); @@ -312,13 +312,14 @@ public class Backend { if (this.fastSneakViolations.containsKey(player.getUniqueId())) { int flags = this.fastSneakViolations.get(player.getUniqueId()); if (flags >= 3) { // TODO possible config + this.fastSneakViolations.put(player.getUniqueId(), flags - 1); return new CheckResult(CheckResult.Result.FAILED, "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); } this.fastSneakViolations.put(player.getUniqueId(), flags + 1); return PASS; } else { - this.fastSneakViolations.put(player.getUniqueId(), 1); + this.fastSneakViolations.put(player.getUniqueId(), 0); return PASS; } } else { @@ -799,6 +800,7 @@ public class Backend { public void logJoin(final Player player) { FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME()); + MorePacketsCheck.EXEMPT_TIMINGS.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME()); } public boolean isMovingExempt(Player player) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java index ed0b37e..f4dd15f 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java @@ -26,6 +26,8 @@ import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerMoveEvent; +import com.rammelkast.anticheatreloaded.AntiCheatReloaded; +import com.rammelkast.anticheatreloaded.check.Backend; import com.rammelkast.anticheatreloaded.check.CheckResult; public class AimbotCheck { @@ -34,6 +36,10 @@ public class AimbotCheck { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); public static CheckResult runCheck(Player player, PlayerMoveEvent event) { + Backend backend = AntiCheatReloaded.getManager().getBackend(); + if (backend.isMovingExempt(player)) { + return PASS; + } UUID uuid = player.getUniqueId(); float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw()); float dPitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch()); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java index 1a9878e..1e3b4da 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java @@ -32,13 +32,13 @@ import org.bukkit.entity.Player; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.util.Distance; -import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VersionUtil; public class GlideCheck { public static final Map LAST_MOTION_Y = new HashMap(); public static final Map LAST_FALL_DISTANCE = new HashMap(); + public static final Map AIR_TICKS = new HashMap(); public static final Map VIOLATIONS = new HashMap(); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); @@ -48,18 +48,22 @@ public class GlideCheck { VIOLATIONS.put(player.getUniqueId(), 0); return PASS; } + if (player.getLocation().getBlock().getType() == Material.LADDER || player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) { return PASS; } + if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) { LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference()); return PASS; } + if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) { LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance()); return PASS; } + int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0); double motionY = distance.getYDifference(); float fallDistance = player.getFallDistance(); @@ -80,34 +84,7 @@ public class GlideCheck { return PASS; } } else { - if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround() - && Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5 - && !Utilities.isNearClimbable(player) - && !player.isSneaking() - && !AntiCheatReloaded.getManager().getBackend().isEating(player) - && !Utilities.isInWater(player)) { - // TODO change this, way too much falses - float predicted = calculateNextMotionY(LAST_MOTION_Y.get(player.getUniqueId()).floatValue()); - float actual = Double.valueOf(motionY).floatValue(); - float scaledDifference = Math.abs((predicted - actual) + 0.1568f); - if (scaledDifference > 3E-8) { - if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT() - && !Utilities.canStand(distance.getTo().getBlock())) { - VIOLATIONS.put(player.getUniqueId(), 1); - if (!AntiCheatReloaded.getManager().getBackend().silentMode()) { - Location prev = player.getLocation().clone(); - prev.setY(prev.getY() - distanceToFall(prev)); - player.teleport(AntiCheatReloaded.getManager().getUserManager() - .getUser(player.getUniqueId()).getGoodLocation(prev)); - } - return new CheckResult(CheckResult.Result.FAILED, "type=gravity, offset=" - + new BigDecimal(scaledDifference).setScale(2, RoundingMode.HALF_UP) + ")"); - } else { - VIOLATIONS.put(player.getUniqueId(), violations + 1); - return PASS; - } - } - } + // TODO redo this } LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference()); LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance()); @@ -117,10 +94,6 @@ public class GlideCheck { return PASS; } - private static float calculateNextMotionY(float motionY) { - return (motionY - 0.08f) * 0.98f; - } - private static double distanceToFall(Location location) { location = location.clone(); double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java index 1e28702..6acc7f4 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java @@ -38,6 +38,7 @@ import com.rammelkast.anticheatreloaded.event.EventListener; public class MorePacketsCheck { public static final Map LAST_PACKET_TIME = new HashMap(); + public static final Map EXEMPT_TIMINGS = new HashMap(); public static final Map PACKET_BALANCE = new HashMap(); public static void runCheck(Player player, PacketEvent event) { @@ -50,6 +51,9 @@ public class MorePacketsCheck { UUID uuid = player.getUniqueId(); Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic(); + if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) { + return; + } long packetTimeNow = System.currentTimeMillis(); long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L); double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java index c274f41..1e37ccd 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java @@ -50,6 +50,8 @@ public class Config extends ConfigurationFile { public ConfigValue> disabledWorlds; public ConfigValue> disabledChecks; + + public ConfigValue notifyEveryVl; public Config(AntiCheatReloaded plugin, Configuration config) { super(plugin, config, FILENAME); @@ -80,5 +82,10 @@ public class Config extends ConfigurationFile { disabledWorlds = new ConfigValue>("disable-in"); disabledChecks = new ConfigValue>("disabled-checks"); + + notifyEveryVl = new ConfigValue("system.notify-every-vl"); + if (notifyEveryVl.getValue() < 1) { + notifyEveryVl.setValue(5); + } } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java index ca481ed..08bffb8 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java @@ -50,27 +50,47 @@ public class EventListener implements Listener { public static void log(String message, Player player, CheckType type) { User user = getUserManager().getUser(player.getUniqueId()); + if (user == null) + return; + + boolean debugMode = CONFIG.getConfig().debugMode.getValue(); + int vlForType = type.getUses(player.getUniqueId()) + 1; + int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue(); if (message == null || message.equals("")) { - message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " - + CheckType.getName(type); + if (debugMode) { + message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + + CheckType.getName(type); + } else { + message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + + CheckType.getName(type) + ChatColor.GOLD + " (x" + vlForType + ")"; + } } else { - message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " - + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message - + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" - + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); - } - if (user != null) { // npc - logCheat(type, user); - if (user.increaseLevel(type)) { - AntiCheatReloaded.getManager().log(message); + if (debugMode) { + message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); + } else { + message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " + + CheckType.getName(type) + ChatColor.GOLD + " (x" + vlForType + ")" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); } - removeDecrease(user); } + + logCheat(type, user); + if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) { + AntiCheatReloaded.getManager().log(message); + } + removeDecrease(user); - if (CONFIG.getConfig().debugMode.getValue()) { + if (debugMode) { player.sendMessage(message); + return; + } + + if (vlForType % notifyEveryVl == 0) { + AntiCheatReloaded.getPlugin().sendToStaff(message); } - AntiCheatReloaded.getPlugin().sendToStaff(message); } private static void logCheat(CheckType type, User user) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java b/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java index 05829cf..9a17bc8 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java @@ -37,7 +37,6 @@ public class PacketListener { @Override public void onPacketReceiving(PacketEvent event) { Player player = event.getPlayer(); - User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); // Run MorePackets check MorePacketsCheck.runCheck(player, event); @@ -51,7 +50,6 @@ public class PacketListener { @Override public void onPacketSending(PacketEvent event) { Player player = event.getPlayer(); - User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); // Compensate for teleport MorePacketsCheck.compensate(player); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java index 0836427..ac4cac0 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java @@ -23,10 +23,10 @@ import org.bukkit.command.CommandSender; public enum Permission { /* Check Nodes */ - CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK, + CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE, - CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER, CHECK_AIMBOT, + CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER, CHECK_AIMBOT, /* System Nodes */ SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_MUTE; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6d86493..a011fea 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -31,8 +31,13 @@ system: # Should Enterprise options be enabled? Only set this to true if you're an advanced user. enterprise: false # Running AntiCheatReloaded in debug mode will send alerts to the cheating players and enable debug logging + # Use this when locating and/or reporting false positives or when testing AntiCheatReloaded # Do NOT enable this in a production environment! debug-mode: false + # To prevent spamming, staff and the console will only be notified every x violations + # Minimum value is 1, default is 5 + # Example with 5: notifications after 5 vl, 10vl, 15vl, etc. + notify-every-vl: 5 # Use /AntiCheatReloaded check for a list of valid checks disabled-checks: - EXAMPLE_CHECK diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f8ed9e5..73bd888 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -49,7 +49,7 @@ permissions: anticheat.check.flight: description: Allow players to use fly cheats default: false - anticheat.check.elytra: + anticheat.check.elytrafly: description: Allow players to use ElytraFly cheats default: false anticheat.check.waterwalk: @@ -64,8 +64,11 @@ permissions: anticheat.check.fastplace: description: Allow players to use build hacks and fastplace default: false - anticheat.check.spam: - description: Allow players to spam the server + anticheat.check.chatspam: + description: Allow players to spam chat messages + default: false + anticheat.check.commandspam: + description: Allow players to spam chat messages default: false anticheat.check.sprint: description: Allow players to sprint when hungry @@ -74,7 +77,10 @@ permissions: description: Allow players to use sneak hacks default: false anticheat.check.speed: - description: Allow players to speed + description: Allow players to use speed hacks + default: false + anticheat.check.vclip: + description: Allow players clip through walls default: false anticheat.check.spider: description: Allow players to climb non-climbable surfaces @@ -97,18 +103,15 @@ permissions: anticheat.check.longreach: description: Allow players to use longreaching hacks default: false - anticheat.check.projectile: - description: Allow players to quickly launch projectiles + anticheat.check.unicode: + description: Allow players to use unicode in chat + default: false + anticheat.check.fastprojectile: + description: Allow players to spam projectiles (fastbow etc.) default: false anticheat.check.itemspam: description: Allow players to use inventory drop spam hacks default: false - anticheat.check.visual: - description: Allow players to interact with objects out of their view - default: false - anticheat.check.vclip: - description: Allow players to become slimeballs and clip down through blocks - default: false anticheat.check.fastinventory: description: Allow players to use fastloot and similar inventory hacks default: false @@ -116,7 +119,7 @@ permissions: description: Allow players to use autotool to switch tools quickly default: false anticheat.check.morepackets: - description: Allow players to send lots of movement packets + description: Allow players to send lots of movement packets or modify their timer default: false anticheat.check.badpackets: description: Allow players to send invalid movement packets @@ -127,9 +130,6 @@ permissions: anticheat.check.criticals: description: Allow players to use criticals default: false - anticheat.check.unicode: - description: Allow players to use unicode in chat - default: false anticheat.check.illegalinteract: description: Allow players to place blocks in illegal places default: false @@ -149,10 +149,12 @@ permissions: anticheat.check.noswing: true anticheat.check.fastbreak: true anticheat.check.fastplace: true - anticheat.check.spam: true + anticheat.check.chatspam: true + anticheat.check.commandspam: true anticheat.check.sprint: true anticheat.check.sneak: true anticheat.check.speed: true + anticheat.check.vclip: true anticheat.check.spider: true anticheat.check.nofall: true anticheat.check.fastbow: true @@ -160,18 +162,15 @@ permissions: anticheat.check.fastheal: true anticheat.check.killaura: true anticheat.check.longreach: true - anticheat.check.projectile: true + anticheat.check.unicode: true + anticheat.check.fastprojectile: true anticheat.check.itemspam: true - anticheat.check.visual: true - anticheat.check.vclip: true anticheat.check.fastinventory: true anticheat.check.autotool: true - anticheat.check.fastanimation: true anticheat.check.morepackets: true anticheat.check.badpackets: true anticheat.check.velocity: true anticheat.check.criticals: true - anticheat.check.unicode: true anticheat.check.illegalinteract: true anticheat.check.fastladder: true anticheat.check.aimbot: true \ No newline at end of file