From f850c3ab96fa639c28780c951a288e849578150b Mon Sep 17 00:00:00 2001 From: h31ix Date: Sun, 9 Sep 2012 14:19:51 -0400 Subject: [PATCH] Let's see if we still need this dependency :D --- pom.xml | 9 +- .../net/h31ix/anticheat/manage/Backend.java | 95 +++++++++---------- .../net/h31ix/anticheat/util/Utilities.java | 15 --- 3 files changed, 47 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 640b2a4..6a8b559 100644 --- a/pom.xml +++ b/pom.xml @@ -45,13 +45,6 @@ 1.3.2-R0.1 jar compile - - - com.gmail.nossr50 - mcMMO - 1.3.08 - jar - compile - + \ No newline at end of file diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 51aff8f..d514654 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -294,7 +294,7 @@ public class Backend public boolean checkLongReachBlock(Player player, double x, double y, double z) { - return !Utilities.isUsingMcMMOAbility(player) && (x >= BLOCK_MAX_DISTANCE || y > BLOCK_MAX_DISTANCE || z > BLOCK_MAX_DISTANCE); + return (x >= BLOCK_MAX_DISTANCE || y > BLOCK_MAX_DISTANCE || z > BLOCK_MAX_DISTANCE); } public boolean checkLongReachDamage(double x, double y, double z) @@ -745,71 +745,68 @@ public class Backend public boolean checkSwing(Player player, Block block) { - return !player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !justAnimated(player) && !Utilities.isUsingMcMMOAbility(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES); + return !player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES); } public boolean checkFastBreak(Player player, Block block) { - if (!Utilities.isUsingMcMMOAbility(player)) + int violations = FASTBREAK_MAXVIOLATIONS; + if (player.getGameMode() == GameMode.CREATIVE) { - int violations = FASTBREAK_MAXVIOLATIONS; - if (player.getGameMode() == GameMode.CREATIVE) + violations = FASTBREAK_MAXVIOLATIONS_CREATIVE; + } + String name = player.getName(); + if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) + { + if (blockPunches.get(name) != null && player.getGameMode() != GameMode.CREATIVE) { - violations = FASTBREAK_MAXVIOLATIONS_CREATIVE; - } - String name = player.getName(); - if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES)) - { - if (blockPunches.get(name) != null && player.getGameMode() != GameMode.CREATIVE) + int i = blockPunches.get(name); + if (i < BLOCK_PUNCH_MIN) { - int i = blockPunches.get(name); - if (i < BLOCK_PUNCH_MIN) - { - return true; - } + return true; } - if (!fastBreakViolation.containsKey(name)) + } + if (!fastBreakViolation.containsKey(name)) + { + fastBreakViolation.put(name, 0); + } + else + { + Long math = System.currentTimeMillis() - lastBlockBroken.get(name); + if (fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME) + { + lastBlockBroken.put(name, System.currentTimeMillis()); + player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks."); + return true; + } + else if (fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME) { fastBreakViolation.put(name, 0); } - else + } + if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name)) + { + if (!lastBlockBroken.containsKey(name)) { - Long math = System.currentTimeMillis() - lastBlockBroken.get(name); - if (fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME) - { - lastBlockBroken.put(name, System.currentTimeMillis()); - player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks."); - return true; - } - else if (fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME) - { - fastBreakViolation.put(name, 0); - } + lastBlockBroken.put(name, System.currentTimeMillis()); } - if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name)) + blocksBroken.put(name, 0); + } + else + { + blocksBroken.put(name, blocksBroken.get(name) + 1); + Long math = System.currentTimeMillis() - lastBlockBroken.get(name); + if (blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX) { - if (!lastBlockBroken.containsKey(name)) - { - lastBlockBroken.put(name, System.currentTimeMillis()); - } blocksBroken.put(name, 0); + lastBlockBroken.put(name, System.currentTimeMillis()); + fastBreakViolation.put(name, fastBreakViolation.get(name) + 1); + return true; } - else + else if (blocksBroken.get(name) > FASTBREAK_LIMIT) { - blocksBroken.put(name, blocksBroken.get(name) + 1); - Long math = System.currentTimeMillis() - lastBlockBroken.get(name); - if (blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX) - { - blocksBroken.put(name, 0); - lastBlockBroken.put(name, System.currentTimeMillis()); - fastBreakViolation.put(name, fastBreakViolation.get(name) + 1); - return true; - } - else if (blocksBroken.get(name) > FASTBREAK_LIMIT) - { - lastBlockBroken.put(name, System.currentTimeMillis()); - blocksBroken.put(name, 0); - } + lastBlockBroken.put(name, System.currentTimeMillis()); + blocksBroken.put(name, 0); } } } diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index a6a6034..b0200c1 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -18,8 +18,6 @@ package net.h31ix.anticheat.util; -import com.gmail.nossr50.datatypes.AbilityType; -import com.gmail.nossr50.mcMMO; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -110,19 +108,6 @@ public final class Utilities return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily; } - public static boolean isUsingMcMMOAbility(Player player) - { - boolean b = false; - if (player.getServer().getPluginManager().getPlugin("mcMMO") != null) - { - if (mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING)) - { - b = true; - } - } - return b; - } - public static boolean isSubmersed(Player player) { return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();