diff --git a/pom.xml b/pom.xml index e605ad1..1ef6af1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.rammelkast.anticheatreloaded AntiCheatReloaded - 1.6.3-ALPHA + 1.6.4-ALPHA AntiCheatReloaded https://rammelkast.com diff --git a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java index cbf9146..4f575b5 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/AntiCheatReloaded.java @@ -70,17 +70,17 @@ public class AntiCheatReloaded extends JavaPlugin { eventList.add(new InventoryListener()); // Order is important in some cases, don't screw with these unless // needed, especially config - setupConfig(); - setupEvents(); - setupCommands(); + this.setupConfig(); + this.setupEvents(); + this.setupCommands(); // Enterprise must come before levels - setupEnterprise(); - restoreLevels(); + this.setupEnterprise(); + this.restoreLevels(); if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) { - setupProtocol(); + this.setupProtocol(); } else { - getLogger().severe("Shutting down, ProtocolLib not found!"); + Bukkit.getConsoleSender().sendMessage("[ACR] " + ChatColor.RED + "Shutting down, ProtocolLib not found!"); Bukkit.getPluginManager().disablePlugin(this); return; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java index b33e35d..3c3b57b 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/Backend.java @@ -431,7 +431,7 @@ public class Backend { public CheckResult checkSwing(Player player, Block block) { UUID uuid = player.getUniqueId(); if (!isInstantBreakExempt(player)) { - if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) { + if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType() == Material.LEAVES)) { if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) { int i = blockPunches.get(uuid); if (i < magic.BLOCK_PUNCH_MIN()) { @@ -447,7 +447,7 @@ public class Backend { public CheckResult checkFastBreak(Player player, Block block) { int violations = magic.FASTBREAK_MAXVIOLATIONS(); - long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(player.getInventory().getItemInHand(), block.getType()); + long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType()); if (player.getGameMode() == GameMode.CREATIVE) { violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE(); timemax = magic.FASTBREAK_TIMEMAX_CREATIVE(); @@ -634,8 +634,8 @@ public class Backend { } public CheckResult checkAutoTool(Player player) { - if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != player.getItemInHand().getType()) { - return new CheckResult(CheckResult.Result.FAILED, player.getName() + " switched tools too fast (had " + itemInHand.get(player.getName()) + ", has " + player.getItemInHand().getType() + ")"); + if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) { + return new CheckResult(CheckResult.Result.FAILED, player.getName() + " switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has " + VersionUtil.getItemInHand(player).getType() + ")"); } else { return PASS; } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java index c150504..19aaa57 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/check/movement/GlideCheck.java @@ -57,6 +57,8 @@ public class GlideCheck { violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1); } } + } else { + // TODO more sophisticated check } lastDiff.put(player.getUniqueId(), distance.getYDifference()); lastFallDistance.put(player.getUniqueId(), player.getFallDistance()); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java index 754ee0d..3d851e6 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/config/files/Config.java @@ -29,7 +29,6 @@ public class Config extends ConfigurationFile { public static final String FILENAME = "config.yml"; public ConfigValue logToConsole; - public ConfigValue autoUpdate; public ConfigValue verboseStartup; public ConfigValue silentMode; public ConfigValue exemptOp; @@ -59,7 +58,6 @@ public class Config extends ConfigurationFile { public void open() { logToConsole = new ConfigValue("system.log-to-console"); - autoUpdate = new ConfigValue("system.auto-update"); verboseStartup = new ConfigValue("system.verbose-startup"); silentMode = new ConfigValue("system.silent-mode"); exemptOp = new ConfigValue("system.exempt-op"); diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/NMS_1_9_PLUS.java b/src/main/java/com/rammelkast/anticheatreloaded/util/NMS_1_9_PLUS.java index 9f82986..14e063e 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/NMS_1_9_PLUS.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/NMS_1_9_PLUS.java @@ -4,6 +4,8 @@ import java.util.EnumSet; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; public class NMS_1_9_PLUS { @@ -17,5 +19,9 @@ public class NMS_1_9_PLUS { static final PotionEffectType LEVITATION = PotionEffectType.LEVITATION; static final Enchantment FROST_WALKER = Enchantment.FROST_WALKER; + + public static ItemStack getItemInHand(Player player) { + return player.getInventory().getItemInMainHand(); + } } diff --git a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java index 2959b63..ad02ccb 100644 --- a/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java +++ b/src/main/java/com/rammelkast/anticheatreloaded/util/VersionUtil.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; public class VersionUtil { @@ -79,5 +80,13 @@ public class VersionUtil { return false; } } + + public static ItemStack getItemInHand(Player player) { + if (getVersion().startsWith("v1_9") || getVersion().startsWith("v1_10") || getVersion().startsWith("v1_11") || getVersion().startsWith("v1_12")) { + return NMS_1_9_PLUS.getItemInHand(player); + } else { + return player.getItemInHand(); + } + } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e45607b..b9a116d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -15,8 +15,6 @@ spam: action-one: KICK action-two: BAN system: - # Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually. - auto-update: true # Should AntiCheatReloaded log ALL failed checks to console? log-to-console: false # Should AntiCheatReloaded log to file? diff --git a/src/main/resources/enterprise.yml b/src/main/resources/enterprise.yml index 5ad3eb9..1a8b976 100644 --- a/src/main/resources/enterprise.yml +++ b/src/main/resources/enterprise.yml @@ -17,7 +17,7 @@ database: # Password for the user password: '' # Prefix for the tables - prefix: 'ac_' + prefix: 'acr_' # Database/Schema to use database: 'anticheat' # Logging settings diff --git a/src/main/resources/magic.yml b/src/main/resources/magic.yml index 919ec41..f992d6b 100644 --- a/src/main/resources/magic.yml +++ b/src/main/resources/magic.yml @@ -1,4 +1,9 @@ # AntiCheatReloaded configuration file +# +# This file is not yet fully documented +# For more information on the undocumented values visit: +# https://github.com/Rammelkast/AntiCheatReloaded/blob/master/src/main/java/com/rammelkast/anticheatreloaded/config/providers/Magic.java#L39-L380 +# ANIMATION_INTERACT_MAX: 3 ANIMATION_MIN: 200 ASCENSION_COUNT_MAX: 8 @@ -82,7 +87,15 @@ Y_MAXVIOLATIONS: 1 Y_MAXVIOTIME: 5500 Y_SPEED_MAX: 0.5125 Y_TIME: 800 +# Amount of suspicious mid-air movements before a player is suspected of glide +# Increase this in case of false positives GLIDE_LIMIT: 10 +# Amount of hits to a bot before a player is suspected +# Increase this in case of false positives KILLAURA_BOTHITS: 4 +# Maximum amount of movement packets allowed per second +# Increase this in case of false positives BLINK_PACKET: 74 +# Maximum amount of suspected "fake-criticalhits" before a player is suspected +# Increase this in case of false positives VELOCITY_AMT: 5