Compare commits

..
16 Commits
Author SHA1 Message Date
Rammelkast 610d53550f Fixed false positives with boats, changes to MorePackets 2020-06-09 14:33:54 +02:00
Rammelkast db9aa97ca1 Fix broken IllegalInteract permission, fix false positive in sneak check 2020-06-09 14:05:32 +02:00
Rammelkast 992c67d894 Fixed Aimbot and MorePackets false positives, staff notifications are now every x violations and not spammy. Removed broken part of glide check and fixed all permission issues. 2020-06-04 16:41:13 +02:00
Rammelkast 12c85b3939 Fix missing permissions 2020-06-02 20:56:03 +02:00
Rammelkast 37d580a4ba Remove old magic.yml contents, fix riptide false positive 2020-05-19 13:20:39 +02:00
Rammelkast f94a430d41 Recoded MorePackets, fixed false positive. This commit is a release candidate. 2020-05-13 17:16:04 +02:00
Rammelkast 918549bc11 Fixed bug in version check, fixed water-related false positive and fixed wrong permission 2020-05-13 15:56:07 +02:00
Rammelkast c6e4ce091a Fix #83, fix BadPackets false positive added packet sneak check. 2020-05-13 15:43:54 +02:00
Rammelkast 7d13aae057 Replaced falsing GCD check, started aimbot check. Added "symbiosis" metric. 2020-05-13 14:52:36 +02:00
Rammelkast 3538b8934c Cleaned up and changed some comments 2020-05-04 17:24:47 +02:00
Rammelkast b2701fa057 Fixed #81, removed POS optifine check code that won't work & fixed console messaging 2020-05-04 17:18:22 +02:00
Rammelkast 8cf2702708 Bleeding fix for #81, added #76 and started working on OF zoom support 2020-05-04 15:40:14 +02:00
Rammelkast cd3184f17b Merge pull request #77 from BlazingAsher/master
make getHandlers() static
2020-04-28 14:23:08 +02:00
David Hui 9078846511 make getHandlers() static 2020-04-25 15:03:10 -04:00
Rammelkast 50247f28c9 Fixed false positive with slow falling potion and upped default teleport protection 2020-04-24 18:54:15 +02:00
Rammelkast cc51e9307f Added FastLadder check, fixed glide false positive 2020-04-24 13:59:06 +02:00
34 changed files with 595 additions and 278 deletions

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ Hacks blocked
------- -------
* Flight * Flight
* Glide * Glide
* FastLadder
* Jesus * Jesus
* Step * Step
* Criticals * Criticals
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.8.1</version> <version>1.8.2-PRE</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url> <url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties> <properties>
@@ -64,6 +64,7 @@ public class AntiCheatReloaded extends JavaPlugin {
private static UpdateManager updateManager; private static UpdateManager updateManager;
private double tps = -1; private double tps = -1;
private String symbiosisMetric = "None";
@Override @Override
public void onEnable() { public void onEnable() {
@@ -109,8 +110,12 @@ public class AntiCheatReloaded extends JavaPlugin {
verboseLog("Finished loading."); verboseLog("Finished loading.");
// Metrics // Metrics
getServer().getScheduler().runTaskLater(this, new Runnable() {
@Override
public void run() {
checkForSymbiosis();
try { try {
Metrics metrics = new Metrics(this, 202); Metrics metrics = new Metrics(AntiCheatReloaded.this, 202);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() { metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() {
@Override @Override
public Integer call() throws Exception { public Integer call() throws Exception {
@@ -132,9 +137,17 @@ public class AntiCheatReloaded extends JavaPlugin {
return VersionUtil.getVersion(); return VersionUtil.getVersion();
} }
})); }));
metrics.addCustomChart(new Metrics.SimplePie("symbiosis", new Callable<String>() {
@Override
public String call() throws Exception {
return symbiosisMetric;
}
}));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
}, 90L);
// Launch TPS check // Launch TPS check
new BukkitRunnable() { new BukkitRunnable() {
@@ -153,8 +166,6 @@ public class AntiCheatReloaded extends JavaPlugin {
} }
} }
}.runTaskTimer(this, 40L, 1L); }.runTaskTimer(this, 40L, 1L);
// Launch MorePackets timer
MorePacketsCheck.startTimer();
} }
@Override @Override
@@ -269,6 +280,49 @@ public class AntiCheatReloaded extends JavaPlugin {
this.playersKicked++; this.playersKicked++;
} }
/**
* Creates metric that checks for anti-cheat symbiosis
* I use this to see if AntiCheatReloaded is actively being used
* together with other anti-cheats, so I can account for that.
*/
protected void checkForSymbiosis() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "NoCheatPlus";
} else {
this.symbiosisMetric += ", NoCheatPlus";
}
}
if (Bukkit.getPluginManager().getPlugin("Matrix") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Matrix";
} else {
this.symbiosisMetric += ", Matrix";
}
}
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "AAC";
} else {
this.symbiosisMetric += ", AAC";
}
}
if (Bukkit.getPluginManager().getPlugin("Spartan") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Spartan";
} else {
this.symbiosisMetric += ", Spartan";
}
}
if (Bukkit.getPluginManager().getPlugin("Negativity") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Negativity";
} else {
this.symbiosisMetric += ", Negativity";
}
}
}
public static void sendToMainThread(Runnable runnable) { public static void sendToMainThread(Runnable runnable) {
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable); Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
} }
@@ -281,7 +335,6 @@ public class AntiCheatReloaded extends JavaPlugin {
} }
} }
}); });
Bukkit.getConsoleSender().sendMessage(message);
} }
public static UpdateManager getUpdateManager() { public static UpdateManager getUpdateManager() {
@@ -63,4 +63,8 @@ public class CheckFailEvent extends Event {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }
@@ -30,13 +30,17 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck; import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck; import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck; import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
@@ -86,6 +90,7 @@ public class Backend {
private HashSet<Byte> transparent = new HashSet<Byte>(); private HashSet<Byte> transparent = new HashSet<Byte>();
private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>(); private Map<UUID, Long> lastFallPacket = new HashMap<UUID, Long>();
private Map<UUID, Integer> fastSneakViolations = new HashMap<UUID, Integer>(); private Map<UUID, Integer> fastSneakViolations = new HashMap<UUID, Integer>();
private Map<UUID, Long> lastSneak = new HashMap<UUID, Long>();
private Magic magic; private Magic magic;
private AntiCheatManager manager = null; private AntiCheatManager manager = null;
@@ -152,16 +157,18 @@ public class Backend {
inventoryClicks.remove(uuid); inventoryClicks.remove(uuid);
lastFallPacket.remove(uuid); lastFallPacket.remove(uuid);
fastSneakViolations.remove(uuid); fastSneakViolations.remove(uuid);
lastSneak.remove(uuid);
AimbotCheck.LAST_DELTA_YAW.remove(uuid);
VelocityCheck.VIOLATIONS.remove(uuid); VelocityCheck.VIOLATIONS.remove(uuid);
MorePacketsCheck.MOVE_COUNT.remove(uuid); MorePacketsCheck.LAST_PACKET_TIME.remove(uuid);
MorePacketsCheck.PACKET_BALANCE.remove(uuid);
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
GlideCheck.LAST_MOTION_Y.remove(uuid); GlideCheck.LAST_MOTION_Y.remove(uuid);
GlideCheck.LAST_FALL_DISTANCE.remove(uuid); GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
GlideCheck.VIOLATIONS.remove(uuid); GlideCheck.VIOLATIONS.remove(uuid);
SpeedCheck.SPEED_VIOLATIONS.remove(uuid); SpeedCheck.SPEED_VIOLATIONS.remove(uuid);
ElytraCheck.JUMP_Y_VALUE.remove(uuid); ElytraCheck.JUMP_Y_VALUE.remove(uuid);
KillAuraCheck.ANGLE_FLAGS.remove(uuid); KillAuraCheck.ANGLE_FLAGS.remove(uuid);
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(uuid);
KillAuraCheck.GCD_CACHE.remove(uuid);
FlightCheck.MOVING_EXEMPT.remove(uuid); FlightCheck.MOVING_EXEMPT.remove(uuid);
FlightCheck.ASCENSION_COUNT.remove(uuid); FlightCheck.ASCENSION_COUNT.remove(uuid);
FlightCheck.BLOCKS_OVER_FLIGHT.remove(uuid); FlightCheck.BLOCKS_OVER_FLIGHT.remove(uuid);
@@ -269,24 +276,12 @@ public class Backend {
} }
} }
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)
&& !Utilities.isSlime(player.getLocation().getBlock())) {
return new CheckResult(CheckResult.Result.FAILED,
"y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
} else {
return PASS;
}
}
public CheckResult checkNoFall(Player player, double y) { public CheckResult checkNoFall(Player player, double y) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player) && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
&& !Utilities.isInWeb(player) && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
&& !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) { && !VersionUtil.isSlowFalling(player)) {
if (player.getFallDistance() == 0) { if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) { if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1); nofallViolation.put(uuid, 1);
@@ -312,19 +307,20 @@ public class Backend {
public CheckResult checkSneak(Player player, Location location, double x, double z) { public CheckResult checkSneak(Player player, Location location, double x, double z) {
if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle() if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle()
&& !Utilities.cantStandAtExp(location)) { && !Utilities.cantStandAtExp(location) && !Utilities.isSlab(location.getBlock().getRelative(BlockFace.DOWN))) {
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1; double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
if (i != -1) { if (i != -1) {
if (this.fastSneakViolations.containsKey(player.getUniqueId())) { if (this.fastSneakViolations.containsKey(player.getUniqueId())) {
int flags = this.fastSneakViolations.get(player.getUniqueId()); int flags = this.fastSneakViolations.get(player.getUniqueId());
if (flags >= 3) { // TODO possible config if (flags >= 3) { // TODO possible config
this.fastSneakViolations.put(player.getUniqueId(), flags - 1);
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
} }
this.fastSneakViolations.put(player.getUniqueId(), flags + 1); this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
return PASS; return PASS;
} else { } else {
this.fastSneakViolations.put(player.getUniqueId(), 1); this.fastSneakViolations.put(player.getUniqueId(), 0);
return PASS; return PASS;
} }
} else { } else {
@@ -337,6 +333,21 @@ public class Backend {
} }
} }
public CheckResult checkSneakToggle(Player player) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
final long lastSneak = this.lastSneak.getOrDefault(player.getUniqueId(), (long) 0);
this.lastSneak.put(player.getUniqueId(), System.currentTimeMillis());
if (System.currentTimeMillis() - lastSneak < 75 && (AntiCheatReloaded.getPlugin().getTPS() > 12
&& !user.isLagging())) {
if (!this.silentMode()) {
player.teleport(user.getGoodLocation(player.getLocation()));
}
return new CheckResult(Result.FAILED,
"toggled sneak too fast (time=" + (System.currentTimeMillis() - lastSneak) + ")");
}
return PASS;
}
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) { public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE
@@ -633,9 +644,15 @@ public class Backend {
} }
public CheckResult checkFastHeal(Player player) { public CheckResult checkFastHeal(Player player) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{ {
long healTime = magic.MIN_HEAL_TIME(); double tps = AntiCheatReloaded.getPlugin().getTPS();
if (tps < 17.5
|| user.isLagging()) {
return PASS;
}
long healTime = magic.MIN_HEAL_TIME() - (tps >= 18.5 ? 0 : 50);
long l = lastHeal.get(player.getUniqueId()); long l = lastHeal.get(player.getUniqueId());
lastHeal.remove(player.getUniqueId()); lastHeal.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < healTime) { if ((System.currentTimeMillis() - l) < healTime) {
@@ -647,8 +664,13 @@ public class Backend {
} }
public CheckResult checkFastEat(Player player) { public CheckResult checkFastEat(Player player) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it. if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{ {
if (AntiCheatReloaded.getPlugin().getTPS() < 17.5
|| user.isLagging()) {
return PASS;
}
long l = startEat.get(player.getUniqueId()); long l = startEat.get(player.getUniqueId());
startEat.remove(player.getUniqueId()); startEat.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) { if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
@@ -777,8 +799,14 @@ public class Backend {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME()); FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
} }
public void logBoatCollision(final Player player) {
// TODO config
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
}
public void logJoin(final Player player) { public void logJoin(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME()); FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
MorePacketsCheck.EXEMPT_TIMINGS.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
} }
public boolean isMovingExempt(Player player) { public boolean isMovingExempt(Player player) {
@@ -64,7 +64,9 @@ public enum CheckType {
VELOCITY(Permission.CHECK_VELOCITY), VELOCITY(Permission.CHECK_VELOCITY),
CRITICALS(Permission.CHECK_CRITICALS), CRITICALS(Permission.CHECK_CRITICALS),
CHAT_UNICODE(Permission.CHECK_UNICODE), CHAT_UNICODE(Permission.CHECK_UNICODE),
ILLEGAL_INTERACT(Permission.CHECK_ILLEGAL_INTERACT); ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT),
FASTLADDER(Permission.CHECK_FASTLADDER),
AIMBOT(Permission.CHECK_AIMBOT);
private final Permission permission; private final Permission permission;
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>(); private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
@@ -18,9 +18,7 @@
*/ */
package com.rammelkast.anticheatreloaded.check.combat; package com.rammelkast.anticheatreloaded.check.combat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -29,21 +27,15 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class KillAuraCheck { public class KillAuraCheck {
// Angle check // Angle check
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>(); 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 CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult checkAngle(Player player, EntityDamageEvent event) { public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
@@ -75,43 +67,6 @@ public class KillAuraCheck {
return PASS; return PASS;
} }
/**
* Check idea by Hawk AntiCheat (https://github.com/HawkAnticheat/Hawk)
*/
public static CheckResult checkAimbot(Player player, PlayerMoveEvent event) {
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>());
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;
}
public static double calculateYawDifference(Location from, Location to) { public static double calculateYawDifference(Location from, Location to) {
Location clonedFrom = from.clone(); Location clonedFrom = from.clone();
Vector startVector = clonedFrom.toVector(); Vector startVector = clonedFrom.toVector();
@@ -33,6 +33,9 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
/*
* TODO improve
*/
public class VelocityCheck { public class VelocityCheck {
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>(); public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
@@ -0,0 +1,65 @@
/*
* 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.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
public class AimbotCheck {
public static final Map<UUID, Float> LAST_DELTA_YAW = new HashMap<UUID, Float>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, PlayerMoveEvent event) {
Backend backend = AntiCheatReloaded.getManager().getBackend();
if (backend.isMovingExempt(player)) {
return PASS;
}
UUID uuid = player.getUniqueId();
float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw());
float dPitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
// Not interesting
if (dYaw < 0.05 && dPitch < 0.05) {
return PASS;
}
final float lastDeltaYaw = LAST_DELTA_YAW.getOrDefault(uuid, -1F);
if (lastDeltaYaw == -1F) {
LAST_DELTA_YAW.put(uuid, dYaw);
return PASS;
}
LAST_DELTA_YAW.put(uuid, dYaw);
float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
if (absoluteYawDifference < 1E-8 && dYaw > 30 && dYaw < 355) {
return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
}
return PASS;
}
}
@@ -0,0 +1,85 @@
/*
* 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.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class FastLadderCheck {
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, double y) {
Magic magic = AntiCheatReloaded.getManager().getBackend().getMagic();
// Only check if fully on ladder
// Liquids are climbable blocks, so we have to add a seperate check
if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|| player.getLocation().getBlock().isLiquid()) {
return PASS;
}
int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
if (y > 0) {
// Check moving up
double max = magic.LADDER_Y_MAX();
// Check if going faster than max Y climbing speed
if (y - max > 0) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
vlCount = 0;
return new CheckResult(Result.FAILED,
"tried to climb up too fast (speed=" + y + ", max=" + max + ")");
}
} else {
if (vlCount > 0)
vlCount--;
}
} else if (y < 0) {
// Check moving down
if (Math.abs(y) > magic.LADDER_DOWN_MAX() + 6E-9) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
vlCount = 0;
return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
+ ", max=" + magic.LADDER_DOWN_MAX() + ")");
}
} else {
if (vlCount > 0)
vlCount--;
}
} else {
if (vlCount > 0)
vlCount--;
}
VIOLATIONS.put(player.getUniqueId(), vlCount);
return PASS;
}
}
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.rammelkast.anticheatreloaded.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
@@ -61,7 +60,8 @@ public class FlightCheck {
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), && Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
new Material[] { Utilities.IRON_BARS }) new Material[] { Utilities.IRON_BARS })
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN), && Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
new String[] { "FENCE", "FENCE_GATE" })) { new String[] { "FENCE", "FENCE_GATE" })
&& !Utilities.couldBeOnBoat(player)) {
if (!BLOCKS_OVER_FLIGHT.containsKey(uuid)) { if (!BLOCKS_OVER_FLIGHT.containsKey(uuid)) {
BLOCKS_OVER_FLIGHT.put(uuid, 0D); BLOCKS_OVER_FLIGHT.put(uuid, 0D);
} }
@@ -94,13 +94,14 @@ public class FlightCheck {
string = " with jump potion"; string = " with jump potion";
} }
Block block = player.getLocation().getBlock(); Block block = player.getLocation().getBlock();
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player) if (!isMovingExempt(player) && !Utilities.isNearWater(player) && !VersionUtil.isFlying(player)
&& !backend.justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && !backend.justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
&& !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) && !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
&& !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock()) && !Utilities.isClimbableBlock(player.getLocation().clone().add(0, -0.98, 0).getBlock())
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock()) && !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) { && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) {
// TODO isMoveUpBlock does not seem to be a success with stairs // TODO isMoveUpBlock does not seem to be a success with stairs
// I suddenly could not replicate this, man this check is a mess
if (y1 < y2) { if (y1 < y2) {
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
&& !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid()
@@ -32,13 +32,13 @@ import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class GlideCheck { public class GlideCheck {
public static final Map<UUID, Double> LAST_MOTION_Y = new HashMap<UUID, Double>(); public static final Map<UUID, Double> LAST_MOTION_Y = new HashMap<UUID, Double>();
public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>(); public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>();
public static final Map<UUID, Integer> AIR_TICKS = new HashMap<UUID, Integer>();
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>(); public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
@@ -48,18 +48,22 @@ public class GlideCheck {
VIOLATIONS.put(player.getUniqueId(), 0); VIOLATIONS.put(player.getUniqueId(), 0);
return PASS; return PASS;
} }
if (player.getLocation().getBlock().getType() == Material.LADDER if (player.getLocation().getBlock().getType() == Material.LADDER
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) { || player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
return PASS; return PASS;
} }
if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) { if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) {
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference()); LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
return PASS; return PASS;
} }
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) { if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance()); LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
return PASS; return PASS;
} }
int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0); int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
double motionY = distance.getYDifference(); double motionY = distance.getYDifference();
float fallDistance = player.getFallDistance(); float fallDistance = player.getFallDistance();
@@ -80,34 +84,7 @@ public class GlideCheck {
return PASS; return PASS;
} }
} else { } else {
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround() // TODO redo this
&& 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();
float scaledDifference = Math.abs((predicted - actual) + 0.1568f);
if (scaledDifference > 3E-8) {
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()
&& !Utilities.canStand(distance.getTo().getBlock())) {
VIOLATIONS.put(player.getUniqueId(), 1);
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
Location prev = player.getLocation().clone();
prev.setY(prev.getY() - distanceToFall(prev));
player.teleport(AntiCheatReloaded.getManager().getUserManager()
.getUser(player.getUniqueId()).getGoodLocation(prev));
}
return new CheckResult(CheckResult.Result.FAILED, "type=gravity, offset="
+ new BigDecimal(scaledDifference).setScale(2, RoundingMode.HALF_UP) + ")");
} else {
VIOLATIONS.put(player.getUniqueId(), violations + 1);
return PASS;
}
}
}
} }
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference()); LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance()); LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
@@ -117,10 +94,6 @@ public class GlideCheck {
return PASS; return PASS;
} }
private static float calculateNextMotionY(float motionY) {
return (motionY - 0.08f) * 0.98f;
}
private static double distanceToFall(Location location) { private static double distanceToFall(Location location) {
location = location.clone(); location = location.clone();
double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D; double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D;
@@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend; import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
@@ -114,16 +115,19 @@ public class SpeedCheck {
} }
} }
public CheckResult checkYSpeed(Player player, double y) { public static CheckResult checkYSpeed(Player player, Distance distance) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
if (!backend.isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() if (!backend.isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping()
&& (y > backend.getMagic().Y_SPEED_MAX()) && (distance.getYDifference() > backend.getMagic().Y_SPEED_MAX())
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME()) && !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
&& !VersionUtil.isRiptiding(player)
&& !Utilities.isNearBed(distance.getTo())
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) && !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getGoodLocation(player.getLocation()).getBlock())) { .getGoodLocation(player.getLocation()).getBlock())
&& !Utilities.couldBeOnBoat(player)) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"y speed was too high (speed=" + y + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")"); "y speed was too high (speed=" + distance.getYDifference() + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -31,16 +31,17 @@ import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.User;
public class BadPacketsCheck { public class BadPacketsCheck {
public static void runCheck(Player player, PacketEvent event) { public static void runCheck(Player player, PacketEvent event) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) // Confirm if we should even check for BadPackets
|| backend.isMovingExempt(player)) { if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) || backend.isMovingExempt(player)) {
return; return;
} }
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
PacketContainer packet = event.getPacket(); PacketContainer packet = event.getPacket();
float pitch = packet.getFloat().read(1); float pitch = packet.getFloat().read(1);
// Check for derp // Check for derp
@@ -50,7 +51,8 @@ public class BadPacketsCheck {
} }
// TODO more precise checking for this // TODO more precise checking for this
if (AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).isLagging()) { double tps = AntiCheatReloaded.getPlugin().getTPS();
if (user.isLagging() || tps < 18) {
return; return;
} }
@@ -23,14 +23,13 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.event.EventListener; import com.rammelkast.anticheatreloaded.event.EventListener;
/** /**
@@ -38,16 +37,9 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
*/ */
public class MorePacketsCheck { public class MorePacketsCheck {
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>(); public static final Map<UUID, Long> LAST_PACKET_TIME = new HashMap<UUID, Long>();
public static final Map<UUID, Long> EXEMPT_TIMINGS = new HashMap<UUID, Long>();
public static void startTimer() { public static final Map<UUID, Double> PACKET_BALANCE = new HashMap<UUID, Double>();
new BukkitRunnable() {
@Override
public void run() {
MOVE_COUNT.clear();
}
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
}
public static void runCheck(Player player, PacketEvent event) { public static void runCheck(Player player, PacketEvent event) {
// Confirm if we should even check for MorePackets // Confirm if we should even check for MorePackets
@@ -56,50 +48,50 @@ public class MorePacketsCheck {
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS) || tps < 15) { if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS) || tps < 15) {
return; return;
} }
Location currentLocation = event.getPlayer().getLocation();
if (!MOVE_COUNT.containsKey(player.getUniqueId())) { UUID uuid = player.getUniqueId();
MOVE_COUNT.put(player.getUniqueId(), 1); Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
} else { if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) {
MOVE_COUNT.put(player.getUniqueId(), MOVE_COUNT.get(player.getUniqueId()) + 1); return;
int ping = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).getPing();
int limit = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_LIMIT();
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_AVERAGE_PING();
float pingLeniency = (float) ((ping / averagePing));
if (pingLeniency < 1)
pingLeniency = 1;
if (pingLeniency > 2)
pingLeniency = 2;
float tpsLeniency = (float) ((19 / tps));
if (tps > 19) {
tpsLeniency = 1;
} }
float leniency = pingLeniency * tpsLeniency; long packetTimeNow = System.currentTimeMillis();
limit = Math.round(leniency * limit); long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L);
final float finalLeniency = leniency; double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
try {
if (MOVE_COUNT.get(player.getUniqueId()) > limit) { long rate = packetTimeNow - lastPacketTime;
final int packets = MOVE_COUNT.get(player.getUniqueId()); packetBalance += 50;
MOVE_COUNT.remove(player.getUniqueId()); packetBalance -= rate;
if (packetBalance >= magic.MOREPACKETS_TRIGGER_BALANCE()) {
int ticks = (int) Math.round(packetBalance / 50);
packetBalance = -1 * (magic.MOREPACKETS_TRIGGER_BALANCE() / 2);
flag(player, event, "overshot timer by " + ticks + " tick(s)");
} else if (packetBalance < -1 * (magic.MOREPACKETS_MINIMUM_CLAMP())) {
// Clamp minimum, 50ms=1tick of lag leniency
packetBalance = -1 * (magic.MOREPACKETS_MINIMUM_CLAMP());
}
LAST_PACKET_TIME.put(uuid, packetTimeNow);
PACKET_BALANCE.put(uuid, packetBalance);
}
private static void flag(Player player, PacketEvent event, String message) {
event.setCancelled(true); event.setCancelled(true);
// We are currently not in the main server thread, so switch // We are currently not in the main server thread, so switch
AntiCheatReloaded.sendToMainThread(new Runnable() { AntiCheatReloaded.sendToMainThread(new Runnable() {
@Override @Override
public void run() { public void run() {
EventListener EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
.log(new CheckResult(CheckResult.Result.FAILED, CheckType.MOREPACKETS);
"sent " + packets + " packets in one second (max=" player.teleport(player.getLocation());
+ AntiCheatReloaded.getManager().getBackend().getMagic()
.MOREPACKETS_LIMIT()
+ ", leniency=" + finalLeniency + ")").getMessage(),
player, CheckType.MOREPACKETS);
player.teleport(currentLocation);
} }
}); });
} }
} catch (NullPointerException nullPointer) {
// TODO this is thrown sometimes, might have something to do with line 83 public static void compensate(Player player) {
} UUID uuid = player.getUniqueId();
} Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
PACKET_BALANCE.put(uuid, packetBalance - magic.MOREPACKETS_TELEPORT_COMPENSATION());
} }
} }
@@ -32,8 +32,8 @@ public class CommandMute extends CommandBase {
private static final String NAME = "AntiCheatReloaded Mute"; private static final String NAME = "AntiCheatReloaded Mute";
private static final String COMMAND = "mute"; private static final String COMMAND = "mute";
private static final String USAGE = "anticheat reload"; private static final String USAGE = "anticheat mute";
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD; private static final Permission PERMISSION = Permission.SYSTEM_MUTE;
private static final String[] HELP = { private static final String[] HELP = {
GRAY + "Use: " + AQUA + "/anticheat mute" + GRAY + " to mute all notifications", }; GRAY + "Use: " + AQUA + "/anticheat mute" + GRAY + " to mute all notifications", };
@@ -157,6 +157,7 @@ public class CommandReport extends CommandBase {
if (page <= pages && page > 0) { if (page <= pages && page > 0) {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page " + page + "/" + pages + "" + GOLD + "]----------------------");
cs.sendMessage(GRAY + "Player: " + WHITE + name); cs.sendMessage(GRAY + "Player: " + WHITE + name);
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
cs.sendMessage(GRAY + "Group: " + groupString); cs.sendMessage(GRAY + "Group: " + groupString);
for (int x = 0; x < 6; x++) { for (int x = 0; x < 6; x++) {
int index = ((page - 1) * 5) + (x + ((page - 1))); int index = ((page - 1) * 5) + (x + ((page - 1)));
@@ -177,6 +178,7 @@ public class CommandReport extends CommandBase {
if (pages == 0 && page == 1) { if (pages == 0 && page == 1) {
cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------"); cs.sendMessage(GOLD + "----------------------[" + GRAY + "Page 1/1" + GOLD + "]----------------------");
cs.sendMessage(GRAY + "Player: " + WHITE + name); cs.sendMessage(GRAY + "Player: " + WHITE + name);
cs.sendMessage(GRAY + "Ping: " + WHITE + user.getPing() + "ms " + (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"));
cs.sendMessage(GRAY + "Group: " + groupString); cs.sendMessage(GRAY + "Group: " + groupString);
cs.sendMessage(GRAY + "This user has not failed any checks."); cs.sendMessage(GRAY + "This user has not failed any checks.");
cs.sendMessage(MENU_END); cs.sendMessage(MENU_END);
@@ -51,6 +51,8 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds; public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<List<String>> disabledChecks; public ConfigValue<List<String>> disabledChecks;
public ConfigValue<Integer> notifyEveryVl;
public Config(AntiCheatReloaded plugin, Configuration config) { public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME); super(plugin, config, FILENAME);
} }
@@ -80,5 +82,10 @@ public class Config extends ConfigurationFile {
disabledWorlds = new ConfigValue<List<String>>("disable-in"); disabledWorlds = new ConfigValue<List<String>>("disable-in");
disabledChecks = new ConfigValue<List<String>>("disabled-checks"); disabledChecks = new ConfigValue<List<String>>("disabled-checks");
notifyEveryVl = new ConfigValue<Integer>("system.notify-every-vl");
if (notifyEveryVl.getValue() < 1) {
notifyEveryVl.setValue(5);
}
} }
} }
@@ -282,6 +282,10 @@ public interface Magic {
* Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE. * Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE.
*/ */
public double LADDER_Y_MIN(); public double LADDER_Y_MIN();
/**
* Maximum speed a player on a ladder can travel downwards
*/
public double LADDER_DOWN_MAX();
/** /**
* Maximum speed a player can travel up; Type=DOUBLE, Leniency=INCREASE. * Maximum speed a player can travel up; Type=DOUBLE, Leniency=INCREASE.
*/ */
@@ -355,13 +359,17 @@ public interface Magic {
*/ */
public int TELEPORT_MIN(); public int TELEPORT_MIN();
/** /**
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE. * The amount of milliseconds to compensate for a teleport; Type=INTEGER, Leniency=INCREASE.
*/ */
public int MOREPACKETS_LIMIT(); public int MOREPACKETS_TELEPORT_COMPENSATION();
/** /**
* The average ping settings used to account for lag; TYPE=INTEGER, Leniency=INCREASE * The amount of milliseconds that were offset to flag for MorePackets; Type=INTEGER, Leniency=INCREASE.
*/ */
public int MOREPACKETS_AVERAGE_PING(); public int MOREPACKETS_TRIGGER_BALANCE();
/**
* The maximum amount of overall lag compensating in milliseconds; Type=INTEGER, Leniency=INCREASE.
*/
public int MOREPACKETS_MINIMUM_CLAMP();
/** /**
* Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE. * Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE.
*/ */
@@ -374,10 +382,6 @@ public interface Magic {
* The maximum amount of violations before flagging player as a cheater; TYPE=INTEGER, Leniency=INCREASE * The maximum amount of violations before flagging player as a cheater; TYPE=INTEGER, Leniency=INCREASE
*/ */
public int KILLAURA_MAX_ANGLE_VIOLATIONS(); public int KILLAURA_MAX_ANGLE_VIOLATIONS();
/**
* The minimum score difference for the fight speed check to consider a player legit; TYPE=INTEGER, Leniency=DECREASE
*/
public int KILLAURA_FIGHTSPEED_MINDIFF();
/** /**
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE * The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
*/ */
@@ -390,4 +394,12 @@ public interface Magic {
* Maximum distance allowed between two movement packets; Type=DOUBLE, Leniency=INCREASE. * Maximum distance allowed between two movement packets; Type=DOUBLE, Leniency=INCREASE.
*/ */
public double BADPACKETS_MAX_DISTANCE(); public double BADPACKETS_MAX_DISTANCE();
/**
* Maximum amount of fastladder movements before flagging; TYPE=INTEGER, Leniency=INCREASE
*/
public int FASTLADDER_MAX_FLAGS();
/**
* The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
*/
public int LAG_DETERMINATION();
} }
@@ -50,28 +50,48 @@ public class EventListener implements Listener {
public static void log(String message, Player player, CheckType type) { public static void log(String message, Player player, CheckType type) {
User user = getUserManager().getUser(player.getUniqueId()); User user = getUserManager().getUser(player.getUniqueId());
if (user == null)
return;
boolean debugMode = CONFIG.getConfig().debugMode.getValue();
int vlForType = type.getUses(player.getUniqueId()) + 1;
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
if (message == null || message.equals("")) { if (message == null || message.equals("")) {
if (debugMode) {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
+ CheckType.getName(type); + CheckType.getName(type);
} else { } else {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
+ CheckType.getName(type) + ChatColor.GOLD + " (x" + vlForType + ")";
}
} else {
if (debugMode) {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed " message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
+ CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message + CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS()); + ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
} else {
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
+ CheckType.getName(type) + ChatColor.GOLD + " (x" + vlForType + ")" + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
} }
if (user != null) { // npc }
logCheat(type, user); logCheat(type, user);
if (user.increaseLevel(type)) { if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
AntiCheatReloaded.getManager().log(message); AntiCheatReloaded.getManager().log(message);
} }
removeDecrease(user); removeDecrease(user);
if (debugMode) {
player.sendMessage(message);
return;
} }
if (CONFIG.getConfig().debugMode.getValue()) { if (vlForType % notifyEveryVl == 0) {
player.sendMessage(message);
}
AntiCheatReloaded.getPlugin().sendToStaff(message); AntiCheatReloaded.getPlugin().sendToStaff(message);
} }
}
private static void logCheat(CheckType type, User user) { private static void logCheat(CheckType type, User user) {
USAGE_LIST.put(type, getCheats(type) + 1); USAGE_LIST.put(type, getCheats(type) + 1);
@@ -25,6 +25,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@@ -50,6 +51,8 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent; import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.vehicle.VehicleCollisionEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
@@ -57,8 +60,9 @@ import org.bukkit.inventory.PlayerInventory;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck; import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck; import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck; import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck; import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck; import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
@@ -146,8 +150,16 @@ public class PlayerListener extends EventListener {
@EventHandler @EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) { public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
if (event.isSneaking()) { if (event.isSneaking()) {
getBackend().logToggleSneak(event.getPlayer()); if (getCheckManager().willCheck(player, CheckType.SNEAK)) {
CheckResult result = getBackend().checkSneakToggle(player);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.SNEAK);
}
}
// getBackend().logToggleSneak(event.getPlayer());
} }
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
@@ -223,6 +235,15 @@ public class PlayerListener extends EventListener {
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@EventHandler
public void onPlayerVehicleCollide(VehicleEntityCollisionEvent event) {
if (!(event.getVehicle() instanceof Boat) || !(event.getEntity() instanceof Player))
return;
Player player = (Player) event.getEntity();
getBackend().logBoatCollision(player);
}
@EventHandler @EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) { public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@@ -388,7 +409,7 @@ public class PlayerListener extends EventListener {
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
/*TODO: player.damage(1); better system for this, too exploitable*/ // TODO better handling of this
} }
log(result.getMessage(), player, CheckType.NOFALL); log(result.getMessage(), player, CheckType.NOFALL);
} }
@@ -400,7 +421,7 @@ public class PlayerListener extends EventListener {
double z = distance.getZDifference(); double z = distance.getZDifference();
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLIGHT)) { if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLIGHT)) {
if (event.getFrom().getY() < event.getTo().getY()) { if (event.getFrom().getY() < event.getTo().getY()) {
CheckResult result = getBackend().checkYSpeed(player, y); CheckResult result = SpeedCheck.checkYSpeed(player, distance);
if (result.failed()) { if (result.failed()) {
if (!silentMode()) { if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone())); event.setTo(user.getGoodLocation(from.clone()));
@@ -449,14 +470,25 @@ public class PlayerListener extends EventListener {
changed = true; changed = true;
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
// Does not use y value created before because that value is absolute
CheckResult result = FastLadderCheck.runCheck(player, event.getTo().getY() - event.getFrom().getY());
if (result.failed()) {
if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.FASTLADDER);
changed = true;
}
}
if (!changed) { if (!changed) {
user.setGoodLocation(event.getFrom()); user.setGoodLocation(event.getFrom());
} }
} }
if (getCheckManager().willCheckQuick(player, CheckType.KILLAURA)) { if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
CheckResult result = KillAuraCheck.checkAimbot(player, event); CheckResult result = AimbotCheck.runCheck(player, event);
if (result.failed()) { if (result.failed()) {
log(result.getMessage(), player, CheckType.KILLAURA); log(result.getMessage(), player, CheckType.AIMBOT);
} }
} }
} }
@@ -76,7 +76,7 @@ public class LoggingManager {
} }
public void logToConsole(String message) { public void logToConsole(String message) {
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + message); Bukkit.getConsoleSender().sendMessage(message);
} }
public void logToFile(String message) { public void logToFile(String message) {
@@ -59,7 +59,6 @@ import com.google.gson.JsonPrimitive;
* <p> * <p>
* Check out https://bStats.org/ to learn more about bStats! * Check out https://bStats.org/ to learn more about bStats!
*/ */
@SuppressWarnings({ "unused" })
public class Metrics { public class Metrics {
static { static {
@@ -1,44 +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;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class NameGenerator {
private static final List<String> BEGIN = Arrays.asList(new String[] { "Pixel", "Pro", "NoHax", "Just", "That",
"New", "Ultra", "Killer", "Swift", "Anarchy", "Yolo", "Rammel" });
private static final List<String> END = Arrays.asList(new String[] { "Gamer", "PvP", "JustYolo", "Gaming",
"Minecraft", "Games", "Bawz", "Tech", "Noob", "Extra", "kast", "" + new Random().nextInt(100) });
public static String generateName() {
Random r = new Random();
String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1));
String end = END.get(r.nextInt(END.size() - 1));
if (r.nextBoolean())
return begin + end + r.nextInt(9);
else
return begin + end;
}
}
@@ -33,7 +33,7 @@ public class PacketListener {
public static void listenMovementPackets() { public static void listenMovementPackets() {
AntiCheatReloaded.getProtocolManager() AntiCheatReloaded.getProtocolManager()
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) { new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@@ -46,6 +46,14 @@ public class PacketListener {
BadPacketsCheck.runCheck(player, event); BadPacketsCheck.runCheck(player, event);
} }
} }
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
// Compensate for teleport
MorePacketsCheck.compensate(player);
}
}); });
} }
@@ -23,14 +23,13 @@ import org.bukkit.command.CommandSender;
public enum Permission { public enum Permission {
/* Check Nodes */ /* Check Nodes */
CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK, CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_AIMBOT,
/* System Nodes */ /* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE, SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_MUTE;
SYSTEM_CALIBRATE, SYSTEM_CHECK, SYSTEM_DEBUG, SYSTEM_RELOAD;
private static final String PERMISSION_ALL = "anticheat.*"; private static final String PERMISSION_ALL = "anticheat.*";
private static final String PERMISSION_SPAM = "anticheat.check.spam"; private static final String PERMISSION_SPAM = "anticheat.check.spam";
@@ -102,6 +102,8 @@ public class UpdateManager {
public VersionSplit(String version) throws Exception { public VersionSplit(String version) throws Exception {
if (version.endsWith("-ALPHA")) { if (version.endsWith("-ALPHA")) {
version = version.substring(0, version.length() - 6); version = version.substring(0, version.length() - 6);
} else if (version.endsWith("-PRE")) {
version = version.substring(0, version.length() - 4);
} }
String[] versionSplit = version.split("\\."); String[] versionSplit = version.split("\\.");
@@ -450,11 +450,12 @@ public class User {
} }
public boolean isLagging() { public boolean isLagging() {
return Math.abs(this.ping - this.lastPing) > 50; return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION();
} }
@Override @Override
public String toString() { public String toString() {
return "User {name = " + getName() + ", level = " + level + "}"; return "User {name = " + getName() + ", level = " + level + "}";
} }
} }
@@ -31,6 +31,8 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
@@ -121,6 +123,14 @@ public final class Utilities {
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST)) && !isSlime(block.getRelative(BlockFace.DOWN)); && !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST)) && !isSlime(block.getRelative(BlockFace.DOWN));
} }
public static boolean couldBeOnBoat(Player player) {
for (Entity entity : player.getNearbyEntities(0.25, 0.25, 0.25)) {
if (entity instanceof Boat)
return true;
}
return false;
}
/** /**
* Determine whether a player is fully submerged in water * Determine whether a player is fully submerged in water
* *
@@ -220,6 +230,29 @@ public final class Utilities {
return type.name().endsWith("SLAB"); return type.name().endsWith("SLAB");
} }
/**
* Determine whether a block is a bed
*
* @param block block to bed
* @return true if bed
*/
public static boolean isBed(Block block) {
Material type = block.getType();
return type.name().endsWith("BED");
}
public static boolean isNearBed(Location location) {
return isBed(location.getBlock())
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/** /**
* Determine whether a block is a stair * Determine whether a block is a stair
* *
@@ -249,7 +282,6 @@ public final class Utilities {
*/ */
public static boolean isOnLilyPad(Player player) { public static boolean isOnLilyPad(Player player) {
Block block = player.getLocation().getBlock(); Block block = player.getLocation().getBlock();
// TODO: Can we fix X this?
return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD return block.getType() == LILY_PAD || block.getRelative(BlockFace.NORTH).getType() == LILY_PAD
|| block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD || block.getRelative(BlockFace.SOUTH).getType() == LILY_PAD
|| block.getRelative(BlockFace.EAST).getType() == LILY_PAD || block.getRelative(BlockFace.EAST).getType() == LILY_PAD
@@ -279,6 +311,26 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid(); || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
} }
/**
* Determine whether a player is near a liquid block
*
* @param player player to check
* @return true if near liquid block
*/
public static boolean isNearWater(Player player) {
return player.getLocation().getBlock().isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.WEST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH_EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.NORTH_WEST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
}
/** /**
* Determine whether a player is in a web * Determine whether a player is in a web
* *
@@ -291,6 +343,22 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB; || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
} }
/**
* Determine whether a player is near a climbable block
*
* @param player player to check
* @return true if near climbable block
*/
public static boolean isNearClimbable(Player player) {
return isClimbableBlock(player.getLocation().getBlock())
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.DOWN))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.UP))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.NORTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.SOUTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
}
/** /**
* Determine whether a block is climbable * Determine whether a block is climbable
* *
@@ -70,6 +70,20 @@ public class VersionUtil {
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION); return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
} }
public static boolean isRiptiding(Player player) {
if (isBountifulUpdate()) {
return false;
}
return player.isRiptiding();
}
public static boolean isSlowFalling(Player player) {
if (isBountifulUpdate()) {
return false;
}
return player.hasPotionEffect(PotionEffectType.SLOW_FALLING);
}
public static boolean isFrostWalk(Player player) { public static boolean isFrostWalk(Player player) {
if (player.getInventory().getBoots() == null || isBountifulUpdate()) { if (player.getInventory().getBoots() == null || isBountifulUpdate()) {
return false; return false;
+5
View File
@@ -31,8 +31,13 @@ system:
# Should Enterprise options be enabled? Only set this to true if you're an advanced user. # Should Enterprise options be enabled? Only set this to true if you're an advanced user.
enterprise: false enterprise: false
# Running AntiCheatReloaded in debug mode will send alerts to the cheating players and enable debug logging # Running AntiCheatReloaded in debug mode will send alerts to the cheating players and enable debug logging
# Use this when locating and/or reporting false positives or when testing AntiCheatReloaded
# Do NOT enable this in a production environment! # Do NOT enable this in a production environment!
debug-mode: false debug-mode: false
# To prevent spamming, staff and the console will only be notified every x violations
# Minimum value is 1, default is 5
# Example with 5: notifications after 5 vl, 10vl, 15vl, etc.
notify-every-vl: 5
# Use /AntiCheatReloaded check for a list of valid checks # Use /AntiCheatReloaded check for a list of valid checks
disabled-checks: disabled-checks:
- EXAMPLE_CHECK - EXAMPLE_CHECK
+6 -6
View File
@@ -4,12 +4,12 @@ ALERT:
- '&c%player%''s last failed check was: %check%.' - '&c%player%''s last failed check was: %check%.'
- '&cType ''/acr report %player%'' for more information.' - '&cType ''/acr report %player%'' for more information.'
WARNING: WARNING:
- '&6&lACR&7 You have been flagged for using cheats.' - '&6&lACR &8>&7 You have been flagged for using cheats.'
- '&6&lACR&7 If you continue to cheat, action will be taken.' - '&6&lACR &8>&7 If you continue to cheat, action will be taken.'
BAN_REASON: '&cBanned by AntiCheatReloaded' BAN_REASON: '&6&lACR &8> &7Banned by AntiCheatReloaded'
BAN_BROADCAST: '&c%player% was banned for hacking.' BAN_BROADCAST: '&6&lACR &8> &7%player% was banned for cheating'
KICK_REASON: '&cKicked by AntiCheatReloaded' KICK_REASON: '&6&lACR &8> &7Kicked for cheating'
KICK_BROADCAST: '&c%player% was kicked for hacking.' KICK_BROADCAST: '&6&lACR &8> &7%player% was kicked for cheating'
SPAM_WARNING: '&cStop spamming the server or you will be kicked!' SPAM_WARNING: '&cStop spamming the server or you will be kicked!'
SPAM_KICK_REASON: '&cKicked for spamming' SPAM_KICK_REASON: '&cKicked for spamming'
SPAM_KICK_BROADCAST: '&c%player% was kicked for spamming' SPAM_KICK_BROADCAST: '&c%player% was kicked for spamming'
+22 -10
View File
@@ -138,6 +138,9 @@ LADDER_Y_MAX: 0.11761
# Minimum speed a player on a ladder can travel # Minimum speed a player on a ladder can travel
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
LADDER_Y_MIN: 0.11759 LADDER_Y_MIN: 0.11759
# Maximum speed a player on a ladder can travel downwards
# This is a set value and shouldn't be changed unless you know what you're doing
LADDER_DOWN_MAX: 0.15
# Number of times a player can fail the nofall check before being considered a cheater # Number of times a player can fail the nofall check before being considered a cheater
# Can be decreased to improve detenction with the risk of false positives # Can be decreased to improve detenction with the risk of false positives
# Increase in case of false positives # Increase in case of false positives
@@ -165,7 +168,7 @@ SPRINT_MAX: 0.2
TELEPORT_MIN: 400 TELEPORT_MIN: 400
# Time to exempt a player from moving because of teleporting # Time to exempt a player from moving because of teleporting
# Increase in case of false positives # Increase in case of false positives
TELEPORT_TIME: 800 TELEPORT_TIME: 1000
# Maximum time a player is considered to have a change in velocity # Maximum time a player is considered to have a change in velocity
# This is a set value and shouldn't be changed unless you know what you're doing # This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_CHECKTIME: 2100 VELOCITY_CHECKTIME: 2100
@@ -238,12 +241,18 @@ Y_TIME: 800
# Amount of suspicious mid-air movements before a player is suspected of glide # Amount of suspicious mid-air movements before a player is suspected of glide
# Increase this in case of false positives # Increase this in case of false positives
GLIDE_LIMIT: 5 GLIDE_LIMIT: 5
# Maximum amount of movement packets allowed per second # The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
# Increase this in case of false positives # Increase this in case of false positives
MOREPACKETS_LIMIT: 30 # Can be decreased in to tighten check
# If the MorePackets check gives false positives replace this with the average user ping on your server MOREPACKETS_TELEPORT_COMPENSATION: 200
# Not a good idea to use a value lower than 75 or higher than 250 # The amount of milliseconds that were offset to flag for MorePackets (50ms = 1 tick)
MOREPACKETS_AVERAGE_PING: 80 # Increase this in case of false positives
# Can be decreased in to tighten check
MOREPACKETS_TRIGGER_BALANCE: 100
# The maximum amount of overall lag compensating in milliseconds (50ms = 1 tick)
# Increase this in case of false positives
# Can be decreased in to tighten check
MOREPACKETS_MINIMUM_CLAMP: 200
# Maximum amount zero-velocity moments before a player is suspected # Maximum amount zero-velocity moments before a player is suspected
# Increase this in case of false positives # Increase this in case of false positives
VELOCITY_MAX_FLAGS: 3 VELOCITY_MAX_FLAGS: 3
@@ -253,10 +262,6 @@ KILLAURA_MAX_ANGLE_DIFFERENCE: 50
# The maximum amount of violations before flagging player as a cheater # The maximum amount of violations before flagging player as a cheater
# Increase this in case of false positives # Increase this in case of false positives
KILLAURA_MAX_ANGLE_VIOLATIONS: 3 KILLAURA_MAX_ANGLE_VIOLATIONS: 3
# The minimum score difference for the fight speed check to consider a player legit
# Increasing this will tighten check but might punish combat consistancy
# Decrease this in case of false positives
KILLAURA_FIGHTSPEED_MINDIFF: 3
# The maximum angle difference allowed when placing or breaking a block # The maximum angle difference allowed when placing or breaking a block
# Increase this in case of false positives, can be slightly decreased to tighten check # Increase this in case of false positives, can be slightly decreased to tighten check
ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75 ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75
@@ -266,3 +271,10 @@ MIN_HEAL_TIME: 490
# Maximum distance allowed between two movement packets # Maximum distance allowed between two movement packets
# Increase this in case of false positives # Increase this in case of false positives
BADPACKETS_MAX_DISTANCE: 25.0 BADPACKETS_MAX_DISTANCE: 25.0
# Maximum amount of fastladder movements before flagging
# Increase this in case of false positives
FASTLADDER_MAX_FLAGS: 3
# The change milliseconds between two keepalives before considering a player to be lagging
# Decrease this in case of clientside lag-related false positives
# Do not lower below 50 or increase above 75
LAG_DETERMINATION: 60
+36 -24
View File
@@ -49,7 +49,7 @@ permissions:
anticheat.check.flight: anticheat.check.flight:
description: Allow players to use fly cheats description: Allow players to use fly cheats
default: false default: false
anticheat.check.elytra: anticheat.check.elytrafly:
description: Allow players to use ElytraFly cheats description: Allow players to use ElytraFly cheats
default: false default: false
anticheat.check.waterwalk: anticheat.check.waterwalk:
@@ -64,17 +64,23 @@ permissions:
anticheat.check.fastplace: anticheat.check.fastplace:
description: Allow players to use build hacks and fastplace description: Allow players to use build hacks and fastplace
default: false default: false
anticheat.check.spam: anticheat.check.chatspam:
description: Allow players to spam the server description: Allow players to spam chat messages
default: false
anticheat.check.commandspam:
description: Allow players to spam chat messages
default: false default: false
anticheat.check.sprint: anticheat.check.sprint:
description: Allow players to sprint when hungry description: Allow players to sprint when hungry
default: false default: false
anticheat.check.sneak: anticheat.check.sneak:
description: Allow players to use auto-sneak description: Allow players to use sneak hacks
default: false default: false
anticheat.check.speed: anticheat.check.speed:
description: Allow players to speed description: Allow players to use speed hacks
default: false
anticheat.check.vclip:
description: Allow players clip through walls
default: false default: false
anticheat.check.spider: anticheat.check.spider:
description: Allow players to climb non-climbable surfaces description: Allow players to climb non-climbable surfaces
@@ -97,18 +103,15 @@ permissions:
anticheat.check.longreach: anticheat.check.longreach:
description: Allow players to use longreaching hacks description: Allow players to use longreaching hacks
default: false default: false
anticheat.check.projectile: anticheat.check.unicode:
description: Allow players to quickly launch projectiles description: Allow players to use unicode in chat
default: false
anticheat.check.fastprojectile:
description: Allow players to spam projectiles (fastbow etc.)
default: false default: false
anticheat.check.itemspam: anticheat.check.itemspam:
description: Allow players to use inventory drop spam hacks description: Allow players to use inventory drop spam hacks
default: false default: false
anticheat.check.visual:
description: Allow players to interact with objects out of their view
default: false
anticheat.check.vclip:
description: Allow players to become slimeballs and clip down through blocks
default: false
anticheat.check.fastinventory: anticheat.check.fastinventory:
description: Allow players to use fastloot and similar inventory hacks description: Allow players to use fastloot and similar inventory hacks
default: false default: false
@@ -116,7 +119,10 @@ permissions:
description: Allow players to use autotool to switch tools quickly description: Allow players to use autotool to switch tools quickly
default: false default: false
anticheat.check.morepackets: anticheat.check.morepackets:
description: Allow players to send lots of movement packets description: Allow players to send lots of movement packets or modify their timer
default: false
anticheat.check.badpackets:
description: Allow players to send invalid movement packets
default: false default: false
anticheat.check.velocity: anticheat.check.velocity:
description: Allow players to use knockback prevention description: Allow players to use knockback prevention
@@ -124,25 +130,31 @@ permissions:
anticheat.check.criticals: anticheat.check.criticals:
description: Allow players to use criticals description: Allow players to use criticals
default: false default: false
anticheat.check.unicode:
description: Allow players to use unicode in chat
default: false
anticheat.check.illegalinteract: anticheat.check.illegalinteract:
description: Allow players to place blocks in illegal places description: Allow players to place blocks in illegal places
default: false default: false
anticheat.check.fastladder:
description: Allow players to climb ladders faster
default: false
anticheat.check.aimbot:
description: Allow players to use aimbot
default: false
anticheat.check.exempt: anticheat.check.exempt:
description: Total exemption from checks description: Total exemption from checks
default: false default: false
children: children:
anticheat.check.fly: true anticheat.check.flight: true
anticheat.check.elytrafly: true
anticheat.check.waterwalk: true anticheat.check.waterwalk: true
anticheat.check.noswing: true anticheat.check.noswing: true
anticheat.check.fastbreak: true anticheat.check.fastbreak: true
anticheat.check.fastplace: true anticheat.check.fastplace: true
anticheat.check.spam: true anticheat.check.chatspam: true
anticheat.check.commandspam: true
anticheat.check.sprint: true anticheat.check.sprint: true
anticheat.check.sneak: true anticheat.check.sneak: true
anticheat.check.speed: true anticheat.check.speed: true
anticheat.check.vclip: true
anticheat.check.spider: true anticheat.check.spider: true
anticheat.check.nofall: true anticheat.check.nofall: true
anticheat.check.fastbow: true anticheat.check.fastbow: true
@@ -150,15 +162,15 @@ permissions:
anticheat.check.fastheal: true anticheat.check.fastheal: true
anticheat.check.killaura: true anticheat.check.killaura: true
anticheat.check.longreach: true anticheat.check.longreach: true
anticheat.check.projectile: true anticheat.check.unicode: true
anticheat.check.fastprojectile: true
anticheat.check.itemspam: true anticheat.check.itemspam: true
anticheat.check.visual: true
anticheat.check.vclip: true
anticheat.check.fastinventory: true anticheat.check.fastinventory: true
anticheat.check.autotool: true anticheat.check.autotool: true
anticheat.check.fastanimation: true
anticheat.check.morepackets: true anticheat.check.morepackets: true
anticheat.check.badpackets: true
anticheat.check.velocity: true anticheat.check.velocity: true
anticheat.check.criticals: true anticheat.check.criticals: true
anticheat.check.unicode: true
anticheat.check.illegalinteract: true anticheat.check.illegalinteract: true
anticheat.check.fastladder: true
anticheat.check.aimbot: true