Fix #133 by adding Enchantments to Survival Fastbreak Calculation.

This commit is contained in:
SuPaH sPii committed 2013-01-02 14:06:56 -06:00
1 parent 24d551468c
commit 75959dbdd9
4 files changed
+44 -1

No files matched your search

@@ -75,7 +75,7 @@ public class BlockListener extends EventListener {
final Block block = event.getBlock();
boolean noHack = true;
if (player != null) {
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && !backend.isInstantBreakExempt(player) && backend.checkFastBreak(player, block)) {
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && backend.checkFastBreak(player, block)) {
event.setCancelled(!config.silentMode());
log("tried to break a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_BREAK);
noHack = false;
@@ -1,3 +1,21 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 AntiCheat Team | http://gravitydevelopment.net
*
* 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 <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.util;
import org.bukkit.Material;
@@ -1,3 +1,21 @@
/*
* AntiCheat for Bukkit.
* Copyright (C) 2012 AntiCheat Team | http://gravitydevelopment.net
*
* 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 <http://www.gnu.org/licenses/>.
*/
package net.h31ix.anticheat.util;
import org.bukkit.Material;
@@ -26,8 +26,10 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.NumberConversions;
public final class Utilities {
@@ -182,10 +184,15 @@ public final class Utilities {
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
double bhardness = BlockHardness.getBlockHardness(block);
double thardness = ToolHardness.getToolHardness(tool.getType());
long enchantlvl = (long) tool.getEnchantmentLevel(Enchantment.DIG_SPEED);
long result = (long) ((long) Math.round((bhardness * thardness) * 0.10 * 10000));
result += 150;
if (enchantlvl > 0)
result /= enchantlvl * enchantlvl + 1L;
if (result > 25000)
result = 25000;
else if (result < 0) result = 0;