mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Also added extra KillAura check and fixed compatibility issues
This commit is contained in:
1 parent
7c9a05ff92
commit
661718d001
11 files changed
+159
-54
No files matched your search
@@ -19,9 +19,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;
|
||||
@@ -72,7 +70,7 @@ public class Backend {
|
||||
private Map<UUID, Long> lastBlockPlaceTime = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Integer> blockPunches = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> projectilesShot = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Integer> velocitytrack = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Long> startEat = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
|
||||
@@ -291,7 +289,8 @@ public class Backend {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player)
|
||||
&& !Utilities.isInWeb(player)) {
|
||||
&& !Utilities.isInWeb(player)
|
||||
&& !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
||||
if (player.getFallDistance() == 0) {
|
||||
if (nofallViolation.get(uuid) == null) {
|
||||
nofallViolation.put(uuid, 1);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
* 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.check.combat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,33 +28,31 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
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>();
|
||||
// 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 void listenPackets() {
|
||||
/*AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
|
||||
ListenerPriority.LOWEST, new PacketType[] { PacketType.Play.Client.POSITION_LOOK }) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PacketContainer packet = e.getPacket();
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
|
||||
String uuid = player.getUniqueId().toString();
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
@@ -66,29 +63,30 @@ public class KillAuraCheck {
|
||||
|
||||
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
if (Math.round(angleDifference) > AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_DIFFERENCE()) {
|
||||
if (!ANGLE_FLAGS.containsKey(player.getUniqueId().toString())) {
|
||||
ANGLE_FLAGS.put(player.getUniqueId().toString(), 1);
|
||||
if (!ANGLE_FLAGS.containsKey(uuid)) {
|
||||
ANGLE_FLAGS.put(uuid, 1);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int flags = ANGLE_FLAGS.get(player.getUniqueId().toString());
|
||||
int flags = ANGLE_FLAGS.get(uuid);
|
||||
if (flags >= AntiCheatReloaded.getManager().getConfiguration().getMagic().KILLAURA_MAX_ANGLE_VIOLATIONS()) {
|
||||
ANGLE_FLAGS.remove(player.getUniqueId().toString());
|
||||
ANGLE_FLAGS.remove(uuid);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
|
||||
}
|
||||
|
||||
ANGLE_FLAGS.put(player.getUniqueId().toString(), flags + 1);
|
||||
ANGLE_FLAGS.put(uuid, flags + 1);
|
||||
}
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkFightSpeed(Player player, EntityDamageEvent event) {
|
||||
if (!CLICKSPEED_MAP.containsKey(player.getUniqueId().toString())) {
|
||||
CLICKSPEED_MAP.put(player.getUniqueId().toString(), new ClickSpeed());
|
||||
String uuid = player.getUniqueId().toString();
|
||||
if (!CLICKSPEED_MAP.containsKey(uuid)) {
|
||||
CLICKSPEED_MAP.put(uuid, new ClickSpeed());
|
||||
return PASS;
|
||||
}
|
||||
ClickSpeed clickSpeed = CLICKSPEED_MAP.get(player.getUniqueId().toString());
|
||||
ClickSpeed clickSpeed = CLICKSPEED_MAP.get(uuid);
|
||||
clickSpeed.registerClick();
|
||||
int deviationScore = clickSpeed.getDeviationScore();
|
||||
// Prevents false positives since scores under 2000 aren't reliable
|
||||
@@ -96,27 +94,63 @@ public class KillAuraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (!DEVIATION_SCORES.containsKey(player.getUniqueId().toString())) {
|
||||
DEVIATION_SCORES.put(player.getUniqueId().toString(), deviationScore);
|
||||
if (!DEVIATION_SCORES.containsKey(uuid)) {
|
||||
DEVIATION_SCORES.put(uuid, deviationScore);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
int lastScore = DEVIATION_SCORES.get(player.getUniqueId().toString());
|
||||
DEVIATION_SCORES.put(player.getUniqueId().toString(), deviationScore);
|
||||
int lastScore = DEVIATION_SCORES.get(uuid);
|
||||
DEVIATION_SCORES.put(uuid, deviationScore);
|
||||
int diff = Math.abs(deviationScore - lastScore);
|
||||
if (!DIFF_MAP.containsKey(player.getUniqueId().toString())) {
|
||||
DIFF_MAP.put(player.getUniqueId().toString(), diff);
|
||||
if (!DIFF_MAP.containsKey(uuid)) {
|
||||
DIFF_MAP.put(uuid, diff);
|
||||
return PASS;
|
||||
}
|
||||
int lastDiff = DIFF_MAP.get(player.getUniqueId().toString());
|
||||
DIFF_MAP.put(player.getUniqueId().toString(), diff);
|
||||
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();
|
||||
float pitchMovement = event.getTo().getPitch() - event.getFrom().getPitch();
|
||||
if (!PITCH_MOVEMENTS_CACHE.containsKey(uuid)) {
|
||||
PITCH_MOVEMENTS_CACHE.put(uuid, new ArrayList<Float>());
|
||||
return PASS;
|
||||
}
|
||||
List<Float> pitchMovements = PITCH_MOVEMENTS_CACHE.get(uuid);
|
||||
if (pitchMovement != 0 && Math.abs(pitchMovement) <= 10 && Math.abs(event.getTo().getPitch()) != 90) {
|
||||
pitchMovements.add(Math.abs(pitchMovement));
|
||||
}
|
||||
|
||||
if (pitchMovements.size() >= 20) {
|
||||
float greatestCommonDivisor = Utilities.gcdRational(pitchMovements);
|
||||
if (!GCD_CACHE.containsKey(uuid)) {
|
||||
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||
}
|
||||
|
||||
float divisorDifference = Math.abs(greatestCommonDivisor - GCD_CACHE.get(uuid));
|
||||
if (divisorDifference > 0.00425 || greatestCommonDivisor < 0.00001) {
|
||||
pitchMovements.clear();
|
||||
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "performed aimbot-like movements (divisor-diff=" + divisorDifference + ")");
|
||||
}
|
||||
pitchMovements.clear();
|
||||
GCD_CACHE.put(uuid, greatestCommonDivisor);
|
||||
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||
}
|
||||
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static class ClickSpeed {
|
||||
private final List<Long> clicks;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class FlightCheck {
|
||||
}
|
||||
|
||||
public static boolean isMovingExempt(Player player) {
|
||||
return isDoing(player, MOVING_EXEMPT, -1);
|
||||
return isDoing(player, MOVING_EXEMPT, -1) || player.isInsideVehicle();
|
||||
}
|
||||
|
||||
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||
|
||||
@@ -31,6 +31,9 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* This check is an outdated mess which needs to be replaced
|
||||
*/
|
||||
public class SpeedCheck {
|
||||
|
||||
public static final Map<UUID, Integer> SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
@@ -73,9 +76,16 @@ public class SpeedCheck {
|
||||
&& ((player.getEyeLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.AIR)
|
||||
&& (player.getEyeLocation().getBlock().getRelative(BlockFace.UP)
|
||||
.getType() != Material.CAVE_AIR))) {
|
||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.165D);
|
||||
if (player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ")
|
||||
+ " and trapdoor";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
+ (blockDownName.equals("BLUE_ICE") ? 0.35925D : 0.35D);
|
||||
} else {
|
||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.2D);
|
||||
}
|
||||
} else {
|
||||
reason = "while sprinting ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
|
||||
|
||||
@@ -99,7 +99,8 @@ public class WaterWalkCheck {
|
||||
}
|
||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid()
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block)
|
||||
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
||||
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN)) && (y < 0.025
|
||||
|| y == 0.09999999999999964 || y == 0.14999999999999947 || y == 0.04999999999999982)) {
|
||||
if (WATER_ASCENSION_VIOLATIONS.containsKey(uuid)) {
|
||||
int v = WATER_ASCENSION_VIOLATIONS.get(uuid);
|
||||
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||
|
||||
Reference in new issue
Block a user