Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Tecnio committed Feb 24, 2021
1 parent d3809a8 commit 52fd82b
Show file tree
Hide file tree
Showing 31 changed files with 153 additions and 75 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@
<dependency>
<groupId>com.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>v1.8-pre-3</version>
<version>v1.8-pre-4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<version>1.18.18</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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() + ".");
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> blocks = data.getPositionProcessor().getBlocks();
if (blocks == null) return;

Expand All @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>
*/

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()) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -80,20 +85,21 @@ 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 {
decreaseBufferBy(0.15);
}
} else {
if (deltaXZ > groundLimit) {
if (increaseBuffer() > 3) {
if (increaseBuffer() > 2) {
fail();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 52fd82b

Please sign in to comment.