From 168c25e5d20d122d5185c235739973fc5018a7a7 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Mon, 20 Jul 2020 21:39:53 +0200 Subject: [PATCH] Ready for pre-release; Removed broken code, finished config migrations and fixed false positive --- README.md | 1 - .../anticheatreloaded/check/Backend.java | 96 ++++++++-------- .../anticheatreloaded/check/CheckType.java | 1 - .../check/movement/FlightCheck.java | 1 - .../check/movement/SpeedCheck.java | 2 +- .../check/movement/WaterWalkCheck.java | 12 +- .../check/player/IllegalInteract.java | 8 +- .../config/providers/Magic.java | 108 +----------------- .../event/BlockListener.java | 16 --- .../event/EntityListener.java | 8 -- .../anticheatreloaded/util/Permission.java | 2 +- .../anticheatreloaded/util/User.java | 19 +-- src/main/resources/checks.yml | 69 +++++++++-- src/main/resources/config.yml | 4 +- src/main/resources/magic.yml | 108 +++--------------- src/main/resources/plugin.yml | 14 +-- 16 files changed, 156 insertions(+), 313 deletions(-) diff --git a/README.md b/README.md index 4167bba..0e62914 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,6 @@ Hacks blocked * FastProjectile * ItemSpam * FastInventory -* AutoTool * MorePackets/Timer * BadPackets * Velocity/Anti-Knockback diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 9c96eb3..b918656 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -77,7 +77,6 @@ public class Backend { private Map lastInventoryTime = new HashMap(); private Map inventoryTime = new HashMap(); private Map inventoryClicks = new HashMap(); - private Map itemInHand = new HashMap(); private HashSet transparent = new HashSet(); private Map lastFallPacket = new HashMap(); private Map fastSneakViolations = new HashMap(); @@ -167,7 +166,8 @@ public class Backend { float f = (float) ticks / 20.0F; f = (f * f + f * 2.0F) / 3.0F; f = f > 1.0F ? 1.0F : f; - if (Math.abs(force - f) > magic.BOW_ERROR()) { + double bowError = checksConfig.getDouble(CheckType.FAST_BOW, "bowError"); + if (Math.abs(force - f) > bowError) { return new CheckResult(CheckResult.Result.FAILED, "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")"); } else { @@ -177,16 +177,18 @@ public class Backend { public CheckResult checkProjectile(Player player) { incrementOld(player, projectilesShot, 10); + int projectilesToWait = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "projectilesToWait"); if (!projectileTime.containsKey(player.getUniqueId())) { projectileTime.put(player.getUniqueId(), System.currentTimeMillis()); return new CheckResult(CheckResult.Result.PASSED); - } else if (projectilesShot.get(player.getUniqueId()) == magic.PROJECTILE_CHECK()) { + } else if (projectilesShot.get(player.getUniqueId()) == projectilesToWait) { long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId()); + int minimumTime = checksConfig.getInteger(CheckType.FAST_PROJECTILE, "minimumTime"); projectileTime.remove(player.getUniqueId()); projectilesShot.remove(player.getUniqueId()); - if (time < magic.PROJECTILE_TIME_MIN()) { - return new CheckResult(CheckResult.Result.FAILED, "wound up a bow too fast (actual time=" + time - + ", min time=" + magic.PROJECTILE_TIME_MIN() + ")"); + if (time < minimumTime) { + return new CheckResult(CheckResult.Result.FAILED, + "wound up a bow too fast (actual time=" + time + ", min time=" + minimumTime + ")"); } } return PASS; @@ -194,24 +196,25 @@ public class Backend { public CheckResult checkFastDrop(Player player) { incrementOld(player, blocksDropped, 10); + int dropsToWait = checksConfig.getInteger(CheckType.ITEM_SPAM, "dropsToWait"); if (!blockTime.containsKey(player.getUniqueId())) { blockTime.put(player.getUniqueId(), System.currentTimeMillis()); return new CheckResult(CheckResult.Result.PASSED); - } else if (blocksDropped.get(player.getUniqueId()) == magic.DROP_CHECK()) { + } else if (blocksDropped.get(player.getUniqueId()) == dropsToWait) { long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId()); + int minimumTime = checksConfig.getInteger(CheckType.ITEM_SPAM, "minimumTime"); blockTime.remove(player.getUniqueId()); blocksDropped.remove(player.getUniqueId()); - if (time < magic.DROP_TIME_MIN()) { + if (time < minimumTime) { return new CheckResult(CheckResult.Result.FAILED, - "dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")"); + "dropped an item too fast (actual time=" + time + ", min time=" + minimumTime + ")"); } } return PASS; } public CheckResult checkSpider(Player player, double y) { - if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN() - && !Utilities.isClimbableBlock(player.getLocation().getBlock()) + if (y <= 0.11761 && y >= 0.11759 && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) && !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())) { return new CheckResult(CheckResult.Result.FAILED, @@ -271,10 +274,11 @@ public class Backend { public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) { Player player = event.getPlayer(); + int sprintFoodMin = checksConfig.getInteger(CheckType.SPRINT, "sprintFoodMin"); if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE - && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) { + && player.getFoodLevel() <= sprintFoodMin) { return new CheckResult(CheckResult.Result.FAILED, - "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")"); + "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + sprintFoodMin + ")"); } else { return PASS; } @@ -358,7 +362,8 @@ public class Backend { } public boolean isEating(Player player) { - return startEat.containsKey(player.getUniqueId()) && startEat.get(player.getUniqueId()) < magic.EAT_TIME_MIN(); + return startEat.containsKey(player.getUniqueId()) + && startEat.get(player.getUniqueId()) < checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin"); } public void logHeal(Player player) { @@ -376,16 +381,18 @@ public class Backend { } Long l = user.getMessageTime(i); - if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN()) { + int repeatIgnore = checksConfig.getInteger(CheckType.CHAT_SPAM, "repeatIgnore"); + if (System.currentTimeMillis() - l > repeatIgnore) { user.clearMessages(); break; } else { + int timeMin = checksConfig.getInteger(CheckType.CHAT_SPAM, "timeMin"); if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) { manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\""); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); } else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() - && System.currentTimeMillis() - user.getLastCommandTime() < magic.CHAT_MIN()) { + && System.currentTimeMillis() - user.getLastCommandTime() < timeMin) { manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\""); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); } @@ -424,15 +431,17 @@ public class Backend { } Long l = user.getCommandTime(i); - if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN()) { + int repeatIgnore = checksConfig.getInteger(CheckType.COMMAND_SPAM, "repeatIgnore"); + if (System.currentTimeMillis() - l > repeatIgnore) { user.clearCommands(); break; } else { + int timeMin = checksConfig.getInteger(CheckType.COMMAND_SPAM, "timeMin"); if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue() && m.equalsIgnoreCase(cmd) && i == 1) { return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); } else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() - && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN()) { + && System.currentTimeMillis() - user.getLastCommandTime() < timeMin) { return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); } } @@ -452,30 +461,21 @@ public class Backend { clicks = inventoryClicks.get(uuid) + 1; } inventoryClicks.put(uuid, clicks); + int clicksToWait = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait"); if (clicks == 1) { inventoryTime.put(uuid, System.currentTimeMillis()); - } else if (clicks == magic.INVENTORY_CHECK()) { + } else if (clicks == clicksToWait) { + int minimumTime = checksConfig.getInteger(CheckType.FAST_INVENTORY, "clicksToWait"); long time = System.currentTimeMillis() - inventoryTime.get(uuid); inventoryClicks.put(uuid, 0); - if (time < magic.INVENTORY_TIMEMIN()) { + if (time < minimumTime) { return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in " - + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)"); + + time + " ms (max=" + clicksToWait + " in " + minimumTime + " ms)"); } } return PASS; } - public CheckResult checkAutoTool(Player player) { - if (itemInHand.containsKey(player.getUniqueId()) - && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) { - return new CheckResult(CheckResult.Result.FAILED, - "switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has " - + VersionUtil.getItemInHand(player).getType() + ")"); - } else { - return PASS; - } - } - public CheckResult checkFastHeal(Player player) { User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()); if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. @@ -508,9 +508,10 @@ public class Backend { } long l = startEat.get(player.getUniqueId()); startEat.remove(player.getUniqueId()); - if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) { + int eatTimeMin = checksConfig.getInteger(CheckType.FAST_EAT, "eatTimeMin"); + if ((System.currentTimeMillis() - l) < eatTimeMin) { return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time=" - + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)"); + + (System.currentTimeMillis() - l) + " ms, min=" + eatTimeMin + " ms)"); } } return PASS; @@ -525,7 +526,8 @@ public class Backend { } public boolean justBroke(Player player) { - return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN()); + // TODO config?? + return isDoing(player, brokenBlock, 0.1); } public void logVelocity(final Player player) { @@ -538,13 +540,13 @@ public class Backend { public boolean justVelocity(Player player) { return (velocitized.containsKey(player.getUniqueId()) - ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() + ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_TIME() : false); } public boolean justLevitated(Player player) { return (levitatingEnd.containsKey(player.getUniqueId()) - ? (System.currentTimeMillis() - levitatingEnd.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() + ? (System.currentTimeMillis() - levitatingEnd.get(player.getUniqueId())) < magic.VELOCITY_TIME() : false); } @@ -559,7 +561,7 @@ public class Backend { public void run() { velocitytrack.put(player.getUniqueId(), 0); } - }, magic.VELOCITY_SCHETIME() * 20L); + }, magic.VELOCITY_EXTENSION() * 20L); return true; } } else { @@ -574,7 +576,8 @@ public class Backend { } public boolean justPlaced(Player player) { - return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN()); + // TODO config?? + return isDoing(player, placedBlock, 0.1); } public void logDamage(final Player player, int type) { @@ -615,7 +618,7 @@ public class Backend { } public void logBoatCollision(final Player player) { - // TODO config + // TODO config?? FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */); } @@ -666,9 +669,10 @@ public class Backend { public void processChatSpammer(Player player) { User user = manager.getUserManager().getUser(player.getUniqueId()); int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0; - if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) { - String event = level >= magic.CHAT_ACTION_TWO_LEVEL() - ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() + int levelActionOne = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionOne"); + int levelActionTwo = checksConfig.getInteger(CheckType.CHAT_SPAM, "levelActionTwo"); + if (player != null && player.isOnline() && level >= levelActionOne) { + String event = level >= levelActionTwo ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue(); manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(), @@ -680,8 +684,10 @@ public class Backend { public void processCommandSpammer(Player player) { User user = manager.getUserManager().getUser(player.getUniqueId()); int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0; - if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) { - String event = level >= magic.COMMAND_ACTION_TWO_LEVEL() + int levelActionOne = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionOne"); + int levelActionTwo = checksConfig.getInteger(CheckType.COMMAND_SPAM, "levelActionTwo"); + if (player != null && player.isOnline() && level >= levelActionOne) { + String event = level >= levelActionTwo ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue(); manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java index 773f2bc..963d8f7 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/CheckType.java @@ -55,7 +55,6 @@ public enum CheckType { FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE, "FastProjectile"), ITEM_SPAM(Permission.CHECK_ITEMSPAM, "ItemSpam"), FAST_INVENTORY(Permission.CHECK_FASTINVENTORY, "FastInventory"), - AUTOTOOL(Permission.CHECK_AUTOTOOL, "AutoTool"), MOREPACKETS(Permission.CHECK_MOREPACKETS, "MorePackets"), BADPACKETS(Permission.CHECK_BADPACKETS, "BadPackets"), VELOCITY(Permission.CHECK_VELOCITY, "Velocity"), 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 5221a28..4b5b78a 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/FlightCheck.java @@ -39,7 +39,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil; /** * @author Rammelkast - * TODO fix cobweb false positives */ public class FlightCheck { 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 0d567d6..57f2ba2 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -228,7 +228,7 @@ public class SpeedCheck { return PASS; if (player.isInsideVehicle() || player.isSleeping() - || backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_SCHETIME()) || VersionUtil.isFlying(player) + || backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_EXTENSION()) || VersionUtil.isFlying(player) || VersionUtil.isRiptiding(player)) { 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 eb954d6..de41949 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/WaterWalkCheck.java @@ -22,6 +22,7 @@ import java.util.UUID; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffectType; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; @@ -60,14 +61,17 @@ public class WaterWalkCheck { return new CheckResult(Result.FAILED, "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); - // TODO fix speed effect falses + double minAbsMotionY = 0.08D; + if (player.hasPotionEffect(PotionEffectType.SPEED)) + minAbsMotionY += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.05D; if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() && Utilities.isSurroundedByWater(player) - && Math.abs(movementManager.lastMotionY - movementManager.motionY) > 0.08 + && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ") && movementManager.lastMotionY > -0.25) - return new CheckResult(Result.FAILED, - "tried to lunge in water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")"); + return new CheckResult(Result.FAILED, "tried to lunge in water (xz=" + + Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY=" + + Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")"); return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java index 5ced8dc..be10ba8 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/player/IllegalInteract.java @@ -32,7 +32,6 @@ import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.config.providers.Checks; -import com.rammelkast.anticheatreloaded.config.providers.Magic; import com.rammelkast.anticheatreloaded.util.User; import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VersionUtil; @@ -88,11 +87,10 @@ public class IllegalInteract { } private static boolean isValidTarget(Player player, Block block) { - Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic(); Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); - double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE() - : player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE() - : magic.BLOCK_MAX_DISTANCE(); + double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0 + : player.getLocation().getDirection().getY() > 0.9 ? 6.0 + : 5.5; Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance))); if (targetBlock == null) { // TODO better check here diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java index e43606f..b0c84e1 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java @@ -66,122 +66,22 @@ public interface Magic { * Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE. */ public int EXPLOSION_DAMAGE_TIME(); - /** - * Minimum time it takes to fire X projectiles; Type=SYSTEM, Leniency=DECREASE. - */ - public int PROJECTILE_TIME_MIN(); - /** - * Number of projectiles to wait for before checking how long they took to fire off; Type=INTEGER. - */ - public int PROJECTILE_CHECK(); - /** - * Minimum time it takes to drop X items; Type=SYSTEM, Leniency=DECREASE. - */ - public int DROP_TIME_MIN(); - /** - * Number of item drops to wait for before checking how long they took to drop; Type=INTEGER. - */ - public int DROP_CHECK(); - /** - * Number of times required to punch a block before it breaks; Type=INTEGER, Leniency=DECREASE. - */ - public int BLOCK_PUNCH_MIN(); - /** - * Number of command spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE. - */ - public int COMMAND_ACTION_ONE_LEVEL(); - /** - * Number of command spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE. - */ - public int COMMAND_ACTION_TWO_LEVEL(); - /** - * Number of chat spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE. - */ - public int CHAT_ACTION_ONE_LEVEL(); - /** - * Number of chat spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE. - */ - public int CHAT_ACTION_TWO_LEVEL(); /** * Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER. */ - public int VELOCITY_SCHETIME(); + public int VELOCITY_EXTENSION(); /** - * Maximum time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE. + * Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE. */ - public int VELOCITY_CHECKTIME(); + public int VELOCITY_TIME(); /** * Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE. */ public int VELOCITY_PREVENT(); /** - * Number of times a player can fail the velocity check before action is taken; Type=INTEGER, Leniency=INCREASE. + * Maximum amount of velocity tracks; Type=INTEGER, Leniency=INCREASE. */ public int VELOCITY_MAXTIMES(); - /** - * Number of times a player can sprint without proper food level before action is taken; Type=INTEGER, Leniency=INCREASE. - */ - public int SPRINT_FOOD_MIN(); - /** - * Maximum times a player can interact between animations; Type=INTEGER, Leniency=INCREASE. - */ - public int ANIMATION_INTERACT_MAX(); - /** - * Minimum time between commands; Type=SYSTEM, Leniency=DECREASE. - */ - public int COMMAND_MIN(); - /** - * Minimum time before repeating a command is ignored; Type=SYSTEM, Leniency=DECREASE. - */ - public int COMMAND_REPEAT_MIN(); - /** - * Minimum time between chats; Type=SYSTEM, Leniency=DECREASE. - */ - public int CHAT_MIN(); - /** - * Time before repeating yourself in chat is ignored; Type=SYSTEM, Leniency=INCREASE. - */ - public int CHAT_REPEAT_MIN(); - /** - * Minimum time in between block breaks; Type=INTEGER, Leniency=DECREASE. - */ - public double BLOCK_BREAK_MIN(); - /** - * Minimum time in between block placing; Type=INTEGER, Leniency=DECREASE. - */ - public double BLOCK_PLACE_MIN(); - /** - * Minimum time in between eating; Type=SYSTEM, Leniency=DECREASE. - */ - public int EAT_TIME_MIN(); - /** - * Maximum percent error between predicted bow force and actual bow force; Type=DOUBLE, Leniency=INCREASE. - */ - public double BOW_ERROR(); - /** - * Maximum distance a player can break a block from; Type=DOUBLE, Leniency=INCREASE. - */ - public double BLOCK_MAX_DISTANCE(); - /** - * Minimum distance a player can break a block from in creative mode; Type=DOUBLE, Leniency=INCREASE. - */ - public double BLOCK_MAX_DISTANCE_CREATIVE(); - /** - * Maximum speed a player on a ladder can travel; Type=DOUBLE, Leniency=INCREASE. - */ - public double LADDER_Y_MAX(); - /** - * Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE. - */ - public double LADDER_Y_MIN(); - /** - * The number of clicks we should wait before checking if the player has used fast inventory; Type=INTEGER; Leniency=INCREASE. - */ - public int INVENTORY_CHECK(); - /** - * The minimum time it should have taken for the player to click X times; Type=INTEGER; Leniency=INCREASE. - */ - public int INVENTORY_TIMEMIN(); /** * Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE. */ diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java index b0eb8a6..9897e2d 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java @@ -20,9 +20,7 @@ package com.rammelkast.anticheatreloaded.event; 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.BlockDamageEvent; import org.bukkit.event.block.BlockPlaceEvent; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; @@ -32,20 +30,6 @@ import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; public class BlockListener extends EventListener { - @EventHandler(priority = EventPriority.MONITOR) - public void onBlockDamage(BlockDamageEvent event) { - Player player = event.getPlayer(); - if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) { - CheckResult result = getBackend().checkAutoTool(player); - if (result.failed()) { - event.setCancelled(!silentMode()); - log(result.getMessage(), player, CheckType.AUTOTOOL); - } - } - - AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); - } - @EventHandler(ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { final Player player = event.getPlayer(); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java index 59d1ca9..6a46a69 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/EntityListener.java @@ -137,14 +137,6 @@ public class EntityListener extends EventListener { if (e.getDamager() instanceof Player) { Player player = (Player) e.getDamager(); getBackend().logDamage(player, 1); - if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) { - CheckResult result = getBackend().checkAutoTool(player); - if (result.failed()) { - event.setCancelled(!silentMode()); - log(result.getMessage(), player, CheckType.AUTOTOOL); - noHack = false; - } - } if (getCheckManager().willCheck(player, CheckType.KILLAURA)) { CheckResult result = KillAuraCheck.checkAngle(player, event); if (result.failed()) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java index 2d6b801..092e9a0 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Permission.java @@ -25,7 +25,7 @@ public enum Permission { /* Check Nodes */ CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, - CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, + CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_AIMBOT, diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java index 3a0c1a2..79b4135 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/User.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/User.java @@ -19,8 +19,14 @@ package com.rammelkast.anticheatreloaded.util; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -30,11 +36,6 @@ import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.util.rule.Rule; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - public class User { private final UUID uuid; private final String name; @@ -48,14 +49,14 @@ public class User { private Long[] messageTimes = new Long[2]; private String[] commands = new String[2]; private Long[] commandTimes = new Long[2]; - + private boolean isWaitingOnLevelSync; private Timestamp levelSyncTimestamp; private long lastServerPing, lastClientPong; private int ping = -1; private int lastPing = -1; - + private MovementManager movementManager; /** @@ -238,7 +239,7 @@ public class User { public boolean setGoodLocation(Location location) { if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location)) - || !location.getBlock().getType().isSolid()) { + || (!location.getBlock().getType().isSolid() && location.getBlock().getType() != Material.AIR)) { return false; } @@ -461,7 +462,7 @@ public class User { public boolean isLagging() { return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION(); } - + public MovementManager getMovementManager() { return this.movementManager; } diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index 96b8a0d..5f7cf36 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -1,5 +1,6 @@ # AntiCheatReloaded checks configuration file # Flight check settings +# Checks if a player moves wrongly in the air flight: # Checks for prolonged air movement # Debugs as 'tried to fly on the Y-axis' or 'had too little Y dropoff' @@ -48,6 +49,7 @@ elytrafly: enabled: true # Speed check settings +# Checks if a player moves too fast speed: # Checks movement speed in the air # Debugs as 'moved too fast in air' @@ -135,6 +137,7 @@ fastladder: vlBeforeFlag: 3 # KillAura check settings +# Checks if the player uses a form of kill aura killaura: # Checks reach distance in fights # Debugs as 'reached too far' @@ -167,6 +170,7 @@ killaura: vlBeforeFlag: 3 # Aimbot check settings +# Checks if the player is sending aimbot-like movements aimbot: # Should this check be enabled? enabled: true @@ -176,6 +180,7 @@ aimbot: maxYaw: 355 # Criticals check settings +# Checks if the player tries to do a crit without needed conditions criticals: # Should this check be enabled? enabled: true @@ -191,6 +196,7 @@ velocity: vlBeforeFlag: 2 # FastPlace check settings +# Checks if the player places blocks too fast fastplace: # Should this check be enabled? enabled: true @@ -204,6 +210,7 @@ fastplace: blockPlacementTime: 1000 # IllegalInteract check settings +# Checks if the player is using, placing or breaking blocks from illegal angles illegalinteract: # Maximum difference in angle from the players view maxAngleDifference: 90 @@ -223,15 +230,16 @@ illegalinteract: # Should this part of the check be enabled? enabled: true # Default survival interact range - survivalRange: 5.5 + survivalRange: 5.8 # Default creative interact range - creativeRange: 6.5 + creativeRange: 6.8 # Extra allowed reach distance per millisecond of ping pingCompensation: 0.0045 # The multiplier of extra compensation for velocity velocityMultiplier: 1.5 # BadPackets check settings +# Checks for illegal packets badpackets: # Should this check be enabled? enabled: true @@ -241,6 +249,7 @@ badpackets: maxDistance: 25.0 # MorePackets check settings +# Checks for an extra amount of packets and modified game timers morepackets: # Should this check be enabled? enabled: true @@ -260,7 +269,7 @@ morepackets: maxPing: -1 # Sneak check settings -# Checks if a player toggles sneak too fast +# Checks if the player toggles sneak too fast sneak: # Should this check be enabled? enabled: true @@ -273,11 +282,13 @@ sneak: minToggleTime: 75 # Spider check settings +# Checks if the player tries to climb a non-climbable block spider: # Should this check be enabled? enabled: true # NoFall check settings +# Checks if the player tries to ignore fall damage nofall: # Should this check be enabled? enabled: true @@ -285,21 +296,31 @@ nofall: vlBeforeFlag: 6 # Sprint check settings +# Checks if the player tries to sprint without the needed conditions sprint: # Should this check be enabled? enabled: true + # Minimum food level needed to sprint + sprintFoodMin: 6 # FastBow check settings +# Checks if the player fires a bow too fast fastbow: # Should this check be enabled? enabled: true + # Maximum percent error between predicted bow force and actual bow force + bowError: 0.25 # FastEat check settings +# Checks if the player consumes food too fast fasteat: # Should this check be enabled? enabled: true + # Minimum time in milliseconds it takes to consume food + eatTimeMin: 1000 # FastHeal check settings +# Checks if the player regains health too fast fastheal: # Should this check be enabled? enabled: true @@ -314,41 +335,71 @@ fastheal: pingCompensation: 0.15 # FastProjectile check settings +# Checks if the player fires a projectile too fast fastprojectile: # Should this check be enabled? enabled: true + # Number of projectiles to wait for before checking how long they took to fire off + projectilesToWait: 10 + # The minimum time in milliseconds it should have taken for the player fire 'projectilesToWait' projectiles + minimumTime: 1500 # ItemSpam check settings +# Checks if the player drops items too fast itemspam: # Should this check be enabled? enabled: true + # The number of item drops we should wait before checking if the player has used item spam + dropsToWait: 10 + # The minimum time in milliseconds it should have taken for the player to drop items 'dropsToWait' times + minimumTime: 800 # FastInventory check settings +# Checks if the player moves items in the inventory too fast fastinventory: # Should this check be enabled? enabled: true - -# AutoTool check settings -autotool: - # Should this check be enabled? - enabled: true + # The number of clicks we should wait before checking if the player has used fast inventory + clicksToWait: 10 + # The minimum time in milliseconds it should have taken for the player to click 'clicksToWait' times + minimumTime: 50 # vClip check settings +# Checks if the player is clipping vclip: # Should this check be enabled? enabled: true # ChatUnicode check settings +# Checks for illegal unicode characters in the chat chatunicode: # Should this check be enabled? enabled: true # ChatSpam check settings +# Checks for a spam of chat messages chatspam: # Should this check be enabled? enabled: true + # Minimum time between chats + timeMin: 500 + # Time in milliseconds after which repeating yourself in chat is ignored + repeatIgnore: 600 + # Number of chat spam violations before action one (see config.yml) is executed + levelActionOne: 5 + # Number of chat spam violations before action two (see config.yml) is executed + levelActionTwo: 10 # CommandSpam check settings +# Checks for a spam of commands commandspam: # Should this check be enabled? - enabled: true \ No newline at end of file + enabled: true + # Minimum time between commands + timeMin: 400 + # Time in milliseconds after which repeating a command is ignored + repeatIgnore: 500 + # Number of command spam violations before action one (see config.yml) is executed + levelActionOne: 5 + # Number of command spam violations before action two (see config.yml) is executed + levelActionTwo: 10 \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 088e28b..9c1325b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -35,9 +35,9 @@ system: # Do NOT enable this in a production environment! debug-mode: false # To prevent spamming, staff and the console will only be notified every x violations - # Minimum value is 1, default is 5 + # Minimum value is 1, default is 10 # Example with 5: notifications after 5 vl, 10vl, 15vl, etc. - notify-every-vl: 5 + notify-every-vl: 10 # Use /AntiCheatReloaded checks for a list of valid checks disable-in: - example-world diff --git a/src/main/resources/magic.yml b/src/main/resources/magic.yml index 2af725f..1187cbb 100644 --- a/src/main/resources/magic.yml +++ b/src/main/resources/magic.yml @@ -1,114 +1,36 @@ -# Number of times required to punch a block before it breaks -# Changing this value is almost never required -BLOCK_PUNCH_MIN: 5 -# Time to exempt a player from moving because of taking damage -# Can be decreased very slightly to increase detection -# Increasing in case of false positives is almost never necessary and is not advised -DAMAGE_TIME: 3000 -# Number of item drops to wait for before checking how long they took to drop -# Changing this value is almost never required -DROP_CHECK: 10 -# Minimum time it takes to drop X items -# Changing this value is almost never required -DROP_TIME_MIN: 800 # Time to exempt a player from moving because of entering/exiting a vehicle # Increase in case of false positives ENTERED_EXITED_TIME: 1000 +# Time to exempt a player from moving because of teleporting +# Increase in case of false positives +TELEPORT_TIME: 1000 # Time to exempt a player from moving because of exiting fly mode # Changing this value is almost never required EXIT_FLY_TIME: 2000 -# Time to exempt a player from moving because of taking damage from an explosion -# Can be decreased very slightly to increase detection -# Increasing in case of false positives is almost never necessary and is not advised -EXPLOSION_DAMAGE_TIME: 5000 # Time to exempt a player from moving because of joining the server # If your server is slow when a player joins, increasing this value is important # Shouldn't be lower than 1500 or higher than 5000 JOIN_TIME: 2000 +# Time to exempt a player from moving because of taking damage +# Can be decreased very slightly to increase detection +# Increasing in case of false positives is almost never necessary and is not advised +DAMAGE_TIME: 3000 # Time to exempt a player from moving because of taking damage with knockback effects # Can be decreased very slightly to increase detection # Increase in case of false positives, but shouldn't be necessary KNOCKBACK_DAMAGE_TIME: 4000 -# Number of projectiles to wait for before checking how long they took to fire off -# Do not decrease this value -PROJECTILE_CHECK: 10 -# Minimum time it takes to fire X projectiles -# Decrease in case of false positives -PROJECTILE_TIME_MIN: 1500 -# Time to exempt a player from moving because of teleporting -# Increase in case of false positives -TELEPORT_TIME: 1000 -# Number of command spam violations before action one is executed -# Should be changed to personal preference -COMMAND_ACTION_ONE_LEVEL: 5 -# Number of command spam violations before action two is executed -# Should be changed to personal preference -COMMAND_ACTION_TWO_LEVEL: 10 -# Number of chat spam violations before action one is executed -# Should be changed to personal preference -CHAT_ACTION_ONE_LEVEL: 5 -# Number of chat spam violations before action two is executed -# Should be changed to personal preference -CHAT_ACTION_TWO_LEVEL: 10 -# This is a set value and shouldn't be changed unless you know what you're doing -VELOCITY_SCHETIME: 2 -# Maximum time a player is considered to have a change in velocity -# This is a set value and shouldn't be changed unless you know what you're doing -VELOCITY_CHECKTIME: 2100 +# Time to exempt a player from moving because of taking damage from an explosion +# Can be decreased very slightly to increase detection +# Increasing in case of false positives is almost never necessary and is not advised +EXPLOSION_DAMAGE_TIME: 5000 +# Amount of seconds to extend a players velocitized state after receiving velocity again +VELOCITY_EXTENSION: 2 +# Time a player is considered to have a change in velocity +VELOCITY_TIME: 2000 # This is a set value and shouldn't be changed unless you know what you're doing VELOCITY_PREVENT: 5000 # This is a set value and shouldn't be changed unless you know what you're doing VELOCITY_MAXTIMES: 2 -# This is a set value and shouldn't be changed unless you know what you're doing -VELOCITY_TIME: 3 -# Number of times a player can sprint without proper food level before being considered a cheater -# Can either be increased or decreased to your liking. Shouldn't make a massive difference. -SPRINT_FOOD_MIN: 6 -# Maximum times a player can interact between animations -# Changing this value of almost never required -ANIMATION_INTERACT_MAX: 3 -# Minimum time between commands in milliseconds -# Should be changed to personal preference -COMMAND_MIN: 400 -# Time before repeating a command in milliseconds -# Should be changed to personal preference -COMMAND_REPEAT_MIN: 500 -# Minimum time between chats in milliseconds -# Should be changed to personal preference -CHAT_MIN: 500 -# Time before repeating yourself in chat is ignored in milliseconds -# Should be changed to personal preference -CHAT_REPEAT_MIN: 600 -# Minimum time in between block breaks -# Decrease in case of false positives -BLOCK_BREAK_MIN: 0.1 -# Minimum time in between block placing -# Decrease in case of false positives -BLOCK_PLACE_MIN: 0.1 -# Minimum time in between eating -# Decrease in case of false positives -EAT_TIME_MIN: 1000 -# Maximum percent error between predicted bow force and actual bow force -# Increase in case of false positives -BOW_ERROR: 0.25 -# Maximum distance a player can break a block from -# Changing this value is almost never required -BLOCK_MAX_DISTANCE: 5.5 -# Maximum distance a player can break a block from when in creative mode -# Changing this value is almost never required -BLOCK_MAX_DISTANCE_CREATIVE: 6.0 -# Maximum speed a player on a ladder can travel -# This is a set value and shouldn't be changed unless you know what you're doing -LADDER_Y_MAX: 0.11761 -# Minimum speed a player on a ladder can travel -# This is a set value and shouldn't be changed unless you know what you're doing -LADDER_Y_MIN: 0.11759 -# The number of clicks we should wait before checking if the player has used fast inventory -# Increase in case of false positives -INVENTORY_CHECK: 10 -# The minimum time it should have taken for the player to click X times -# Increase in case of false positives -INVENTORY_TIMEMIN: 50 # Minimum travel distance for move to be considered a teleport and subsequently be ignored # This is a set value and shouldn't be changed unless you know what you're doing TELEPORT_MIN: 400 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3ccdb0c..248ae70 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -55,12 +55,6 @@ permissions: anticheat.check.waterwalk: description: Allow players to walk on water default: false - anticheat.check.noswing: - description: Allow players to not ever swing their arm - default: false - anticheat.check.fastbreak: - description: Allow players to quickly break blocks - default: false anticheat.check.fastplace: description: Allow players to use build hacks and fastplace default: false @@ -112,9 +106,6 @@ permissions: anticheat.check.fastinventory: description: Allow players to use fastloot and similar inventory hacks default: false - anticheat.check.autotool: - description: Allow players to use autotool to switch tools quickly - default: false anticheat.check.morepackets: description: Allow players to send lots of movement packets or modify their timer default: false @@ -143,8 +134,6 @@ permissions: anticheat.check.flight: true anticheat.check.elytrafly: true anticheat.check.waterwalk: true - anticheat.check.noswing: true - anticheat.check.fastbreak: true anticheat.check.fastplace: true anticheat.check.chatspam: true anticheat.check.commandspam: true @@ -158,15 +147,14 @@ permissions: anticheat.check.fasteat: true anticheat.check.fastheal: true anticheat.check.killaura: true - anticheat.check.unicode: true anticheat.check.fastprojectile: true anticheat.check.itemspam: true anticheat.check.fastinventory: true - anticheat.check.autotool: true anticheat.check.morepackets: true anticheat.check.badpackets: true anticheat.check.velocity: true anticheat.check.criticals: true + anticheat.check.unicode: true anticheat.check.illegalinteract: true anticheat.check.fastladder: true anticheat.check.aimbot: true \ No newline at end of file