diff --git a/pom.xml b/pom.xml index c15a144..c6b6c41 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.rammelkast.anticheatreloaded AntiCheatReloaded - 1.8.0 + 1.8.1-PRE AntiCheatReloaded https://www.spigotmc.org/resources/anticheatreloaded.23799/ diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java index 35b6be4..ac4018a 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java @@ -255,7 +255,7 @@ public class AntiCheatReloaded extends JavaPlugin { } public static void sendToMainThread(Runnable runnable) { - Bukkit.getServer().getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable); + Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable); } public void sendToStaff(String message) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index 3fc1883..6c663b8 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -21,6 +21,7 @@ package com.rammelkast.anticheatreloaded.check; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -57,337 +58,357 @@ import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.VersionUtil; public class Backend { - private List isAscending = new ArrayList(); - private Map ascensionCount = new HashMap(); - private Map chatLevel = new HashMap(); - private Map commandLevel = new HashMap(); - private Map nofallViolation = new HashMap(); - private Map fastBreakViolation = new HashMap(); - private Map fastBreaks = new HashMap(); - private Map blockBreakHolder = new HashMap(); - private Map lastBlockBroken = new HashMap(); - private Map fastPlaceViolation = new HashMap(); - private Map lastBlockPlaced = new HashMap(); - private Map lastBlockPlaceTime = new HashMap(); - private Map blockPunches = new HashMap(); - private Map projectilesShot = new HashMap(); - private Map velocitized = new HashMap(); - private Map velocitytrack = new HashMap(); - private Map startEat = new HashMap(); - private Map lastHeal = new HashMap(); - private Map projectileTime = new HashMap(); - private Map bowWindUp = new HashMap(); - private Map instantBreakExempt = new HashMap(); - private Map sprinted = new HashMap(); - private Map brokenBlock = new HashMap(); - private Map placedBlock = new HashMap(); - private Map blockTime = new HashMap(); - private Map blocksDropped = new HashMap(); - private Map lastInventoryTime = new HashMap(); - private Map inventoryTime = new HashMap(); - private Map inventoryClicks = new HashMap(); - private Map itemInHand = new HashMap(); - private Map steps = new HashMap(); - private Map stepTime = new HashMap(); - private HashSet transparent = new HashSet(); - private Map lastFallPacket = new HashMap(); - private Map fastSneakViolations = new HashMap(); + private List isAscending = new ArrayList(); + private Map ascensionCount = new HashMap(); + private Map chatLevel = new HashMap(); + private Map commandLevel = new HashMap(); + private Map nofallViolation = new HashMap(); + private Map fastBreakViolation = new HashMap(); + private Map fastBreaks = new HashMap(); + private Map blockBreakHolder = new HashMap(); + private Map lastBlockBroken = new HashMap(); + private Map fastPlaceViolation = new HashMap(); + private Map lastBlockPlaced = new HashMap(); + private Map lastBlockPlaceTime = new HashMap(); + private Map blockPunches = new HashMap(); + private Map projectilesShot = new HashMap(); + private Map velocitized = new HashMap(); + private Map velocitytrack = new HashMap(); + private Map startEat = new HashMap(); + private Map lastHeal = new HashMap(); + private Map projectileTime = new HashMap(); + private Map bowWindUp = new HashMap(); + private Map instantBreakExempt = new HashMap(); + private Map sprinted = new HashMap(); + private Map brokenBlock = new HashMap(); + private Map placedBlock = new HashMap(); + private Map blockTime = new HashMap(); + private Map blocksDropped = new HashMap(); + private Map lastInventoryTime = new HashMap(); + private Map inventoryTime = new HashMap(); + private Map inventoryClicks = new HashMap(); + private Map itemInHand = new HashMap(); + private Map steps = new HashMap(); + private Map stepTime = new HashMap(); + private HashSet transparent = new HashSet(); + private Map lastFallPacket = new HashMap(); + private Map fastSneakViolations = new HashMap(); - private Magic magic; - private AntiCheatManager manager = null; - private Lang lang = null; - private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); + private Magic magic; + private AntiCheatManager manager = null; + private Lang lang = null; + private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); - public Backend(AntiCheatManager instance) { - magic = instance.getConfiguration().getMagic(); - manager = instance; - lang = manager.getConfiguration().getLang(); - transparent.add((byte) -1); - } - - public Magic getMagic() { - return magic; - } + public Backend(AntiCheatManager instance) { + magic = instance.getConfiguration().getMagic(); + manager = instance; + lang = manager.getConfiguration().getLang(); + transparent.add((byte) -1); + } - public void updateConfig(Configuration config) { - magic = config.getMagic(); - lang = config.getLang(); - } + public Magic getMagic() { + return magic; + } - public void resetChatLevel(User user) { - chatLevel.put(user.getUUID(), 0); - } + public void updateConfig(Configuration config) { + magic = config.getMagic(); + lang = config.getLang(); + } - public void garbageClean(Player player) { - UUID pU = player.getUniqueId(); + public void resetChatLevel(User user) { + chatLevel.put(user.getUUID(), 0); + } - VelocityCheck.cleanPlayer(player); - BlinkCheck.MOVE_COUNT.remove(player.getUniqueId()); - blocksDropped.remove(pU); - blockTime.remove(pU); - FlightCheck.MOVING_EXEMPT.remove(pU); - brokenBlock.remove(pU); - placedBlock.remove(pU); - bowWindUp.remove(pU); - startEat.remove(pU); - lastHeal.remove(pU); - sprinted.remove(pU); - WaterWalkCheck.IS_IN_WATER.remove(pU); - WaterWalkCheck.IS_IN_WATER_CACHE.remove(pU); - instantBreakExempt.remove(pU); - isAscending.remove(player.getUniqueId()); - ascensionCount.remove(player.getUniqueId()); - FlightCheck.BLOCKS_OVER_FLIGHT.remove(pU); - nofallViolation.remove(pU); - fastBreakViolation.remove(pU); - YAxisCheck.Y_AXIS_VIOLATIONS.remove(pU); - YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU); - YAxisCheck.LAST_Y_COORD_CACHE.remove(pU); - YAxisCheck.LAST_Y_TIME.remove(pU); - fastBreaks.remove(pU); - blockBreakHolder.remove(pU); - lastBlockBroken.remove(pU); - fastPlaceViolation.remove(pU); - lastBlockPlaced.remove(pU); - lastBlockPlaceTime.remove(pU); - blockPunches.remove(pU); - WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU); - WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU); - projectilesShot.remove(pU); - velocitized.remove(pU); - velocitytrack.remove(pU); - startEat.remove(pU); - lastHeal.remove(pU); - projectileTime.remove(pU); - bowWindUp.remove(pU); - instantBreakExempt.remove(pU); - sprinted.remove(pU); - brokenBlock.remove(pU); - placedBlock.remove(pU); - FlightCheck.MOVING_EXEMPT.remove(pU); - blockTime.remove(pU); - blocksDropped.remove(pU); - lastInventoryTime.remove(pU); - inventoryTime.remove(pU); - inventoryClicks.remove(pU); - lastFallPacket.remove(pU); - fastSneakViolations.remove(player.getUniqueId().toString()); - GlideCheck.LAST_DIFFERENCE.remove(pU); - GlideCheck.LAST_FALL_DISTANCE.remove(pU); - GlideCheck.VIOLATIONS.remove(pU); - SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId()); - ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString()); - KillAuraCheck.ANGLE_FLAGS.remove(player.getUniqueId().toString()); - KillAuraCheck.CLICKSPEED_MAP.remove(player.getUniqueId().toString()); - KillAuraCheck.DEVIATION_SCORES.remove(player.getUniqueId().toString()); - KillAuraCheck.DIFF_MAP.remove(player.getUniqueId().toString()); - } + public void garbageClean(Player player) { + UUID pU = player.getUniqueId(); - public CheckResult checkFastBow(Player player, float force) { - // Ignore magic numbers here, they are minecrafty vanilla stuff. - if (!bowWindUp.containsKey(player.getUniqueId())) { - return PASS; - } - int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3); - bowWindUp.remove(player.getUniqueId()); - 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()) { - return new CheckResult(CheckResult.Result.FAILED, "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")"); - } else { - return PASS; - } - } + VelocityCheck.cleanPlayer(player); + BlinkCheck.MOVE_COUNT.remove(player.getUniqueId()); + blocksDropped.remove(pU); + blockTime.remove(pU); + FlightCheck.MOVING_EXEMPT.remove(pU); + brokenBlock.remove(pU); + placedBlock.remove(pU); + bowWindUp.remove(pU); + startEat.remove(pU); + lastHeal.remove(pU); + sprinted.remove(pU); + WaterWalkCheck.IS_IN_WATER.remove(pU); + WaterWalkCheck.IS_IN_WATER_CACHE.remove(pU); + instantBreakExempt.remove(pU); + isAscending.remove(player.getUniqueId()); + ascensionCount.remove(player.getUniqueId()); + FlightCheck.BLOCKS_OVER_FLIGHT.remove(pU); + nofallViolation.remove(pU); + fastBreakViolation.remove(pU); + YAxisCheck.Y_AXIS_VIOLATIONS.remove(pU); + YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU); + YAxisCheck.LAST_Y_COORD_CACHE.remove(pU); + YAxisCheck.LAST_Y_TIME.remove(pU); + fastBreaks.remove(pU); + blockBreakHolder.remove(pU); + lastBlockBroken.remove(pU); + fastPlaceViolation.remove(pU); + lastBlockPlaced.remove(pU); + lastBlockPlaceTime.remove(pU); + blockPunches.remove(pU); + WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU); + WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU); + projectilesShot.remove(pU); + velocitized.remove(pU); + velocitytrack.remove(pU); + startEat.remove(pU); + lastHeal.remove(pU); + projectileTime.remove(pU); + bowWindUp.remove(pU); + instantBreakExempt.remove(pU); + sprinted.remove(pU); + brokenBlock.remove(pU); + placedBlock.remove(pU); + FlightCheck.MOVING_EXEMPT.remove(pU); + blockTime.remove(pU); + blocksDropped.remove(pU); + lastInventoryTime.remove(pU); + inventoryTime.remove(pU); + inventoryClicks.remove(pU); + lastFallPacket.remove(pU); + fastSneakViolations.remove(player.getUniqueId().toString()); + GlideCheck.LAST_DIFFERENCE.remove(pU); + GlideCheck.LAST_FALL_DISTANCE.remove(pU); + GlideCheck.VIOLATIONS.remove(pU); + SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId()); + ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString()); + KillAuraCheck.ANGLE_FLAGS.remove(player.getUniqueId().toString()); + KillAuraCheck.CLICKSPEED_MAP.remove(player.getUniqueId().toString()); + KillAuraCheck.DEVIATION_SCORES.remove(player.getUniqueId().toString()); + KillAuraCheck.DIFF_MAP.remove(player.getUniqueId().toString()); + } - public CheckResult checkProjectile(Player player) { - incrementOld(player, projectilesShot, 10); - 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()) { - long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId()); - 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() + ")"); - } - } - return PASS; - } + public CheckResult checkFastBow(Player player, float force) { + // Ignore magic numbers here, they are minecrafty vanilla stuff. + if (!bowWindUp.containsKey(player.getUniqueId())) { + return PASS; + } + int ticks = (int) ((((System.currentTimeMillis() - bowWindUp.get(player.getUniqueId())) * 20) / 1000) + 3); + bowWindUp.remove(player.getUniqueId()); + 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()) { + return new CheckResult(CheckResult.Result.FAILED, + "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")"); + } else { + return PASS; + } + } - public CheckResult checkFastDrop(Player player) { - incrementOld(player, blocksDropped, 10); - 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()) { - long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId()); - blockTime.remove(player.getUniqueId()); - blocksDropped.remove(player.getUniqueId()); - if (time < magic.DROP_TIME_MIN()) { - return new CheckResult(CheckResult.Result.FAILED,"dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")"); - } - } - return PASS; - } + public CheckResult checkProjectile(Player player) { + incrementOld(player, projectilesShot, 10); + 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()) { + long time = System.currentTimeMillis() - projectileTime.get(player.getUniqueId()); + 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() + ")"); + } + } + return PASS; + } - public CheckResult checkLongReachBlock(Player player, double x, double y, double z) { - if (isInstantBreakExempt(player)) { - return new CheckResult(CheckResult.Result.PASSED); - } else { - String string = "reached too far for a block"; - 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 i = x >= distance ? x : y > distance ? y : z > distance ? z : -1; - if (i != -1) { - return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")"); - } else { - return PASS; - } - } - } + public CheckResult checkFastDrop(Player player) { + incrementOld(player, blocksDropped, 10); + 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()) { + long time = System.currentTimeMillis() - blockTime.get(player.getUniqueId()); + blockTime.remove(player.getUniqueId()); + blocksDropped.remove(player.getUniqueId()); + if (time < magic.DROP_TIME_MIN()) { + return new CheckResult(CheckResult.Result.FAILED, + "dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")"); + } + } + return PASS; + } - public CheckResult checkLongReachDamage(Player player, double x, double y, double z) { - String string = "reached too far for an entity"; - double i = x >= magic.ENTITY_MAX_DISTANCE() ? x : y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1; - if (i != -1) { - return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")"); - } else { - return PASS; - } - } + public CheckResult checkLongReachBlock(Player player, double x, double y, double z) { + if (isInstantBreakExempt(player)) { + return new CheckResult(CheckResult.Result.PASSED); + } else { + String string = "reached too far for a block"; + 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 i = x >= distance ? x : y > distance ? y : z > distance ? z : -1; + if (i != -1) { + return new CheckResult(CheckResult.Result.FAILED, + string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")"); + } else { + 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())) { - return new CheckResult(CheckResult.Result.FAILED, "tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")"); - } else { - return PASS; - } - } + public CheckResult checkLongReachDamage(Player player, double x, double y, double z) { + String string = "reached too far for an entity"; + double i = x >= magic.ENTITY_MAX_DISTANCE() ? x + : y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1; + if (i != -1) { + return new CheckResult(CheckResult.Result.FAILED, + string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")"); + } else { + return PASS; + } + } - public CheckResult checkYSpeed(Player player, double y) { - if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX()) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) { - return new CheckResult(CheckResult.Result.FAILED, "y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")"); - } else { - 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())) { + return new CheckResult(CheckResult.Result.FAILED, + "tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")"); + } else { + return PASS; + } + } - public CheckResult checkNoFall(Player player, double y) { - UUID uuid = player.getUniqueId(); - if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player) && !Utilities.isInWeb(player)) { - if (player.getFallDistance() == 0) { - if (nofallViolation.get(uuid) == null) { - nofallViolation.put(uuid, 1); - } else { - nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1); - } + public CheckResult checkYSpeed(Player player, double y) { + if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX()) + && !isDoing(player, velocitized, magic.VELOCITY_TIME()) + && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) { + return new CheckResult(CheckResult.Result.FAILED, + "y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")"); + } else { + return PASS; + } + } - int i = nofallViolation.get(uuid); - if (i >= magic.NOFALL_LIMIT()) { - nofallViolation.put(player.getUniqueId(), 1); - return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")"); - } else { - return PASS; - } - } else { - nofallViolation.put(uuid, 0); - return PASS; - } - } - return PASS; - } + public CheckResult checkNoFall(Player player, double y) { + UUID uuid = player.getUniqueId(); + if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() + && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player) + && !Utilities.isInWeb(player)) { + if (player.getFallDistance() == 0) { + if (nofallViolation.get(uuid) == null) { + nofallViolation.put(uuid, 1); + } else { + nofallViolation.put(uuid, nofallViolation.get(player.getUniqueId()) + 1); + } - public CheckResult checkSneak(Player player, Location location, double x, double z) { - if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle() && !Utilities.cantStandAtExp(location)) { - double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1; - if (i != -1) { - if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) { - int flags = this.fastSneakViolations.get(player.getUniqueId().toString()); - if (flags >= 3) { // TODO possible config - return new CheckResult(CheckResult.Result.FAILED, "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); - } - this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1); - return PASS; - } else { - this.fastSneakViolations.put(player.getUniqueId().toString(), 1); - return PASS; - } - } else { - this.fastSneakViolations.remove(player.getUniqueId().toString()); - return PASS; - } - } else { - this.fastSneakViolations.remove(player.getUniqueId().toString()); - return PASS; - } - } + int i = nofallViolation.get(uuid); + if (i >= magic.NOFALL_LIMIT()) { + nofallViolation.put(player.getUniqueId(), 1); + return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " + + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")"); + } else { + return PASS; + } + } else { + nofallViolation.put(uuid, 0); + return PASS; + } + } + return PASS; + } - public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) { - Player player = event.getPlayer(); - if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) { - return new CheckResult(CheckResult.Result.FAILED, "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")"); - } else { - return PASS; - } - } + public CheckResult checkSneak(Player player, Location location, double x, double z) { + if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle() + && !Utilities.cantStandAtExp(location)) { + double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1; + if (i != -1) { + if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) { + int flags = this.fastSneakViolations.get(player.getUniqueId().toString()); + if (flags >= 3) { // TODO possible config + return new CheckResult(CheckResult.Result.FAILED, + "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); + } + this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1); + return PASS; + } else { + this.fastSneakViolations.put(player.getUniqueId().toString(), 1); + return PASS; + } + } else { + this.fastSneakViolations.remove(player.getUniqueId().toString()); + return PASS; + } + } else { + this.fastSneakViolations.remove(player.getUniqueId().toString()); + return PASS; + } + } - public CheckResult checkVClip(Player player, Distance distance) { - double from = Math.round(distance.fromY()); - double to = Math.round(distance.toY()); + public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) { + Player player = event.getPlayer(); + if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE + && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) { + return new CheckResult(CheckResult.Result.FAILED, + "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")"); + } else { + return PASS; + } + } - if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) { - return PASS; - } + public CheckResult checkVClip(Player player, Distance distance) { + double from = Math.round(distance.fromY()); + double to = Math.round(distance.toY()); - for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) { - Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation().getZ()).getBlock(); - if (block.getType() != Material.AIR && block.getType().isSolid()) { - return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block", (int) from + 3); - } - } + if (player.isInsideVehicle() || (from == to || from < to) || Math.round(distance.getYDifference()) < 2) { + return PASS; + } - return PASS; - } + for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) { + Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, + player.getLocation().getZ()).getBlock(); + if (block.getType() != Material.AIR && block.getType().isSolid()) { + return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block", + (int) from + 3); + } + } - public CheckResult checkTimer(Player player) { - UUID uuid = player.getUniqueId(); - int step = 1; - if (steps.containsKey(uuid)) { - step = steps.get(uuid) + 1; - } - if (step == 1) { - stepTime.put(uuid, System.currentTimeMillis()); - } - incrementOld(player, steps, step); - if (step == magic.TIMER_STEP_CHECK()) { - long time = System.currentTimeMillis() - stepTime.get(uuid); - steps.put(uuid, 0); - if (time < magic.TIMER_TIMEMIN()) { - return new CheckResult(CheckResult.Result.FAILED, "tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)"); - } - } - return PASS; - } + return PASS; + } - public void logAscension(Player player, double y1, double y2) { - UUID name = player.getUniqueId(); - if (y1 < y2 && !isAscending.contains(name)) { - isAscending.add(name); - } else { - isAscending.remove(name); - } - } + public CheckResult checkTimer(Player player) { + UUID uuid = player.getUniqueId(); + int step = 1; + if (steps.containsKey(uuid)) { + step = steps.get(uuid) + 1; + } + if (step == 1) { + stepTime.put(uuid, System.currentTimeMillis()); + } + incrementOld(player, steps, step); + if (step == magic.TIMER_STEP_CHECK()) { + long time = System.currentTimeMillis() - stepTime.get(uuid); + steps.put(uuid, 0); + if (time < magic.TIMER_TIMEMIN()) { + return new CheckResult(CheckResult.Result.FAILED, "tried to alter their timer, took " + step + + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)"); + } + } + return PASS; + } - public CheckResult checkAscension(Player player, double y1, double y2) { - int max = magic.ASCENSION_COUNT_MAX(); - String string = ""; - if (player.hasPotionEffect(PotionEffectType.JUMP)) { - max += 12; - string = " with jump potion"; + public void logAscension(Player player, double y1, double y2) { + UUID name = player.getUniqueId(); + if (y1 < y2 && !isAscending.contains(name)) { + isAscending.add(name); + } else { + isAscending.remove(name); + } + } + + public CheckResult checkAscension(Player player, double y1, double y2) { + int max = magic.ASCENSION_COUNT_MAX(); + String string = ""; + if (player.hasPotionEffect(PotionEffectType.JUMP)) { + max += 12; + string = " with jump potion"; } Block block = player.getLocation().getBlock(); if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player) @@ -401,8 +422,8 @@ public class Backend { increment(player, ascensionCount, max); if (ascensionCount.get(player.getUniqueId()) >= max) { return new CheckResult(CheckResult.Result.FAILED, - "ascended " + ascensionCount.get(player.getUniqueId()) - + " times in a row (max = " + max + string + ")"); + "ascended " + ascensionCount.get(player.getUniqueId()) + " times in a row (max = " + max + + string + ")"); } } } else { @@ -412,477 +433,512 @@ public class Backend { return PASS; } - public CheckResult checkSwing(Player player, Block block) { - UUID uuid = player.getUniqueId(); - if (!isInstantBreakExempt(player)) { - if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType().name().endsWith("LEAVES"))) { - if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) { - int i = blockPunches.get(uuid); - if (i < magic.BLOCK_PUNCH_MIN()) { - return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")"); - } else { - blockPunches.put(uuid, 0); // it should reset after EACH block break. - } - } - } - } - return PASS; - } - - public CheckResult checkFastBreak(Player player, Block block) { - int violations = magic.FASTBREAK_MAXVIOLATIONS(); - long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType()); - if (player.getGameMode() == GameMode.CREATIVE) { - violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE(); - timemax = magic.FASTBREAK_TIMEMAX_CREATIVE(); - } - UUID uuid = player.getUniqueId(); - if (!fastBreakViolation.containsKey(uuid)) { - fastBreakViolation.put(uuid, 0); - } else { - Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid); - int i = fastBreakViolation.get(uuid); - if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) { - lastBlockBroken.put(uuid, System.currentTimeMillis()); - return new CheckResult(CheckResult.Result.FAILED, "broke blocks too fast " + i + " times in a row (max=" + violations + ")"); - } else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) { - fastBreakViolation.put(uuid, 0); - } - } - if (!fastBreaks.containsKey(uuid) || !lastBlockBroken.containsKey(uuid)) { - if (!lastBlockBroken.containsKey(uuid)) { - lastBlockBroken.put(uuid, System.currentTimeMillis()); - } - if (!fastBreaks.containsKey(uuid)) { - fastBreaks.put(uuid, 0); - } - } else { - Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid); - if ((math != 0L && timemax != 0L)) { - if (math < timemax) { - if (fastBreakViolation.containsKey(uuid) && fastBreakViolation.get(uuid) > 0) { - fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1); - } else { - fastBreaks.put(uuid, fastBreaks.get(uuid) + 1); - } - blockBreakHolder.put(uuid, false); - } - if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() && math < timemax) { - int i = fastBreaks.get(uuid); - fastBreaks.put(uuid, 0); - fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1); - return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math + " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)"); - } else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) { - if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) { - blockBreakHolder.put(uuid, true); - } else { - fastBreaks.put(uuid, fastBreaks.get(uuid) - 1); - if (fastBreakViolation.get(uuid) > 0) { - fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) - 1); - } - blockBreakHolder.put(uuid, false); - } - } - } - } - - lastBlockBroken.put(uuid, System.currentTimeMillis()); // always keep a log going. - return PASS; - } - - public CheckResult checkFastPlace(Player player) { - int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() : magic.FASTPLACE_MAXVIOLATIONS(); - long time = System.currentTimeMillis(); - UUID uuid = player.getUniqueId(); - if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) { - lastBlockPlaceTime.put(uuid, 0L); - if (!fastPlaceViolation.containsKey(uuid)) { - fastPlaceViolation.put(uuid, 0); - } - } else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) { - AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid)); - Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid); - AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math); - if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) { - lastBlockPlaced.put(uuid, time); - return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")"); - } else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) { - AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid); - fastPlaceViolation.put(uuid, 0); - } - } else if (lastBlockPlaced.containsKey(uuid)) { - long last = lastBlockPlaced.get(uuid); - long lastTime = lastBlockPlaceTime.get(uuid); - long thisTime = time - last; - - if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN()) { - lastBlockPlaceTime.put(uuid, (time - last)); - lastBlockPlaced.put(uuid, time); - fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1); - return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)"); - } - lastBlockPlaceTime.put(uuid, (time - last)); - } - lastBlockPlaced.put(uuid, time); - return PASS; - } - - public void logBowWindUp(Player player) { - bowWindUp.put(player.getUniqueId(), System.currentTimeMillis()); - } - - public void logEatingStart(Player player) { - startEat.put(player.getUniqueId(), System.currentTimeMillis()); - } - - public void logHeal(Player player) { - lastHeal.put(player.getUniqueId(), System.currentTimeMillis()); - } - - public CheckResult checkChatSpam(Player player, String msg) { - UUID uuid = player.getUniqueId(); - User user = manager.getUserManager().getUser(uuid); - if (user.getLastMessageTime() != -1) { - for (int i = 0; i < 2; i++) { - String m = user.getMessage(i); - if (m == null) { - break; - } - Long l = user.getMessageTime(i); - - if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN()) { - user.clearMessages(); - break; - } else { - 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()) { - manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\""); - return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); - } - } - } - } - user.addMessage(msg); - return PASS; - } - - public CheckResult checkChatUnicode(Player player, String msg) { - UUID uuid = player.getUniqueId(); - User user = manager.getUserManager().getUser(uuid); - if (!isPureAscii(msg)) { - return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed."); - } - user.addMessage(msg); - return PASS; - } - - private boolean isPureAscii(String v) { - return StandardCharsets.US_ASCII.newEncoder().canEncode(v.replaceAll("¡", "!").replaceAll("¿", "?")); + public CheckResult checkSwing(Player player, Block block) { + UUID uuid = player.getUniqueId(); + if (!isInstantBreakExempt(player)) { + if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) + && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS + && block.getType().name().endsWith("LEAVES"))) { + if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) { + int i = blockPunches.get(uuid); + if (i < magic.BLOCK_PUNCH_MIN()) { + return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType() + + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")"); + } else { + blockPunches.put(uuid, 0); // it should reset after EACH block break. + } + } + } + } + return PASS; } - - public CheckResult checkCommandSpam(Player player, String cmd) { - UUID uuid = player.getUniqueId(); - User user = manager.getUserManager().getUser(uuid); - if (user.getLastCommandTime() != -1) { - for (int i = 0; i < 2; i++) { - String m = user.getCommand(i); - if (m == null) { - break; - } - Long l = user.getCommandTime(i); - if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN()) { - user.clearCommands(); - break; - } else { - 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()) { - return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); - } - } - } - } - user.addCommand(cmd); - return PASS; - } + public CheckResult checkFastBreak(Player player, Block block) { + int violations = magic.FASTBREAK_MAXVIOLATIONS(); + long timemax = isInstantBreakExempt(player) ? 0 + : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType()); + if (player.getGameMode() == GameMode.CREATIVE) { + violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE(); + timemax = magic.FASTBREAK_TIMEMAX_CREATIVE(); + } + UUID uuid = player.getUniqueId(); + if (!fastBreakViolation.containsKey(uuid)) { + fastBreakViolation.put(uuid, 0); + } else { + Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid); + int i = fastBreakViolation.get(uuid); + if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) { + lastBlockBroken.put(uuid, System.currentTimeMillis()); + return new CheckResult(CheckResult.Result.FAILED, + "broke blocks too fast " + i + " times in a row (max=" + violations + ")"); + } else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) { + fastBreakViolation.put(uuid, 0); + } + } + if (!fastBreaks.containsKey(uuid) || !lastBlockBroken.containsKey(uuid)) { + if (!lastBlockBroken.containsKey(uuid)) { + lastBlockBroken.put(uuid, System.currentTimeMillis()); + } + if (!fastBreaks.containsKey(uuid)) { + fastBreaks.put(uuid, 0); + } + } else { + Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid); + if ((math != 0L && timemax != 0L)) { + if (math < timemax) { + if (fastBreakViolation.containsKey(uuid) && fastBreakViolation.get(uuid) > 0) { + fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1); + } else { + fastBreaks.put(uuid, fastBreaks.get(uuid) + 1); + } + blockBreakHolder.put(uuid, false); + } + if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() && math < timemax) { + int i = fastBreaks.get(uuid); + fastBreaks.put(uuid, 0); + fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1); + return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math + + " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)"); + } else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) { + if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) { + blockBreakHolder.put(uuid, true); + } else { + fastBreaks.put(uuid, fastBreaks.get(uuid) - 1); + if (fastBreakViolation.get(uuid) > 0) { + fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) - 1); + } + blockBreakHolder.put(uuid, false); + } + } + } + } - public CheckResult checkInventoryClicks(Player player) { - if (player.getGameMode() == GameMode.CREATIVE) { - return PASS; - } - UUID uuid = player.getUniqueId(); - int clicks = 1; - if (inventoryClicks.containsKey(uuid)) { - clicks = inventoryClicks.get(uuid) + 1; - } - inventoryClicks.put(uuid, clicks); - if (clicks == 1) { - inventoryTime.put(uuid, System.currentTimeMillis()); - } else if (clicks == magic.INVENTORY_CHECK()) { - long time = System.currentTimeMillis() - inventoryTime.get(uuid); - inventoryClicks.put(uuid, 0); - if (time < magic.INVENTORY_TIMEMIN()) { - return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)"); - } - } - return PASS; - } + lastBlockBroken.put(uuid, System.currentTimeMillis()); // always keep a log going. + 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 checkFastPlace(Player player) { + int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() + : magic.FASTPLACE_MAXVIOLATIONS(); + long time = System.currentTimeMillis(); + UUID uuid = player.getUniqueId(); + if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) { + lastBlockPlaceTime.put(uuid, 0L); + if (!fastPlaceViolation.containsKey(uuid)) { + fastPlaceViolation.put(uuid, 0); + } + } else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) { + AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + + fastPlaceViolation.get(uuid)); + Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid); + AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math); + if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) { + lastBlockPlaced.put(uuid, time); + return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast " + + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")"); + } else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) { + AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid); + fastPlaceViolation.put(uuid, 0); + } + } else if (lastBlockPlaced.containsKey(uuid)) { + long last = lastBlockPlaced.get(uuid); + long lastTime = lastBlockPlaceTime.get(uuid); + long thisTime = time - last; - public CheckResult checkSprintDamage(Player player) { - if (isDoing(player, sprinted, magic.SPRINT_MAX())) { - return new CheckResult(CheckResult.Result.FAILED, "sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)"); - } else { - return PASS; - } - } + if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN()) { + lastBlockPlaceTime.put(uuid, (time - last)); + lastBlockPlaced.put(uuid, time); + fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1); + return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime + + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)"); + } + lastBlockPlaceTime.put(uuid, (time - last)); + } + lastBlockPlaced.put(uuid, time); + return PASS; + } - public CheckResult checkFastHeal(Player player) { - if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. - { - long healTime = VersionUtil.getHealTime(); - long l = lastHeal.get(player.getUniqueId()); - lastHeal.remove(player.getUniqueId()); - if ((System.currentTimeMillis() - l) < healTime) { - return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)"); - } - } - return PASS; - } + public void logBowWindUp(Player player) { + bowWindUp.put(player.getUniqueId(), System.currentTimeMillis()); + } - public CheckResult checkFastEat(Player player) { - if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. - { - long l = startEat.get(player.getUniqueId()); - startEat.remove(player.getUniqueId()); - if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) { - return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)"); - } - } - return PASS; - } + public void logEatingStart(Player player) { + startEat.put(player.getUniqueId(), System.currentTimeMillis()); + } - public void logInstantBreak(final Player player) { - instantBreakExempt.put(player.getUniqueId(), System.currentTimeMillis()); - } + public void logHeal(Player player) { + lastHeal.put(player.getUniqueId(), System.currentTimeMillis()); + } - public boolean isInstantBreakExempt(Player player) { - return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME()); - } + public CheckResult checkChatSpam(Player player, String msg) { + UUID uuid = player.getUniqueId(); + User user = manager.getUserManager().getUser(uuid); + if (user.getLastMessageTime() != -1) { + for (int i = 0; i < 2; i++) { + String m = user.getMessage(i); + if (m == null) { + break; + } + Long l = user.getMessageTime(i); - public void logSprint(final Player player) { - sprinted.put(player.getUniqueId(), System.currentTimeMillis()); - } + if (System.currentTimeMillis() - l > magic.CHAT_REPEAT_MIN()) { + user.clearMessages(); + break; + } else { + 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()) { + manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\""); + return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); + } + } + } + } + user.addMessage(msg); + return PASS; + } - public boolean isHoveringOverWaterAfterViolation(Player player) { - if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) { - if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) { - return true; - } - } - return false; - } + public CheckResult checkChatUnicode(Player player, String msg) { + UUID uuid = player.getUniqueId(); + User user = manager.getUserManager().getUser(uuid); + for (char ch : msg.toCharArray()) { + if (Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.BASIC_LATIN + && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_1_SUPPLEMENT + && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_EXTENDED_A + && Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.GENERAL_PUNCTUATION) { + return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed."); + } + } + user.addMessage(msg); + return PASS; + } - public void logBlockBreak(final Player player) { - brokenBlock.put(player.getUniqueId(), System.currentTimeMillis()); - } + public CheckResult checkCommandSpam(Player player, String cmd) { + UUID uuid = player.getUniqueId(); + User user = manager.getUserManager().getUser(uuid); + if (user.getLastCommandTime() != -1) { + for (int i = 0; i < 2; i++) { + String m = user.getCommand(i); + if (m == null) { + break; + } + Long l = user.getCommandTime(i); - public boolean justBroke(Player player) { - return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN()); - } + if (System.currentTimeMillis() - l > magic.COMMAND_REPEAT_MIN()) { + user.clearCommands(); + break; + } else { + 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()) { + return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); + } + } + } + } + user.addCommand(cmd); + return PASS; + } - public void logVelocity(final Player player) { - velocitized.put(player.getUniqueId(), System.currentTimeMillis()); - } + public CheckResult checkInventoryClicks(Player player) { + if (player.getGameMode() == GameMode.CREATIVE) { + return PASS; + } + UUID uuid = player.getUniqueId(); + int clicks = 1; + if (inventoryClicks.containsKey(uuid)) { + clicks = inventoryClicks.get(uuid) + 1; + } + inventoryClicks.put(uuid, clicks); + if (clicks == 1) { + inventoryTime.put(uuid, System.currentTimeMillis()); + } else if (clicks == magic.INVENTORY_CHECK()) { + long time = System.currentTimeMillis() - inventoryTime.get(uuid); + inventoryClicks.put(uuid, 0); + if (time < magic.INVENTORY_TIMEMIN()) { + return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in " + + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)"); + } + } + return PASS; + } - public boolean justVelocity(Player player) { - return (velocitized.containsKey(player.getUniqueId()) ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() : false); - } + 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 boolean extendVelocityTime(final Player player) { - if (velocitytrack.containsKey(player.getUniqueId())) { - velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1); - if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) { - velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT()); - manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), new Runnable() { - @Override - public void run() { - velocitytrack.put(player.getUniqueId(), 0); - } - }, magic.VELOCITY_SCHETIME() * 20L); - return true; - } - } else { - velocitytrack.put(player.getUniqueId(), 0); - } + public CheckResult checkSprintDamage(Player player) { + if (isDoing(player, sprinted, magic.SPRINT_MAX())) { + return new CheckResult(CheckResult.Result.FAILED, + "sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)"); + } else { + return PASS; + } + } - return false; - } + public CheckResult checkFastHeal(Player player) { + if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. + { + long healTime = VersionUtil.getHealTime(); + long l = lastHeal.get(player.getUniqueId()); + lastHeal.remove(player.getUniqueId()); + if ((System.currentTimeMillis() - l) < healTime) { + return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time=" + + (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)"); + } + } + return PASS; + } - public void logBlockPlace(final Player player) { - placedBlock.put(player.getUniqueId(), System.currentTimeMillis()); - } + public CheckResult checkFastEat(Player player) { + if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. + { + long l = startEat.get(player.getUniqueId()); + startEat.remove(player.getUniqueId()); + if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) { + return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time=" + + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)"); + } + } + return PASS; + } - public boolean justPlaced(Player player) { - return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN()); - } - public void logDamage(final Player player, int type) { - long time; - switch (type) { - case 1: - time = magic.DAMAGE_TIME(); - break; - case 2: - time = magic.KNOCKBACK_DAMAGE_TIME(); - break; - case 3: - time = magic.EXPLOSION_DAMAGE_TIME(); - break; - default: - time = magic.DAMAGE_TIME(); - break; + public void logInstantBreak(final Player player) { + instantBreakExempt.put(player.getUniqueId(), System.currentTimeMillis()); + } - } - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time); - // Only map in which termination time is calculated beforehand. - } + public boolean isInstantBreakExempt(Player player) { + return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME()); + } - public void logEnterExit(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME()); - } + public void logSprint(final Player player) { + sprinted.put(player.getUniqueId(), System.currentTimeMillis()); + } - public void logToggleSneak(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME()); - } + public boolean isHoveringOverWaterAfterViolation(Player player) { + if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) { + if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() + && Utilities.isHoveringOverWater(player.getLocation())) { + return true; + } + } + return false; + } - public void logTeleport(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME()); + public void logBlockBreak(final Player player) { + brokenBlock.put(player.getUniqueId(), System.currentTimeMillis()); + } - /* Data for fly/speed should be reset */ - nofallViolation.remove(player.getUniqueId()); - FlightCheck.BLOCKS_OVER_FLIGHT.remove(player.getUniqueId()); - YAxisCheck.Y_AXIS_VIOLATIONS.remove(player.getUniqueId()); - YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(player.getUniqueId()); - YAxisCheck.LAST_Y_COORD_CACHE.remove(player.getUniqueId()); - YAxisCheck.LAST_Y_TIME.remove(player.getUniqueId()); - GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId()); - GlideCheck.LAST_DIFFERENCE.remove(player.getUniqueId()); - GlideCheck.VIOLATIONS.remove(player.getUniqueId()); - ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString()); - } + public boolean justBroke(Player player) { + return isDoing(player, brokenBlock, magic.BLOCK_BREAK_MIN()); + } - public void logExitFly(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME()); - } + public void logVelocity(final Player player) { + velocitized.put(player.getUniqueId(), System.currentTimeMillis()); + } - public void logJoin(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME()); - } + public boolean justVelocity(Player player) { + return (velocitized.containsKey(player.getUniqueId()) + ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() + : false); + } - public boolean isMovingExempt(Player player) { - return isDoing(player, FlightCheck.MOVING_EXEMPT, -1); - } + public boolean extendVelocityTime(final Player player) { + if (velocitytrack.containsKey(player.getUniqueId())) { + velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1); + if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) { + velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT()); + manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), + new Runnable() { + @Override + public void run() { + velocitytrack.put(player.getUniqueId(), 0); + } + }, magic.VELOCITY_SCHETIME() * 20L); + return true; + } + } else { + velocitytrack.put(player.getUniqueId(), 0); + } - public boolean isAscending(Player player) { - return isAscending.contains(player.getUniqueId()); - } + return false; + } - private boolean isDoing(Player player, Map map, double max) { - if (map.containsKey(player.getUniqueId())) { - if (max != -1) { - if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) { - map.remove(player.getUniqueId()); - return false; - } else { - return true; - } - } else { - // Termination time has already been calculated - if (map.get(player.getUniqueId()) < System.currentTimeMillis()) { - map.remove(player.getUniqueId()); - return false; - } else { - return true; - } - } - } else { - return false; - } - } + public void logBlockPlace(final Player player) { + placedBlock.put(player.getUniqueId(), System.currentTimeMillis()); + } - public boolean hasJumpPotion(Player player) { - return player.hasPotionEffect(PotionEffectType.JUMP); - } + public boolean justPlaced(Player player) { + return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN()); + } - public boolean hasSpeedPotion(Player player) { - return player.hasPotionEffect(PotionEffectType.SPEED); - } + public void logDamage(final Player player, int type) { + long time; + switch (type) { + case 1: + time = magic.DAMAGE_TIME(); + break; + case 2: + time = magic.KNOCKBACK_DAMAGE_TIME(); + break; + case 3: + time = magic.EXPLOSION_DAMAGE_TIME(); + break; + default: + time = magic.DAMAGE_TIME(); + break; - 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() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue(); - manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); - } - chatLevel.put(user.getUUID(), level + 1); - } + } + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time); + // Only map in which termination time is calculated beforehand. + } - 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() ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue(); - manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); - } - commandLevel.put(user.getUUID(), level + 1); - } + public void logEnterExit(final Player player) { + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME()); + } - public int increment(Player player, Map ascensionCount2, int num) { - UUID name = player.getUniqueId(); - if (ascensionCount2.get(name) == null) { - ascensionCount2.put(name, 1); - return 1; - } else { - int amount = ascensionCount2.get(name) + 1; - if (amount < num + 1) { - ascensionCount2.put(name, amount); - return amount; - } else { - ascensionCount2.put(name, num); - return num; - } - } - } - - public int incrementOld(Player player, Map ascensionCount2, int num) { - UUID uuid = player.getUniqueId(); - if (ascensionCount2.get(uuid) == null) { - ascensionCount2.put(uuid, 1); - return 1; - } else { - int amount = ascensionCount2.get(uuid) + 1; - if (amount < num + 1) { - ascensionCount2.put(uuid, amount); - return amount; - } else { - ascensionCount2.put(uuid, num); - return num; - } - } - } + public void logToggleSneak(final Player player) { + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME()); + } - public boolean silentMode() { - return manager.getConfiguration().getConfig().silentMode.getValue(); - } + public void logTeleport(final Player player) { + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME()); + + /* Data for fly/speed should be reset */ + nofallViolation.remove(player.getUniqueId()); + FlightCheck.BLOCKS_OVER_FLIGHT.remove(player.getUniqueId()); + YAxisCheck.Y_AXIS_VIOLATIONS.remove(player.getUniqueId()); + YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(player.getUniqueId()); + YAxisCheck.LAST_Y_COORD_CACHE.remove(player.getUniqueId()); + YAxisCheck.LAST_Y_TIME.remove(player.getUniqueId()); + GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId()); + GlideCheck.LAST_DIFFERENCE.remove(player.getUniqueId()); + GlideCheck.VIOLATIONS.remove(player.getUniqueId()); + ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString()); + } + + public void logExitFly(final Player player) { + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME()); + } + + public void logJoin(final Player player) { + FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME()); + } + + public boolean isMovingExempt(Player player) { + return isDoing(player, FlightCheck.MOVING_EXEMPT, -1); + } + + public boolean isAscending(Player player) { + return isAscending.contains(player.getUniqueId()); + } + + private boolean isDoing(Player player, Map map, double max) { + if (map.containsKey(player.getUniqueId())) { + if (max != -1) { + if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) { + map.remove(player.getUniqueId()); + return false; + } else { + return true; + } + } else { + // Termination time has already been calculated + if (map.get(player.getUniqueId()) < System.currentTimeMillis()) { + map.remove(player.getUniqueId()); + return false; + } else { + return true; + } + } + } else { + return false; + } + } + + public boolean hasJumpPotion(Player player) { + return player.hasPotionEffect(PotionEffectType.JUMP); + } + + public boolean hasSpeedPotion(Player player) { + return player.hasPotionEffect(PotionEffectType.SPEED); + } + + 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() + : manager.getConfiguration().getConfig().chatSpamActionOne.getValue(); + manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), + Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(), + Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); + } + chatLevel.put(user.getUUID(), level + 1); + } + + 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() + ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() + : manager.getConfiguration().getConfig().commandSpamActionOne.getValue(); + manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), + Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(), + Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); + } + commandLevel.put(user.getUUID(), level + 1); + } + + public int increment(Player player, Map ascensionCount2, int num) { + UUID name = player.getUniqueId(); + if (ascensionCount2.get(name) == null) { + ascensionCount2.put(name, 1); + return 1; + } else { + int amount = ascensionCount2.get(name) + 1; + if (amount < num + 1) { + ascensionCount2.put(name, amount); + return amount; + } else { + ascensionCount2.put(name, num); + return num; + } + } + } + + public int incrementOld(Player player, Map ascensionCount2, int num) { + UUID uuid = player.getUniqueId(); + if (ascensionCount2.get(uuid) == null) { + ascensionCount2.put(uuid, 1); + return 1; + } else { + int amount = ascensionCount2.get(uuid) + 1; + if (amount < num + 1) { + ascensionCount2.put(uuid, amount); + return amount; + } else { + ascensionCount2.put(uuid, num); + return num; + } + } + } + + public boolean silentMode() { + return manager.getConfiguration().getConfig().silentMode.getValue(); + } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java index 163a01e..5d00eaa 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/PlayerListener.java @@ -345,9 +345,6 @@ public class PlayerListener extends EventListener { final User user = getUserManager().getUser(player.getUniqueId()); user.setTo(to.getX(), to.getY(), to.getZ()); - //KillAuraCheck.doMove(event); - //TODO - if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) { CheckResult result = FlightCheck.runCheck(player, distance); if (result.failed()) { @@ -360,7 +357,6 @@ public class PlayerListener extends EventListener { if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) { CheckResult result = GlideCheck.runCheck(player, distance); if (result.failed()) { - // NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF log(result.getMessage(), player, CheckType.FLIGHT); } } @@ -457,6 +453,7 @@ public class PlayerListener extends EventListener { } } } + AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java index 2e2d616..6b62507 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/Utilities.java @@ -503,7 +503,7 @@ public final class Utilities { } return seconds; } - + static { // Start instant break materials INSTANT_BREAK.add(Material.COMPARATOR); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java index 8e1858c..1804ad6 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java @@ -19,10 +19,13 @@ package com.rammelkast.anticheatreloaded.util; +import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -82,5 +85,5 @@ public class VersionUtil { return -1; } } - + } diff --git a/src/main/resources/magic.yml b/src/main/resources/magic.yml index 3514296..60d4d05 100644 --- a/src/main/resources/magic.yml +++ b/src/main/resources/magic.yml @@ -246,10 +246,10 @@ Y_TIME: 800 GLIDE_LIMIT: 10 # Maximum amount of movement packets allowed per second # Increase this in case of false positives -BLINK_PACKET: 25 +BLINK_PACKET: 30 # If the blink check gives false positives replace this with the average user ping on your server -# Not a good idea to use a value lower than 100 or higher than 200 -BLINK_AVERAGE_PING: 120 +# Not a good idea to use a value lower than 150 or higher than 300 +BLINK_AVERAGE_PING: 200 # Maximum amount zero-velocity moments before a player is suspected # Increase this in case of false positives VELOCITY_MAX_FLAGS: 5