mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
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.
This commit is contained in:
1 parent
12c85b3939
commit
992c67d894
10 files changed
+89
-75
No files matched your search
@@ -51,7 +51,6 @@ import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
@@ -162,6 +161,7 @@ public class Backend {
|
||||
VelocityCheck.VIOLATIONS.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_FALL_DISTANCE.remove(uuid);
|
||||
GlideCheck.VIOLATIONS.remove(uuid);
|
||||
@@ -312,13 +312,14 @@ public class Backend {
|
||||
if (this.fastSneakViolations.containsKey(player.getUniqueId())) {
|
||||
int flags = this.fastSneakViolations.get(player.getUniqueId());
|
||||
if (flags >= 3) { // TODO possible config
|
||||
this.fastSneakViolations.put(player.getUniqueId(), flags - 1);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
|
||||
}
|
||||
this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
|
||||
return PASS;
|
||||
} else {
|
||||
this.fastSneakViolations.put(player.getUniqueId(), 1);
|
||||
this.fastSneakViolations.put(player.getUniqueId(), 0);
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
@@ -799,6 +800,7 @@ public class Backend {
|
||||
|
||||
public void logJoin(final Player player) {
|
||||
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) {
|
||||
|
||||
@@ -26,6 +26,8 @@ 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 {
|
||||
@@ -34,6 +36,10 @@ public class AimbotCheck {
|
||||
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());
|
||||
|
||||
@@ -32,13 +32,13 @@ import org.bukkit.entity.Player;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class GlideCheck {
|
||||
|
||||
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, Integer> AIR_TICKS = 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);
|
||||
|
||||
@@ -48,18 +48,22 @@ public class GlideCheck {
|
||||
VIOLATIONS.put(player.getUniqueId(), 0);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (player.getLocation().getBlock().getType() == Material.LADDER
|
||||
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) {
|
||||
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
|
||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||
double motionY = distance.getYDifference();
|
||||
float fallDistance = player.getFallDistance();
|
||||
@@ -80,34 +84,7 @@ public class GlideCheck {
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()
|
||||
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5
|
||||
&& !Utilities.isNearClimbable(player)
|
||||
&& !player.isSneaking()
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)
|
||||
&& !Utilities.isInWater(player)) {
|
||||
// TODO change this, way too much falses
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO redo this
|
||||
}
|
||||
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||
@@ -117,10 +94,6 @@ public class GlideCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static float calculateNextMotionY(float motionY) {
|
||||
return (motionY - 0.08f) * 0.98f;
|
||||
}
|
||||
|
||||
private static double distanceToFall(Location location) {
|
||||
location = location.clone();
|
||||
double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D;
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
public class MorePacketsCheck {
|
||||
|
||||
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 final Map<UUID, Double> PACKET_BALANCE = new HashMap<UUID, Double>();
|
||||
|
||||
public static void runCheck(Player player, PacketEvent event) {
|
||||
@@ -50,6 +51,9 @@ public class MorePacketsCheck {
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
|
||||
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) {
|
||||
return;
|
||||
}
|
||||
long packetTimeNow = System.currentTimeMillis();
|
||||
long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L);
|
||||
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
|
||||
|
||||
@@ -50,6 +50,8 @@ public class Config extends ConfigurationFile {
|
||||
|
||||
public ConfigValue<List<String>> disabledWorlds;
|
||||
public ConfigValue<List<String>> disabledChecks;
|
||||
|
||||
public ConfigValue<Integer> notifyEveryVl;
|
||||
|
||||
public Config(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
@@ -80,5 +82,10 @@ public class Config extends ConfigurationFile {
|
||||
|
||||
disabledWorlds = new ConfigValue<List<String>>("disable-in");
|
||||
disabledChecks = new ConfigValue<List<String>>("disabled-checks");
|
||||
|
||||
notifyEveryVl = new ConfigValue<Integer>("system.notify-every-vl");
|
||||
if (notifyEveryVl.getValue() < 1) {
|
||||
notifyEveryVl.setValue(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,27 +50,47 @@ public class EventListener implements Listener {
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
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("")) {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ CheckType.getName(type);
|
||||
if (debugMode) {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ CheckType.getName(type);
|
||||
} else {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ CheckType.getName(type) + ChatColor.GOLD + " (x" + vlForType + ")";
|
||||
}
|
||||
} else {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||
}
|
||||
if (user != null) { // npc
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type)) {
|
||||
AntiCheatReloaded.getManager().log(message);
|
||||
if (debugMode) {
|
||||
message = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + player.getName() + " failed "
|
||||
+ CheckType.getName(type) + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||
+ ", 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());
|
||||
}
|
||||
removeDecrease(user);
|
||||
}
|
||||
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
|
||||
AntiCheatReloaded.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
|
||||
if (CONFIG.getConfig().debugMode.getValue()) {
|
||||
if (debugMode) {
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vlForType % notifyEveryVl == 0) {
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
|
||||
@@ -37,7 +37,6 @@ public class PacketListener {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
// Run MorePackets check
|
||||
MorePacketsCheck.runCheck(player, event);
|
||||
@@ -51,7 +50,6 @@ public class PacketListener {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
|
||||
// Compensate for teleport
|
||||
MorePacketsCheck.compensate(player);
|
||||
|
||||
@@ -23,10 +23,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum Permission {
|
||||
/* 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_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_FASTLADDER, CHECK_AIMBOT,
|
||||
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER, CHECK_AIMBOT,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_MUTE;
|
||||
|
||||
Reference in new issue
Block a user