Added FastLadder check, fixed glide false positive

This commit is contained in:
Rammelkast committed 2020-04-24 13:59:06 +02:00
1 parent 0288a9734a
commit cc51e9307f
14 files changed
+146 -14

No files matched your search

@@ -64,7 +64,8 @@ public enum CheckType {
VELOCITY(Permission.CHECK_VELOCITY),
CRITICALS(Permission.CHECK_CRITICALS),
CHAT_UNICODE(Permission.CHECK_UNICODE),
ILLEGAL_INTERACT(Permission.CHECK_ILLEGAL_INTERACT);
ILLEGAL_INTERACT(Permission.CHECK_ILLEGAL_INTERACT),
FASTLADDER(Permission.CHECK_FASTLADDER);
private final Permission permission;
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
@@ -0,0 +1,85 @@
/*
* 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.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class FastLadderCheck {
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, double y) {
Magic magic = AntiCheatReloaded.getManager().getBackend().getMagic();
// Only check if fully on ladder
// Liquids are climbable blocks, so we have to add a seperate check
if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|| player.getLocation().getBlock().isLiquid()) {
return PASS;
}
int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
if (y > 0) {
// Check moving up
double max = magic.LADDER_Y_MAX();
// Check if going faster than max Y climbing speed
if (y - max > 0) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
vlCount = 0;
return new CheckResult(Result.FAILED,
"tried to climb up too fast (speed=" + y + ", max=" + max + ")");
}
} else {
if (vlCount > 0)
vlCount--;
}
} else if (y < 0) {
// Check moving down
if (Math.abs(y) > magic.LADDER_DOWN_MAX() + 6E-9) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
vlCount = 0;
return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
+ ", max=" + magic.LADDER_DOWN_MAX() + ")");
}
} else {
if (vlCount > 0)
vlCount--;
}
} else {
if (vlCount > 0)
vlCount--;
}
VIOLATIONS.put(player.getUniqueId(), vlCount);
return PASS;
}
}
@@ -16,7 +16,6 @@
* 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.check.movement;
import java.util.HashMap;
@@ -82,7 +82,8 @@ public class GlideCheck {
} else {
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5
&& !Utilities.isClimbableBlock(distance.getTo().getBlock()) && !player.isSneaking()
&& !Utilities.isNearClimbable(player)
&& !player.isSneaking()
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)) {
// TODO that fallDistance check is a horrible way to prevent a certain false
// positive
@@ -282,6 +282,10 @@ public interface Magic {
* Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE.
*/
public double LADDER_Y_MIN();
/**
* Maximum speed a player on a ladder can travel downwards
*/
public double LADDER_DOWN_MAX();
/**
* Maximum speed a player can travel up; Type=DOUBLE, Leniency=INCREASE.
*/
@@ -390,4 +394,8 @@ public interface Magic {
* Maximum distance allowed between two movement packets; Type=DOUBLE, Leniency=INCREASE.
*/
public double BADPACKETS_MAX_DISTANCE();
/**
* Maximum amount of fastladder movements before flagging; TYPE=INTEGER, Leniency=INCREASE
*/
public int FASTLADDER_MAX_FLAGS();
}
@@ -59,6 +59,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
@@ -449,6 +450,17 @@ public class PlayerListener extends EventListener {
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
// Does not use y value created before because that value is absolute
CheckResult result = FastLadderCheck.runCheck(player, event.getTo().getY() - event.getFrom().getY());
if (result.failed()) {
if (!silentMode()) {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.FASTLADDER);
changed = true;
}
}
if (!changed) {
user.setGoodLocation(event.getFrom());
}
@@ -59,7 +59,6 @@ import com.google.gson.JsonPrimitive;
* <p>
* Check out https://bStats.org/ to learn more about bStats!
*/
@SuppressWarnings({ "unused" })
public class Metrics {
static {
@@ -26,7 +26,7 @@ public enum Permission {
CHECK_FLIGHT, CHECK_ELYTRA, 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_LONGREACH, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER,
/* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
@@ -290,6 +290,22 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
}
/**
* Determine whether a player is near a climbable block
*
* @param player player to check
* @return true if near climbable block
*/
public static boolean isNearClimbable(Player player) {
return isClimbableBlock(player.getLocation().getBlock())
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.DOWN))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.UP))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.NORTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.SOUTH))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
}
/**
* Determine whether a block is climbable