mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fixes regarding 1.9+ support
This commit is contained in:
1 parent
06c1eab2e6
commit
7ae3f010a3
10 files changed
+43
-17
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -29,7 +29,6 @@ public class Config extends ConfigurationFile {
|
||||
public static final String FILENAME = "config.yml";
|
||||
|
||||
public ConfigValue<Boolean> logToConsole;
|
||||
public ConfigValue<Boolean> autoUpdate;
|
||||
public ConfigValue<Boolean> verboseStartup;
|
||||
public ConfigValue<Boolean> silentMode;
|
||||
public ConfigValue<Boolean> exemptOp;
|
||||
@@ -59,7 +58,6 @@ public class Config extends ConfigurationFile {
|
||||
public void open() {
|
||||
logToConsole = new ConfigValue<Boolean>("system.log-to-console");
|
||||
|
||||
autoUpdate = new ConfigValue<Boolean>("system.auto-update");
|
||||
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
|
||||
silentMode = new ConfigValue<Boolean>("system.silent-mode");
|
||||
exemptOp = new ConfigValue<Boolean>("system.exempt-op");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user