From 2086a01f80c42e0c5173a96cbecd081086338be0 Mon Sep 17 00:00:00 2001 From: Rammelkast Date: Sun, 12 Jul 2020 14:04:18 +0200 Subject: [PATCH] Added NoSlowdown, migrations to new config --- .../anticheatreloaded/AntiCheatReloaded.java | 16 +- .../anticheatreloaded/check/Backend.java | 5 - .../check/combat/CriticalsCheck.java | 1 + .../check/combat/KillAuraCheck.java | 2 - .../check/movement/NoSlowdownCheck.java | 23 --- .../check/movement/SpeedCheck.java | 13 +- .../check/packet/MorePacketsCheck.java | 13 +- .../command/CommandHandler.java | 4 +- .../command/executors/CommandCheck.java | 98 ---------- .../command/executors/CommandChecks.java | 57 ++++++ .../command/executors/CommandHelp.java | 2 +- .../config/files/Config.java | 2 - .../config/holders/yaml/YamlChecksHolder.java | 12 +- .../event/BlockListener.java | 1 - .../manage/CheckManager.java | 16 +- .../util/MovementManager.java | 6 +- .../util/PacketListener.java | 79 ++++---- .../anticheatreloaded/util/XMaterial.java | 3 - src/main/resources/checks.yml | 174 ++++++++++++++---- src/main/resources/config.yml | 4 +- 20 files changed, 288 insertions(+), 243 deletions(-) delete mode 100644 src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowdownCheck.java delete mode 100644 src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandCheck.java create mode 100644 src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandChecks.java diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java index 31dda47..673a64b 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java @@ -34,7 +34,6 @@ import org.bukkit.scheduler.BukkitRunnable; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; -import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck; import com.rammelkast.anticheatreloaded.command.CommandHandler; import com.rammelkast.anticheatreloaded.config.Configuration; import com.rammelkast.anticheatreloaded.event.BlockListener; @@ -89,17 +88,18 @@ public class AntiCheatReloaded extends JavaPlugin { if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { this.setupProtocol(); } else { - Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED + "Shutting down, ProtocolLib not found!"); + Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.RED + + "Could not find ProtocolLib. Shutting down!"); Bukkit.getPluginManager().disablePlugin(this); return; } - getLogger().info("NMS version is " + VersionUtil.getVersion()); - if (!VersionUtil.isSupported()) { - Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED - + "The version of this server is NOT supported by ACR! The plugin will not work as expected!"); - } - + Bukkit.getConsoleSender() + .sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + + "Running Minecraft version " + VersionUtil.getVersion() + " " + + (VersionUtil.isSupported() ? (ChatColor.GREEN + "(supported)") + : (ChatColor.RED + "(NOT SUPPORTED!)"))); + getLogger().info("Enabling packet listeners"); PacketListener.listenKeepAlivePackets(); PacketListener.listenMovementPackets(); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index d542fcb..e52a4d5 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.rammelkast.anticheatreloaded.check; import java.util.ArrayList; @@ -758,10 +757,6 @@ public class Backend { FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME()); } - public void logToggleSneak(final Player player) { - FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME()); - } - public void logTeleport(final Player player) { manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System.currentTimeMillis(); /* Data for fly/speed should be reset */ diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java index 4c0bacc..75b4dca 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/CriticalsCheck.java @@ -46,6 +46,7 @@ public class CriticalsCheck { } } + @SuppressWarnings("deprecation") private static boolean isCritical(Player player) { return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java index 051932e..6599c3c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/combat/KillAuraCheck.java @@ -27,12 +27,10 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; -import com.rammelkast.anticheatreloaded.util.MovementManager; import com.rammelkast.anticheatreloaded.util.User; public class KillAuraCheck { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowdownCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowdownCheck.java deleted file mode 100644 index 0b8cb64..0000000 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/NoSlowdownCheck.java +++ /dev/null @@ -1,23 +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 . - */ -package com.rammelkast.anticheatreloaded.check.movement; - -public class NoSlowdownCheck { - -} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java index f85814f..feb1c29 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/SpeedCheck.java @@ -105,10 +105,14 @@ public class SpeedCheck { // Players can move faster in air with slow falling if (VersionUtil.isSlowFalling(player)) predict *= 1.25D; + // Prevent NoSlow + // TODO better way for this + if (player.isBlocking() && movementManager.airTicks > 2) + predict *= 0.8D; if (distanceXZ - predict > limit) { return new CheckResult(CheckResult.Result.FAILED, - "moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ")"); + "moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", blocking=" + player.isBlocking() + ")"); } } @@ -175,14 +179,19 @@ public class SpeedCheck { limit *= 1.25D; } } + // Increased speed when stepping on/off half blocks if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards) || Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0))) limit *= 2.0D; + // Increased speed when stepping on/off boat if (Utilities.couldBeOnBoat(player)) limit += 0.2D; + // Prevent NoSlow + if (player.isBlocking() && movementManager.groundTicks > 2) + limit *= 0.45D; if (distanceXZ - limit > 0) { return new CheckResult(CheckResult.Result.FAILED, - "moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ")"); + "moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")"); } } return PASS; diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java index 29147e2..5396542 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/packet/MorePacketsCheck.java @@ -29,6 +29,7 @@ import com.comphenix.protocol.events.PacketEvent; import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType; +import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Magic; import com.rammelkast.anticheatreloaded.event.EventListener; @@ -50,7 +51,7 @@ public class MorePacketsCheck { } UUID uuid = player.getUniqueId(); - Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic(); + Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) { return; } @@ -61,13 +62,15 @@ public class MorePacketsCheck { long rate = packetTimeNow - lastPacketTime; packetBalance += 50; packetBalance -= rate; - if (packetBalance >= magic.MOREPACKETS_TRIGGER_BALANCE()) { + int triggerBalance = checksConfig.getInteger(CheckType.MOREPACKETS, "triggerBalance"); + int minimumClamp = checksConfig.getInteger(CheckType.MOREPACKETS, "minimumClamp"); + if (packetBalance >= triggerBalance) { int ticks = (int) Math.round(packetBalance / 50); - packetBalance = -1 * (magic.MOREPACKETS_TRIGGER_BALANCE() / 2); + packetBalance = -1 * (triggerBalance / 2); flag(player, event, "overshot timer by " + ticks + " tick(s)"); - } else if (packetBalance < -1 * (magic.MOREPACKETS_MINIMUM_CLAMP())) { + } else if (packetBalance < -1 * minimumClamp) { // Clamp minimum, 50ms=1tick of lag leniency - packetBalance = -1 * (magic.MOREPACKETS_MINIMUM_CLAMP()); + packetBalance = -1 * minimumClamp; } LAST_PACKET_TIME.put(uuid, packetTimeNow); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java index f32e79a..45e7a6f 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/command/CommandHandler.java @@ -26,7 +26,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import com.rammelkast.anticheatreloaded.command.executors.CommandCheck; +import com.rammelkast.anticheatreloaded.command.executors.CommandChecks; import com.rammelkast.anticheatreloaded.command.executors.CommandHelp; import com.rammelkast.anticheatreloaded.command.executors.CommandLog; import com.rammelkast.anticheatreloaded.command.executors.CommandMute; @@ -41,7 +41,7 @@ public class CommandHandler implements CommandExecutor { public CommandHandler() { commands.add(new CommandHelp()); - commands.add(new CommandCheck()); + commands.add(new CommandChecks()); commands.add(new CommandLog()); commands.add(new CommandReload()); commands.add(new CommandReport()); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandCheck.java deleted file mode 100644 index 9090a7c..0000000 --- a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandCheck.java +++ /dev/null @@ -1,98 +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 . - */ - -package com.rammelkast.anticheatreloaded.command.executors; - -import org.bukkit.command.CommandSender; - -import com.rammelkast.anticheatreloaded.check.CheckType; -import com.rammelkast.anticheatreloaded.command.CommandBase; -import com.rammelkast.anticheatreloaded.util.Permission; - -import java.util.List; - -public class CommandCheck extends CommandBase { - - private static final String NAME = "AntiCheatReloaded Check Management"; - private static final String COMMAND = "check"; - private static final String USAGE = "anticheat check [check] [on/off]"; - private static final Permission PERMISSION = Permission.SYSTEM_CHECK; - private static final String[] HELP = new String[3]; - - static { - HELP[0] = GRAY + "Use: " + AQUA + "/anticheat check [check] on" + GRAY + " to enable a check"; - HELP[1] = GRAY + "Use: " + AQUA + "/anticheat check [check] off" + GRAY + " to disable a check"; - StringBuilder builder = new StringBuilder(); - builder.append(GRAY + "Checks: "); - for (int i=0;i checks = CONFIG.getConfig().disabledChecks.getValue(); - if (checks.contains(type.toString())) { - checks.remove(type.toString()); - CONFIG.getConfig().disabledChecks.setValue(checks); - } - } else { - CHECK_MANAGER.deactivateCheck(type, cs.getName()); - List checks = CONFIG.getConfig().disabledChecks.getValue(); - checks.add(type.toString()); - CONFIG.getConfig().disabledChecks.setValue(checks); - } - cs.sendMessage(GREEN + type.toString() + strValue + "."); - } - return; - } - } - } - sendHelp(cs); - } -} diff --git a/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandChecks.java b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandChecks.java new file mode 100644 index 0000000..b81e43b --- /dev/null +++ b/src/main/java/com/rammelkast/anticheatreloaded/command/executors/CommandChecks.java @@ -0,0 +1,57 @@ +/* + * 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 . + */ + +package com.rammelkast.anticheatreloaded.command.executors; + +import org.bukkit.command.CommandSender; + +import com.rammelkast.anticheatreloaded.check.CheckType; +import com.rammelkast.anticheatreloaded.command.CommandBase; +import com.rammelkast.anticheatreloaded.util.Permission; + +public class CommandChecks extends CommandBase { + + private static final String NAME = "AntiCheatReloaded Checks Management"; + private static final String COMMAND = "checks"; + private static final String USAGE = "anticheat checks"; + private static final Permission PERMISSION = Permission.SYSTEM_CHECK; + private static final String[] HELP = new String[2]; + + static { + HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks"; + StringBuilder builder = new StringBuilder(); + builder.append(GRAY + "Checks: "); + for (int i=0;i logToFile; public ConfigValue> disabledWorlds; - public ConfigValue> disabledChecks; public ConfigValue notifyEveryVl; @@ -81,7 +80,6 @@ public class Config extends ConfigurationFile { logToFile = new ConfigValue("system.log-to-file"); disabledWorlds = new ConfigValue>("disable-in"); - disabledChecks = new ConfigValue>("disabled-checks"); notifyEveryVl = new ConfigValue("system.notify-every-vl"); if (notifyEveryVl.getValue() < 1) { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java index 3fe11cc..da5c816 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/config/holders/yaml/YamlChecksHolder.java @@ -18,6 +18,9 @@ */ package com.rammelkast.anticheatreloaded.config.holders.yaml; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; + import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.config.Configuration; @@ -78,8 +81,13 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks { @Override public boolean isEnabled(CheckType checkType) { // If the root of a check has no enabled or disabled option, it has to be configured on a subcheck basis - if (!this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).contains("enabled")) + if (!this.getConfigFile().isConfigurationSection(checkType.getName().toLowerCase())) { + Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED + + "Missing configuration settings for " + checkType.getName() + "!"); return true; - return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getBoolean("enabled"); + } + if (!this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).contains("enabled")) + return true; + return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean("enabled"); } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java index e6ce259..c2bbb20 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/event/BlockListener.java @@ -31,7 +31,6 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded; import com.rammelkast.anticheatreloaded.check.CheckResult; import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.player.IllegalInteract; -import com.rammelkast.anticheatreloaded.util.Distance; import com.rammelkast.anticheatreloaded.util.Utilities; public class BlockListener extends EventListener { diff --git a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java index dd48a5d..1f5c6d5 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/manage/CheckManager.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; import com.rammelkast.anticheatreloaded.check.CheckType; @@ -47,14 +48,17 @@ public class CheckManager { this.manager = manager; this.config = manager.getConfiguration(); - for (String string : config.getConfig().disabledChecks.getValue()) { - for (CheckType type : CheckType.values()) { - if (type.toString().equalsIgnoreCase(string)) { - checkIgnoreList.add(type); - break; - } + for (CheckType type : CheckType.values()) { + if (!config.getChecks().isEnabled(type)) { + checkIgnoreList.add(type); + break; } } + + if (!checkIgnoreList.isEmpty()) { + Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY + + checkIgnoreList.size() + " check(s) have been disabled"); + } } /** diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java index d527547..ad4569c 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/MovementManager.java @@ -18,12 +18,7 @@ */ package com.rammelkast.anticheatreloaded.util; -import java.util.ArrayList; -import java.util.List; - import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.entity.Player; public class MovementManager { @@ -69,6 +64,7 @@ public class MovementManager { // Elytra effect ticks public int elytraEffectTicks; + @SuppressWarnings("deprecation") public void handle(Player player, Location from, Location to, Distance distance) { this.onGround = player.isOnGround(); // TODO temp solution, can be spoofed diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java b/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java index b00d4cc..6ad5706 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/PacketListener.java @@ -32,46 +32,49 @@ public class PacketListener { public static void listenMovementPackets() { AntiCheatReloaded.getProtocolManager() - .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, - new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Server.POSITION }) { - @Override - public void onPacketReceiving(PacketEvent event) { - Player player = event.getPlayer(); - - // Run MorePackets check - MorePacketsCheck.runCheck(player, event); - - if (!event.isCancelled()) { - // Run BadPackets check - BadPacketsCheck.runCheck(player, event); - } - } - - @Override - public void onPacketSending(PacketEvent event) { - Player player = event.getPlayer(); - // Compensate for teleport - MorePacketsCheck.compensate(player); - } - }); + .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, + new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, + PacketType.Play.Server.POSITION }) { + @Override + public void onPacketReceiving(PacketEvent event) { + Player player = event.getPlayer(); + + // Run MorePackets check + MorePacketsCheck.runCheck(player, event); + + if (!event.isCancelled()) { + // Run BadPackets check + BadPacketsCheck.runCheck(player, event); + } + } + + @Override + public void onPacketSending(PacketEvent event) { + Player player = event.getPlayer(); + // Compensate for teleport + MorePacketsCheck.compensate(player); + } + }); } - + public static void listenKeepAlivePackets() { AntiCheatReloaded.getProtocolManager() - .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, - new PacketType[] { PacketType.Play.Client.KEEP_ALIVE, PacketType.Play.Server.KEEP_ALIVE }) { - @Override - public void onPacketSending(PacketEvent event) { - User user = AntiCheatReloaded.getManager().getUserManager().getUser(event.getPlayer().getUniqueId()); - user.onServerPing(); - } - - @Override - public void onPacketReceiving(PacketEvent event) { - User user = AntiCheatReloaded.getManager().getUserManager().getUser(event.getPlayer().getUniqueId()); - user.onClientPong(); - } - }); + .addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST, + new PacketType[] { PacketType.Play.Client.KEEP_ALIVE, PacketType.Play.Server.KEEP_ALIVE }) { + @Override + public void onPacketSending(PacketEvent event) { + User user = AntiCheatReloaded.getManager().getUserManager() + .getUser(event.getPlayer().getUniqueId()); + user.onServerPing(); + } + + @Override + public void onPacketReceiving(PacketEvent event) { + User user = AntiCheatReloaded.getManager().getUserManager() + .getUser(event.getPlayer().getUniqueId()); + user.onClientPong(); + } + }); } - + } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/XMaterial.java b/src/main/java/com/rammelkast/anticheatreloaded/util/XMaterial.java index 12e074d..51a8b03 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/XMaterial.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/XMaterial.java @@ -1250,7 +1250,6 @@ public enum XMaterial { * * @since 3.0.0 */ - @SuppressWarnings("UnstableApiUsage") private static final ImmutableMap duplicated = Maps.immutableEnumMap(ImmutableMap.builder() .put(MELON, MELON_SLICE) .put(CARROT, CARROTS) @@ -1906,7 +1905,6 @@ public enum XMaterial { * @return data of this material, or 0 if none. * @since 1.0.0 */ - @SuppressWarnings("deprecation") public byte getData() { return data; } @@ -1974,7 +1972,6 @@ public enum XMaterial { * @return the material related to this XMaterial based on the server version. * @since 2.0.0 */ - @SuppressWarnings("OptionalAssignedToNull") @Nullable public Material parseMaterial(boolean suggest) { Optional cache = PARSED_CACHE.getIfPresent(this); diff --git a/src/main/resources/checks.yml b/src/main/resources/checks.yml index bc096d2..35242f6 100644 --- a/src/main/resources/checks.yml +++ b/src/main/resources/checks.yml @@ -1,4 +1,46 @@ # AntiCheatReloaded checks configuration file +# Flight check settings +flight: + # Checks for gliding behaviour + # Debugs as 'had gliding behaviour' + glide: + # Should this part of the check be enabled? + enabled: true + # Amount of glide-like moves before flagging + vlBeforeFlag: 3 + # Checks for prolonged air movement + # Debugs as 'tried to fly on the Y-axis' or 'had too little Y dropoff' + airFlight: + # Should this part of the check be enabled? + enabled: true + # How many milliseconds to account for block placement + # Increase this if you get false positives when building a tower + accountForBlockPlacement: 1200 + # How many milliseconds to account for TPS drops + # Increase this if you get false positives when building a tower during TPS drops + accountForTpsDrops: 250 + # How many milliseconds to account for teleports + # Increase this is you debug 'had too little Y dropoff' after teleports + accountForTeleports: 50 + # Checks for climbing behaviour in air + # Debugs as 'tried to climb air' + airClimb: + # Should this part of the check be enabled? + enabled: true + # How many milliseconds to account for teleports + # Increase this is you debug 'tried to climb air' after teleports + accountForTeleports: 50 + # Checks if a player is faking it's ground status to fly + # Debugs as 'faked ground to fly' + groundFlight: + # Should this part of the check be enabled? + enabled: true + +# ElytraFly check settings +elytrafly: + # Should this check be enabled? + enabled: true + # Speed check settings speed: # Checks movement speed in the air @@ -45,42 +87,10 @@ speed: # Extra compensation when moving off a ladder up a slab climbableCompensation: 0.04 -# Flight check settings -flight: - # Checks for gliding behaviour - # Debugs as 'had gliding behaviour' - glide: - # Should this part of the check be enabled? - enabled: true - # Amount of glide-like moves before flagging - vlBeforeFlag: 3 - # Checks for prolonged air movement - # Debugs as 'tried to fly on the Y-axis' or 'had too little Y dropoff' - airFlight: - # Should this part of the check be enabled? - enabled: true - # How many milliseconds to account for block placement - # Increase this if you get false positives when building a tower - accountForBlockPlacement: 1200 - # How many milliseconds to account for TPS drops - # Increase this if you get false positives when building a tower during TPS drops - accountForTpsDrops: 250 - # How many milliseconds to account for teleports - # Increase this is you debug 'had too little Y dropoff' after teleports - accountForTeleports: 50 - # Checks for climbing behaviour in air - # Debugs as 'tried to climb air' - airClimb: - # Should this part of the check be enabled? - enabled: true - # How many milliseconds to account for teleports - # Increase this is you debug 'tried to climb air' after teleports - accountForTeleports: 50 - # Checks if a player is faking it's ground status to fly - # Debugs as 'faked ground to fly' - groundFlight: - # Should this part of the check be enabled? - enabled: true +# WaterWalk check settings +waterwalk: + # Should this check be enabled? + enabled: true # FastLadder check settings fastladder: @@ -150,6 +160,16 @@ velocity: # Amount of zero-velocity moments before flagging vlBeforeFlag: 3 +# FastBreak check settings +fastbreak: + # Should this check be enabled? + enabled: true + +# FastPlace check settings +fastplace: + # Should this check be enabled? + enabled: true + # IllegalInteract check settings illegalinteract: # Maximum difference in angle from the players view @@ -189,4 +209,84 @@ morepackets: disableForLagging: false # Maximum ping value before MorePackets stops checking a player (-1 to disable) # This can easily be spoofed by clients! - maxPing: -1 \ No newline at end of file + maxPing: -1 + +# Sneak check settings +sneak: + # Should this check be enabled? + enabled: true + +# Spider check settings +spider: + # Should this check be enabled? + enabled: true + +# NoFall check settings +nofall: + # Should this check be enabled? + enabled: true + +# NoSwing check settings +noswing: + # Should this check be enabled? + enabled: true + +# Sprint check settings +sprint: + # Should this check be enabled? + enabled: true + +# FastBow check settings +fastbow: + # Should this check be enabled? + enabled: true + +# FastEat check settings +fasteat: + # Should this check be enabled? + enabled: true + +# FastHeal check settings +fastheal: + # Should this check be enabled? + enabled: true + +# FastProjectile check settings +fastprojectile: + # Should this check be enabled? + enabled: true + +# ItemSpam check settings +itemspam: + # Should this check be enabled? + enabled: true + +# FastInventory check settings +fastinventory: + # Should this check be enabled? + enabled: true + +# AutoTool check settings +autotool: + # Should this check be enabled? + enabled: true + +# vClip check settings +vclip: + # Should this check be enabled? + enabled: true + +# ChatUnicode check settings +chatunicode: + # Should this check be enabled? + enabled: true + +# ChatSpam check settings +chatspam: + # Should this check be enabled? + enabled: true + +# CommandSpam check settings +commandspam: + # Should this check be enabled? + enabled: true \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a011fea..088e28b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -38,9 +38,7 @@ system: # 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 -disabled-checks: -- EXAMPLE_CHECK +# Use /AntiCheatReloaded checks for a list of valid checks disable-in: - example-world - example-world-2