Remove broken FastBreak and NoSwing, fixed false positives and more config migrations

This commit is contained in:
Rammelkast committed 2020-07-19 12:32:43 +02:00
1 parent 128a668e6c
commit 07f3c3abce
16 files changed
+128 -582

No files matched your search

@@ -29,8 +29,6 @@ import org.bukkit.GameMode;
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.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType;
@@ -60,10 +58,7 @@ public class Backend {
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
private Map<UUID, Integer> commandLevel = new HashMap<UUID, Integer>();
private Map<UUID, Integer> nofallViolation = new HashMap<UUID, Integer>();
private Map<UUID, Integer> fastBreakViolation = new HashMap<UUID, Integer>();
private Map<UUID, Integer> fastBreaks = new HashMap<UUID, Integer>();
private Map<UUID, Boolean> blockBreakHolder = new HashMap<UUID, Boolean>();
private Map<UUID, Long> lastBlockBroken = new HashMap<UUID, Long>();
private Map<UUID, Integer> fastPlaceViolation = new HashMap<UUID, Integer>();
private Map<UUID, Long> lastBlockPlaced = new HashMap<UUID, Long>();
private Map<UUID, Long> lastBlockPlaceTime = new HashMap<UUID, Long>();
@@ -74,7 +69,6 @@ public class Backend {
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
private Map<UUID, Long> projectileTime = new HashMap<UUID, Long>();
private Map<UUID, Long> bowWindUp = new HashMap<UUID, Long>();
private Map<UUID, Long> instantBreakExempt = new HashMap<UUID, Long>();
private Map<UUID, Long> sprinted = new HashMap<UUID, Long>();
private Map<UUID, Long> brokenBlock = new HashMap<UUID, Long>();
public Map<UUID, Long> placedBlock = new HashMap<UUID, Long>();
@@ -127,13 +121,9 @@ public class Backend {
startEat.remove(uuid);
lastHeal.remove(uuid);
sprinted.remove(uuid);
instantBreakExempt.remove(uuid);
isAscending.remove(uuid);
nofallViolation.remove(uuid);
fastBreakViolation.remove(uuid);
fastBreaks.remove(uuid);
blockBreakHolder.remove(uuid);
lastBlockBroken.remove(uuid);
fastPlaceViolation.remove(uuid);
lastBlockPlaced.remove(uuid);
lastBlockPlaceTime.remove(uuid);
@@ -145,7 +135,6 @@ public class Backend {
lastHeal.remove(uuid);
projectileTime.remove(uuid);
bowWindUp.remove(uuid);
instantBreakExempt.remove(uuid);
sprinted.remove(uuid);
brokenBlock.remove(uuid);
placedBlock.remove(uuid);
@@ -219,7 +208,7 @@ public class Backend {
}
return PASS;
}
public CheckResult checkSpider(Player player, double y) {
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN()
&& !Utilities.isClimbableBlock(player.getLocation().getBlock())
@@ -262,45 +251,18 @@ public class Backend {
return PASS;
}
public CheckResult checkSneak(Player player, Location location, double x, double z) {
if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle()
&& !Utilities.cantStandAtExp(location)
&& !Utilities.isSlab(location.getBlock().getRelative(BlockFace.DOWN))) {
double xzMaxSneaking = checksConfig.getDouble(CheckType.SNEAK, "xzMaxSneaking");
double i = x > xzMaxSneaking ? x : z > xzMaxSneaking ? z : -1;
if (i != -1) {
if (this.fastSneakViolations.containsKey(player.getUniqueId())) {
int flags = this.fastSneakViolations.get(player.getUniqueId());
if (flags >= checksConfig.getInteger(CheckType.SNEAK, "vlBeforeFlag")) {
this.fastSneakViolations.put(player.getUniqueId(), flags - 1);
return new CheckResult(CheckResult.Result.FAILED,
"was sneaking too fast (speed=" + i + ", max=" + xzMaxSneaking + ")");
}
this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
return PASS;
} else {
this.fastSneakViolations.put(player.getUniqueId(), 0);
return PASS;
}
} else {
this.fastSneakViolations.remove(player.getUniqueId());
return PASS;
}
} else {
this.fastSneakViolations.remove(player.getUniqueId());
return PASS;
}
}
public CheckResult checkSneakToggle(Player player) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
final long lastSneak = this.lastSneak.getOrDefault(player.getUniqueId(), (long) 0);
this.lastSneak.put(player.getUniqueId(), System.currentTimeMillis());
if (System.currentTimeMillis() - lastSneak < 75
&& (AntiCheatReloaded.getPlugin().getTPS() > 12 && !user.isLagging())) {
if (!this.silentMode()) {
if (System.currentTimeMillis() - lastSneak < checksConfig.getInteger(CheckType.SNEAK, "minToggleTime")
&& (AntiCheatReloaded.getPlugin().getTPS() > checksConfig.getInteger(CheckType.SNEAK, "minimumTps"))) {
if (user.isLagging() && checksConfig.getBoolean(CheckType.SNEAK, "disableForLagging"))
return PASS;
if (!this.silentMode())
player.teleport(user.getGoodLocation(player.getLocation()));
}
return new CheckResult(Result.FAILED,
"toggled sneak too fast (time=" + (System.currentTimeMillis() - lastSneak) + ")");
}
@@ -347,93 +309,11 @@ public class Backend {
}
}
public CheckResult checkSwing(Player player, Block block) {
UUID uuid = player.getUniqueId();
if (!isInstantBreakExempt(player)) {
if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED)
&& !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS
&& block.getType().name().endsWith("LEAVES"))) {
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
int i = blockPunches.get(uuid);
if (i < magic.BLOCK_PUNCH_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType()
+ " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
} else {
blockPunches.put(uuid, 0); // it should reset after EACH block break.
}
}
}
}
return PASS;
}
public CheckResult checkFastBreak(Player player, Block block) {
int violations = magic.FASTBREAK_MAXVIOLATIONS();
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();
}
UUID uuid = player.getUniqueId();
if (!fastBreakViolation.containsKey(uuid)) {
fastBreakViolation.put(uuid, 0);
} else {
Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid);
int i = fastBreakViolation.get(uuid);
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
lastBlockBroken.put(uuid, System.currentTimeMillis());
return new CheckResult(CheckResult.Result.FAILED,
"broke blocks too fast " + i + " times in a row (max=" + violations + ")");
} else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
fastBreakViolation.put(uuid, 0);
}
}
if (!fastBreaks.containsKey(uuid) || !lastBlockBroken.containsKey(uuid)) {
if (!lastBlockBroken.containsKey(uuid)) {
lastBlockBroken.put(uuid, System.currentTimeMillis());
}
if (!fastBreaks.containsKey(uuid)) {
fastBreaks.put(uuid, 0);
}
} else {
Long math = System.currentTimeMillis() - lastBlockBroken.get(uuid);
if ((math != 0L && timemax != 0L)) {
if (math < timemax) {
if (fastBreakViolation.containsKey(uuid) && fastBreakViolation.get(uuid) > 0) {
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
} else {
fastBreaks.put(uuid, fastBreaks.get(uuid) + 1);
}
blockBreakHolder.put(uuid, false);
}
if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() && math < timemax) {
int i = fastBreaks.get(uuid);
fastBreaks.put(uuid, 0);
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math
+ " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)");
} else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) {
if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) {
blockBreakHolder.put(uuid, true);
} else {
fastBreaks.put(uuid, fastBreaks.get(uuid) - 1);
if (fastBreakViolation.get(uuid) > 0) {
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) - 1);
}
blockBreakHolder.put(uuid, false);
}
}
}
}
lastBlockBroken.put(uuid, System.currentTimeMillis()); // always keep a log going.
return PASS;
}
public CheckResult checkFastPlace(Player player) {
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE()
: magic.FASTPLACE_MAXVIOLATIONS();
int vlBeforeFlagSurvival = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagSurvival");
int vlBeforeFlagCreative = checksConfig.getInteger(CheckType.FAST_PLACE, "vlBeforeFlagCreative");
int blockPlacementTime = checksConfig.getInteger(CheckType.FAST_PLACE, "blockPlacementTime");
int violations = player.getGameMode() == GameMode.CREATIVE ? vlBeforeFlagCreative : vlBeforeFlagSurvival;
long time = System.currentTimeMillis();
UUID uuid = player.getUniqueId();
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
@@ -443,11 +323,11 @@ public class Backend {
}
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
if (lastBlockPlaced.get(uuid) > 0 && math < blockPlacementTime) {
lastBlockPlaced.put(uuid, time);
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
+ fastPlaceViolation.get(uuid) + " times in a row (max=" + violations + ")");
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
} else if (lastBlockPlaced.get(uuid) > 0 && math > blockPlacementTime) {
fastPlaceViolation.put(uuid, 0);
}
} else if (lastBlockPlaced.containsKey(uuid)) {
@@ -596,15 +476,6 @@ public class Backend {
}
}
public CheckResult checkSprintDamage(Player player) {
if (isDoing(player, sprinted, magic.SPRINT_MAX())) {
return new CheckResult(CheckResult.Result.FAILED,
"sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)");
} else {
return PASS;
}
}
public CheckResult checkFastHeal(Player player) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
@@ -645,14 +516,6 @@ public class Backend {
return PASS;
}
public void logInstantBreak(final Player player) {
instantBreakExempt.put(player.getUniqueId(), System.currentTimeMillis());
}
public boolean isInstantBreakExempt(Player player) {
return isDoing(player, instantBreakExempt, magic.INSTANT_BREAK_TIME());
}
public void logSprint(final Player player) {
sprinted.put(player.getUniqueId(), System.currentTimeMillis());
}
@@ -39,8 +39,6 @@ public enum CheckType {
FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
ELYTRAFLY(Permission.CHECK_FLIGHT, "ElytraFly"),
WATER_WALK(Permission.CHECK_WATERWALK, "WaterWalk"),
NO_SWING(Permission.CHECK_NOSWING, "NoSwing"),
FAST_BREAK(Permission.CHECK_FASTBREAK, "FastBreak"),
FAST_PLACE(Permission.CHECK_FASTPLACE, "FastPlace"),
CHAT_SPAM(Permission.CHECK_CHATSPAM, "ChatSpam"),
COMMAND_SPAM(Permission.CHECK_COMMANDSPAM, "CommandSpam"),
@@ -114,6 +114,7 @@ public class KillAuraCheck {
ANGLE_FLAGS.put(uuid, flags + 1);
}
}
return PASS;
}
@@ -39,6 +39,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast
* TODO fix cobweb false positives
*/
public class FlightCheck {
@@ -98,7 +99,7 @@ public class FlightCheck {
&& !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& !VersionUtil.isSlowFalling(player))
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player))
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
}
@@ -142,7 +143,8 @@ public class FlightCheck {
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
&& movementManager.motionY < 0 && !backend.justVelocity(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))) {
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
&& !Utilities.isInWeb(player)) {
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
double offset = Math.abs(gravitatedY - movementManager.motionY);
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
@@ -151,7 +153,8 @@ public class FlightCheck {
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
if (vl >= vlBeforeFlag)
return new CheckResult(CheckResult.Result.FAILED, "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
return new CheckResult(CheckResult.Result.FAILED,
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
} else {
GRAVITY_VIOLATIONS.remove(player.getUniqueId());
}
@@ -35,7 +35,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast
* TODO web speed, soulsand speed
* TODO soulsand speed
*/
public class SpeedCheck {
@@ -196,14 +196,26 @@ public class SpeedCheck {
// Increased speed when stepping on/off boat
if (Utilities.couldBeOnBoat(player))
limit += 0.2D;
// Adjust for custom walk speed
limit += (player.getWalkSpeed() - 0.2) * 2.0D;
// Prevent NoSlow
if (player.isBlocking() && movementManager.groundTicks > 2)
limit *= 0.45D;
// Prevent NoWeb
// TODO config
if (Utilities.isInWeb(player))
limit *= 0.65D;
// Sneak speed check
// TODO config
if (player.isSneaking())
limit *= 0.68D;
if (distanceXZ - limit > 0) {
return new CheckResult(CheckResult.Result.FAILED,
"moved too fast on ground (speed=" + distanceXZ + ", limit=" + limit + ", blocking=" + player.isBlocking() + ")");
}
}
return PASS;
}
@@ -232,6 +244,8 @@ public class SpeedCheck {
}
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat, boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
// TODO config for these values
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check this..
double base = couldBeOnBoat ? 0.600000025 : (nearBed ? 0.5625 : (halfMovement ? 0.6 : 0.42));
if (fromClimbable)
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
@@ -54,10 +54,6 @@ public interface Magic {
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
*/
public int JOIN_TIME();
/**
* Time to exempt a player from fastbreak check because of using instant break; Type=INTEGER, Leniency=INCREASE.
*/
public int INSTANT_BREAK_TIME();
/**
* Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
*/
@@ -86,42 +82,6 @@ public interface Magic {
* Number of item drops to wait for before checking how long they took to drop; Type=INTEGER.
*/
public int DROP_CHECK();
/**
* Max number of blocks that can be broken in a given time; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTBREAK_LIMIT();
/**
* Time to wait before checking block breaks; Type=SYSTEM, Leniency=INCREASE.
*/
public int FASTBREAK_TIMEMAX();
/**
* Time to wait before checking block breaks in creative mode; Type=SYSTEM, Leniency=INCREASE.
*/
public int FASTBREAK_TIMEMAX_CREATIVE();
/**
* Number of times fastbreak can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTBREAK_MAXVIOLATIONS();
/**
* Number of times fastbreak can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTBREAK_MAXVIOLATIONS_CREATIVE();
/**
* Time a player is forced to wait after fastbreak has been detected; Type=SYSTEM, Leniency=DECREASE.
*/
public int FASTBREAK_MAXVIOLATIONTIME();
/**
* Number of times fastplace can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTPLACE_MAXVIOLATIONS();
/**
* Number of times fastplace can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTPLACE_MAXVIOLATIONS_CREATIVE();
/**
* Time a player is forced to wait after fastplace has been detected; Type=SYSTEM, Leniency=DECREASE.
*/
public int FASTPLACE_MAXVIOLATIONTIME();
/**
* Number of times required to punch a block before it breaks; Type=INTEGER, Leniency=DECREASE.
*/
@@ -166,10 +126,6 @@ public interface Magic {
* Maximum times a player can interact between animations; Type=INTEGER, Leniency=INCREASE.
*/
public int ANIMATION_INTERACT_MAX();
/**
* Minimum time between animations; Type=SYSTEM, Leniency=INCREASE.
*/
public int ANIMATION_MIN();
/**
* Minimum time between commands; Type=SYSTEM, Leniency=DECREASE.
*/
@@ -186,10 +142,6 @@ public interface Magic {
* Time before repeating yourself in chat is ignored; Type=SYSTEM, Leniency=INCREASE.
*/
public int CHAT_REPEAT_MIN();
/**
* Maximum speed you can travel while sprinting; Type=DOUBLE, Leniency=INCREASE.
*/
public double SPRINT_MAX();
/**
* Minimum time in between block breaks; Type=INTEGER, Leniency=DECREASE.
*/
@@ -214,14 +166,6 @@ public interface Magic {
* Minimum distance a player can break a block from in creative mode; Type=DOUBLE, Leniency=INCREASE.
*/
public double BLOCK_MAX_DISTANCE_CREATIVE();
/**
* Maximum distance a player can damage an entity from; Type=DOUBLE, Leniency=INCREASE.
*/
public double ENTITY_MAX_DISTANCE();
/**
* Maximum distance a player can damage an entity from in creative mode; Type=DOUBLE, Leniency=INCREASE.
*/
public double ENTITY_MAX_DISTANCE_CREATIVE();
/**
* Maximum speed a player on a ladder can travel; Type=DOUBLE, Leniency=INCREASE.
*/
@@ -16,10 +16,8 @@
* 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 com.rammelkast.anticheatreloaded.event;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -31,17 +29,12 @@ 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 {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamage(BlockDamageEvent event) {
Player player = event.getPlayer();
if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
getBackend().logInstantBreak(player);
}
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
CheckResult result = getBackend().checkAutoTool(player);
if (result.failed()) {
@@ -84,25 +77,8 @@ public class BlockListener extends EventListener {
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
final Player player = event.getPlayer();
final Block block = event.getBlock();
boolean noHack = true;
CheckResult result;
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) {
result = getBackend().checkFastBreak(player, block);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.FAST_BREAK);
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
result = getBackend().checkSwing(player, block);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.NO_SWING);
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
result = IllegalInteract.performCheck(player, event);
if (result.failed()) {
@@ -145,14 +145,6 @@ public class EntityListener extends EventListener {
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = getBackend().checkSprintDamage(player);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkAngle(player, event);
if (result.failed()) {
@@ -472,17 +472,6 @@ public class PlayerListener extends EventListener {
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.SNEAK)) {
CheckResult result = getBackend().checkSneak(player, event.getTo(), x, z);
if (result.failed()) {
if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone()));
player.setSneaking(false);
}
log(result.getMessage(), player, CheckType.SNEAK);
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
CheckResult result = getBackend().checkSpider(player, y);
if (result.failed()) {
@@ -1,86 +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 <http://www.gnu.org/licenses/>.
*/
package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Material;
public enum BlockHardness {
STONE(1.50D), GRASS(0.60D), DIRT(0.50D), COBBLESTONE(2.00D), WOOD(2.00D), SAPLING(0.00D), WATER(100.00D),
STATIONARY_WATER(100.00D), LAVA(0.00D), STATIONARY_LAVA(100.00D), SAND(0.50D), GRAVEL(0.60D), GOLD_ORE(3.00D),
IRON_ORE(3.00D), COAL_ORE(3.00D), LOG(2.00D), LOG_2(2.00D), LEAVES(0.20D), LEAVES_2(0.20D), SPONGE(0.60D),
GLASS(0.30D), LAPIS_ORE(3.00D), LAPIS_BLOCK(3.00D), DISPENSER(3.50D), DROPPER(3.50D), SANDSTONE(0.80D),
NOTE_BLOCK(0.80D), BED(0.20D), RAILS(0.70D), DETECTOR_RAIL(0.70D), POWERED_RAIL(0.70D), ACTIVATOR_RAIL(0.70D),
WEB(4.00D), LONG_GRASS(0.00D), DOUBLE_PLANT(0.00D), DEAD_BUSH(0.00D), WOOL(0.80D), YELLOW_FLOWER(0.00D),
RED_ROSE(0.00D), BROWN_MUSHROOM(0.00D), RED_MUSHROOM(0.00D), GOLD_BLOCK(3.00D), IRON_BLOCK(5.00D),
DOUBLE_STEP(2.00D), STEP(2.00D), BRICK(2.00D), TNT(0.00D), BOOKSHELF(1.50D), MOSSY_COBBLESTONE(2.00D),
OBSIDIAN(50.00D), TORCH(0.00D), FIRE(0.00D), MOB_SPAWNER(5.00D), CHEST(2.50D), TRAPPED_CHEST(2.50D),
REDSTONE_WIRE(0.00D), DIAMOND_ORE(3.00D), DIAMOND_BLOCK(5.00D), WORKBENCH(2.50D), SOIL(0.60D), FURNACE(3.50D),
BURNING_FURNACE(3.50D), WOODEN_DOOR(3.00D), LADDER(0.40D), LEVER(0.50D), IRON_DOOR_BLOCK(5.00D), HOPPER(2.00D),
STONE_PLATE(0.50D), WOOD_PLATE(0.50D), GOLD_PLATE(0.50D), IRON_PLATE(0.50D), QUARTZ_BLOCK(0.80D), QUARTZ_ORE(3.00D),
REDSTONE_BLOCK(5.00D), REDSTONE_ORE(3.00D), GLOWING_REDSTONE_ORE(3.00D), REDSTONE_TORCH_OFF(0.00D),
REDSTONE_TORCH_ON(0.00D), REDSTONE_COMPARATOR_OFF(0.00D), REDSTONE_COMPARATOR_ON(0.00D), DAYLIGHT_DETECTOR(0.20D),
STONE_BUTTON(0.50D), SNOW(0.10D), ICE(0.50D), PACKED_ICE(0.50D), SNOW_BLOCK(0.20D), CACTUS(0.40D), CLAY(0.60D),
HARD_CLAY(1.25D), STAINED_CLAY(1.25D), SUGAR_CANE_BLOCK(0.00D), JUKEBOX(2.00D), FENCE(2.00D), NETHERRACK(0.40D),
SOUL_SAND(0.50D), GLOWSTONE(0.30D), PORTAL(-1.00D), CAKE_BLOCK(0.50D), LOCKED_CHEST(0.00D), TRAP_DOOR(3.00D),
MONSTER_EGGS(0.750D), SMOOTH_BRICK(1.50D), IRON_FENCE(5.00D), THIN_GLASS(0.30D), STAINED_GLASS(0.30D),
STAINED_GLASS_PANE(0.30D), PUMPKIN_STEM(0.00D), MELON_STEM(0.00D), VINE(0.20D), FENCE_GATE(2.00D), MYCEL(0.60D),
WATER_LILY(0.00D), NETHER_BRICK(2.00D), NETHER_FENCE(2.00D), ENCHANTMENT_TABLE(5.00D), BREWING_STAND(0.50D),
CAULDRON(2.00D), ENDER_PORTAL(-1.00D), ENDER_PORTAL_FRAME(-1.00D), DRAGON_EGG(3.00D), REDSTONE_LAMP_OFF(0.30D),
REDSTONE_LAMP_ON(0.30D), WOOD_DOUBLE_STEP(2.00D), WOOD_STEP(2.00D), COCOA(0.20D), EMERALD_ORE(3.00D),
ENDER_CHEST(22.50D), EMERALD_BLOCK(5.00D), FLOWER_POT(0.00D), WOOD_BUTTON(0.50D), ANVIL(5.00D),
HUGE_MUSHROOM_1(0.20D), HUGE_MUSHROOM_2(0.20D), BED_BLOCK(0.20D), WOOD_STAIRS(2.00D), COBBLESTONE_STAIRS(2.00D),
BRICK_STAIRS(2.00D), SMOOTH_STAIRS(1.50D), NETHER_BRICK_STAIRS(2.00D), SPRUCE_WOOD_STAIRS(2.00D),
BIRCH_WOOD_STAIRS(2.00D), JUNGLE_WOOD_STAIRS(2.00D), DARK_OAK_STAIRS(2.00D), ACACIA_STAIRS(2.00D),
QUARTZ_STAIRS(0.80D), SANDSTONE_STAIRS(0.80D), COMMAND(0.00D), BEACON(3.00D), COBBLE_WALL(2.00D), CROPS(0.00D),
CARROT(0.00D), POTATO(0.00D), SKULL(1.00D), NETHER_WARTS(0.00D), SIGN_POST(1.00D), WALL_SIGN(1.00D), PUMPKIN(1.00D),
JACK_O_LANTERN(1.00D), DIODE_BLOCK_ON(0.00D), DIODE_BLOCK_OFF(0.00D), MELON_BLOCK(1.00D), ENDER_STONE(3.00D),
TRIPWIRE(0.00D), TRIPWIRE_HOOK(0.00D), HAY_BLOCK(0.50D), CARPET(0.10D), COAL_BLOCK(5.00D), PISTON_BASE(0.70D),
PISTON_EXTENSION(0.70D), PISTON_MOVING_PIECE(0.70D), PISTON_STICKY_BASE(0.70D);
Material mat;
double hardness;
BlockHardness(double hard) {
mat = Material.getMaterial(name());
hardness = hard;
}
public static double getBlockHardness(Material m) {
try {
BlockHardness h = getHardness(m);
return h == null ? 0D : h.hardness;
} catch (Exception e) {
return 0D;
}
}
public static boolean hasBlockHardness(Material m) {
return getHardness(m) != null;
}
public static BlockHardness getHardness(Material m) {
for (BlockHardness e : BlockHardness.values()) {
if (e.mat.equals(m)) {
return e;
}
}
return null;
}
}
@@ -43,6 +43,8 @@ public class MovementManager {
public double lastMotionY;
// Horizontal distance of movement
public double distanceXZ;
// Previous horizontal distance of movement
public double lastDistanceXZ;
// If the player touched the ground again this tick
public boolean touchedGroundThisTick = false;
// Last recorded distance
@@ -75,6 +77,7 @@ public class MovementManager {
double x = distance.getXDifference();
double z = distance.getZDifference();
this.lastDistanceXZ = this.distanceXZ;
this.distanceXZ = Math.sqrt(x * x + z * z);
// Account for standing on boat
@@ -23,14 +23,15 @@ import org.bukkit.command.CommandSender;
public enum Permission {
/* Check Nodes */
CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS,
CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER, CHECK_AIMBOT,
CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT,
CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL,
CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY, CHECK_AUTOTOOL,
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
CHECK_AIMBOT,
/* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD, SYSTEM_MUTE;
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
SYSTEM_MUTE;
private static final String PERMISSION_ALL = "anticheat.*";
private static final String PERMISSION_SPAM = "anticheat.check.spam";
@@ -237,7 +237,8 @@ public class User {
*/
public boolean setGoodLocation(Location location) {
if (Utilities.cantStandAtExp(location)
|| (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
|| (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))
|| !location.getBlock().getType().isSolid()) {
return false;
}
@@ -544,54 +544,6 @@ public final class Utilities {
}
}
/**
* Calculate the time in milliseconds that it should take to break the given
* block with the given tool
*
* @param tool tool to check
* @param block block to check
* @return time in milliseconds to break
*/
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
if (isInstantBreak(block) || (tool.getType() == XMaterial.SHEARS.parseMaterial() && block.name().endsWith("LEAVES"))) {
return 0;
}
double bhardness = BlockHardness.getBlockHardness(block);
double thardness = ToolHardness.getToolHardness(tool.getType());
long enchantlvl = (long) tool.getEnchantmentLevel(Enchantment.DIG_SPEED);
long result = Math.round((bhardness * thardness) * 0.10 * 10000);
if (enchantlvl > 0) {
result /= enchantlvl * enchantlvl + 1L;
}
result = result > 25000 ? 25000 : result < 0 ? 0 : result;
if (isQuickCombo(tool, block)) {
result = result / 2;
}
return result;
}
/**
* Determine whether the given tool is a combination that makes the breaking of
* this block faster
*
* @param tool tool to check
* @param block block to check
* @return true if quick combo
*/
private static boolean isQuickCombo(ItemStack tool, Material block) {
for (Material t : COMBO.keySet()) {
if (tool.getType() == t && COMBO.get(t) == block) {
return true;
}
}
return false;
}
/**
* Determine if a block ISN'T one of the specified types
*