From f123e397b6b976bd7ec5a6d5415cfceb53eefc06 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Thu, 30 Dec 2021 22:37:55 +0100 Subject: [PATCH 01/17] Fix #205 --- .../check/combat/KillAuraCheck.java | 3 ++- .../anticheatreloaded/util/MovementManager.java | 16 +++++++--------- .../anticheatreloaded/util/Utilities.java | 8 ++++---- .../anticheatreloaded/util/VersionUtil.java | 7 +++++++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java index ff364dff..6b9b2078 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java @@ -38,6 +38,7 @@ import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; +import com.rammelkast.anticheatreloaded.util.VersionUtil; public final class KillAuraCheck { @@ -98,7 +99,7 @@ public static CheckResult checkAngle(final Player player, final EntityDamageEven final Entity entity = event.getEntity(); // Do not check while in vehicles - if (player.getVehicle() != null || entity.getVehicle() != null || player.isRiptiding()) { + if (player.getVehicle() != null || entity.getVehicle() != null || VersionUtil.isRiptiding(player)) { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index 9698f762..88fd4878 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -218,15 +218,13 @@ public void handle(final Player player, final Location from, final Location to, } } - if (VersionUtil.CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) { - if (player.isRiptiding()) { - this.riptideTicks = 30; + if (VersionUtil.isRiptiding(player)) { + this.riptideTicks = 30; + } else { + if (this.riptideTicks > 0) { + this.riptideTicks--; } else { - if (this.riptideTicks > 0) { - this.riptideTicks--; - } else { - this.riptideTicks = 0; - } + this.riptideTicks = 0; } } @@ -247,7 +245,7 @@ public void handle(final Player player, final Location from, final Location to, final Location bottom = to.clone().add(0, -1, 0); this.bottomSolid = bottom.getBlock().getType().isSolid(); - if ((this.motionY > 0.42D && this.motionY <= 0.5625D) + if ((this.motionY > 0.42f && this.motionY <= 0.5625f) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) { this.halfMovement = true; this.halfMovementHistoryCounter = 30; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 2411c5bb..e0567d17 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -185,9 +185,9 @@ public static boolean isNearShulkerBox(final Location location) { */ public static boolean couldBeOnHalfblock(final Location location) { return isNearHalfblock( - new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getBlockZ())) + new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ())) || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, - location.getBlockZ())); + location.getZ())); } public static boolean isNearHalfblock(final Location location) { @@ -344,11 +344,11 @@ public static boolean isFood(Material m) { */ public static boolean isSlab(final Block block) { final Material type = block.getType(); - return type.name().endsWith("SLAB"); + return type.name().toUpperCase().endsWith("SLAB") || type.name().toUpperCase().endsWith("STEP"); } public static boolean isNearBed(final Location location) { - return isCollisionPoint(location, material -> material.name().endsWith("BED")); + return isCollisionPoint(location, material -> material.name().toUpperCase().endsWith("BED")); } /** diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java index 259e60ba..7d947eb3 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java @@ -70,6 +70,13 @@ public static boolean isSlowFalling(final Player player) { } return player.hasPotionEffect(PotionEffectType.SLOW_FALLING); } + + public static boolean isRiptiding(final Player player) { + if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) { + return false; + } + return player.isRiptiding(); + } public static boolean isFrostWalk(final Player player) { if (player.getInventory().getBoots() == null) { From 6aaaf883e5a302b0698058c067f6183e744c5f85 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Thu, 30 Dec 2021 23:20:22 +0100 Subject: [PATCH 02/17] Fix #178 --- README.md | 2 +- .../check/movement/WaterWalkCheck.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cdfebb27..ec77181c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ AntiCheatReloaded helps server admins combat the use of hacked clients and spamb Installation ------------ -AntiCheatReloaded requires you to have ProtocolLib. You can download it [here](https://www.spigotmc.org/resources/protocollib.1997/). +AntiCheatReloaded **requires** you to have ProtocolLib. You can download it [here](https://www.spigotmc.org/resources/protocollib.1997/). Simply drag and drop the AntiCheatReloaded and ProtocolLib jars in your plugin folder. You can now use AntiCheatReloaded, but be sure to have a look at the configuration files, which allow you to change every aspect of the plugin. Bug Reporting diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java index d551692e..4d209d94 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java @@ -79,6 +79,19 @@ public static CheckResult runCheck(final Player player, final double x, final do + Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY=" + Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")"); } + + if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && Utilities.isSurroundedByWater(player) + && movementManager.distanceXZ > 0.16 && movementManager.motionY > 0.0 + && movementManager.lastMotionY < 0.0 + && (Math.abs(movementManager.motionY) < 0.017 && Math.abs(movementManager.lastMotionY) < 0.02) + && Math.abs(movementManager.lastMotionY - 0.004) < 0.021 + && user.getVelocityTracker().getHorizontal() < 0.04 + && !Utilities.couldBeOnBoat(player, 0.3, false)) { + return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz=" + + Utilities.roundDouble(movementManager.distanceXZ, 5) + ", motionY=" + + Utilities.roundDouble(movementManager.motionY, 5) + ", lastMotionY=" + + Utilities.roundDouble(movementManager.lastMotionY, 5) + ")"); + } return PASS; } From 38e6a5a99ccef2fa48292f8251fabf782296ab4b Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Thu, 30 Dec 2021 23:28:54 +0100 Subject: [PATCH 03/17] Fix #167 --- .../anticheatreloaded/check/movement/FlightCheck.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java index 55422923..d2f49852 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -175,6 +175,16 @@ public static CheckResult runCheck(final Player player, final Distance distance) "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); } + if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0.0 + && movementManager.motionY > 0.0 && movementManager.airTicks > 3 + && movementManager.motionY > movementManager.lastMotionY + && user.getVelocityTracker().getVertical() <= 0.0 + && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig + .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) { + return new CheckResult(CheckResult.Result.FAILED, "AirClimb", + "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); + } + if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks && !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0 && movementManager.elytraEffectTicks <= 25 From 2d827e951ceff1fde16bd29d7c7c3c8ba06d58f8 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Thu, 30 Dec 2021 23:41:11 +0100 Subject: [PATCH 04/17] I think this should fix #199 --- .../check/movement/FlightCheck.java | 2 +- .../anticheatreloaded/util/Utilities.java | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java index d2f49852..5022f645 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -150,7 +150,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0))) && movementManager.motionY > 0.15)) && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25 - && !Utilities.couldBeOnBoat(player, 0.8d, false)) + && !Utilities.couldBeOnBoat(player, 0.8, false)) return new CheckResult(CheckResult.Result.FAILED, "AirClimb", "tried to climb air (mY=" + movementManager.motionY + ")"); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index e0567d17..fd9c6278 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -80,8 +80,8 @@ public static boolean cantStandAt(final Block block) { * @return true if the player should be unable to stand here */ public static boolean cantStandAtExp(final Location location) { - return cantStandAt(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, - location.getBlockZ()).getBlock()); + return cantStandAt(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, + location.getZ()).getBlock()); } /** @@ -159,14 +159,16 @@ public static boolean couldBeOnBoat(final Player player, final double range, fin * @return true if the player could be standing on ice */ public static boolean couldBeOnIce(final Location location) { - return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, - location.getBlockZ())) - || isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D, - location.getBlockZ())); + return isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, + location.getZ())) + || isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.26D, + location.getZ())) + || isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, + location.getZ())); } public static boolean isNearIce(final Location location) { - return isCollisionPoint(location, material -> material.name().endsWith("ICE")); + return isCollisionPoint(location, material -> material.name().toUpperCase().endsWith("ICE")); } public static boolean isNearShulkerBox(final Location location) { @@ -174,7 +176,7 @@ public static boolean isNearShulkerBox(final Location location) { if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.COLOR_UPDATE)) { return false; } - return isCollisionPoint(location, material -> material.name().endsWith("SHULKER_BOX")); + return isCollisionPoint(location, material -> material.name().toUpperCase().endsWith("SHULKER_BOX")); } /** @@ -221,10 +223,10 @@ public static boolean isHalfblock(final Block block) { * @return true if the player could be standing on slime */ public static boolean couldBeOnSlime(final Location location) { - return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, - location.getBlockZ())) - || isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D, - location.getBlockZ())); + return isNearSlime(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, + location.getZ())) + || isNearSlime(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, + location.getZ())); } public static boolean isNearSlime(final Location location) { @@ -238,10 +240,10 @@ public static boolean isNearSlime(final Location location) { * @return true if the player could be standing on soil */ public static boolean couldBeOnSoil(final Location location) { - return isNearSoil(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D, - location.getBlockZ())) - || isNearSoil(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D, - location.getBlockZ())); + return isNearSoil(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, + location.getZ())) + || isNearSoil(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, + location.getZ())); } public static boolean isNearSoil(final Location location) { From 279efba0905c7857289a06a3e1c900e7c9eea135 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Thu, 30 Dec 2021 23:52:48 +0100 Subject: [PATCH 05/17] Improved formatting --- .../command/CommandBase.java | 20 ++++++++++--------- .../command/executors/CommandReport.java | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java index cdb74e99..4383ea01 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandBase.java @@ -64,21 +64,23 @@ public CommandBase(String name, String command, String usage, String help[], Per public void run(CommandSender cs, String[] args) { if (permission.get(cs)) { execute(cs, args); - } else { - if (args == null) { - cs.sendMessage(GRAY + "Running " + GOLD + "" + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion()); - } else { - cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")"); - } - } - } + } else { + if (args == null) { + cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR" + ChatColor.DARK_GRAY + " > " + + ChatColor.GRAY + "Running " + GOLD + "AntiCheatReloaded " + GRAY + "version " + + GOLD + AntiCheatReloaded.getVersion()); + } else { + cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")"); + } + } + } protected void execute(CommandSender cs, String[] args) { return; // Stub } public void sendHelp(CommandSender cs) { - cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + ChatColor.GRAY + "Help Menu"); + cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded" + ChatColor.DARK_GRAY + " > " + ChatColor.GRAY + "Help Menu"); cs.sendMessage(GOLD + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage()); cs.sendMessage(GOLD + "Permission: " + GRAY + getPermission().toString()); for (String string : getHelp()) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java index 27acb41d..249c0ee3 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReport.java @@ -108,7 +108,7 @@ private void groupReport(CommandSender cs, Group group, int page) { String groupName = group == null ? "Low" : group.getName(); int pages = (int) Math.ceil(((float) users.size()) / 7); if (page <= pages && page > 0) { - cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GRAY + "Group: " + color + groupName); for (int x = 0; x < 7; x++) { @@ -121,7 +121,7 @@ private void groupReport(CommandSender cs, Group group, int page) { cs.sendMessage(MENU_END); } else { if (pages == 0) { - cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); + cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page 1/1" + GOLD + "]----------------------"); cs.sendMessage(GRAY + "Group: " + color + groupName); cs.sendMessage(GRAY + "There are no users in this group."); cs.sendMessage(MENU_END); @@ -152,7 +152,7 @@ private void playerReport(CommandSender cs, User user, int page) { groupString += " (" + user.getLevel() + ")"; if (page <= pages && page > 0) { - cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GRAY + "Player: " + WHITE + name); int ping = user.getPing(); @@ -177,7 +177,7 @@ private void playerReport(CommandSender cs, User user, int page) { cs.sendMessage(MENU_END); } else { if (pages == 0 && page == 1) { - cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); + cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page 1/1" + GOLD + "]----------------------"); cs.sendMessage(GRAY + "Player: " + WHITE + name); int ping = user.getPing(); cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline") From 14ee2ebba054dc444fdbaabca897f3413654e31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Smoli=C5=84ski?= <34658474+kacperleague9@users.noreply.github.com> Date: Fri, 31 Dec 2021 10:34:30 +0100 Subject: [PATCH 06/17] Create workflow --- .github/workflows/maven-publish.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 00000000..23689ee0 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,26 @@ +name: Maven Package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + + - uses: actions/checkout@v2.4.0 + - name: Set up JDK 1.8 + uses: actions/setup-java@v2.5.0 + with: + java-version: 1.8 + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Upload build artifacts + uses: actions/upload-artifact@v2.3.1 + with: + path: target/AntiCheatReloaded.jar From a3483dfc9be5a166eb16baeb52516238c482793e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Smoli=C5=84ski?= <34658474+kacperleague9@users.noreply.github.com> Date: Fri, 31 Dec 2021 10:35:30 +0100 Subject: [PATCH 07/17] Fix error --- .github/workflows/maven-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 23689ee0..e0acd092 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -11,9 +11,9 @@ jobs: steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v1 - name: Set up JDK 1.8 - uses: actions/setup-java@v2.5.0 + uses: actions/setup-java@v1 with: java-version: 1.8 From edf1d1c2340891f074134998830ca211a5429fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Smoli=C5=84ski?= <34658474+kacperleague9@users.noreply.github.com> Date: Fri, 31 Dec 2021 15:34:15 +0100 Subject: [PATCH 08/17] Change license --- LICENSE | 829 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 669 insertions(+), 160 deletions(-) diff --git a/LICENSE b/LICENSE index f0156c53..3877ae0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,674 @@ - GNU LESSER GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 7842153e603dc8a5af9d8e223caeaa07841a3816 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 1 Jan 2022 12:55:31 +0100 Subject: [PATCH 09/17] "Lets remove features in a minor build! -some guy at SpigotMC" --- pom.xml | 2 +- .../config/yaml/CommentedConfiguration.java | 39 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index bb30cb19..91ecc9a3 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ org.spigotmc spigot-api - 1.18-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java b/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java index 713a45bf..7cab8c83 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/config/yaml/CommentedConfiguration.java @@ -16,11 +16,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.rammelkast.anticheatreloaded.config.yaml; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayDeque; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; + import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConstructor; @@ -30,16 +40,6 @@ import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.representer.Representer; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayDeque; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; - /** * An extension of {@link org.bukkit.configuration.file.YamlConfiguration} which preserves comments. * Note that this implementation is not synchronized. @@ -87,7 +87,7 @@ public void loadFromString(String contents) throws InvalidConfigurationException blank++; continue; } - if (lines[i].contains(COMMENT_PREFIX)) { + if (lines[i].contains("# ")) { comments.put(i - blank, lines[i]); } i++; @@ -104,7 +104,7 @@ public String saveToString() { // String header = buildHeader(); - CommentedConfiguration String dump = yaml.dump(getValues(false)); - if (dump.equals(BLANK_CONFIG)) { + if (dump.equals("{}\\n")) { dump = ""; } @@ -201,4 +201,17 @@ public static CommentedConfiguration loadConfiguration(InputStream stream) { return config; } + + private static void convertMapsToSections(Map input, ConfigurationSection section) { + for (Map.Entry entry : input.entrySet()) { + String key = entry.getKey().toString(); + Object value = entry.getValue(); + + if (value instanceof Map) { + convertMapsToSections((Map) value, section.createSection(key)); + } else { + section.set(key, value); + } + } + } } From 67e6f0df62ec6f37f2351bccdd04e2caa1e19296 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 1 Jan 2022 13:09:02 +0100 Subject: [PATCH 10/17] Move NoFall check out of backend --- .../anticheatreloaded/AntiCheatReloaded.java | 58 -------------- .../anticheatreloaded/check/Backend.java | 42 +--------- .../check/movement/AimbotCheck.java | 3 +- .../check/player/NoFallCheck.java | 79 +++++++++++++++++++ .../command/executors/CommandReload.java | 3 +- .../event/PlayerListener.java | 25 +++--- .../manage/CheckManager.java | 5 +- 7 files changed, 103 insertions(+), 112 deletions(-) create mode 100644 src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java index 28970e6e..bf6a8733 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java @@ -75,7 +75,6 @@ public final class AntiCheatReloaded extends JavaPlugin { private static boolean verbose; private double tps = -1; - private String symbiosisMetric = "None"; @Override public void onLoad() { @@ -165,7 +164,6 @@ public void run() { getServer().getScheduler().runTaskLater(this, new Runnable() { @Override public void run() { - checkForSymbiosis(); try { final Metrics metrics = new Metrics(AntiCheatReloaded.this, 202); metrics.addCustomChart(new SingleLineChart("cheaters_kicked", new Callable() { @@ -189,12 +187,6 @@ public String call() throws Exception { return VersionUtil.getVersion(); } })); - metrics.addCustomChart(new SimplePie("symbiosis", new Callable() { - @Override - public String call() throws Exception { - return symbiosisMetric; - } - })); metrics.addCustomChart(new SimplePie("floodgate_enabled", new Callable() { @Override public String call() throws Exception { @@ -312,56 +304,6 @@ public void onPlayerKicked() { this.playersKicked++; } - /** - * Creates metric that checks for anti-cheat symbiosis I use this to see if - * AntiCheatReloaded is actively being used together with other anti-cheats, so - * I can account for that. - */ - protected void checkForSymbiosis() { - if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "NoCheatPlus"; - } else { - this.symbiosisMetric += ", NoCheatPlus"; - } - } - if (Bukkit.getPluginManager().getPlugin("Matrix") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "Matrix"; - } else { - this.symbiosisMetric += ", Matrix"; - } - } - if (Bukkit.getPluginManager().getPlugin("AAC") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "AAC"; - } else { - this.symbiosisMetric += ", AAC"; - } - } - if (Bukkit.getPluginManager().getPlugin("Spartan") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "Spartan"; - } else { - this.symbiosisMetric += ", Spartan"; - } - } - if (Bukkit.getPluginManager().getPlugin("Negativity") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "Negativity"; - } else { - this.symbiosisMetric += ", Negativity"; - } - } - if (Bukkit.getPluginManager().getPlugin("SoaromaSAC") != null) { - if (this.symbiosisMetric.equals("None")) { - this.symbiosisMetric = "SoaromaSAC"; - } else { - this.symbiosisMetric += ", SoaromaSAC"; - } - } - } - public static void sendToMainThread(final Runnable runnable) { Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable); } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 23ebb62c..83904278 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -26,7 +26,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.potion.PotionEffectType; @@ -39,6 +38,7 @@ import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck; import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; +import com.rammelkast.anticheatreloaded.check.player.NoFallCheck; import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Lang; @@ -47,7 +47,6 @@ import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; public class Backend { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); @@ -57,7 +56,6 @@ public class Backend { private final Map levitatingEnd = new HashMap(); private final Map chatLevel = new HashMap(); private final Map commandLevel = new HashMap(); - private final Map nofallViolation = new HashMap(); private final Map fastPlaceViolation = new HashMap(); private final Map lastBlockPlaced = new HashMap(); private final Map lastBlockPlaceTime = new HashMap(); @@ -105,7 +103,6 @@ public void cleanup(final Player player) { startEat.remove(uuid); lastHeal.remove(uuid); sprinted.remove(uuid); - nofallViolation.remove(uuid); fastPlaceViolation.remove(uuid); lastBlockPlaced.remove(uuid); lastBlockPlaceTime.remove(uuid); @@ -124,6 +121,7 @@ public void cleanup(final Player player) { fastSneakViolations.remove(uuid); lastSneak.remove(uuid); levitatingEnd.remove(uuid); + NoFallCheck.VIOLATIONS.remove(uuid); VelocityCheck.VIOLATIONS.remove(uuid); MorePacketsCheck.LAST_PACKET_TIME.remove(uuid); MorePacketsCheck.PACKET_BALANCE.remove(uuid); @@ -211,40 +209,6 @@ public CheckResult checkSpider(final Player player, final double y) { } } - public CheckResult checkNoFall(final Player player, final double y) { - final UUID uuid = player.getUniqueId(); - if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() - && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player) - && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") - && !VersionUtil.isSlowFalling(player) - && !Utilities - .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) - && !Utilities.isNearClimbable(player) - && !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) { - if (player.getFallDistance() == 0) { - if (nofallViolation.get(uuid) == null) { - nofallViolation.put(uuid, 1); - } else { - nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1); - } - - int i = nofallViolation.get(uuid); - int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag"); - if (i >= vlBeforeFlag) { - nofallViolation.put(player.getUniqueId(), 1); - return new CheckResult(CheckResult.Result.FAILED, - "tried to avoid fall damage (" + i + " times in a row, max=" + vlBeforeFlag + ")"); - } else { - return PASS; - } - } else { - nofallViolation.put(uuid, 0); - return PASS; - } - } - return PASS; - } - public CheckResult checkSneakToggle(final Player player) { final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); final long lastSneak = this.lastSneak.getOrDefault(player.getUniqueId(), (long) 0); @@ -534,7 +498,7 @@ public void logTeleport(final Player player) { manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System .currentTimeMillis(); /* Data for fly/speed should be reset */ - nofallViolation.remove(player.getUniqueId()); + NoFallCheck.VIOLATIONS.remove(player.getUniqueId()); ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId()); } 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 2354ee8f..ad8e0210 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java @@ -31,7 +31,8 @@ import com.rammelkast.anticheatreloaded.util.Utilities; /* - * In development - expect issues + * TODO redo (again) + * Just go for a basic GCD check and implement optifine detection */ public final class AimbotCheck { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java new file mode 100644 index 00000000..57d0078e --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java @@ -0,0 +1,79 @@ +/* + * AntiCheatReloaded for Bukkit and Spigot. + * Copyright (c) 2012-2015 AntiCheat Team + * Copyright (c) 2016-2022 Rammelkast + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rammelkast.anticheatreloaded.check.player; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.GameMode; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import com.rammelkast.anticheatreloaded.AntiCheatReloaded; +import com.rammelkast.anticheatreloaded.check.Backend; +import com.rammelkast.anticheatreloaded.check.CheckResult; +import com.rammelkast.anticheatreloaded.check.CheckType; +import com.rammelkast.anticheatreloaded.config.providers.Checks; +import com.rammelkast.anticheatreloaded.util.Utilities; +import com.rammelkast.anticheatreloaded.util.VersionUtil; + +public final class NoFallCheck { + + public static final Map VIOLATIONS = new HashMap<>(); + + private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); + + public static CheckResult performCheck(final Player player, final double motionY) { + final UUID uuid = player.getUniqueId(); + final Backend backend = AntiCheatReloaded.getManager().getBackend(); + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); + if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() + && !backend.isMovingExempt(player) && !backend.justPlaced(player) && !Utilities.isNearWater(player) + && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") + && !VersionUtil.isSlowFalling(player) + && !Utilities + .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) + && !Utilities.isNearClimbable(player) + && !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) { + if (player.getFallDistance() == 0.0) { + if (VIOLATIONS.get(uuid) == null) { + VIOLATIONS.put(uuid, 1); + } else { + VIOLATIONS.put(uuid, VIOLATIONS.get(player.getUniqueId()) + 1); + } + + final int violations = VIOLATIONS.get(uuid); + final int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag"); + if (violations >= vlBeforeFlag) { + VIOLATIONS.put(player.getUniqueId(), 1); + return new CheckResult(CheckResult.Result.FAILED, + "tried to avoid fall damage (" + violations + " times in a row, max=" + vlBeforeFlag + ")"); + } else { + return PASS; + } + } else { + VIOLATIONS.put(uuid, 0); + return PASS; + } + } + return PASS; + } + +} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java index 6edc341b..5570b686 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandReload.java @@ -42,6 +42,7 @@ public CommandReload() { @Override protected void execute(CommandSender cs, String[] args) { CONFIG.load(); - cs.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + "The configuration was reloaded"); + cs.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + + ChatColor.GRAY + "The configuration was reloaded"); } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java index f3f24f93..b1a11ff9 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java @@ -72,6 +72,7 @@ import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; +import com.rammelkast.anticheatreloaded.check.player.NoFallCheck; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager; import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Permission; @@ -82,7 +83,7 @@ public final class PlayerListener extends EventListener { private static final AntiCheatManager MANAGER = AntiCheatReloaded.getManager(); - + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { final Player player = event.getPlayer(); @@ -184,18 +185,18 @@ public void onPlayerVelocity(final PlayerVelocityEvent event) { if (!user.getMovementManager().onGround) { return; } - + final double motionY = velocity.getY(); user.getMovementManager().velocityExpectedMotionY = motionY; // End part of Velocity check - + MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); } @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerChat(final AsyncPlayerChatEvent event) { final Player player = event.getPlayer(); - + if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) { final CheckResult result = getBackend().checkChatSpam(player, event.getMessage()); if (result.failed()) { @@ -252,7 +253,8 @@ public User call() throws Exception { }).get(); getUserManager().removeUser(user); } catch (final InterruptedException | ExecutionException exception) { - AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to destroy user object async", exception); + AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to destroy user object async", + exception); return; } @@ -290,7 +292,8 @@ public void onPlayerInteract(final PlayerInteractEvent event) { final Player player = event.getPlayer(); final PlayerInventory inv = player.getInventory(); if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { - final ItemStack itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand() : inv.getItemInOffHand()); + final ItemStack itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand() + : inv.getItemInOffHand()); if (itemInHand.getType() == Material.BOW) { getBackend().logBowWindUp(player); @@ -372,10 +375,11 @@ public User call() throws Exception { }).get(); getUserManager().addUser(user); } catch (final InterruptedException | ExecutionException exception) { - AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to create user object async", exception); + AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to create user object async", + exception); return; } - + MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) { @@ -427,7 +431,8 @@ public void onPlayerMove(final PlayerMoveEvent event) { } if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) { - final CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo())); + final CheckResult result = getBackend().checkVClip(player, + new Distance(event.getFrom(), event.getTo())); if (result.failed()) { if (!silentMode()) { int data = result.getData() > 3 ? 3 : result.getData(); @@ -447,7 +452,7 @@ public void onPlayerMove(final PlayerMoveEvent event) { && getCheckManager().willCheck(player, CheckType.FLIGHT) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) { - final CheckResult result = getBackend().checkNoFall(player, y); + final CheckResult result = NoFallCheck.performCheck(player, y); if (result.failed()) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java index 0f6164a6..5cacd72a 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java @@ -36,10 +36,9 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil; /** - *

- * The manager that AntiCheat will check with to see if it should watch certain checks and certain players. + * The manager that AntiCheatReloaded will check with to see if it should watch + * certain checks and certain players. */ - public final class CheckManager { private final AntiCheatManager manager; From 5c85b8717bc4f6314ea7dff605514508610b8a17 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 1 Jan 2022 21:53:16 +0100 Subject: [PATCH 11/17] Small changes to reach check, redid aimbot check, improved default config Prepared for release. --- pom.xml | 2 +- .../check/combat/KillAuraCheck.java | 8 +++---- .../check/movement/AimbotCheck.java | 20 +++++++----------- .../anticheatreloaded/util/Utilities.java | 21 +++++++------------ src/main/resources/checks.yml | 12 +++++------ 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/pom.xml b/pom.xml index 91ecc9a3..4d296e40 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.rammelkast.anticheatreloaded AntiCheatReloaded - 1.10.3-PRE + 1.10.3 AntiCheatReloaded https://www.spigotmc.org/resources/anticheatreloaded.23799/ diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java index 6b9b2078..19252bae 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java @@ -85,11 +85,11 @@ public static CheckResult checkReach(final Player player, final Entity target) { // Velocity compensation final double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier"); allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier; - final double reachedDistance = ((LivingEntity) target).getLocation().toVector() - .distance(player.getLocation().toVector()); - if (reachedDistance > allowedReach) { + final double reachedDistance = Utilities.roundDouble(((LivingEntity) target).getLocation().toVector() + .distance(player.getLocation().toVector()), 2); + if (reachedDistance > Utilities.roundDouble(allowedReach, 2)) { return new CheckResult(CheckResult.Result.FAILED, "Reach", - "reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")"); + "reached too far (distance=" + reachedDistance + ", max=" + Utilities.roundDouble(allowedReach, 2) + ")"); } return PASS; } 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 ad8e0210..127eac17 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java @@ -30,12 +30,9 @@ import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -/* - * TODO redo (again) - * Just go for a basic GCD check and implement optifine detection - */ public final class AimbotCheck { + private static final double EXPANDER = Math.pow(2, 24); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); public static CheckResult runCheck(final Player player, final EntityDamageByEntityEvent event) { @@ -49,19 +46,18 @@ public static CheckResult runCheck(final Player player, final EntityDamageByEnti final MovementManager movementManager = user.getMovementManager(); final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); final float deltaPitch = movementManager.deltaPitch; - final float deltaYaw = movementManager.deltaYaw; final float pitchAcceleration = Math.abs(deltaPitch - movementManager.lastDeltaPitch); - final double gcd = Utilities.computeGcd(deltaPitch, movementManager.lastDeltaPitch); - final double mod = Math.abs(player.getLocation().getPitch() % gcd); + final long gcd = Utilities.getGcd((long) (deltaPitch * EXPANDER), + (long) (movementManager.lastDeltaPitch * EXPANDER)); + final double mod = Math.abs(player.getLocation().getPitch() % (gcd / EXPANDER)); final double minAcceleration = checksConfig.getDouble(CheckType.AIMBOT, "minAcceleration"); final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod"); - if (mod < maxMod && pitchAcceleration > minAcceleration - && (deltaPitch == 0.0f || (deltaPitch > 45.0f && deltaYaw > 45.0f))) { + if ((gcd > 0L && gcd < 131072L) && mod <= maxMod && pitchAcceleration > minAcceleration && deltaPitch > 5.0f) { return new CheckResult(CheckResult.Result.FAILED, - "failed computational check (gcd=" + Utilities.roundDouble(gcd, 4) + ", mod=" - + Utilities.roundDouble(mod, 4) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 4) - + ")"); + "failed computational check (gcd=" + gcd + ", mod=" + + Utilities.roundDouble(mod, 5) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 3) + + ", delta=" + Utilities.roundDouble(deltaPitch, 1) + ")"); } return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index fd9c6278..776a2b4c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -766,22 +766,15 @@ public static float computeAngleDifference(final float a, final float b) { /** * Calculates the greatest common divider - * @param a value a - * @param b value b - * @return the greatest common divider of a and b + * + * @param current - The current value + * @param previous - The previous value + * @return - The GCD of those two values */ - public static double computeGcd(final double a, final double b) { - if (a < b) { - return computeGcd(b, a); - } + public static long getGcd(final long current, final long previous) { + return (previous <= 16384L) ? current : getGcd(previous, current % previous); + } - if (Math.abs(b) < 0.001) { - return a; - } else { - return computeGcd(b, a - Math.floor(a / b) * b); - } - } - public static boolean isCollisionPoint(final Location location, final Predicate predicate) { final ArrayList materials = new ArrayList<>(); for (double x = -0.3; x <= 0.3; x += 0.3) { diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index aebcc575..90b8e404 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -58,7 +58,7 @@ speed: # Should this part of the check be enabled? enabled: true # Base unadjusted air speed limit - baseLimit: 0.03125 + baseLimit: 0.0315 # Prediction multiplier for custom walk speeds walkSpeedMultiplier: 1.4 # Checks movement acceleration in the air @@ -67,7 +67,7 @@ speed: # Should this part of the check be enabled? enabled: true # Base unadjusted air acceleration limit - baseLimit: 0.3725 + baseLimit: 0.375 # Limit multiplier for custom walk speeds walkSpeedMultiplier: 1.4 # Checks movement acceleration in the air @@ -157,7 +157,7 @@ killaura: # Maximum base reach distances baseMaxValue: # Maximum base reach value - normal: 3.6 + normal: 3.5 # Maximum base reach value when a player has velocity velocitized: 4.0 # Settings for lag compensation @@ -167,7 +167,7 @@ killaura: # Extra allowed reach distance per millisecond of ping pingCompensation: 0.0025 # The multiplier of extra compensation for velocity - velocityMultiplier: 1.2 + velocityMultiplier: 1.3 # Checks if the target it within a players viewing angle # Debugs as 'tried to attack from an illegal angle' angle: @@ -194,9 +194,9 @@ aimbot: # Should this check be enabled? enabled: true # Maximum pitch acceleration for check to consider aim illegal - minAcceleration: 0.5 + minAcceleration: 5.5 # Maximum mod value for check to consider aim illegal - maxMod: 0.0001 + maxMod: 0.001 # Criticals check settings # Checks if the player tries to do a crit without needed conditions criticals: From 031e7b145b410500b3aef1594decb55022cce9b7 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 15 Jan 2022 16:49:47 +0100 Subject: [PATCH 12/17] Started on ACR 1.11.0: Added 3 new KillAura checks (ThroughWalls, RepeatedAim and Variance), added new Speed check (Predict), started added buffer systems to speed checks, improved BoatFly (still needs testing), performance improvements, config changes, fixed Flight false positive, fixed BadPackets false positive, some code reformatting --- pom.xml | 6 +- .../anticheatreloaded/AntiCheatReloaded.java | 16 +- .../anticheatreloaded/check/Backend.java | 5 + .../check/combat/KillAuraCheck.java | 155 ++++++++++++-- .../check/movement/AimbotCheck.java | 6 +- .../check/movement/BoatFlyCheck.java | 6 +- .../check/movement/FastLadderCheck.java | 4 +- .../check/movement/FlightCheck.java | 15 +- .../check/movement/NoSlowCheck.java | 5 + .../check/movement/SpeedCheck.java | 167 +++++++++++---- .../check/movement/StrafeCheck.java | 11 +- .../check/movement/WaterWalkCheck.java | 6 +- .../check/packet/BadPacketsCheck.java | 26 +-- .../check/packet/MorePacketsCheck.java | 5 + ...nteract.java => IllegalInteractCheck.java} | 8 +- .../check/player/NoFallCheck.java | 9 +- .../event/BlockListener.java | 40 ++-- .../event/EntityListener.java | 196 ++++++++++-------- .../event/EventListener.java | 6 +- .../event/PacketListener.java | 93 +++++++++ .../event/PlayerListener.java | 63 ++++-- .../manage/CheckManager.java | 4 +- .../anticheatreloaded/util/Friction.java | 66 ++++++ .../util/MovementManager.java | 24 ++- .../util/PacketListener.java | 100 --------- .../anticheatreloaded/util/User.java | 15 +- .../anticheatreloaded/util/Utilities.java | 105 +++++++--- .../{VersionUtil.java => VersionLib.java} | 2 +- src/main/resources/checks.yml | 43 +++- 29 files changed, 819 insertions(+), 388 deletions(-) rename src/main/java/com/rammelkast/anticheatreloaded/check/player/{IllegalInteract.java => IllegalInteractCheck.java} (93%) create mode 100644 src/main/java/com/rammelkast/anticheatreloaded/event/PacketListener.java create mode 100644 src/main/java/com/rammelkast/anticheatreloaded/util/Friction.java delete mode 100644 src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java rename src/main/java/com/rammelkast/anticheatreloaded/util/{VersionUtil.java => VersionLib.java} (96%) diff --git a/pom.xml b/pom.xml index 4d296e40..fc237355 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.rammelkast.anticheatreloaded AntiCheatReloaded - 1.10.3 + 1.11.0-PRE AntiCheatReloaded https://www.spigotmc.org/resources/anticheatreloaded.23799/ @@ -61,6 +61,10 @@ com.cryptomorin.xseries com.rammelkast.anticheatreloaded.util + + + com.github.juliarn.npc + com.rammelkast.anticheatreloaded.util.npc diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java index bf6a8733..bbb0433e 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java @@ -42,13 +42,13 @@ import com.rammelkast.anticheatreloaded.event.BlockListener; import com.rammelkast.anticheatreloaded.event.EntityListener; import com.rammelkast.anticheatreloaded.event.InventoryListener; +import com.rammelkast.anticheatreloaded.event.PacketListener; import com.rammelkast.anticheatreloaded.event.PlayerListener; import com.rammelkast.anticheatreloaded.event.VehicleListener; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager; -import com.rammelkast.anticheatreloaded.util.PacketListener; import com.rammelkast.anticheatreloaded.util.UpdateManager; import com.rammelkast.anticheatreloaded.util.User; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; import lombok.Getter; @@ -118,13 +118,10 @@ public void onEnable() { setupProtocol(); Bukkit.getConsoleSender() - .sendMessage(PREFIX + ChatColor.GRAY + "Running Minecraft version " + VersionUtil.getVersion() + " " - + (VersionUtil.isSupported() ? (ChatColor.GREEN + "(supported)") + .sendMessage(PREFIX + ChatColor.GRAY + "Running Minecraft version " + VersionLib.getVersion() + " " + + (VersionLib.isSupported() ? (ChatColor.GREEN + "(supported)") : (ChatColor.RED + "(NOT SUPPORTED!)"))); - - // Load protocol manager - PacketListener.load(protocolManager); - + // Check for Floodgate if (Bukkit.getPluginManager().getPlugin("Floodgate") != null) { floodgateEnabled = true; @@ -184,7 +181,7 @@ public String call() throws Exception { metrics.addCustomChart(new SimplePie("nms_version", new Callable() { @Override public String call() throws Exception { - return VersionUtil.getVersion(); + return VersionLib.getVersion(); } })); metrics.addCustomChart(new SimplePie("floodgate_enabled", new Callable() { @@ -220,6 +217,7 @@ public void onDisable() { private void setupProtocol() { protocolManager = ProtocolLibrary.getProtocolManager(); + protocolManager.addPacketListener(new PacketListener(this)); verboseLog("Hooked into ProtocolLib"); } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 83904278..29ff0d34 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -37,6 +37,7 @@ import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck; +import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; import com.rammelkast.anticheatreloaded.check.player.NoFallCheck; import com.rammelkast.anticheatreloaded.config.Configuration; @@ -129,9 +130,13 @@ public void cleanup(final Player player) { ElytraCheck.JUMP_Y_VALUE.remove(uuid); KillAuraCheck.ANGLE_FLAGS.remove(uuid); KillAuraCheck.PACKETORDER_FLAGS.remove(uuid); + KillAuraCheck.THROUGHWALLS_FLAGS.remove(uuid); FlightCheck.MOVING_EXEMPT.remove(uuid); NoSlowCheck.LAST_RELEASE.remove(uuid); NoSlowCheck.VIOLATIONS.remove(uuid); + SpeedCheck.PREDICT_BUFFER.remove(uuid); + SpeedCheck.AIRSPEED_BUFFER.remove(uuid); + SpeedCheck.AIRACCELERATION_BUFFER.remove(uuid); } public Magic getMagic() { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java index 19252bae..8fb7129f 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java @@ -22,14 +22,19 @@ import java.util.Map; import java.util.UUID; +import org.bukkit.FluidCollisionMode; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; +import com.google.common.collect.EvictingQueue; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult.Result; @@ -38,14 +43,23 @@ import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class KillAuraCheck { // Angle check public static final Map ANGLE_FLAGS = new HashMap(); + // PacketOrder check public static final Map PACKETORDER_FLAGS = new HashMap(); + + // ThroughWalls check + public static final Map THROUGHWALLS_FLAGS = new HashMap(); + private static final double RAY_LENGTH = 4.5; + + // Variance check + public static final Map> FACTOR_MAP = new HashMap>(); + private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); public static CheckResult checkReach(final Player player, final Entity target) { @@ -68,7 +82,8 @@ public static CheckResult checkReach(final Player player, final Entity target) { allowedReach += 1.5D; } // Lag compensation - final double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach"); + final double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", + "lagCompensation.lagExtraReach"); final double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.pingCompensation"); allowedReach += user.getPing() * pingCompensation; @@ -85,11 +100,11 @@ public static CheckResult checkReach(final Player player, final Entity target) { // Velocity compensation final double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier"); allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier; - final double reachedDistance = Utilities.roundDouble(((LivingEntity) target).getLocation().toVector() - .distance(player.getLocation().toVector()), 2); + final double reachedDistance = Utilities.roundDouble( + ((LivingEntity) target).getLocation().toVector().distance(player.getLocation().toVector()), 2); if (reachedDistance > Utilities.roundDouble(allowedReach, 2)) { - return new CheckResult(CheckResult.Result.FAILED, "Reach", - "reached too far (distance=" + reachedDistance + ", max=" + Utilities.roundDouble(allowedReach, 2) + ")"); + return new CheckResult(CheckResult.Result.FAILED, "Reach", "reached too far (distance=" + reachedDistance + + ", max=" + Utilities.roundDouble(allowedReach, 2) + ")"); } return PASS; } @@ -97,12 +112,12 @@ public static CheckResult checkReach(final Player player, final Entity target) { public static CheckResult checkAngle(final Player player, final EntityDamageEvent event) { final UUID uuid = player.getUniqueId(); final Entity entity = event.getEntity(); - + // Do not check while in vehicles - if (player.getVehicle() != null || entity.getVehicle() != null || VersionUtil.isRiptiding(player)) { + if (player.getVehicle() != null || entity.getVehicle() != null || VersionLib.isRiptiding(player)) { return PASS; } - + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); // Check if enabled @@ -149,9 +164,9 @@ public static CheckResult checkPacketOrder(final Player player, final Entity ent if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder")) { return PASS; } - - if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100 - || AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps")) { + + if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100 || AntiCheatReloaded + .getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps")) { return PASS; } @@ -166,14 +181,126 @@ public static CheckResult checkPacketOrder(final Player player, final Entity ent int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag"); if (flags >= vlBeforeFlag) { PACKETORDER_FLAGS.remove(uuid); - return new CheckResult(Result.FAILED, "PacketOrder", "suspicious packet order (elapsed=" + elapsed + ")"); + return new CheckResult(Result.FAILED, "PacketOrder", + "suspicious packet order (elapsed=" + elapsed + ")"); } PACKETORDER_FLAGS.put(uuid, flags + 1); } return PASS; } - + + public static CheckResult checkVariance(final Player player) { + final UUID uuid = player.getUniqueId(); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); + final MovementManager movementManager = user.getMovementManager(); + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); + + // Check if enabled + if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "variance")) { + return PASS; + } + + final int samples = checksConfig.getInteger(CheckType.KILLAURA, "variance", "samples"); + if (movementManager.deltaPitch > 0.0f && movementManager.lastDeltaPitch > 0.0f + && movementManager.deltaYaw > 5.0f) { + final float factor = movementManager.deltaPitch % movementManager.lastDeltaPitch; + final EvictingQueue queue = FACTOR_MAP.getOrDefault(uuid, EvictingQueue.create(samples)); + queue.add(factor); + if (queue.size() >= samples) { + final double variance = Utilities.getVariance(queue); + if (variance < 0.25) { + FACTOR_MAP.put(uuid, queue); + return new CheckResult(Result.FAILED, "Variance", + "had suspicous aim behaviour (variance: " + Utilities.roundDouble(variance, 3) + ")"); + } + } + FACTOR_MAP.put(uuid, queue); + } + + return PASS; + } + + public static CheckResult checkRepeatedAim(final Player player) { + final UUID uuid = player.getUniqueId(); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); + final MovementManager movementManager = user.getMovementManager(); + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); + + // Check if enabled + if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "repeatedAim")) { + return PASS; + } + + final float deltaYaw = movementManager.deltaYaw; + final float lastDeltaYaw = movementManager.lastDeltaYaw; + final float deltaPitch = movementManager.deltaPitch; + final float lastDeltaPitch = movementManager.lastDeltaPitch; + if (deltaYaw > 0.0f && Math.abs(deltaYaw - lastDeltaYaw) < 1e-5 && deltaPitch > 10.0f) { + return new CheckResult(Result.FAILED, "RepeatedAim", + "repeated aim pattern (type=yaw, deltaPitch=" + Utilities.roundFloat(deltaPitch, 1) + ")"); + } else if (deltaPitch > 0.0f && Math.abs(deltaPitch - lastDeltaPitch) < 1e-5 && deltaYaw > 12.0f) { + return new CheckResult(Result.FAILED, "RepeatedAim", + "repeated aim pattern (type=pitch, deltaYaw=" + Utilities.roundFloat(deltaYaw, 1) + ")"); + } + return PASS; + } + + public static CheckResult checkThroughWalls(final Player player, final Entity target) { + final UUID uuid = player.getUniqueId(); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); + final MovementManager movementManager = user.getMovementManager(); + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); + + // Check if enabled + if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "throughWalls")) { + return PASS; + } + + if ((user.isLagging() && checksConfig.getBoolean(CheckType.KILLAURA, "throughWalls", "disableForLagging")) + || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100 || AntiCheatReloaded.getPlugin() + .getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "throughWalls", "minimumTps")) { + return PASS; + } + + if (Math.abs(player.getLocation().getPitch()) > 30.0f) { + return PASS; + } + + final Location eyes = player.getEyeLocation().clone(); + final World world = player.getWorld(); + final double expansion = checksConfig.getDouble(CheckType.KILLAURA, "throughWalls", "expand"); + final RayTraceResult result = world.rayTrace(eyes, eyes.getDirection(), RAY_LENGTH, FluidCollisionMode.NEVER, + true, expansion, entity -> entity.equals(target)); + if (player.getLocation().toVector().clone().setY(0.0) + .distance(target.getLocation().toVector().clone().setY(0)) <= expansion) { + return PASS; + } + + if (result != null) { + final Block block = result.getHitBlock(); + final Entity entity = result.getHitEntity(); + final double distance = result.getHitPosition().distance(eyes.toVector()); + if (entity == null && block != null && distance > 0.3) { + final int flags = THROUGHWALLS_FLAGS.getOrDefault(uuid, 0) + 1; + if (flags > checksConfig.getInteger(CheckType.KILLAURA, "throughWalls", "vlBeforeFlag")) { + THROUGHWALLS_FLAGS.put(uuid, 0); + return new CheckResult(Result.FAILED, "ThroughWalls", + "hit through object (distance: " + Utilities.roundDouble(distance, 2) + ", block: " + + block.getType().name().toLowerCase() + ", pitch: " + + Utilities.roundFloat(player.getLocation().getPitch(), 1) + ")"); + } + THROUGHWALLS_FLAGS.put(uuid, flags); + } else { + final int flags = THROUGHWALLS_FLAGS.getOrDefault(uuid, 1) - 1; + THROUGHWALLS_FLAGS.put(uuid, flags); + } + } else { + // TODO should be covered by angle & reach check, but maybe continue anyway? + } + return PASS; + } + public static double calculateYawDifference(final Location from, final Location to) { final Location clonedFrom = from.clone(); final Vector startVector = clonedFrom.toVector(); 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 127eac17..04b0c59d 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/AimbotCheck.java @@ -35,6 +35,10 @@ public final class AimbotCheck { private static final double EXPANDER = Math.pow(2, 24); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); + /** + * This falses sometimes? + * TODO we need to check yaw deltas + */ public static CheckResult runCheck(final Player player, final EntityDamageByEntityEvent event) { final Backend backend = AntiCheatReloaded.getManager().getBackend(); if (backend.isMovingExempt(player)) { @@ -53,7 +57,7 @@ public static CheckResult runCheck(final Player player, final EntityDamageByEnti final double mod = Math.abs(player.getLocation().getPitch() % (gcd / EXPANDER)); final double minAcceleration = checksConfig.getDouble(CheckType.AIMBOT, "minAcceleration"); final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod"); - if ((gcd > 0L && gcd < 131072L) && mod <= maxMod && pitchAcceleration > minAcceleration && deltaPitch > 5.0f) { + if ((gcd > 0L && gcd < 131072L) && mod <= maxMod && pitchAcceleration > minAcceleration && deltaPitch > 5.0f && deltaPitch < 20.0f) { return new CheckResult(CheckResult.Result.FAILED, "failed computational check (gcd=" + gcd + ", mod=" + Utilities.roundDouble(mod, 5) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 3) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java index 6154495c..301fa4ed 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/BoatFlyCheck.java @@ -35,7 +35,7 @@ import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class BoatFlyCheck { @@ -43,8 +43,8 @@ public final class BoatFlyCheck { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); public static CheckResult runCheck(final Player player, final MovementManager movementManager, final Location to) { - if (movementManager.distanceXZ <= 0 || movementManager.motionY <= 1E-3 - || (System.currentTimeMillis() - movementManager.lastTeleport <= 50) || VersionUtil.isFlying(player) + if (movementManager.motionY <= 1E-3 + || (System.currentTimeMillis() - movementManager.lastTeleport <= 150) || VersionLib.isFlying(player) || !player.isInsideVehicle()) { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java index deb427ab..29411625 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FastLadderCheck.java @@ -30,7 +30,7 @@ import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class FastLadderCheck { @@ -42,7 +42,7 @@ public static CheckResult runCheck(Player player, double y) { // Liquids are climbable blocks, so we have to add a seperate check if (!Utilities.isClimbableBlock(player.getLocation().getBlock()) || !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) - || player.getLocation().getBlock().isLiquid() || VersionUtil.isFlying(player)) { + || player.getLocation().getBlock().isLiquid() || VersionLib.isFlying(player)) { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java index 5022f645..17db1bcb 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -36,7 +36,7 @@ import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VelocityTracker; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; /** * @author Rammelkast @@ -47,11 +47,11 @@ public final class FlightCheck { public static final Map GRAVITY_VIOLATIONS = new HashMap(); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); - private static final double GRAVITY_FRICTION = 0.9800000190734863D; + private static final double GRAVITY_FRICTION = 0.98f; public static CheckResult runCheck(final Player player, final Distance distance) { if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN() - || VersionUtil.isFlying(player) || player.getVehicle() != null + || VersionLib.isFlying(player) || player.getVehicle() != null || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) { // This was a teleport or user is flying/using elytra/in a vehicle, so we don't // care about it. @@ -70,7 +70,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) int minAirTicks = 13; if (player.hasPotionEffect(PotionEffectType.JUMP)) { - minAirTicks += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 3; + minAirTicks += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 3; } if (movementManager.halfMovementHistoryCounter > 25) { @@ -125,11 +125,12 @@ public static CheckResult runCheck(final Player player, final Distance distance) && !Utilities.couldBeOnBoat(player) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports")) - && !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player) + && !VersionLib.isSlowFalling(player) && !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25 && !Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0)) && !Utilities.isNearWater(player) - && !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) { + && !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)) + && velocityTracker.getVertical() == 0.0) { return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff=" + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); } @@ -229,7 +230,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig .getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports")) && !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25 - && !VersionUtil.isSlowFalling(player)) { + && !VersionLib.isSlowFalling(player)) { final double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION; final double offset = Math.abs(gravitatedY - movementManager.motionY); double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset"); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java index 91b75f20..612dd6b1 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowCheck.java @@ -39,6 +39,11 @@ public final class NoSlowCheck { public static final Map VIOLATIONS = new HashMap(); public static void runCheck(final Player player, final PacketEvent event) { + if (event.isCancelled()) { + // Do not check if cancelled + return; + } + if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.NOSLOW)) { return; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java index 040984f6..cb06ac02 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -18,6 +18,10 @@ */ package com.rammelkast.anticheatreloaded.check.movement; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Location; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; @@ -30,34 +34,99 @@ import com.rammelkast.anticheatreloaded.check.Backend; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType; +import com.rammelkast.anticheatreloaded.check.CheckResult.Result; import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.Distance; +import com.rammelkast.anticheatreloaded.util.Friction; import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VelocityTracker; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; /** - * @author Rammelkast TODO soulsand speed TODO buffer system + * @author Rammelkast TODO soulsand speed TODO buffer system for all */ public final class SpeedCheck { + public static final Map PREDICT_BUFFER = new HashMap<>(); + public static final Map AIRSPEED_BUFFER = new HashMap<>(); + public static final Map AIRACCELERATION_BUFFER = new HashMap<>(); + private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static boolean isSpeedExempt(final Player player, final Backend backend) { - return backend.isMovingExempt(player) || VersionUtil.isFlying(player); + return backend.isMovingExempt(player) || VersionLib.isFlying(player); } - - public static CheckResult checkXZSpeed(final Player player, final double x, final double z, - final Location movingTowards) { + + /** + * Largely based on Elevated's Frequency speed check + * @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java + */ + public static CheckResult checkPredict(final Player player, final Location movingTowards) { + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); + if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "predict")) { + return PASS; + } + + final Backend backend = AntiCheatReloaded.getManager().getBackend(); + if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player) + || Utilities.isInWeb(player)) { + return PASS; + } + + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); + final UUID uuid = player.getUniqueId(); + final MovementManager movementManager = user.getMovementManager(); + final VelocityTracker velocityTracker = user.getVelocityTracker(); + + final double motion = movementManager.distanceXZ; + final boolean sprinting = true; // TODO do this using packets + + double buffer = PREDICT_BUFFER.getOrDefault(uuid, 0.0); + double movementSpeed = Utilities.getMovementSpeed(player); + if (movementManager.wasOnGround) { + if (sprinting) { + movementSpeed *= 1.3f; + } + + movementSpeed *= 0.16277136 / Math.pow((movementManager.friction *= 0.91f), 3); + if (!movementManager.onGround && movementManager.motionY >= 0.42f && sprinting) { + movementSpeed += 0.2f; + } + } else { + movementSpeed = sprinting ? 0.026f : 0.02f; + movementManager.friction = 0.91f; + } + + movementSpeed += velocityTracker.getHorizontal(); + + final double factor = (motion - movementManager.adjusted) / movementSpeed; + if (factor > 1.001) { + if (buffer++ > 2.5) { + buffer /= 2; + PREDICT_BUFFER.put(uuid, buffer); + return new CheckResult(Result.FAILED, "Predict", "moved unexpectedly (factor=" + Utilities.roundDouble(factor, 3) + ")"); + } + } else { + buffer = Math.max(buffer - 0.05, 0.0); + } + + PREDICT_BUFFER.put(uuid, buffer); + + movementManager.adjusted = motion * movementManager.friction; + movementManager.friction = Friction.getFactor(movingTowards.clone().subtract(0, 1, 0).getBlock()); + return PASS; + } + + public static CheckResult checkXZSpeed(final Player player, final Location movingTowards) { final Backend backend = AntiCheatReloaded.getManager().getBackend(); if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)) { return PASS; } - final User user = AntiCheatReloaded.getManager().getUserManager() - .getUser(player.getUniqueId()); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); + final UUID uuid = player.getUniqueId(); final MovementManager movementManager = user.getMovementManager(); final VelocityTracker velocityTracker = user.getVelocityTracker(); @@ -65,6 +134,7 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina if (movementManager.riptideTicks > 0) { return PASS; } + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); final double distanceXZ = movementManager.distanceXZ; final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid; @@ -72,6 +142,8 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina // AirSpeed if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1 && movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) { + double buffer = AIRSPEED_BUFFER.getOrDefault(uuid, 0.0); + final double multiplier = 0.985D; double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1); // Prevents false when falling from great heights @@ -119,13 +191,13 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina // Adjust for soul speed final ItemStack boots = player.getInventory().getBoots(); - if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionUtil.isSoulSpeed(boots)) { + if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionLib.isSoulSpeed(boots)) { predict += boots.getEnchantmentLevel(Enchantment.SOUL_SPEED) * 0.05D; } // Adjust for speed effects if (movementManager.hasSpeedEffect) { - predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D; + predict += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D; } // Adjust for speed effects ending @@ -135,7 +207,7 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina // Adjust for jump boost effects if (player.hasPotionEffect(PotionEffectType.JUMP)) { - predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D; + predict += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D; } // Adjust for custom walking speed @@ -166,7 +238,7 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina } // Players can move faster in air with slow falling - if (VersionUtil.isSlowFalling(player)) { + if (VersionLib.isSlowFalling(player)) { predict *= 1.25D; } @@ -183,24 +255,32 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina && movementManager.motionY < -0.18 && movementManager.motionY > -0.182) { predict += Math.abs(movementManager.motionY); } - + // Adjust for velocity limit += velocityTracker.getHorizontal(); if (distanceXZ - predict > limit) { - return new CheckResult(CheckResult.Result.FAILED, "AirSpeed", - "moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", block=" - + movementManager.blockingTicks + ", box=" + boxedIn + ", at=" - + movementManager.airTicks + ")"); + if (buffer++ > 1.5) { + buffer /= 2; + AIRSPEED_BUFFER.put(uuid, buffer); + return new CheckResult(CheckResult.Result.FAILED, "AirSpeed", + "moved too fast in air (speed=" + Utilities.roundDouble(distanceXZ, 4) + ", limit=" + + Utilities.roundDouble(predict, 4) + ", block=" + movementManager.blockingTicks + + ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")"); + } + } else { + buffer = Math.max(buffer - 0.05, 0.0); } + + AIRSPEED_BUFFER.put(uuid, buffer); } // AirAcceleration - // As of right now, this falses sometimes, dont know why if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airAcceleration") && movementManager.airTicks > 1 && movementManager.iceInfluenceTicks <= 0 && movementManager.slimeInfluenceTicks <= 0 && movementManager.elytraEffectTicks <= 0) { final double initialAcceleration = movementManager.acceleration; + double buffer = AIRACCELERATION_BUFFER.getOrDefault(uuid, 0.0); double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725 // Slight increase when boxed in if (boxedIn) { @@ -209,13 +289,13 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina // Adjust for soul speed final ItemStack boots = player.getInventory().getBoots(); - if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionUtil.isSoulSpeed(boots)) { + if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionLib.isSoulSpeed(boots)) { limit += boots.getEnchantmentLevel(Enchantment.SOUL_SPEED) * 0.025D; } // Adjust for speed effects if (player.hasPotionEffect(PotionEffectType.SPEED)) { - limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D; + limit += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D; } // Adjust for slabs @@ -232,14 +312,23 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina if (Utilities.couldBeOnBoat(player)) { limit *= 1.25D; } - + // Add velocity limit += velocityTracker.getHorizontal(); if (initialAcceleration > limit) { - return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration", - "exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")"); + if (buffer++ > 1.5) { + buffer /= 2; + AIRACCELERATION_BUFFER.put(uuid, buffer); + return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration", + "exceeded acceleration limits (acceleration=" + Utilities.roundDouble(initialAcceleration, 4) + + ", max=" + Utilities.roundDouble(limit, 4) + ")"); + } + } else { + buffer = Math.max(buffer - 0.05, 0.0); } + + AIRACCELERATION_BUFFER.put(uuid, buffer); } // JumpBehaviour @@ -247,8 +336,7 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick && !boxedIn && movementManager.slimeInfluenceTicks <= 10 && !Utilities.isNearHalfblock(movingTowards) && !Utilities.isNearHalfblock(movingTowards.clone().subtract(0, 0.51, 0)) - && !Utilities.couldBeOnBoat(player, 0.8, false) - && movementManager.elytraEffectTicks <= 0) { + && !Utilities.couldBeOnBoat(player, 0.8, false) && movementManager.elytraEffectTicks <= 0) { // This happens naturally if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) { final double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default @@ -261,7 +349,8 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina } // GroundSpeed - if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1 && movementManager.elytraEffectTicks < 10) { + if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1 + && movementManager.elytraEffectTicks < 10) { final double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default // 0.34 double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks); @@ -287,7 +376,7 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina // Adjust for speed effects if (movementManager.hasSpeedEffect) { - limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D; + limit += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D; } if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3) { limit *= 1.4D; @@ -331,24 +420,23 @@ public static CheckResult checkXZSpeed(final Player player, final double x, fina } // Prevent NoWeb - // TODO config if (Utilities.isInWeb(player)) { limit *= 0.65D; } // Sneak speed check - // TODO config if (movementManager.sneakingTicks > 1) { limit *= 0.68D; } - + // Velocity adjustment limit += velocityTracker.getHorizontal(); if (distanceXZ - limit > 0) { return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed", - "moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" - + player.isBlocking() + ", gt=" + movementManager.groundTicks + ")"); + "moved too fast on ground (speed=" + Utilities.roundDouble(distanceXZ, 4) + ", limit=" + + Utilities.roundDouble(limit, 4) + ", blocking=" + player.isBlocking() + ", gt=" + + movementManager.groundTicks + ")"); } } @@ -362,8 +450,7 @@ public static CheckResult checkVerticalSpeed(final Player player, final Distance return PASS; } - final User user = AntiCheatReloaded.getManager().getUserManager() - .getUser(player.getUniqueId()); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); final MovementManager movementManager = user.getMovementManager(); final VelocityTracker velocityTracker = user.getVelocityTracker(); // Riptiding exemption @@ -385,18 +472,19 @@ public static CheckResult checkVerticalSpeed(final Player player, final Distance if (movementManager.nearLiquidTicks > 6) { maxMotionY *= 1.0525D; } - + // Adjust for powdered snow if (distance.getFrom().getBlock().getType() == XMaterial.POWDER_SNOW.parseMaterial()) { maxMotionY += 0.17D; } - + // Adjust for velocity maxMotionY += velocityTracker.getVertical(); if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) { return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed", - "exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); + "exceeded vertical speed limit (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", max=" + + Utilities.roundDouble(maxMotionY, 4) + ")"); } return PASS; } @@ -404,16 +492,13 @@ public static CheckResult checkVerticalSpeed(final Player player, final Distance private static double getMaxAcceptableMotionY(final Player player, final boolean nearBed, final boolean couldBeOnBoat, final boolean fromClimbable, final boolean halfMovement, final Checks checksConfig) { - // TODO config for these values - // TODO something funky vanilla stuff going on with 0.42, like 0.445.., check - // this.. double base = couldBeOnBoat ? 0.6f : (nearBed ? 0.5625f : ((halfMovement) ? 0.6f : 0.42f)); if (fromClimbable) { base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04 } if (player.hasPotionEffect(PotionEffectType.JUMP)) { - base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D; + base += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D; } return base; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java index a1af5691..496f68a6 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/StrafeCheck.java @@ -32,7 +32,7 @@ import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VelocityTracker; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; /** * @@ -46,24 +46,23 @@ public final class StrafeCheck { public static CheckResult runCheck(final Player player, final double x, final double z, final Location from, final Location to) { if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player) - || Utilities.isNearClimbable(player) || VersionUtil.isFlying(player) || player.isDead() + || Utilities.isNearClimbable(player) || VersionLib.isFlying(player) || player.isDead() || Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)) || Utilities.isNearHalfblock(to)) { return PASS; } - final User user = AntiCheatReloaded.getManager().getUserManager() - .getUser(player.getUniqueId()); + final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); final MovementManager movementManager = user.getMovementManager(); final VelocityTracker velocityTracker = user.getVelocityTracker(); if (velocityTracker.isVelocitized()) { return PASS; } - + final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); if (System.currentTimeMillis() - movementManager.lastTeleport <= checksConfig.getInteger(CheckType.STRAFE, "accountForTeleports") || movementManager.elytraEffectTicks >= 20 - || movementManager.halfMovementHistoryCounter >= 20 || Utilities.couldBeOnBoat(player, 0.5d, false)) { + || movementManager.halfMovementHistoryCounter >= 20 || Utilities.couldBeOnBoat(player, 0.5, false)) { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java index 4d209d94..92dfb0e3 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java @@ -32,7 +32,7 @@ import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class WaterWalkCheck { @@ -44,7 +44,7 @@ public static CheckResult runCheck(final Player player, final double x, final do final MovementManager movementManager = user.getMovementManager(); if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player) || Utilities.isOnCarpet(player) - || movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player) || user.getVelocityTracker().isVelocitized()) { + || movementManager.riptideTicks > 0 || VersionLib.isSwimming(player) || VersionLib.isFlying(player) || user.getVelocityTracker().isVelocitized()) { return PASS; } @@ -68,7 +68,7 @@ public static CheckResult runCheck(final Player player, final double x, final do "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); } - final double minAbsMotionY = 0.12D + (VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D); + final double minAbsMotionY = 0.12D + (VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D); if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() && Utilities.isSurroundedByWater(player) && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java index e82d4664..3a0e2fa7 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/BadPacketsCheck.java @@ -36,6 +36,11 @@ public final class BadPacketsCheck { public static void runCheck(final Player player, final PacketEvent event) { + if (event.isCancelled()) { + // Do not check if cancelled + return; + } + final Backend backend = AntiCheatReloaded.getManager().getBackend(); // Confirm if we should even check for BadPackets if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) @@ -48,7 +53,7 @@ public static void runCheck(final Player player, final PacketEvent event) { final float pitch = packet.getFloat().read(1); // Check for derp if (Math.abs(pitch) > 90) { - flag(player, event, "had an illegal pitch"); + flag(player, event, "had an illegal pitch", null); return; } @@ -78,27 +83,24 @@ public static void runCheck(final Player player, final PacketEvent event) { if (distanceHorizontal > maxDistanceHorizontal) { flag(player, event, "moved too far between packets (HT, distance=" + Utilities.roundDouble(distanceHorizontal, 1) - + ", max=" + Utilities.roundDouble(maxDistanceHorizontal, 1) + ")"); + + ", max=" + Utilities.roundDouble(maxDistanceHorizontal, 1) + ")", user.getGoodLocation(previous)); return; } - if (distanceVertical < -4.0D && user.getVelocityTracker().getVertical() != 0.0D) { + if (distanceVertical < -4.0D && user.getVelocityTracker().getVertical() == 0.0D) { flag(player, event, "moved too far between packets (VT, distance=" - + Utilities.roundDouble(Math.abs(distanceVertical), 1) + ", max=4.0)"); + + Utilities.roundDouble(Math.abs(distanceVertical), 1) + ", max=4.0)", user.getGoodLocation(previous)); return; } } - private static void flag(final Player player, final PacketEvent event, final String message) { + private static void flag(final Player player, final PacketEvent event, final String message, final Location setback) { event.setCancelled(true); // We are currently not in the main server thread, so switch - AntiCheatReloaded.sendToMainThread(new Runnable() { - @Override - public void run() { - EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player, - CheckType.BADPACKETS, null); - player.teleport(player.getLocation()); - } + AntiCheatReloaded.sendToMainThread(() -> { + EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player, + CheckType.BADPACKETS, null); + player.teleport(setback != null ? setback : player.getLocation()); }); } 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 79d5ee14..603443fe 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java @@ -43,6 +43,11 @@ public final class MorePacketsCheck { public static final Map PACKET_BALANCE = new HashMap(); public static void runCheck(final Player player, final PacketEvent event) { + if (event.isCancelled()) { + // Do not check if cancelled + return; + } + // Confirm if we should even check for MorePackets final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); final double tps = AntiCheatReloaded.getPlugin().getTPS(); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteractCheck.java similarity index 93% rename from src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java rename to src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteractCheck.java index 66558351..7f12cd70 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteractCheck.java @@ -36,13 +36,13 @@ import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; -public final class IllegalInteract { +public final class IllegalInteractCheck { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); - public static CheckResult performCheck(final Player player, final Event event) { + public static CheckResult runCheck(final Player player, final Event event) { final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); if (event instanceof BlockPlaceEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "place")) { return checkBlockPlace(player, (BlockPlaceEvent) event); @@ -105,7 +105,7 @@ private static boolean isValidTarget(final Player player, final Block block) { final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); final double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0 : player.getLocation().getDirection().getY() > 0.9 ? 6.0 : 5.5; - final Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance))); + final Block targetBlock = VersionLib.getTargetBlock(player, ((int) Math.ceil(distance))); if (targetBlock == null) { // TODO better check here return true; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java index 57d0078e..b2ff9cbe 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/player/NoFallCheck.java @@ -32,7 +32,7 @@ import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class NoFallCheck { @@ -40,18 +40,19 @@ public final class NoFallCheck { private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); - public static CheckResult performCheck(final Player player, final double motionY) { + public static CheckResult runCheck(final Player player, final double motionY) { final UUID uuid = player.getUniqueId(); final Backend backend = AntiCheatReloaded.getManager().getBackend(); final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !backend.isMovingExempt(player) && !backend.justPlaced(player) && !Utilities.isNearWater(player) && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") - && !VersionUtil.isSlowFalling(player) + && !VersionLib.isSlowFalling(player) && !Utilities .isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) && !Utilities.isNearClimbable(player) - && !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) { + && !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0)) + && !Utilities.couldBeOnBoat(player, 0.35, false)) { if (player.getFallDistance() == 0.0) { if (VIOLATIONS.get(uuid) == null) { VIOLATIONS.put(uuid, 1); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java index a717e63f..8f046ad1 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java @@ -20,59 +20,55 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType; -import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; +import com.rammelkast.anticheatreloaded.check.player.IllegalInteractCheck; -public class BlockListener extends EventListener { +public final class BlockListener extends EventListener { - @EventHandler(ignoreCancelled = true) - public void onBlockPlace(BlockPlaceEvent event) { + @EventHandler(priority = EventPriority.LOWEST) + public void onBlockPlace(final BlockPlaceEvent event) { final Player player = event.getPlayer(); - boolean noHack = true; if (getCheckManager().willCheck(player, CheckType.FAST_PLACE)) { - CheckResult result = getBackend().checkFastPlace(player); + final CheckResult result = getBackend().checkFastPlace(player); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.FAST_PLACE, result.getSubCheck()); - noHack = false; + return; } } if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) { - CheckResult result = IllegalInteract.performCheck(player, event); + final CheckResult result = IllegalInteractCheck.runCheck(player, event); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck()); - noHack = false; + return; } } - if (noHack) { - decrease(player); - getBackend().logBlockPlace(player); - } + + decrease(player); + getBackend().logBlockPlace(player); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); } - @EventHandler(ignoreCancelled = true) - public void onBlockBreak(BlockBreakEvent event) { + @EventHandler(priority = EventPriority.LOWEST) + public void onBlockBreak(final BlockBreakEvent event) { final Player player = event.getPlayer(); - boolean noHack = true; - CheckResult result; if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) { - result = IllegalInteract.performCheck(player, event); + final CheckResult result = IllegalInteractCheck.runCheck(player, event); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck()); - noHack = false; + return; } } - if (noHack) { - decrease(player); - } + + decrease(player); } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java index db04fc84..6b476ef1 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java @@ -39,110 +39,138 @@ public class EntityListener extends EventListener { - @EventHandler - public void onEntityShootBow(EntityShootBowEvent event) { - if (event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); - if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) { - CheckResult result = getBackend().checkFastBow(player, event.getForce()); - if (result.failed()) { - event.setCancelled(!silentMode()); - log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck()); - } else { - decrease(player); - } - } - } - - AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); - } - - @EventHandler - public void onEntityRegainHealth(EntityRegainHealthEvent event) { - if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) { - Player player = (Player) event.getEntity(); - if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) { - CheckResult result = getBackend().checkFastHeal(player); - if (result.failed()) { - event.setCancelled(!silentMode()); - log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck()); - } else { - decrease(player); - getBackend().logHeal(player); - } - } - } - - AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); - } - - @EventHandler - public void onFoodLevelChange(FoodLevelChangeEvent event) { - if (event.getEntity() instanceof Player) { - Player player = (Player) event.getEntity(); - if (player.getFoodLevel() < event.getFoodLevel() && getCheckManager().willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level - { - CheckResult result = getBackend().checkFastEat(player); - if (result.failed()) { - event.setCancelled(!silentMode()); - log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck()); - } else { - decrease(player); - } - } - } - - AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); - } - - @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true) - public void onEntityDamage(EntityDamageEvent event) { - boolean noHack = true; - if (event instanceof EntityDamageByEntityEvent) { - EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; - if (e.getDamager() instanceof Player) { - if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) { - CriticalsCheck.doDamageEvent(e, (Player)e.getDamager()); - } - if (getCheckManager().willCheckQuick((Player)e.getDamager(), CheckType.AIMBOT)) { - final CheckResult result = AimbotCheck.runCheck((Player)e.getDamager(), e); - if (result.failed()) { - log(result.getMessage(), (Player)e.getDamager(), CheckType.AIMBOT, result.getSubCheck()); - } - } - } + @EventHandler + public void onEntityShootBow(EntityShootBowEvent event) { + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) { + CheckResult result = getBackend().checkFastBow(player, event.getForce()); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck()); + } else { + decrease(player); + } + } + } + + AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); + } + + @EventHandler + public void onEntityRegainHealth(EntityRegainHealthEvent event) { + if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) { + Player player = (Player) event.getEntity(); + if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) { + CheckResult result = getBackend().checkFastHeal(player); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck()); + } else { + decrease(player); + getBackend().logHeal(player); + } + } + } + + AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); + } + + @EventHandler + public void onFoodLevelChange(FoodLevelChangeEvent event) { + if (event.getEntity() instanceof Player) { + Player player = (Player) event.getEntity(); + if (player.getFoodLevel() < event.getFoodLevel() + && getCheckManager().willCheck(player, CheckType.FAST_EAT)) { + CheckResult result = getBackend().checkFastEat(player); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck()); + } else { + decrease(player); + } + } + } + + AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onEntityDamage(final EntityDamageEvent event) { + if (event instanceof EntityDamageByEntityEvent) { + final EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; + if (e.getDamager() instanceof Player) { + if (getCheckManager().willCheck((Player) e.getDamager(), CheckType.CRITICALS)) { + CriticalsCheck.doDamageEvent(e, (Player) e.getDamager()); + } + if (getCheckManager().willCheckQuick((Player) e.getDamager(), CheckType.AIMBOT)) { + final CheckResult result = AimbotCheck.runCheck((Player) e.getDamager(), e); + if (result.failed()) { + log(result.getMessage(), (Player) e.getDamager(), CheckType.AIMBOT, result.getSubCheck()); + } + } + } + if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) { - Player player = (Player) e.getDamager(); + final Player player = (Player) e.getDamager(); if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { - CheckResult result = KillAuraCheck.checkAngle(player, event); + final CheckResult result = KillAuraCheck.checkAngle(player, event); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); - noHack = false; + return; } } + if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { - CheckResult result = KillAuraCheck.checkReach(player, event.getEntity()); + final CheckResult result = KillAuraCheck.checkReach(player, event.getEntity()); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); - noHack = false; + return; } } + if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { - CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity()); + final CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity()); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); - noHack = false; + return; } } - if (noHack) { - decrease(player); + + if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { + final CheckResult result = KillAuraCheck.checkRepeatedAim(player); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); + return; + } } + + if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { + final CheckResult result = KillAuraCheck.checkVariance(player); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); + return; + } + } + + if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { + final CheckResult result = KillAuraCheck.checkThroughWalls(player, event.getEntity()); + if (result.failed()) { + event.setCancelled(!silentMode()); + log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck()); + return; + } + } + + decrease(player); } - } + } - AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); - } + AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); + } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java index 7dd5bcd4..29ece770 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/EventListener.java @@ -66,15 +66,15 @@ public static void log(String message, Player player, CheckType type, String sub if (message == null || message.equals("")) { if (debugMode) { message = prefix + player.getName() + " failed " - + type.getName(); + + type.getName() + (subcheck != null ? (" (" + subcheck + ")") : ""); } else { message = prefix + player.getName() + " failed " - + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"; + + type.getName() + (subcheck != null ? (" (" + subcheck + ")") : "") + ChatColor.GOLD + " (x" + vlForType + ")"; } } else { if (debugMode) { message = prefix + player.getName() + " failed " - + type.getName() + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + + type.getName() + (subcheck != null ? (" (" + subcheck + ")") : "") + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); } else { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PacketListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PacketListener.java new file mode 100644 index 00000000..d6b24353 --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PacketListener.java @@ -0,0 +1,93 @@ +/* + * AntiCheatReloaded for Bukkit and Spigot. + * Copyright (c) 2012-2015 AntiCheat Team + * Copyright (c) 2016-2022 Rammelkast + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rammelkast.anticheatreloaded.event; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.injector.server.TemporaryPlayer; +import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType; +import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck; +import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck; +import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; + +public final class PacketListener extends PacketAdapter { + + public PacketListener(final Plugin plugin) { + super(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, + PacketType.Play.Client.LOOK, PacketType.Play.Server.POSITION, PacketType.Play.Client.BLOCK_DIG); + } + + @Override + public void onPacketReceiving(final PacketEvent event) { + final Player player = event.getPlayer(); + if (player == null || !player.isOnline()) { + return; + } + + // Check if we have an actual player object + if (player instanceof TemporaryPlayer) { + return; + } + + final PacketType type = event.getPacketType(); + final PacketContainer packet = event.getPacket(); + if (type == PacketType.Play.Client.POSITION || type == PacketType.Play.Client.POSITION_LOOK) { + // Run MorePackets check + MorePacketsCheck.runCheck(player, event); + // Run BadPackets check + BadPacketsCheck.runCheck(player, event); + return; + } + + if (event.getPacketType() == PacketType.Play.Client.BLOCK_DIG) { + if (packet.getPlayerDigTypes().read(0) == PlayerDigType.RELEASE_USE_ITEM) { + // Run NoSlow check + NoSlowCheck.runCheck(event.getPlayer(), event); + } + + return; + } + } + + @Override + public void onPacketSending(final PacketEvent event) { + final Player player = event.getPlayer(); + if (player == null || !player.isOnline()) { + return; + } + + // Check if we have an actual player object + if (player instanceof TemporaryPlayer) { + return; + } + + final PacketType type = event.getPacketType(); + if (type == PacketType.Play.Server.POSITION) { + // Compensate for teleport + MorePacketsCheck.compensate(player); + } + } + +} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java index b1a11ff9..86853f8d 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java @@ -71,14 +71,14 @@ import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck; import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck; -import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; +import com.rammelkast.anticheatreloaded.check.player.IllegalInteractCheck; import com.rammelkast.anticheatreloaded.check.player.NoFallCheck; import com.rammelkast.anticheatreloaded.manage.AntiCheatManager; import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; public final class PlayerListener extends EventListener { @@ -313,7 +313,7 @@ public void onPlayerInteract(final PlayerInteractEvent event) { if (block != null && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) { if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) { - final CheckResult result = IllegalInteract.performCheck(player, event); + final CheckResult result = IllegalInteractCheck.runCheck(player, event); if (result.failed()) { event.setCancelled(!silentMode()); log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck()); @@ -390,7 +390,7 @@ public User call() throws Exception { } } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent event) { final Player player = event.getPlayer(); if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) { @@ -404,7 +404,7 @@ public void onPlayerMove(final PlayerMoveEvent event) { user.setTo(to.getX(), to.getY(), to.getZ()); user.getMovementManager().handle(player, from, to, distance); - if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) { + if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionLib.isFlying(player)) { final CheckResult result = FlightCheck.runCheck(player, distance); if (result.failed()) { if (!silentMode()) { @@ -452,7 +452,7 @@ public void onPlayerMove(final PlayerMoveEvent event) { && getCheckManager().willCheck(player, CheckType.FLIGHT) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) { - final CheckResult result = NoFallCheck.performCheck(player, y); + final CheckResult result = NoFallCheck.runCheck(player, y); if (result.failed()) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); @@ -464,43 +464,66 @@ && getCheckManager().willCheck(player, CheckType.FLIGHT) if (event.getTo() != event.getFrom()) { final double x = distance.getXDifference(); final double z = distance.getZDifference(); - if (getCheckManager().willCheckQuick(player, CheckType.SPEED) - && getCheckManager().willCheck(player, CheckType.FLIGHT)) { - if (event.getFrom().getY() < event.getTo().getY()) { - final CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance); - if (result.failed()) { - if (!silentMode()) { - event.setTo(user.getGoodLocation(from.clone())); - } - log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck()); + if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) { + final CheckResult result = SpeedCheck.checkPredict(player, event.getTo()); + if (result.failed()) { + if (!silentMode()) { + event.setTo(user.getGoodLocation(from.clone())); } + + log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck()); + return; } - final CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo()); + } + + if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && event.getFrom().getY() < event.getTo().getY()) { + final CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance); + if (result.failed()) { + if (!silentMode()) { + event.setTo(user.getGoodLocation(from.clone())); + } + + log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck()); + return; + } + } + + if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) { + final CheckResult result = SpeedCheck.checkXZSpeed(player, event.getTo()); if (result.failed()) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); } + log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck()); + return; } } + if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) { final CheckResult result = WaterWalkCheck.runCheck(player, x, y, z); if (result.failed()) { if (!silentMode()) { - player.teleport(player.getLocation().clone().subtract(0, 0.42, 0)); + player.teleport(player.getLocation().clone().subtract(0, 0.42f, 0)); } + log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck()); + return; } } + if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) { final CheckResult result = getBackend().checkSpider(player, y); if (result.failed()) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); } + log(result.getMessage(), player, CheckType.SPIDER, result.getSubCheck()); + return; } } + if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) { // Does not use y value created before because that value is absolute final CheckResult result = FastLadderCheck.runCheck(player, @@ -509,19 +532,25 @@ && getCheckManager().willCheck(player, CheckType.FLIGHT)) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); } + log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck()); + return; } } + if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) { final CheckResult result = StrafeCheck.runCheck(player, x, z, event.getFrom(), event.getTo()); if (result.failed()) { if (!silentMode()) { event.setTo(user.getGoodLocation(from.clone())); } + log(result.getMessage(), player, CheckType.STRAFE, result.getSubCheck()); + return; } } } + if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) { final CheckResult result = VelocityCheck.runCheck(player, distance); if (result.failed()) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java index 5cacd72a..75bf60ca 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java @@ -33,7 +33,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.Configuration; -import com.rammelkast.anticheatreloaded.util.VersionUtil; +import com.rammelkast.anticheatreloaded.util.VersionLib; /** * The manager that AntiCheatReloaded will check with to see if it should watch @@ -191,7 +191,7 @@ && checkInWorld(player) && !isExempt(player, type) && !type.checkPermission(player) && !isOpExempt(player); - if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionUtil.isFlying(player)) { + if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionLib.isFlying(player)) { return false; } return check; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Friction.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Friction.java new file mode 100644 index 00000000..976ac717 --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Friction.java @@ -0,0 +1,66 @@ +/* + * AntiCheatReloaded for Bukkit and Spigot. + * Copyright (c) 2012-2015 AntiCheat Team + * Copyright (c) 2016-2022 Rammelkast + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rammelkast.anticheatreloaded.util; + +import org.bukkit.Material; +import org.bukkit.block.Block; + +/** + * Friction data library to prevent using Reflection or NMS + */ +public enum Friction { + + DEFAULT(0.6f), + ICE(0.98f), + BLUE_ICE(0.989f), + PACKED_ICE(0.98f), + SLIME_BLOCK(0.8f), + ; + + private final float factor; + + Friction(final float factor) { + this.factor = factor; + } + + /** + * Gets the friction factor + * + * @return the factor + */ + public float getFactor() { + return this.factor; + } + + /** + * Gets the friction factor for the given block + * + * @param block The block + * @return the friction factor + */ + public static float getFactor(final Block block) { + final Material type = block.getType(); + try { + return valueOf(type.name()).getFactor(); + } catch (final Exception exception) { + return DEFAULT.getFactor(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index 88fd4878..b50e0529 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -73,6 +73,8 @@ public final class MovementManager { public Distance lastDistance = new Distance(); // Movement acceleration public double acceleration; + // Last movement acceleration + public double lastAcceleration; // Is the block above solid public boolean topSolid; // Is the block below solid @@ -81,6 +83,8 @@ public final class MovementManager { public boolean halfMovement; // If the player is on the ground (determined clientside!) public boolean onGround; + // If the player was on the ground (determined clientside!) + public boolean wasOnGround; // Ticks counter for last halfMovement public int halfMovementHistoryCounter = 0; // Time of last teleport @@ -107,12 +111,16 @@ public final class MovementManager { public long lastUpdate; // Last location public Location lastLocation; + + /** + * Used by prediction speed check + */ + public float friction; + public double adjusted; @SuppressWarnings("deprecation") public void handle(final Player player, final Location from, final Location to, final Distance distance) { - // TODO as of now, we "trust" the client to send the right thing - // This is checked for spoofing by "GroundFlight" - // Also seems to make NoFall cheats flag for speed lmao + this.wasOnGround = this.onGround; this.onGround = player.isOnGround(); this.lastLocation = from; @@ -139,7 +147,7 @@ public void handle(final Player player, final Location from, final Location to, // Handle 1.9+ potion effects if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) { for (PotionEffect effect : player.getActivePotionEffects()) { - if (!VersionUtil.isLevitationEffect(effect)) { + if (!VersionLib.isLevitationEffect(effect)) { continue; } AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1); @@ -188,7 +196,7 @@ public void handle(final Player player, final Location from, final Location to, } } - if (VersionUtil.isGliding(player)) { + if (VersionLib.isGliding(player)) { this.elytraEffectTicks = 30; } else { if (this.elytraEffectTicks > 0) { @@ -218,7 +226,7 @@ public void handle(final Player player, final Location from, final Location to, } } - if (VersionUtil.isRiptiding(player)) { + if (VersionLib.isRiptiding(player)) { this.riptideTicks = 30; } else { if (this.riptideTicks > 0) { @@ -235,6 +243,7 @@ public void handle(final Player player, final Location from, final Location to, + this.lastDistance.getZDifference() * this.lastDistance.getZDifference()); final double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference() + distance.getZDifference() * distance.getZDifference()); + this.lastAcceleration = this.acceleration; this.acceleration = currentDistanceSq - lastDistanceSq; this.lastMotionY = this.motionY; @@ -245,7 +254,7 @@ public void handle(final Player player, final Location from, final Location to, final Location bottom = to.clone().add(0, -1, 0); this.bottomSolid = bottom.getBlock().getType().isSolid(); - if ((this.motionY > 0.42f && this.motionY <= 0.5625f) + if ((this.motionY >= 0.42f && this.motionY <= 0.5625f) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) { this.halfMovement = true; this.halfMovementHistoryCounter = 30; @@ -263,4 +272,5 @@ public void handle(final Player player, final Location from, final Location to, // Update "good location" user.setGoodLocation(from); } + } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java b/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java deleted file mode 100644 index 7e28c6c4..00000000 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * AntiCheatReloaded for Bukkit and Spigot. - * Copyright (c) 2012-2015 AntiCheat Team - * Copyright (c) 2016-2022 Rammelkast - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.rammelkast.anticheatreloaded.util; - -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.events.ListenerPriority; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.injector.server.TemporaryPlayer; -import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType; -import com.rammelkast.anticheatreloaded.AntiCheatReloaded; -import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck; -import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck; -import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; - -public final class PacketListener { - - public static void load(final ProtocolManager manager) { - // Used for MorePackets and BadPackets - manager.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, - new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, - PacketType.Play.Server.POSITION }) { - @Override - public void onPacketReceiving(final PacketEvent event) { - final Player player = event.getPlayer(); - if (player == null || !player.isOnline()) { - return; - } - - // Run MorePackets check - MorePacketsCheck.runCheck(player, event); - - if (!event.isCancelled()) { - // Run BadPackets check - BadPacketsCheck.runCheck(player, event); - } - } - - @Override - public void onPacketSending(final PacketEvent event) { - final Player player = event.getPlayer(); - // Check if we have an actual player object - if (player instanceof TemporaryPlayer) { - return; - } - // Compensate for teleport - MorePacketsCheck.compensate(player); - } - }); - - // Used for accurate ping - manager.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, - new PacketType[] { PacketType.Play.Client.KEEP_ALIVE, PacketType.Play.Server.KEEP_ALIVE }) { - @Override - public void onPacketSending(final PacketEvent event) { - final User user = AntiCheatReloaded.getManager().getUserManager() - .getUser(event.getPlayer().getUniqueId()); - user.onServerPing(); - } - - @Override - public void onPacketReceiving(final PacketEvent event) { - final User user = AntiCheatReloaded.getManager().getUserManager() - .getUser(event.getPlayer().getUniqueId()); - user.onClientPong(); - } - }); - - // Used for NoSlow - manager.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), - ListenerPriority.LOWEST, new PacketType[] { PacketType.Play.Client.BLOCK_DIG }) { - @Override - public void onPacketReceiving(final PacketEvent event) { - if (event.getPacket().getPlayerDigTypes().read(0) == PlayerDigType.RELEASE_USE_ITEM) { - NoSlowCheck.runCheck(event.getPlayer(), event); - } - } - }); - } - -} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java index 80626292..744facb5 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java @@ -50,7 +50,6 @@ public final class User { private boolean isWaitingOnLevelSync; private Timestamp levelSyncTimestamp; - private long lastServerPing, lastClientPong; private int ping = -1; private int lastPing = -1; @@ -68,7 +67,7 @@ public User(final UUID uuid) { this.uuid = uuid; this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : ""; this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1; - this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionUtil.getPlayerPing(getPlayer()) : -1; + this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionLib.getPlayerPing(getPlayer()) : -1; this.movementManager = new MovementManager(); this.velocityTracker = new VelocityTracker(this.config.getMagic().VELOCITY_TIME()); @@ -402,20 +401,10 @@ public Timestamp getLevelSyncTimestamp() { return levelSyncTimestamp; } - public void onServerPing() { - this.lastServerPing = System.currentTimeMillis(); - } - - public void onClientPong() { - this.lastClientPong = System.currentTimeMillis(); - this.lastPing = this.ping; - this.ping = (int) (this.lastClientPong - this.lastServerPing); - } - public int getPing() { final int ping = this.ping; if (ping < 0) { - return VersionUtil.getPlayerPing(getPlayer()); + return VersionLib.getPlayerPing(getPlayer()); } return ping; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 776a2b4c..8e857317 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -22,6 +22,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,6 +32,8 @@ import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeInstance; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; @@ -80,8 +83,8 @@ public static boolean cantStandAt(final Block block) { * @return true if the player should be unable to stand here */ public static boolean cantStandAtExp(final Location location) { - return cantStandAt(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, - location.getZ()).getBlock()); + return cantStandAt(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ()) + .getBlock()); } /** @@ -134,7 +137,7 @@ public static boolean isSlime(final Block block) { final Material type = block.getType(); return type.equals(XMaterial.SLIME_BLOCK.parseMaterial()); } - + public static boolean couldBeOnBoat(final Player player) { return couldBeOnBoat(player, 0.35, false); } @@ -159,12 +162,11 @@ public static boolean couldBeOnBoat(final Player player, final double range, fin * @return true if the player could be standing on ice */ public static boolean couldBeOnIce(final Location location) { - return isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, - location.getZ())) - || isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.26D, - location.getZ())) - || isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, - location.getZ())); + return isNearIce(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ())) + || isNearIce( + new Location(location.getWorld(), location.getX(), location.getY() - 0.26D, location.getZ())) + || isNearIce( + new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, location.getZ())); } public static boolean isNearIce(final Location location) { @@ -188,8 +190,8 @@ public static boolean isNearShulkerBox(final Location location) { public static boolean couldBeOnHalfblock(final Location location) { return isNearHalfblock( new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ())) - || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, - location.getZ())); + || isNearHalfblock( + new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, location.getZ())); } public static boolean isNearHalfblock(final Location location) { @@ -223,16 +225,15 @@ public static boolean isHalfblock(final Block block) { * @return true if the player could be standing on slime */ public static boolean couldBeOnSlime(final Location location) { - return isNearSlime(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, - location.getZ())) - || isNearSlime(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, - location.getZ())); + return isNearSlime(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ())) + || isNearSlime( + new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, location.getZ())); } public static boolean isNearSlime(final Location location) { return isCollisionPoint(location, material -> material == XMaterial.SLIME_BLOCK.parseMaterial()); } - + /** * Determine whether a player could be standing on soil * @@ -240,14 +241,14 @@ public static boolean isNearSlime(final Location location) { * @return true if the player could be standing on soil */ public static boolean couldBeOnSoil(final Location location) { - return isNearSoil(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, - location.getZ())) - || isNearSoil(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, - location.getZ())); + return isNearSoil(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getZ())) + || isNearSoil( + new Location(location.getWorld(), location.getX(), location.getY() - 0.51D, location.getZ())); } public static boolean isNearSoil(final Location location) { - return isCollisionPoint(location, material -> material == XMaterial.SOUL_SOIL.parseMaterial() || material == XMaterial.SOUL_SAND.parseMaterial()); + return isCollisionPoint(location, material -> material == XMaterial.SOUL_SOIL.parseMaterial() + || material == XMaterial.SOUL_SAND.parseMaterial()); } /** @@ -374,7 +375,7 @@ public static boolean isWall(final Block block) { Material type = block.getType(); return type.name().endsWith("WALL") || type.name().endsWith("FENCE") || type.name().endsWith("FENCE_GATE"); } - + public static boolean isNearWall(final Location location) { return isWall(location.getBlock()) || isWall(location.getBlock().getRelative(BlockFace.NORTH)) || isWall(location.getBlock().getRelative(BlockFace.SOUTH)) @@ -400,7 +401,7 @@ public static boolean isOnLilyPad(final Player player) { || block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial() || block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial(); } - + /** * Determine whether a player is standing on a carpet * @@ -748,9 +749,10 @@ public static int floor(double value) { int rounded = (int) value; return value < rounded ? rounded - 1 : rounded; } - + /** * Computes the difference between two angles + * * @param a Angle A * @param b Angle B * @return the difference between two angles @@ -759,10 +761,12 @@ public static float computeAngleDifference(final float a, final float b) { float diff = Math.abs(a - b); final float altDiff = b + 360 - a; final float altAltDiff = a + 360 - b; - if (altDiff < diff) diff = altDiff; - if (altAltDiff < diff) diff = altAltDiff; - return diff; - } + if (altDiff < diff) + diff = altDiff; + if (altAltDiff < diff) + diff = altAltDiff; + return diff; + } /** * Calculates the greatest common divider @@ -789,6 +793,49 @@ public static boolean isCollisionPoint(final Location location, final Predicate< } return materials.stream().anyMatch(predicate); } + + /** + * @author Elevated + * @param data - The set of data you want to find the variance from + * @return - The variance of the numbers. + * + * @See - https://en.wikipedia.org/wiki/Variance + */ + public static double getVariance(final Collection data) { + int count = 0; + + double sum = 0.0; + double variance = 0.0; + + double average; + + // Increase the sum and the count to find the average and the standard deviation + for (final Number number : data) { + sum += number.doubleValue(); + ++count; + } + + average = sum / count; + + // Run the standard deviation formula + for (final Number number : data) { + variance += Math.pow(number.doubleValue() - average, 2.0); + } + + return variance; + } + + + /** + * Gets the allowed player movement speed through the "GENERIC_MOVEMENT_SPEED" + * attribute + * + * @return the allowed player movement speed + */ + public static double getMovementSpeed(final Player player) { + final AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED); + return attribute.getValue(); + } static { MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion(); @@ -941,7 +988,7 @@ public static boolean isCollisionPoint(final Location location, final Predicate< CLIMBABLE.add(XMaterial.HONEY_BLOCK.parseMaterial()); } // End 1.15 objects - + // Start 1.16 objects if (currentVersion.isAtLeast(MinecraftVersion.NETHER_UPDATE)) { CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial()); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionLib.java similarity index 96% rename from src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java rename to src/main/java/com/rammelkast/anticheatreloaded/util/VersionLib.java index 7d947eb3..91fa65c4 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionLib.java @@ -34,7 +34,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded; -public class VersionUtil { +public class VersionLib { public static final MinecraftVersion CURRENT_VERSION; private static final List SUPPORTED_VERSIONS; diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index 90b8e404..c9945f53 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -52,6 +52,11 @@ elytrafly: # Speed check settings # Checks if a player moves too fast speed: + # Checks movement speed through prediction + # Debugs as 'moved unexpectedly' + predict: + # Should this part of the check be enabled? + enabled: true # Checks movement speed in the air # Debugs as 'moved too fast in air' airSpeed: @@ -157,9 +162,9 @@ killaura: # Maximum base reach distances baseMaxValue: # Maximum base reach value - normal: 3.5 + normal: 3.55 # Maximum base reach value when a player has velocity - velocitized: 4.0 + velocitized: 4.05 # Settings for lag compensation lagCompensation: # Basic extra allowed reach when a player is lagging @@ -188,6 +193,31 @@ killaura: minElapsedTime: 5 # Amount of suspicious combat packet situations before flagging vlBeforeFlag: 3 + # Checks player pitch behaviour during combat + # Debugs as 'had suspicious aim behaviour' + variance: + # Should this part of the check be enabled? + enabled: true + # How many samples should be taken (increase in case of false positives) + samples: 8 + # Checks player pitch and yaw behaviour during combat + # Debugs as 'repeated aim pattern' + repeatedAim: + # Should this part of the check be enabled? + enabled: true + # Checks if the player is hitting through objects + # Debugs as 'hit through object' + throughWalls: + # Should this part of the check be enabled? + enabled: true + # Minimum server TPS needed for the packet order subcheck to be active + minimumTps: 17.5 + # Should this check be disabled for lagging players? (this can be spoofed!) + disableForLagging: true + # Amount to expand hitbox by + expand: 0.3 + # Amount of illegal hits before flagging + vlBeforeFlag: 4 # Aimbot check settings # Checks if the player is sending aimbot-like movements aimbot: @@ -196,7 +226,7 @@ aimbot: # Maximum pitch acceleration for check to consider aim illegal minAcceleration: 5.5 # Maximum mod value for check to consider aim illegal - maxMod: 0.001 + maxMod: 8.0E-4 # Criticals check settings # Checks if the player tries to do a crit without needed conditions criticals: @@ -362,6 +392,13 @@ fastprojectile: projectilesToWait: 10 # The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles minimumTime: 1500 +# FastBreak check settings +# Checks if the player breaks too many blocks in too little time +fastbreak: + # Should this check be enabled? + enabled: true + # Minimum server TPS needed for FastBreak to be active + minimumTps: 15.0 # ItemSpam check settings # Checks if the player drops items too fast itemspam: From 3a48e8c602aed38a211b8083db7805b2f7a4df35 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 15 Jan 2022 17:02:08 +0100 Subject: [PATCH 13/17] Create PlayerPunishEvent, implementing #206 --- .../api/{ => event}/CheckFailEvent.java | 2 +- .../api/event/PlayerPunishEvent.java | 82 +++++++++++++++++++ .../anticheatreloaded/check/CheckType.java | 2 +- .../anticheatreloaded/manage/UserManager.java | 26 ++++-- 4 files changed, 102 insertions(+), 10 deletions(-) rename src/main/java/com/rammelkast/anticheatreloaded/api/{ => event}/CheckFailEvent.java (97%) create mode 100644 src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java diff --git a/src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java b/src/main/java/com/rammelkast/anticheatreloaded/api/event/CheckFailEvent.java similarity index 97% rename from src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java rename to src/main/java/com/rammelkast/anticheatreloaded/api/event/CheckFailEvent.java index e3809379..206ba915 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/api/CheckFailEvent.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/api/event/CheckFailEvent.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.rammelkast.anticheatreloaded.api; +package com.rammelkast.anticheatreloaded.api.event; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java b/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java new file mode 100644 index 00000000..1335883d --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java @@ -0,0 +1,82 @@ +/* + * AntiCheatReloaded for Bukkit and Spigot. + * Copyright (c) 2012-2015 AntiCheat Team + * Copyright (c) 2016-2022 Rammelkast + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.rammelkast.anticheatreloaded.api.event; + +import java.util.List; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import com.rammelkast.anticheatreloaded.util.User; + +/** + * Fired when a player is punished by AntiCheatReloaded + */ +public final class PlayerPunishEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + private final User user; + private final List actions; + + private boolean cancelled; + + public PlayerPunishEvent(final User user, final List actions) { + this.user = user; + this.actions = actions; + } + + /** + * Get the {@link com.rammelkast.anticheatreloaded.util.User} who failed the check + * + * @return a {@link com.rammelkast.anticheatreloaded.util.User} + */ + public User getUser() { + return user; + } + + /** + * Get the list of actions the punishment will perform + * + * @return a a list of punishment strings + */ + public List getActions() { + return actions; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + +} \ No newline at end of file diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java index cb206f63..e4d703de 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java @@ -26,7 +26,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import com.rammelkast.anticheatreloaded.api.CheckFailEvent; +import com.rammelkast.anticheatreloaded.api.event.CheckFailEvent; import com.rammelkast.anticheatreloaded.util.Permission; import com.rammelkast.anticheatreloaded.util.User; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/UserManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/UserManager.java index 58c035b3..d9b262f3 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/manage/UserManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/manage/UserManager.java @@ -29,6 +29,7 @@ import org.bukkit.ChatColor; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; +import com.rammelkast.anticheatreloaded.api.event.PlayerPunishEvent; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.util.Group; @@ -188,17 +189,26 @@ public void run() { if (user.getPlayer() == null) { return; } + + final PlayerPunishEvent event = new PlayerPunishEvent(user, actions); + { + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + } + final String name = user.getName(); - for (String event : actions) { - event = event.replaceAll("%player%", name) + for (String action : actions) { + action = action.replaceAll("%player%", name) .replaceAll("%world%", user.getPlayer().getWorld().getName()) .replaceAll("%check%", type.name()); - if (event.startsWith("COMMAND[")) { - for (String cmd : Utilities.getCommands(event)) { + if (action.startsWith("COMMAND[")) { + for (String cmd : Utilities.getCommands(action)) { Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd); } - } else if (event.equalsIgnoreCase("KICK")) { + } else if (action.equalsIgnoreCase("KICK")) { user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', kickReason)); AntiCheatReloaded.getPlugin().onPlayerKicked(); String msg = ChatColor.translateAlternateColorCodes('&', @@ -208,14 +218,14 @@ public void run() { manager.log(msg); manager.playerLog(msg); } - } else if (event.equalsIgnoreCase("WARN")) { + } else if (action.equalsIgnoreCase("WARN")) { List message = warning; for (String string : message) { if (!string.equals("")) { user.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', string)); } } - } else if (event.equalsIgnoreCase("BAN")) { + } else if (action.equalsIgnoreCase("BAN")) { Bukkit.getBanList(Type.NAME).addBan(user.getPlayer().getName(), ChatColor.translateAlternateColorCodes('&', banReason), null, null); user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', banReason)); @@ -226,7 +236,7 @@ public void run() { manager.log(msg); manager.playerLog(msg); } - } else if (event.equalsIgnoreCase("RESET")) { + } else if (action.equalsIgnoreCase("RESET")) { user.resetLevel(); } } From c3fffbd68a2e2924d97d2881797fcda1ecddd2d8 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 15 Jan 2022 17:03:32 +0100 Subject: [PATCH 14/17] Fix formatting --- .../api/event/PlayerPunishEvent.java | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java b/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java index 1335883d..92a5158a 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/api/event/PlayerPunishEvent.java @@ -31,43 +31,44 @@ */ public final class PlayerPunishEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList handlers = new HandlerList(); - private final User user; - private final List actions; - - private boolean cancelled; + private final User user; + private final List actions; - public PlayerPunishEvent(final User user, final List actions) { - this.user = user; - this.actions = actions; - } + private boolean cancelled; - /** - * Get the {@link com.rammelkast.anticheatreloaded.util.User} who failed the check - * - * @return a {@link com.rammelkast.anticheatreloaded.util.User} - */ - public User getUser() { - return user; - } + public PlayerPunishEvent(final User user, final List actions) { + this.user = user; + this.actions = actions; + } + + /** + * Get the {@link com.rammelkast.anticheatreloaded.util.User} who will be + * punished + * + * @return a {@link com.rammelkast.anticheatreloaded.util.User} + */ + public User getUser() { + return user; + } - /** - * Get the list of actions the punishment will perform - * - * @return a a list of punishment strings - */ - public List getActions() { - return actions; - } + /** + * Get the list of actions the punishment will perform + * + * @return a a list of punishment strings + */ + public List getActions() { + return actions; + } - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } @Override public boolean isCancelled() { From ffb7ea1ad406b84aa14c667c0a13a5dcfa387c96 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 15 Jan 2022 19:22:43 +0100 Subject: [PATCH 15/17] New ThroughWalls check is not (yet?) supported on 1.12.2 --- .../anticheatreloaded/check/combat/KillAuraCheck.java | 8 ++++++++ .../anticheatreloaded/check/movement/SpeedCheck.java | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java index 8fb7129f..374f1f90 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java @@ -40,6 +40,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult.Result; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.providers.Checks; +import com.rammelkast.anticheatreloaded.util.MinecraftVersion; import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; @@ -247,6 +248,13 @@ public static CheckResult checkRepeatedAim(final Player player) { } public static CheckResult checkThroughWalls(final Player player, final Entity target) { + // TODO this does not work on 1.12.2 + // Either we finally drop 1.12.2 as well, or we create a workaround + // For now we just skip if server version is 1.12.2 + if (MinecraftVersion.getCurrentVersion().getMinor() <= 12) { + return PASS; + } + final UUID uuid = player.getUniqueId(); final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); final MovementManager movementManager = user.getMovementManager(); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java index cb06ac02..3d122d2c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -62,6 +62,9 @@ private static boolean isSpeedExempt(final Player player, final Backend backend) /** * Largely based on Elevated's Frequency speed check * @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java + * + * TODO fix falses with jumping under blocks + * TODO fix falses with entity collisions */ public static CheckResult checkPredict(final Player player, final Location movingTowards) { final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); From 4d5b357c364204915ee4b6004d87fecee2d9a941 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sun, 16 Jan 2022 14:16:02 +0100 Subject: [PATCH 16/17] Fix #215 --- .../check/movement/FlightCheck.java | 24 +++++++------- .../check/movement/SpeedCheck.java | 8 +++-- .../anticheatreloaded/util/Utilities.java | 33 +++++++++++++++---- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java index 17db1bcb..7356285d 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -116,7 +116,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) && (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0)) && distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) { return new CheckResult(CheckResult.Result.FAILED, "AirFlight", - "tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); + "tried to fly on the Y-axis (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", max=" + Utilities.roundDouble(maxMotionY, 4) + ")"); } // TODO falses when falling large distances @@ -132,7 +132,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) && !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)) && velocityTracker.getVertical() == 0.0) { return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff=" - + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); + + Utilities.roundDouble(Math.abs(movementManager.motionY - movementManager.lastMotionY), 4) + ")"); } } // End AirFlight @@ -151,9 +151,10 @@ public static CheckResult runCheck(final Player player, final Distance distance) || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0))) && movementManager.motionY > 0.15)) && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25 - && !Utilities.couldBeOnBoat(player, 0.8, false)) + && !Utilities.couldBeOnBoat(player, 0.8, false)) { return new CheckResult(CheckResult.Result.FAILED, "AirClimb", - "tried to climb air (mY=" + movementManager.motionY + ")"); + "tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ")"); + } if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42 && movementManager.airTicks > 2 && !velocityTracker.isVelocitized() @@ -163,7 +164,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) { return new CheckResult(CheckResult.Result.FAILED, "AirClimb", - "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); + "tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")"); } if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks @@ -173,7 +174,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) && !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) { return new CheckResult(CheckResult.Result.FAILED, "AirClimb", - "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); + "tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")"); } if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0.0 @@ -183,14 +184,15 @@ public static CheckResult runCheck(final Player player, final Distance distance) && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) { return new CheckResult(CheckResult.Result.FAILED, "AirClimb", - "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); + "tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")"); } if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks && !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0 && movementManager.elytraEffectTicks <= 25 && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig - .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) { + .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) + && !Utilities.isNearClimbable(distance.getFrom(), 0.8)) { // Config default base is 1200ms // Ping clamped to max. 1000 to prevent spoofing for an advantage int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight", @@ -209,7 +211,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) : 0.42; if (movementManager.motionY > maxMotionY) { return new CheckResult(CheckResult.Result.FAILED, "AirClimb", - "tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")"); + "tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")"); } } // End AirClimb @@ -220,7 +222,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) && Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)) && Utilities.cantStandAt(distance.getTo().getBlock())) { return new CheckResult(CheckResult.Result.FAILED, "GroundFlight", - "faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")"); + "faked ground to fly (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", gt=" + movementManager.groundTicks + ")"); } // End GroundFlight @@ -246,7 +248,7 @@ public static CheckResult runCheck(final Player player, final Distance distance) if (vl >= vlBeforeFlag) { GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2)); return new CheckResult(CheckResult.Result.FAILED, "Gravity", - "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")"); + "ignored gravity (offset=" + Utilities.roundDouble(offset, 4) + ", at=" + movementManager.airTicks + ")"); } } else { if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java index 3d122d2c..814b58fd 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -63,7 +63,6 @@ private static boolean isSpeedExempt(final Player player, final Backend backend) * Largely based on Elevated's Frequency speed check * @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java * - * TODO fix falses with jumping under blocks * TODO fix falses with entity collisions */ public static CheckResult checkPredict(final Player player, final Location movingTowards) { @@ -84,6 +83,7 @@ public static CheckResult checkPredict(final Player player, final Location movin final VelocityTracker velocityTracker = user.getVelocityTracker(); final double motion = movementManager.distanceXZ; + final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid; final boolean sprinting = true; // TODO do this using packets double buffer = PREDICT_BUFFER.getOrDefault(uuid, 0.0); @@ -94,7 +94,7 @@ public static CheckResult checkPredict(final Player player, final Location movin } movementSpeed *= 0.16277136 / Math.pow((movementManager.friction *= 0.91f), 3); - if (!movementManager.onGround && movementManager.motionY >= 0.42f && sprinting) { + if (!movementManager.onGround && (movementManager.motionY >= 0.42f || (boxedIn && movementManager.motionY > 0.0f)) && sprinting) { movementSpeed += 0.2f; } } else { @@ -105,7 +105,9 @@ public static CheckResult checkPredict(final Player player, final Location movin movementSpeed += velocityTracker.getHorizontal(); final double factor = (motion - movementManager.adjusted) / movementSpeed; - if (factor > 1.001) { + final boolean exempted = Utilities.isCollisionPoint(movingTowards, + material -> material == XMaterial.HONEY_BLOCK.parseMaterial()); + if (factor > 1.001 && !exempted) { if (buffer++ > 2.5) { buffer /= 2; PREDICT_BUFFER.put(uuid, buffer); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 8e857317..88cdfb1b 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -438,13 +438,12 @@ public static boolean isInWater(Player player) { return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid() - || (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE) + || MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE) && (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial() || player.getLocation().getBlock().getRelative(BlockFace.UP) .getType() == XMaterial.KELP_PLANT.parseMaterial() || player.getLocation().getBlock().getRelative(BlockFace.DOWN) - .getType() == XMaterial.KELP_PLANT.parseMaterial()) - && isNearWater(player)); + .getType() == XMaterial.KELP_PLANT.parseMaterial()); } /** @@ -547,6 +546,17 @@ public static boolean isNearClimbable(final Player player) { public static boolean isNearClimbable(final Location location) { return isCollisionPoint(location, material -> CLIMBABLE.contains(material)); } + + /** + * Determine whether a location is near a climbable block + * + * @param location location to check + * @param expand expansion factor + * @return true if near climbable block + */ + public static boolean isNearClimbable(final Location location, final double expand) { + return isCollisionPoint(location, expand, material -> CLIMBABLE.contains(material)); + } /** * Determine whether a block is climbable @@ -780,10 +790,14 @@ public static long getGcd(final long current, final long previous) { } public static boolean isCollisionPoint(final Location location, final Predicate predicate) { + return isCollisionPoint(location, 0.3, predicate); + } + + public static boolean isCollisionPoint(final Location location, final double expand, final Predicate predicate) { final ArrayList materials = new ArrayList<>(); - for (double x = -0.3; x <= 0.3; x += 0.3) { - for (double y = -0.3; y <= 0.3; y += 0.3) { - for (double z = -0.3; z <= 0.3; z += 0.3) { + for (double x = -expand; x <= expand; x += expand) { + for (double y = -expand; y <= expand; y += expand) { + for (double z = -expand; z <= expand; z += expand) { final Material material = location.clone().add(x, y, z).getBlock().getType(); if (material != null) { materials.add(material); @@ -976,6 +990,13 @@ public static double getMovementSpeed(final Player player) { CLIMBABLE.add(XMaterial.VINE.parseMaterial()); CLIMBABLE.add(XMaterial.LADDER.parseMaterial()); CLIMBABLE.add(XMaterial.WATER.parseMaterial()); + // Start 1.13 objects + if (currentVersion.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) { + CLIMBABLE.add(XMaterial.KELP.parseMaterial()); + CLIMBABLE.add(XMaterial.KELP_PLANT.parseMaterial()); + } + // End 1.13 objects + // Start 1.14 objects if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) { CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial()); From f61a2bc7b5fd9592aa47539fad614c3a8d604937 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sat, 18 May 2024 10:38:15 +0200 Subject: [PATCH 17/17] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec77181c..75d2845c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -AntiCheatReloaded [![Latest Release](https://img.shields.io/github/v/release/Rammelkast/AntiCheatReloaded)](https://github.com/Rammelkast/AntiCheatReloaded/releases) [![Downloads](https://img.shields.io/github/downloads/Rammelkast/AntiCheatReloaded/total)](https://github.com/Rammelkast/AntiCheatReloaded/releases) [![Last Commit](https://img.shields.io/github/last-commit/Rammelkast/AntiCheatReloaded)](https://github.com/Rammelkast/AntiCheatReloaded/commits/master) [![Last Build](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.rammelkast.com%2Fjob%2FAntiCheatReloaded)](https://ci.rammelkast.com/job/AntiCheatReloaded/lastBuild/) +AntiCheatReloaded (_unmaintained_) [![Latest Release](https://img.shields.io/github/v/release/Rammelkast/AntiCheatReloaded)](https://github.com/Rammelkast/AntiCheatReloaded/releases) [![Downloads](https://img.shields.io/github/downloads/Rammelkast/AntiCheatReloaded/total)](https://github.com/Rammelkast/AntiCheatReloaded/releases) [![Last Commit](https://img.shields.io/github/last-commit/Rammelkast/AntiCheatReloaded)](https://github.com/Rammelkast/AntiCheatReloaded/commits/master) ============= -AntiCheatReloaded helps server admins combat the use of hacked clients and spambots. It analyses the behavior of players and can prevent malicious gameplay. The plugin offers a lot of customizability and can be connected across multiple servers in case it is used in a server network context. AntiCheatReloaded is based on gravitylow's AntiCheat and has been around since 2012. +AntiCheatReloaded is currently **unmaintained.** There will be **no further updates** to the current codebase and **no support** will be provided. The last released version (1.10.3) supports 1.12.2 - 1.18.1. You can use this version of the plugin **at your own risk**. Some development may occur on a completely rewritten version of the plugin. No support or definitive release date is provided for this version. You can follow its progress [here](https://github.com/Rammelkast/AntiCheatReloaded/tree/version-2). Installation ------------ @@ -50,4 +50,4 @@ Hacks blocked * Scaffold * FastLadder * Strafe -* NoSlow \ No newline at end of file +* NoSlow