From 52fd82b7759c9992e52b95217d7c8e13b84655c9 Mon Sep 17 00:00:00 2001 From: Tecnio Date: Wed, 24 Feb 2021 20:33:20 +0300 Subject: [PATCH] Stuff --- pom.xml | 4 +-- .../me/tecnio/antihaxerman/AntiHaxerman.java | 15 ++++---- .../check/impl/combat/aim/AimA.java | 2 +- .../check/impl/combat/aim/AimB.java | 4 +-- .../check/impl/combat/aim/AimC.java | 16 ++------- .../check/impl/combat/aim/AimD.java | 3 +- .../check/impl/combat/aim/AimF.java | 6 ++-- .../check/impl/combat/aim/AimG.java | 6 ++-- .../check/impl/combat/aim/AimH.java | 3 +- .../impl/combat/autoclicker/AutoClickerE.java | 2 +- .../impl/movement/fastclimb/FastClimbB.java | 8 +++-- .../check/impl/movement/jesus/JesusA.java | 14 +++++--- .../check/impl/movement/jesus/JesusB.java | 9 +++-- .../check/impl/movement/jesus/JesusC.java | 36 +++++++++++++++++++ .../check/impl/movement/motion/MotionD.java | 2 +- .../impl/movement/omnisprint/OmniSprintA.java | 2 +- .../check/impl/movement/speed/SpeedC.java | 14 +++++--- .../check/impl/movement/speed/SpeedD.java | 2 +- .../check/impl/movement/strafe/StrafeA.java | 6 ++-- .../impl/player/badpackets/BadPacketsB.java | 5 ++- .../impl/player/groundspoof/GroundSpoofA.java | 4 ++- .../check/impl/player/interact/InteractE.java | 3 ++ .../me/tecnio/antihaxerman/config/Config.java | 11 ++---- .../antihaxerman/exempt/type/ExemptType.java | 2 ++ .../listener/packet/NetworkManager.java | 14 ++++++++ .../antihaxerman/manager/CheckManager.java | 2 ++ .../antihaxerman/update/UpdateChecker.java | 17 +++++++-- .../tecnio/antihaxerman/util/ColorUtil.java | 1 - .../me/tecnio/antihaxerman/util/MathUtil.java | 2 +- .../tecnio/antihaxerman/util/PlayerUtil.java | 2 +- src/main/resources/config.yml | 11 +++--- 31 files changed, 153 insertions(+), 75 deletions(-) create mode 100644 src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusC.java diff --git a/pom.xml b/pom.xml index e71df70a..1ac4e1e7 100644 --- a/pom.xml +++ b/pom.xml @@ -79,12 +79,12 @@ com.github.retrooper packetevents - v1.8-pre-3 + v1.8-pre-4 org.projectlombok lombok - 1.18.16 + 1.18.18 provided diff --git a/src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java b/src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java index a05c5a60..cf73314a 100644 --- a/src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java +++ b/src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java @@ -20,6 +20,7 @@ import io.github.retrooper.packetevents.PacketEvents; import io.github.retrooper.packetevents.utils.server.ServerVersion; import lombok.Getter; +import lombok.Setter; import me.tecnio.antihaxerman.command.CommandManager; import me.tecnio.antihaxerman.config.Config; import me.tecnio.antihaxerman.listener.bukkit.BukkitEventManager; @@ -35,7 +36,6 @@ import org.bukkit.Bukkit; import org.bukkit.plugin.messaging.Messenger; -import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -58,7 +58,7 @@ public enum AntiHaxerman { private final String version = "3.0.0"; private final UpdateChecker updateChecker = new UpdateChecker(); - private boolean updateAvailable; + @Setter private boolean updateAvailable; public void load(final AntiHaxermanPlugin plugin) { this.plugin = plugin; @@ -89,10 +89,7 @@ public void start(final AntiHaxermanPlugin plugin) { registerEvents(); - try { - updateAvailable = updateChecker.isUpdateAvailable(); - } catch (final IOException ignored) { - } + if (Config.UPDATE_CHECKER_ENABLED) updateChecker.checkUpdates(); if (updateAvailable) { Bukkit.getLogger().info("New update available for AntiHaxerman! You have " + version + " latest is " + updateChecker.getLatestVersion() + "."); @@ -111,9 +108,9 @@ public void stop(final AntiHaxermanPlugin plugin) { private void setupPacketEvents() { PacketEvents.create(plugin).getSettings() - .injectAsync(Config.ASYNC_INJECT_UNINJECT) - .ejectAsync(Config.ASYNC_INJECT_UNINJECT) - .injectEarly(Config.EARLY_INJECT) + .injectAsync(true) + .ejectAsync(true) + .injectEarly(true) .backupServerVersion(ServerVersion.v_1_7_10); PacketEvents.get().load(); diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimA.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimA.java index 88d4f28c..583a5e99 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimA.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimA.java @@ -62,7 +62,7 @@ public void handle(final Packet packet) { final boolean invalidX = moduloX > 90.d && floorModuloX > 0.1; final boolean invalidY = moduloY > 90.d && floorModuloY > 0.1; - if (data.getRotationProcessor().isCinematic()) decreaseBufferBy(0.1); + if (data.getRotationProcessor().isCinematic()) decreaseBufferBy(0.15); if (invalidX && invalidY) { if (increaseBuffer() > 6) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimB.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimB.java index 48d9ca2d..85d470fc 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimB.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimB.java @@ -41,11 +41,11 @@ public void handle(final Packet packet) { final boolean invalid = gcd < 131072L && deltaPitch > 0.5F && deltaPitch < 20.0F && !cinematic; if (invalid) { - if (increaseBuffer() > 7) { + if (increaseBuffer() > 8) { fail(); } } else { - decreaseBuffer(); + decreaseBufferBy(2.5); } } } diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimC.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimC.java index 5dc705b9..5cc9de5f 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimC.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimC.java @@ -22,7 +22,7 @@ import me.tecnio.antihaxerman.data.PlayerData; import me.tecnio.antihaxerman.packet.Packet; -@CheckInfo(name = "Aim", type = "C", description = "Checks for invalid sensitivity.") +@CheckInfo(name = "Aim", type = "C", description = "Checks for rounded rotations.") public final class AimC extends Check { public AimC(final PlayerData data) { super(data); @@ -31,18 +31,8 @@ public AimC(final PlayerData data) { @Override public void handle(final Packet packet) { if (packet.isRotation()) { - final double sensitivity = data.getRotationProcessor().getSensitivity(); - - final boolean exempt = data.getRotationProcessor().isCinematic(); - final boolean invalid = sensitivity < 0.0F; - - if (invalid && !exempt) { - if (increaseBuffer() > 5) { - fail(); - } - } else { - decreaseBufferBy(2); - } + final float deltaYaw = data.getRotationProcessor().getDeltaYaw(); + final float deltaPitch = data.getRotationProcessor().getDeltaPitch(); } } } diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimD.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimD.java index ee0dd040..0a7b81c4 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimD.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimD.java @@ -21,6 +21,7 @@ import me.tecnio.antihaxerman.check.api.CheckInfo; import me.tecnio.antihaxerman.data.PlayerData; import me.tecnio.antihaxerman.packet.Packet; +import me.tecnio.antihaxerman.util.MathUtil; @CheckInfo(name = "Aim", type = "D", description = "Checks for unlikely pitch deltas.") public final class AimD extends Check { @@ -37,7 +38,7 @@ public void handle(final Packet packet) { final float deltaPitch = data.getRotationProcessor().getDeltaPitch(); final float deltaYaw = data.getRotationProcessor().getDeltaYaw(); - final boolean invalid = deltaPitch == 0.0F && deltaYaw >= 15.6F; + final boolean invalid = MathUtil.isExponentiallySmall(deltaPitch) && deltaYaw >= 10.0F; if (invalid) { if (increaseBuffer() > 7) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimF.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimF.java index 69b3f516..a02856e6 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimF.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimF.java @@ -44,11 +44,11 @@ public void handle(final Packet packet) { final double moduloPitch = Math.abs(pitch % constantPitch); if (moduloPitch < 1.0E-5) { - if (increaseBuffer() > 2) { - fail(moduloPitch); + if (increaseBuffer() > 1) { + fail(); } } else { - decreaseBufferBy(0.05); + decreaseBufferBy(0.01); } } } diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimG.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimG.java index 78695bd1..15ce3fe4 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimG.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimG.java @@ -31,7 +31,7 @@ public void handle(final Packet packet) { final float deltaYaw = data.getRotationProcessor().getDeltaYaw(); final float lastDeltaYaw = data.getRotationProcessor().getLastDeltaYaw(); - if (deltaYaw < 0.5) { + if (deltaYaw > 0.5) { final long expandedYaw = (long) (deltaYaw * MathUtil.EXPANDER); final long lastExpandedYaw = (long) (lastDeltaYaw * MathUtil.EXPANDER); @@ -42,8 +42,8 @@ public void handle(final Packet packet) { final double moduloYaw = Math.abs(yaw % constantYaw); if (moduloYaw < 1.0E-5) { - if (increaseBuffer() > 3) { - fail(moduloYaw); + if (increaseBuffer() > 2) { + fail(); } } else { decreaseBufferBy(0.05); diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimH.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimH.java index bbf67a62..883f1259 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimH.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/aim/AimH.java @@ -21,6 +21,7 @@ import me.tecnio.antihaxerman.check.api.CheckInfo; import me.tecnio.antihaxerman.data.PlayerData; import me.tecnio.antihaxerman.packet.Packet; +import me.tecnio.antihaxerman.util.MathUtil; @CheckInfo(name = "Aim", type = "H", description = "Checks for unlikely yaw deltas.") public final class AimH extends Check { @@ -35,7 +36,7 @@ public void handle(final Packet packet) { final float deltaPitch = data.getRotationProcessor().getDeltaPitch(); final float deltaYaw = data.getRotationProcessor().getDeltaYaw(); - final boolean invalid = deltaYaw == 0.0F && deltaPitch >= 20.0F; + final boolean invalid = MathUtil.isExponentiallySmall(deltaYaw) && deltaPitch >= 20.0F; if (invalid) { if (increaseBuffer() > 1) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/autoclicker/AutoClickerE.java b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/autoclicker/AutoClickerE.java index d90325aa..1af2b123 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/combat/autoclicker/AutoClickerE.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/combat/autoclicker/AutoClickerE.java @@ -46,7 +46,7 @@ public void handle(final Packet packet) { if (samples.size() == 30) { final double kurtosis = MathUtil.getKurtosis(samples); - final boolean invalid = kurtosis < 40000 || Double.isNaN(kurtosis); + final boolean invalid = kurtosis < 30000 || Double.isNaN(kurtosis); if (invalid) { if (increaseBuffer() > 1) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/fastclimb/FastClimbB.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/fastclimb/FastClimbB.java index 41985c91..4b756147 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/fastclimb/FastClimbB.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/fastclimb/FastClimbB.java @@ -36,6 +36,8 @@ public FastClimbB(final PlayerData data) { @Override public void handle(final Packet packet) { if (packet.isFlying()) { + final int sinceGround = data.getPositionProcessor().getClientAirTicks(); + final List blocks = data.getPositionProcessor().getBlocks(); if (blocks == null) return; @@ -44,15 +46,17 @@ public void handle(final Packet packet) { final float deltaY = (float) data.getPositionProcessor().getDeltaY(); final float limit = 0.1176F; + final float groundLimit = sinceGround < 4 ? 0.42F / (sinceGround / 2.0F) : 0.0F; + final boolean exempt = isExempt(ExemptType.TELEPORT, ExemptType.PISTON, ExemptType.FLYING, ExemptType.BOAT, ExemptType.VEHICLE); - final boolean invalid = deltaY > limit && onClimbable; + final boolean invalid = deltaY > (limit + groundLimit) && onClimbable; if (invalid && !exempt) { if (increaseBuffer() > 3 || deltaY > (limit * 5.0F)) { fail(); } } else { - decreaseBufferBy(0.25); + decreaseBufferBy(0.1); } } } diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusA.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusA.java index 3a4a00b9..f3dd5e12 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusA.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusA.java @@ -22,6 +22,7 @@ import me.tecnio.antihaxerman.data.PlayerData; import me.tecnio.antihaxerman.exempt.type.ExemptType; import me.tecnio.antihaxerman.packet.Packet; +import org.bukkit.Material; import org.bukkit.block.Block; import java.util.List; @@ -40,21 +41,24 @@ public void handle(final Packet packet) { if (blocks == null || blocksBelow == null) return; - final boolean onLiquid = blocksBelow.stream().allMatch(Block::isLiquid); - final boolean noBlock = blocksBelow.stream().anyMatch(block -> block.getType().isSolid()); + final boolean containsLiquid = blocksBelow.stream().anyMatch(Block::isLiquid); + final boolean doesntContainSolid = blocksBelow.stream().noneMatch(block -> block.getType().isSolid()); + + final boolean liquidBelow = containsLiquid && doesntContainSolid; + final boolean noBlocks = blocks.stream().anyMatch(block -> block.getType().isSolid() || (block.getType() != Material.AIR && !block.isLiquid())); final boolean clientGround = data.getPositionProcessor().isOnGround(); final boolean serverGround = data.getPositionProcessor().isMathematicallyOnGround(); final boolean exempt = isExempt(ExemptType.BOAT, ExemptType.VEHICLE, ExemptType.FLYING, ExemptType.CHUNK); - final boolean invalid = (clientGround || serverGround) && onLiquid && !noBlock; + final boolean invalid = (clientGround || serverGround) && liquidBelow && !noBlocks; if (invalid && !exempt) { - if (increaseBuffer() > 5) { + if (increaseBuffer() > 2) { fail(); } } else { - decreaseBufferBy(0.50); + decreaseBuffer(); } } } diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusB.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusB.java index e0024720..e552cdfc 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusB.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusB.java @@ -22,6 +22,7 @@ import me.tecnio.antihaxerman.data.PlayerData; import me.tecnio.antihaxerman.exempt.type.ExemptType; import me.tecnio.antihaxerman.packet.Packet; +import org.bukkit.Material; import org.bukkit.block.Block; import java.util.List; @@ -43,9 +44,13 @@ public void handle(final Packet packet) { if (blocks == null || blocksBelow == null || blocksAbove == null) return; - final boolean liquidBelow = blocksBelow.stream().allMatch(Block::isLiquid); + final boolean containsLiquid = blocksBelow.stream().anyMatch(Block::isLiquid); + final boolean doesntContainSolid = blocksBelow.stream().noneMatch(block -> block.getType().isSolid()); + + final boolean liquidBelow = containsLiquid && doesntContainSolid; + final boolean noLiquidAbove = blocksAbove.stream().noneMatch(Block::isLiquid); - final boolean noBlocks = blocks.stream().anyMatch(block -> block.getType().isSolid()); + final boolean noBlocks = blocks.stream().anyMatch(block -> block.getType().isSolid() || (block.getType() != Material.AIR && !block.isLiquid())); final boolean fullySubmerged = data.getPositionProcessor().isFullySubmergedInLiquidStat(); diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusC.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusC.java new file mode 100644 index 00000000..11ced225 --- /dev/null +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/jesus/JesusC.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 - 2021 Tecnio + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package me.tecnio.antihaxerman.check.impl.movement.jesus; + +import me.tecnio.antihaxerman.check.Check; +import me.tecnio.antihaxerman.check.api.CheckInfo; +import me.tecnio.antihaxerman.data.PlayerData; +import me.tecnio.antihaxerman.packet.Packet; + +@CheckInfo(name = "Jesus", type = "C", description = "Checks for invalid movement on water.") +public final class JesusC extends Check { + public JesusC(final PlayerData data) { + super(data); + } + + @Override + public void handle(final Packet packet) { + if (packet.isFlying()) { + } + } +} diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/motion/MotionD.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/motion/MotionD.java index a7335951..23b3c1a5 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/motion/MotionD.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/motion/MotionD.java @@ -37,7 +37,7 @@ public void handle(final Packet packet) { final double deltaY = data.getPositionProcessor().getDeltaY(); final double modifierJump = PlayerUtil.getPotionLevel(data.getPlayer(), PotionEffectType.JUMP) * 0.1; - final double modifierVelocity = isExempt(ExemptType.VELOCITY) ? data.getVelocityProcessor().getVelocityY() + 0.15 : 0.0; + final double modifierVelocity = isExempt(ExemptType.VELOCITY) ? data.getVelocityProcessor().getVelocityY() + 0.5 : 0.0; final double maximum = 0.6 + modifierJump + modifierVelocity; diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/omnisprint/OmniSprintA.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/omnisprint/OmniSprintA.java index bacf9b8a..889888ae 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/omnisprint/OmniSprintA.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/omnisprint/OmniSprintA.java @@ -49,7 +49,7 @@ public void handle(final Packet packet) { final Vector move = new Vector(deltaX, 0.0, deltaZ); final double delta = move.distanceSquared(direction); - final boolean exempt = isExempt(ExemptType.LIQUID, ExemptType.WEB, ExemptType.VELOCITY, ExemptType.CHUNK, ExemptType.UNDERBLOCK, ExemptType.ICE); + final boolean exempt = isExempt(ExemptType.VELOCITY, ExemptType.CHUNK, ExemptType.UNDERBLOCK, ExemptType.ICE); final boolean invalid = delta > getLimit() && deltaXZ > 0.1 && sprinting && onGround; if (invalid && !exempt) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedC.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedC.java index e2cc8dc6..21211165 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedC.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedC.java @@ -61,12 +61,17 @@ public void handle(final Packet packet) { airLimit += Math.hypot(x, z); } + if (data.getPositionProcessor().isNearStair()) { + airLimit += 0.91F; + groundLimit += 0.91F; + } + if (isExempt(ExemptType.ICE, ExemptType.SLIME)) { airLimit += 0.34F; groundLimit += 0.34F; } - if (isExempt(ExemptType.UNDERBLOCK)) { + if (data.getPositionProcessor().getSinceBlockNearHeadTicks() < 3) { airLimit += 0.91F; groundLimit += 0.91F; } @@ -80,12 +85,13 @@ public void handle(final Packet packet) { airLimit += data.getVelocityProcessor().getVelocityXZ() + 0.05; } - final boolean exempt = isExempt(ExemptType.VEHICLE, ExemptType.PISTON, ExemptType.FLYING, ExemptType.TELEPORT, ExemptType.CHUNK); + final boolean exempt = isExempt(ExemptType.VEHICLE, ExemptType.PISTON, + ExemptType.FLYING, ExemptType.TELEPORT, ExemptType.CHUNK); if (!exempt) { if (airTicks > 0) { if (deltaXZ > airLimit) { - if (increaseBuffer() > 3) { + if (increaseBuffer() > 2) { fail(); } } else { @@ -93,7 +99,7 @@ public void handle(final Packet packet) { } } else { if (deltaXZ > groundLimit) { - if (increaseBuffer() > 3) { + if (increaseBuffer() > 2) { fail(); } } else { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedD.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedD.java index bec1cb88..d4ed6aa1 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedD.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/speed/SpeedD.java @@ -40,7 +40,7 @@ public void handle(final Packet packet) { final double acceleration = deltaXZ - lastDeltaXZ; - final boolean exempt = isExempt(ExemptType.FLYING, ExemptType.VEHICLE, ExemptType.BOAT, ExemptType.UNDERBLOCK, ExemptType.TELEPORT, ExemptType.LIQUID, ExemptType.PISTON, ExemptType.CLIMBABLE, ExemptType.VEHICLE, ExemptType.SLIME); + final boolean exempt = isExempt(ExemptType.FLYING, ExemptType.VEHICLE, ExemptType.BOAT, ExemptType.UNDERBLOCK, ExemptType.TELEPORT, ExemptType.PISTON, ExemptType.CLIMBABLE, ExemptType.VEHICLE, ExemptType.SLIME); final boolean invalid = acceleration > limit; if (invalid && !exempt) fail(); diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/strafe/StrafeA.java b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/strafe/StrafeA.java index 0179ddde..23e48191 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/movement/strafe/StrafeA.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/movement/strafe/StrafeA.java @@ -70,10 +70,10 @@ public void handle(final Packet packet) { // getAiSpeed but I can't run it the way I am using right now attributeSpeed *= data.getPlayer().getWalkSpeed() / 2.0; - //cancel not usable in this way + // cancel not usable in this way attributeSpeed = 1000; } else { - attributeSpeed = sprinting ? 0.0263 : 0.02; + attributeSpeed = sprinting ? 0.026 : 0.02; blockSlipperiness = 0.91f; } @@ -84,7 +84,7 @@ public void handle(final Packet packet) { final double diffX = deltaX - predictedDeltaX; final double diffZ = deltaZ - predictedDeltaZ; - final double limit = sprinting ? 0.026 : 0.02; + final double limit = 0.01; final boolean exempt = this.isExempt(ExemptType.TPS, ExemptType.TELEPORT, ExemptType.PISTON, ExemptType.FLYING, ExemptType.UNDERBLOCK, ExemptType.VEHICLE, ExemptType.CLIMBABLE, ExemptType.LIQUID, ExemptType.VELOCITY, ExemptType.UNDERBLOCK, ExemptType.CHUNK); final boolean invalid = (diffX > limit || diffZ > limit) && deltaXZ > .175 && (airTicks > 2 || groundTicks > 2); diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/player/badpackets/BadPacketsB.java b/src/main/java/me/tecnio/antihaxerman/check/impl/player/badpackets/BadPacketsB.java index 38f5e634..47d2f70b 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/player/badpackets/BadPacketsB.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/player/badpackets/BadPacketsB.java @@ -21,6 +21,7 @@ import me.tecnio.antihaxerman.check.Check; import me.tecnio.antihaxerman.check.api.CheckInfo; import me.tecnio.antihaxerman.data.PlayerData; +import me.tecnio.antihaxerman.exempt.type.ExemptType; import me.tecnio.antihaxerman.packet.Packet; @CheckInfo(name = "BadPackets", type = "B", description = "Checks for invalid sprint packets.") @@ -39,7 +40,9 @@ public void handle(final Packet packet) { if (sprinting) { if (increaseBuffer() > 1) { - fail(); + if (!isExempt(ExemptType.TELEPORT)) { + fail(); + } } } } else if (packet.isFlying()) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/player/groundspoof/GroundSpoofA.java b/src/main/java/me/tecnio/antihaxerman/check/impl/player/groundspoof/GroundSpoofA.java index f91cf1ba..1564f204 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/player/groundspoof/GroundSpoofA.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/player/groundspoof/GroundSpoofA.java @@ -39,7 +39,9 @@ public void handle(final Packet packet) { final boolean clientGround = wrapper.isOnGround(); final boolean serverGround = wrapper.getY() % 0.015625 == 0.0; - final boolean exempt = isExempt(ExemptType.BOAT, ExemptType.LIQUID, ExemptType.CLIMBABLE, ExemptType.VEHICLE, ExemptType.TELEPORT_DELAY, ExemptType.CHUNK, ExemptType.SLIME, ExemptType.FLYING, ExemptType.PISTON); + final boolean exempt = isExempt(ExemptType.BOAT, ExemptType.LIQUID, ExemptType.CLIMBABLE, + ExemptType.VEHICLE, ExemptType.TELEPORT_DELAY, ExemptType.CHUNK, ExemptType.SLIME, + ExemptType.FLYING, ExemptType.PISTON, ExemptType.STAIR); final boolean invalid = clientGround != serverGround; if (invalid && !exempt) { diff --git a/src/main/java/me/tecnio/antihaxerman/check/impl/player/interact/InteractE.java b/src/main/java/me/tecnio/antihaxerman/check/impl/player/interact/InteractE.java index 949fa4fc..c5030162 100644 --- a/src/main/java/me/tecnio/antihaxerman/check/impl/player/interact/InteractE.java +++ b/src/main/java/me/tecnio/antihaxerman/check/impl/player/interact/InteractE.java @@ -18,6 +18,7 @@ package me.tecnio.antihaxerman.check.impl.player.interact; import io.github.retrooper.packetevents.packetwrappers.play.in.blockplace.WrappedPacketInBlockPlace; +import io.github.retrooper.packetevents.utils.player.Direction; import me.tecnio.antihaxerman.check.Check; import me.tecnio.antihaxerman.check.api.CheckInfo; import me.tecnio.antihaxerman.data.PlayerData; @@ -38,6 +39,8 @@ public void handle(final Packet packet) { if (packet.isBlockPlace()) { final WrappedPacketInBlockPlace wrapper = new WrappedPacketInBlockPlace(packet.getRawPacket()); + if (wrapper.getDirection() == Direction.INVALID) fail(); + final float x = wrapper.getCursorX(); final float y = wrapper.getCursorY(); final float z = wrapper.getCursorZ(); diff --git a/src/main/java/me/tecnio/antihaxerman/config/Config.java b/src/main/java/me/tecnio/antihaxerman/config/Config.java index 2e603b4e..05082ef7 100644 --- a/src/main/java/me/tecnio/antihaxerman/config/Config.java +++ b/src/main/java/me/tecnio/antihaxerman/config/Config.java @@ -34,12 +34,9 @@ public final class Config { public boolean TESTMODE; - public String PREFIX, NO_PERMS, COMMAND_PREFIX, ALERT_FORMAT, COMMAND_NAME, LOG_FORMAT; - public int VL_TO_ALERT, CLEAR_VIOLATIONS_DELAY; - - public boolean BYPASS_OP, LOGGING_ENABLED, LOG_TO_CONSOLE, EARLY_INJECT, ASYNC_INJECT_UNINJECT, API_ENABLED; + public boolean BYPASS_OP, LOGGING_ENABLED, LOG_TO_CONSOLE, API_ENABLED, UPDATE_CHECKER_ENABLED; public List ENABLED_CHECKS = new ArrayList<>(); public List SETBACK_CHECKS = new ArrayList<>(); @@ -60,14 +57,12 @@ public void updateConfig() { LOGGING_ENABLED = getBoolean("logging.enabled"); LOG_FORMAT = getString("logging.log-format"); - LOG_TO_CONSOLE = getBoolean("violations.alert-console"); - EARLY_INJECT = getBoolean("general.early-inject"); - ASYNC_INJECT_UNINJECT = getBoolean("general.async-inject-uninject"); - API_ENABLED = getBoolean("api.enabled"); + UPDATE_CHECKER_ENABLED = getBoolean("update-checker.enabled"); + VL_TO_ALERT = getInteger("violations.minimum-vl"); ALERT_FORMAT = getString("violations.alert-format"); diff --git a/src/main/java/me/tecnio/antihaxerman/exempt/type/ExemptType.java b/src/main/java/me/tecnio/antihaxerman/exempt/type/ExemptType.java index 745200c5..dda6b557 100644 --- a/src/main/java/me/tecnio/antihaxerman/exempt/type/ExemptType.java +++ b/src/main/java/me/tecnio/antihaxerman/exempt/type/ExemptType.java @@ -64,6 +64,8 @@ public enum ExemptType { PISTON(data -> data.getPositionProcessor().isNearPiston()), + STAIR(data -> data.getPositionProcessor().isNearStair()), + VOID(data -> data.getPositionProcessor().getY() < 4), COMBAT(data -> data.getCombatProcessor().getHitTicks() < 5), diff --git a/src/main/java/me/tecnio/antihaxerman/listener/packet/NetworkManager.java b/src/main/java/me/tecnio/antihaxerman/listener/packet/NetworkManager.java index dee850df..99a2d98c 100644 --- a/src/main/java/me/tecnio/antihaxerman/listener/packet/NetworkManager.java +++ b/src/main/java/me/tecnio/antihaxerman/listener/packet/NetworkManager.java @@ -22,6 +22,8 @@ import io.github.retrooper.packetevents.event.impl.PacketPlaySendEvent; import io.github.retrooper.packetevents.event.impl.PostPlayerInjectEvent; import io.github.retrooper.packetevents.event.priority.PacketEventPriority; +import io.github.retrooper.packetevents.packettype.PacketType.Play.*; +import io.github.retrooper.packetevents.utils.immutableset.ImmutableSetCustom; import io.github.retrooper.packetevents.utils.player.ClientVersion; import me.tecnio.antihaxerman.AntiHaxerman; import me.tecnio.antihaxerman.data.PlayerData; @@ -39,6 +41,18 @@ public final class NetworkManager extends PacketListenerDynamic { public NetworkManager() { super(PacketEventPriority.MONITOR); + + // Filter all of the packets because retrooper best. + serverSidedPlayAllowance = new ImmutableSetCustom<>(); + + // Whitelist packets that we want to listen. + addServerSidedPlayFilter( + Server.ENTITY_VELOCITY, + Server.TRANSACTION, + Server.KEEP_ALIVE, + Server.POSITION, + Server.HELD_ITEM_SLOT + ); } @Override diff --git a/src/main/java/me/tecnio/antihaxerman/manager/CheckManager.java b/src/main/java/me/tecnio/antihaxerman/manager/CheckManager.java index 06fe0919..42c567b7 100644 --- a/src/main/java/me/tecnio/antihaxerman/manager/CheckManager.java +++ b/src/main/java/me/tecnio/antihaxerman/manager/CheckManager.java @@ -38,6 +38,7 @@ import me.tecnio.antihaxerman.check.impl.movement.flight.FlightD; import me.tecnio.antihaxerman.check.impl.movement.jesus.JesusA; import me.tecnio.antihaxerman.check.impl.movement.jesus.JesusB; +import me.tecnio.antihaxerman.check.impl.movement.jesus.JesusC; import me.tecnio.antihaxerman.check.impl.movement.largemove.LargeMoveA; import me.tecnio.antihaxerman.check.impl.movement.largemove.LargeMoveB; import me.tecnio.antihaxerman.check.impl.movement.liquidspeed.LiquidSpeedA; @@ -131,6 +132,7 @@ public final class CheckManager { FastClimbB.class, JesusA.class, JesusB.class, + JesusC.class, LiquidSpeedA.class, LiquidSpeedB.class, LiquidSpeedC.class, diff --git a/src/main/java/me/tecnio/antihaxerman/update/UpdateChecker.java b/src/main/java/me/tecnio/antihaxerman/update/UpdateChecker.java index abd209ec..25d33147 100644 --- a/src/main/java/me/tecnio/antihaxerman/update/UpdateChecker.java +++ b/src/main/java/me/tecnio/antihaxerman/update/UpdateChecker.java @@ -23,8 +23,8 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; @Getter public final class UpdateChecker { @@ -39,8 +39,21 @@ public UpdateChecker() { } } + public void checkUpdates() { + AntiHaxerman.INSTANCE.getExecutorService().execute(() -> { + try { + AntiHaxerman.INSTANCE.setUpdateAvailable(isUpdateAvailable()); + } catch (final Exception e) { + e.printStackTrace(); + } + }); + } + public boolean isUpdateAvailable() throws IOException { - final URLConnection connection = apiUrl.openConnection(); + final HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); + + connection.setConnectTimeout(5000); + connection.connect(); latestVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine(); diff --git a/src/main/java/me/tecnio/antihaxerman/util/ColorUtil.java b/src/main/java/me/tecnio/antihaxerman/util/ColorUtil.java index 94a7d608..1d6ddc6b 100644 --- a/src/main/java/me/tecnio/antihaxerman/util/ColorUtil.java +++ b/src/main/java/me/tecnio/antihaxerman/util/ColorUtil.java @@ -22,7 +22,6 @@ @UtilityClass public class ColorUtil { - public String translate(final String string) { return ChatColor.translateAlternateColorCodes('&', string); } diff --git a/src/main/java/me/tecnio/antihaxerman/util/MathUtil.java b/src/main/java/me/tecnio/antihaxerman/util/MathUtil.java index b816b588..d37d098b 100644 --- a/src/main/java/me/tecnio/antihaxerman/util/MathUtil.java +++ b/src/main/java/me/tecnio/antihaxerman/util/MathUtil.java @@ -178,7 +178,7 @@ public T getModeNiggar(final Collection collect) { } public boolean isExponentiallySmall(final Number number) { - return number.doubleValue() < 1 && Double.toString(number.doubleValue()).contains("E"); + return number.doubleValue() < 1 && (Double.toString(number.doubleValue()).contains("E") || number.doubleValue() == 0.0); } public boolean isExponentiallyLarge(final Number number) { diff --git a/src/main/java/me/tecnio/antihaxerman/util/PlayerUtil.java b/src/main/java/me/tecnio/antihaxerman/util/PlayerUtil.java index 9b2b1e85..ac001e6e 100644 --- a/src/main/java/me/tecnio/antihaxerman/util/PlayerUtil.java +++ b/src/main/java/me/tecnio/antihaxerman/util/PlayerUtil.java @@ -54,7 +54,7 @@ public float getBaseSpeed(final Player player, final float base) { } public double getBaseSpeed(final Player player) { - return 0.3615 + (getPotionLevel(player, PotionEffectType.SPEED) * 0.062f) + ((player.getWalkSpeed() - 0.2f) * 1.6f); + return 0.36 + (getPotionLevel(player, PotionEffectType.SPEED) * 0.062f) + ((player.getWalkSpeed() - 0.2f) * 1.6f); } public double getBaseGroundSpeed(final Player player) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index fc59b31c..a0f1bf56 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -35,11 +35,8 @@ bypass: # When enabled this will bypass players that have OP and the players with the permission "antihaxerman.bypass". bypass-operators: false -general: - # Early inject allows us to see client version etc. - early-inject: true - # Enable async injection and uninjection. Enabled by default for performance reasons but will cost us reload support. (RECOMMENDED TO KEEP IT ENABLED) - async-inject-uninject: true +update-checker: + enabled: true api: # API is disabled by default for performance reasons. Recommended to keep disabled unless the API is used. @@ -265,6 +262,10 @@ checks: enabled: true max-violations: 50 punish-command: '' + c: + enabled: true + max-violations: 50 + punish-command: '' liquidspeed: a: enabled: true