mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Fixed false positives in glide check, removed broken figtspeed check.
This commit is contained in:
1 parent
9771387909
commit
da4a61e228
7 files changed
+49
-166
No files matched your search
@@ -143,6 +143,8 @@ public class Backend {
|
||||
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU);
|
||||
YAxisCheck.LAST_Y_COORD_CACHE.remove(pU);
|
||||
YAxisCheck.LAST_Y_TIME.remove(pU);
|
||||
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU);
|
||||
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU);
|
||||
fastBreaks.remove(pU);
|
||||
blockBreakHolder.remove(pU);
|
||||
lastBlockBroken.remove(pU);
|
||||
@@ -150,8 +152,6 @@ public class Backend {
|
||||
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);
|
||||
@@ -176,10 +176,9 @@ public class Backend {
|
||||
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());
|
||||
KillAuraCheck.ANGLE_FLAGS.remove(pU);
|
||||
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(pU);
|
||||
KillAuraCheck.GCD_CACHE.remove(pU);
|
||||
}
|
||||
|
||||
public CheckResult checkFastBow(Player player, float force) {
|
||||
@@ -544,6 +543,10 @@ public class Backend {
|
||||
public void logEatingStart(Player player) {
|
||||
startEat.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean isEating(Player player) {
|
||||
return startEat.containsKey(player.getUniqueId()) && startEat.get(player.getUniqueId()) < magic.EAT_TIME_MIN();
|
||||
}
|
||||
|
||||
public void logHeal(Player player) {
|
||||
lastHeal.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -29,36 +30,30 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.checkassist.KillauraAssist;
|
||||
|
||||
public class KillAuraCheck {
|
||||
|
||||
// Angle check
|
||||
public static final Map<String, Integer> ANGLE_FLAGS = new HashMap<String, Integer>();
|
||||
// Heuristic fight speed check
|
||||
public static final Map<String, Integer> DEVIATION_SCORES = new HashMap<String, Integer>();
|
||||
public static final Map<String, Integer> DIFF_MAP = new HashMap<String, Integer>();
|
||||
public static final Map<String, ClickSpeed> CLICKSPEED_MAP = new HashMap<String, ClickSpeed>();
|
||||
// Heuristic aimbot check
|
||||
public static final Map<String, List<Float>> PITCH_MOVEMENTS_CACHE = new HashMap<String, List<Float>>();
|
||||
public static final Map<String, Float> GCD_CACHE = new HashMap<String, Float>();
|
||||
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
|
||||
// Aimbot check
|
||||
public static final Map<UUID, List<Float>> PITCH_MOVEMENTS_CACHE = new HashMap<UUID, List<Float>>();
|
||||
public static final Map<UUID, Float> GCD_CACHE = new HashMap<UUID, Float>();
|
||||
// Not used as of now, code not committed yet
|
||||
private static final KillauraAssist KILLAURA_ASSIST;
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
||||
String uuid = player.getUniqueId().toString();
|
||||
UUID uuid = player.getUniqueId();
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, living.getLocation());
|
||||
double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
|
||||
double playerYaw = player.getEyeLocation().getYaw();
|
||||
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
@@ -79,48 +74,12 @@ public class KillAuraCheck {
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkFightSpeed(Player player, EntityDamageEvent event) {
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (!CLICKSPEED_MAP.containsKey(uuid)) {
|
||||
CLICKSPEED_MAP.put(uuid, new ClickSpeed());
|
||||
return PASS;
|
||||
}
|
||||
ClickSpeed clickSpeed = CLICKSPEED_MAP.get(uuid);
|
||||
clickSpeed.registerClick();
|
||||
int deviationScore = clickSpeed.getDeviationScore();
|
||||
// Prevents false positives since scores under 2000 aren't reliable
|
||||
if (deviationScore < 2000) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (!DEVIATION_SCORES.containsKey(uuid)) {
|
||||
DEVIATION_SCORES.put(uuid, deviationScore);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
int lastScore = DEVIATION_SCORES.get(uuid);
|
||||
DEVIATION_SCORES.put(uuid, deviationScore);
|
||||
int diff = Math.abs(deviationScore - lastScore);
|
||||
if (!DIFF_MAP.containsKey(uuid)) {
|
||||
DIFF_MAP.put(uuid, diff);
|
||||
return PASS;
|
||||
}
|
||||
int lastDiff = DIFF_MAP.get(uuid);
|
||||
DIFF_MAP.put(uuid, diff);
|
||||
if (Math.abs(diff - lastDiff) < magic.KILLAURA_FIGHTSPEED_MINDIFF()) {
|
||||
event.setCancelled(true);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had a suspiciously consistant fighting speed (absdiff=" + Math.abs(diff - lastDiff) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check idea by Hawk AntiCheat (https://github.com/HawkAnticheat/Hawk)
|
||||
*/
|
||||
public static CheckResult checkAimbot(Player player, PlayerMoveEvent event) {
|
||||
String uuid = player.getUniqueId().toString();
|
||||
UUID uuid = player.getUniqueId();
|
||||
float pitchMovement = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||
if (!PITCH_MOVEMENTS_CACHE.containsKey(uuid)) {
|
||||
PITCH_MOVEMENTS_CACHE.put(uuid, new ArrayList<Float>());
|
||||
@@ -152,49 +111,12 @@ public class KillAuraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static class ClickSpeed {
|
||||
private final List<Long> clicks;
|
||||
private long lastClick;
|
||||
|
||||
public ClickSpeed() {
|
||||
this.clicks = new ArrayList<Long>();
|
||||
this.lastClick = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void registerClick() {
|
||||
this.lastClick = System.currentTimeMillis();
|
||||
this.clicks.add(this.lastClick);
|
||||
}
|
||||
|
||||
public int getDeviationScore() {
|
||||
long last = 0;
|
||||
List<Integer> deviation = new ArrayList<Integer>();
|
||||
List<Long> toRemove = new ArrayList<Long>();
|
||||
for (long clickTime : this.clicks) {
|
||||
if (clickTime > (this.lastClick - 5000)) {
|
||||
if (last == 0) {
|
||||
last = clickTime;
|
||||
continue;
|
||||
}
|
||||
deviation.add((int) (clickTime - last));
|
||||
} else {
|
||||
toRemove.add(clickTime);
|
||||
}
|
||||
}
|
||||
this.clicks.removeAll(toRemove);
|
||||
if (deviation.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
float averageDeviationScore = deviation.get(0);
|
||||
for (int i = 1; i < deviation.size(); i++) {
|
||||
averageDeviationScore += deviation.get(i);
|
||||
}
|
||||
return Math.round(averageDeviationScore / deviation.size());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
KILLAURA_ASSIST = new KillauraAssist();
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
Vector targetVector = to.toVector();
|
||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||
return clonedFrom.getYaw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
@@ -81,8 +82,11 @@ public class GlideCheck {
|
||||
}
|
||||
} else {
|
||||
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()
|
||||
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5) {
|
||||
// TODO that fallDistance check is a horrible way to prevent a certain false positive
|
||||
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5
|
||||
&& !Utilities.isClimbableBlock(distance.getTo().getBlock()) && !player.isSneaking()
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)) {
|
||||
// TODO that fallDistance check is a horrible way to prevent a certain false
|
||||
// positive
|
||||
// Needs to be fixed since this only works for slight above ground movements
|
||||
float predicted = calculateNextMotionY(LAST_MOTION_Y.get(player.getUniqueId()).floatValue());
|
||||
float actual = Double.valueOf(motionY).floatValue();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BadPacketsCheck {
|
||||
public static void runCheck(Player player, PacketEvent event) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||
|| backend.isMovingExempt(player)) {
|
||||
|| backend.isMovingExempt(player) || AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).isWaitingOnLevelSync()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,9 +58,13 @@ public class BadPacketsCheck {
|
||||
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
|
||||
double distance = previous.distanceSquared(current);
|
||||
double maxDistance = backend.getMagic().BADPACKETS_MAX_DISTANCE();
|
||||
boolean hasNewLocation = packet.getBooleans().read(0);
|
||||
if (distance > maxDistance) {
|
||||
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
|
||||
return;
|
||||
} else if (distance < 1E-9 && !hasNewLocation) {
|
||||
flag(player, event, "sent the same packet twice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +75,7 @@ public class BadPacketsCheck {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.MOREPACKETS);
|
||||
CheckType.BADPACKETS);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,15 +29,15 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
import com.rammelkast.anticheatreloaded.util.checkassist.KillauraAssist;
|
||||
|
||||
public class IllegalInteract {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
|
||||
public static CheckResult performCheck(Player player, Event event) {
|
||||
if (event instanceof BlockPlaceEvent) {
|
||||
return checkBlockPlace(player, (BlockPlaceEvent) event);
|
||||
@@ -49,44 +49,41 @@ public class IllegalInteract {
|
||||
|
||||
private static CheckResult checkBlockBreak(Player player, BlockBreakEvent event) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to break a block which was out of view");
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block which was out of view");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to place a block out of their view");
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block out of their view");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isValidTarget(Player player, Block block) {
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
double distance =
|
||||
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: magic.BLOCK_MAX_DISTANCE();
|
||||
double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
|
||||
: magic.BLOCK_MAX_DISTANCE();
|
||||
Block targetBlock = VersionUtil.getTargetBlock(player, ((int) Math.ceil(distance)));
|
||||
if (targetBlock == null) {
|
||||
// TODO better check here
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (Utilities.isClimbableBlock(targetBlock)) {
|
||||
if (targetBlock.getLocation().distance(player.getLocation()) <= distance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (targetBlock.equals(block)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Location eyeLocation = player.getEyeLocation();
|
||||
double yawDifference = KillauraAssist.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
double playerYaw = player.getEyeLocation().getYaw();
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
if (Math.round(angleDifference) > magic.ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE()) {
|
||||
@@ -94,5 +91,5 @@ public class IllegalInteract {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -161,14 +161,6 @@ public class EntityListener extends EventListener {
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
CheckResult result = KillAuraCheck.checkFightSpeed(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (noHack) {
|
||||
decrease(player);
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2020 Rammelkast
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util.checkassist;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class KillauraAssist {
|
||||
|
||||
public KillauraAssist() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
Vector targetVector = to.toVector();
|
||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||
return clonedFrom.getYaw();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user