Glide -> Gravity, more migration towards new config, expanded illegalinteract, fix false positives

This commit is contained in:
Rammelkast committed 2020-07-13 18:24:25 +02:00
1 parent 2086a01f80
commit ad618ffaf0
20 files changed
+291 -349

No files matched your search

@@ -42,10 +42,10 @@ import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.config.providers.Lang;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
@@ -91,12 +91,14 @@ public class Backend {
private Map<UUID, Long> lastSneak = new HashMap<UUID, Long>();
private Magic magic;
private Checks checksConfig;
private AntiCheatManager manager = null;
private Lang lang = null;
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public Backend(AntiCheatManager instance) {
magic = instance.getConfiguration().getMagic();
checksConfig = instance.getConfiguration().getChecks();
manager = instance;
lang = manager.getConfiguration().getLang();
transparent.add((byte) -1);
@@ -162,9 +164,6 @@ public class Backend {
MorePacketsCheck.LAST_PACKET_TIME.remove(uuid);
MorePacketsCheck.PACKET_BALANCE.remove(uuid);
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
GlideCheck.LAST_MOTION_Y.remove(uuid);
GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
GlideCheck.VIOLATIONS.remove(uuid);
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
FlightCheck.MOVING_EXEMPT.remove(uuid);
@@ -225,25 +224,7 @@ public class Backend {
}
return PASS;
}
public CheckResult checkLongReachBlock(Player player, double x, double y, double z) {
if (isInstantBreakExempt(player)) {
return new CheckResult(CheckResult.Result.PASSED);
} else {
String string = "reached too far for a block";
double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: magic.BLOCK_MAX_DISTANCE();
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED,
string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
} else {
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())
@@ -270,10 +251,11 @@ public class Backend {
}
int i = nofallViolation.get(uuid);
if (i >= magic.NOFALL_LIMIT()) {
int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
if (i >= vlBeforeFlag) {
nofallViolation.put(player.getUniqueId(), 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 "
+ i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
+ i + " times in a row, max=" + vlBeforeFlag + ")");
} else {
return PASS;
}
@@ -287,15 +269,17 @@ public class Backend {
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 i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
&& !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 >= 3) { // TODO possible config
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=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
"was sneaking too fast (speed=" + i + ", max=" + xzMaxSneaking + ")");
}
this.fastSneakViolations.put(player.getUniqueId(), flags + 1);
return PASS;
@@ -317,8 +301,8 @@ public class Backend {
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 (System.currentTimeMillis() - lastSneak < 75
&& (AntiCheatReloaded.getPlugin().getTPS() > 12 && !user.isLagging())) {
if (!this.silentMode()) {
player.teleport(user.getGoodLocation(player.getLocation()));
}
@@ -475,13 +459,14 @@ public class Backend {
long last = lastBlockPlaced.get(uuid);
long lastTime = lastBlockPlaceTime.get(uuid);
long thisTime = time - last;
int minimumTime = checksConfig.getInteger(CheckType.FAST_PLACE, "minimumTime");
if (lastTime != 0 && thisTime < magic.FASTPLACE_TIMEMIN()) {
if (lastTime != 0 && thisTime < minimumTime) {
lastBlockPlaceTime.put(uuid, (time - last));
lastBlockPlaced.put(uuid, time);
fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime
+ " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
return new CheckResult(CheckResult.Result.FAILED,
"tried to place a block " + thisTime + " ms after the last one (min=" + minimumTime + " ms)");
}
lastBlockPlaceTime.put(uuid, (time - last));
}
@@ -630,16 +615,19 @@ public class Backend {
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{
double tps = AntiCheatReloaded.getPlugin().getTPS();
if (tps < 17.5
|| user.isLagging()) {
if (tps < checksConfig.getDouble(CheckType.FAST_HEAL, "minimumTps")
|| (user.isLagging() && checksConfig.getBoolean(CheckType.FAST_HEAL, "disableForLagging"))) {
return PASS;
}
long healTime = magic.MIN_HEAL_TIME() - (tps >= 18.5 ? 0 : 50);
long l = lastHeal.get(player.getUniqueId());
long minHealTime = checksConfig.getInteger(CheckType.FAST_HEAL, "minHealTime");
long lastHealTime = lastHeal.get(player.getUniqueId());
int ping = user.getPing();
double pingCompensation = checksConfig.getInteger(CheckType.FAST_HEAL, "pingCompensation");
long allowedHealTime = (long) (minHealTime - (ping * pingCompensation));
lastHeal.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < healTime) {
if ((System.currentTimeMillis() - lastHealTime) < allowedHealTime) {
return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time="
+ (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)");
+ (System.currentTimeMillis() - lastHealTime) + " ms, min=" + allowedHealTime + " ms)");
}
}
return PASS;
@@ -649,8 +637,7 @@ public class Backend {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
if (startEat.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{
if (AntiCheatReloaded.getPlugin().getTPS() < 17.5
|| user.isLagging()) {
if (AntiCheatReloaded.getPlugin().getTPS() < 17.5 || user.isLagging()) {
return PASS;
}
long l = startEat.get(player.getUniqueId());
@@ -690,13 +677,13 @@ public class Backend {
public void logLevitating(final Player player, final int duration) {
levitatingEnd.put(player.getUniqueId(), System.currentTimeMillis() + (duration * 1000L));
}
public boolean justVelocity(Player player) {
return (velocitized.containsKey(player.getUniqueId())
? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME()
: false);
}
public boolean justLevitated(Player player) {
return (levitatingEnd.containsKey(player.getUniqueId())
? (System.currentTimeMillis() - levitatingEnd.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME()
@@ -758,19 +745,17 @@ public class Backend {
}
public void logTeleport(final Player player) {
manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System.currentTimeMillis();
manager.getUserManager().getUser(player.getUniqueId()).getMovementManager().lastTeleport = System
.currentTimeMillis();
/* Data for fly/speed should be reset */
nofallViolation.remove(player.getUniqueId());
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
GlideCheck.LAST_MOTION_Y.remove(player.getUniqueId());
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
}
public void logExitFly(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
}
public void logBoatCollision(final Player player) {
// TODO config
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
@@ -31,17 +31,17 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
public class CriticalsCheck {
public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) {
if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK)
public static void doDamageEvent(EntityDamageByEntityEvent event, Player damager) {
if (!(event.getDamager() instanceof Player) || event.getCause() != DamageCause.ENTITY_ATTACK)
return;
Player p = (Player) e.getDamager();
if (isCritical(p)) {
if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0)
&& p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
e.setCancelled(true);
Player player = (Player) event.getDamager();
if (isCritical(player)) {
if ((player.getLocation().getY() % 1.0 == 0 || player.getLocation().getY() % 0.5 == 0)
&& player.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
event.setCancelled(true);
EventListener.log(new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
.getMessage(),
p, CheckType.CRITICALS);
player, CheckType.CRITICALS);
}
}
}
@@ -31,7 +31,10 @@ import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class KillAuraCheck {
@@ -42,32 +45,49 @@ public class KillAuraCheck {
public static CheckResult checkReach(Player player, Entity target) {
if (!(target instanceof LivingEntity))
return PASS;
// TODO add configs for everything here
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
double allowedReach = target.getVelocity().length() < 0.08 ? 3.6D : 4.0D;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
// Check if enabled
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "reach"))
return PASS;
double allowedReach = target.getVelocity().length() < 0.08
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
// Lag compensation
allowedReach += user.getPing() * 0.0025D;
double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
"lagCompensation.pingCompensation");
allowedReach += user.getPing() * pingCompensation;
if (user.isLagging())
allowedReach += 0.2D;
allowedReach += lagExtraReach;
if (target instanceof Player) {
User targetUser = AntiCheatReloaded.getManager().getUserManager().getUser(target.getUniqueId());
allowedReach += targetUser.getPing()
* 0.0025D;
allowedReach += targetUser.getPing() * pingCompensation;
if (targetUser.isLagging())
allowedReach += 0.2D;
allowedReach += lagExtraReach;
}
// Velocity compensation
allowedReach += Math.abs(target.getVelocity().length()) * 1.2D;
double reachedDistance = ((LivingEntity)target).getLocation().toVector().distance(player.getLocation().toVector());
double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier");
allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier;
double reachedDistance = ((LivingEntity) target).getLocation().toVector()
.distance(player.getLocation().toVector());
if (reachedDistance > allowedReach)
return new CheckResult(CheckResult.Result.FAILED,
"reached too far (distance=" + reachedDistance + ", max=" + allowedReach + ")");
"reached too far (distance=" + Utilities.roundDouble(reachedDistance, 6) + ", max=" + Utilities.roundDouble(allowedReach, 6) + ")");
return PASS;
}
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
UUID uuid = player.getUniqueId();
Entity entity = event.getEntity();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
// Check if enabled
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "angle"))
return PASS;
if (entity instanceof LivingEntity) {
LivingEntity living = (LivingEntity) entity;
Location eyeLocation = player.getEyeLocation();
@@ -76,16 +96,16 @@ public class KillAuraCheck {
double playerYaw = player.getEyeLocation().getYaw();
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
if (Math.round(angleDifference) > AntiCheatReloaded.getManager().getConfiguration().getMagic()
.KILLAURA_MAX_ANGLE_DIFFERENCE()) {
int maxDifference = checksConfig.getInteger(CheckType.KILLAURA, "angle", "maxDifference");
if (Math.round(angleDifference) > maxDifference) {
if (!ANGLE_FLAGS.containsKey(uuid)) {
ANGLE_FLAGS.put(uuid, 1);
return PASS;
}
int flags = ANGLE_FLAGS.get(uuid);
if (flags >= AntiCheatReloaded.getManager().getConfiguration().getMagic()
.KILLAURA_MAX_ANGLE_VIOLATIONS()) {
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
if (flags >= vlBeforeFlag) {
ANGLE_FLAGS.remove(uuid);
return new CheckResult(CheckResult.Result.FAILED,
"tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
@@ -31,10 +31,11 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.event.EventListener;
/*
* TODO improve
* TODO recode
*/
public class VelocityCheck {
@@ -43,25 +44,26 @@ public class VelocityCheck {
public static void runCheck(EntityDamageByEntityEvent e, final Player player) {
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.VELOCITY))
return;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
final double minVelocitizedDistance = checksConfig.getDouble(CheckType.VELOCITY, "minVelocitizedDistance");
final int vlBeforeFlag = checksConfig.getInteger(CheckType.VELOCITY, "vlBeforeFlag");
final Location then = player.getLocation();
new BukkitRunnable() {
@Override
public void run() {
if (!player.isOnline())
return;
if (then.distance(player.getLocation()) < 0.125) {
if (then.distance(player.getLocation()) < minVelocitizedDistance) {
if (!VIOLATIONS.containsKey(player.getUniqueId()))
VIOLATIONS.put(player.getUniqueId(), 1);
else {
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
if (VIOLATIONS.get(player.getUniqueId()) > AntiCheatReloaded.getManager().getBackend().getMagic()
.VELOCITY_MAX_FLAGS()) {
if (VIOLATIONS.get(player.getUniqueId()) > vlBeforeFlag) {
EventListener.log(
new CheckResult(CheckResult.Result.FAILED,
"had zero/low velocity " + VIOLATIONS.get(player.getUniqueId()) + " times (max="
+ AntiCheatReloaded.getManager().getBackend().getMagic()
.VELOCITY_MAX_FLAGS()
+ ", dist=" + then.distance(player.getLocation()) + ")").getMessage(),
"had zero/low velocity " + VIOLATIONS.get(player.getUniqueId())
+ " times (max=" + vlBeforeFlag + ", dist="
+ then.distance(player.getLocation()) + ")").getMessage(),
player, CheckType.VELOCITY);
VIOLATIONS.remove(player.getUniqueId());
}
@@ -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;
@@ -29,6 +28,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
public class AimbotCheck {
@@ -37,6 +38,7 @@ public class AimbotCheck {
public static CheckResult runCheck(Player player, PlayerMoveEvent event) {
Backend backend = AntiCheatReloaded.getManager().getBackend();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (backend.isMovingExempt(player)) {
return PASS;
}
@@ -57,7 +59,9 @@ public class AimbotCheck {
LAST_DELTA_YAW.put(uuid, dYaw);
float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
if (absoluteYawDifference < 1E-8 && dYaw > 30 && dYaw < 355)
int minYaw = checksConfig.getInteger(CheckType.AIMBOT, "minYaw");
int maxYaw = checksConfig.getInteger(CheckType.AIMBOT, "maxYaw");
if (absoluteYawDifference < 1E-8 && minYaw > 30 && dYaw < maxYaw)
return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
return PASS;
}
@@ -28,7 +28,8 @@ 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.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class FastLadderCheck {
@@ -37,7 +38,6 @@ public class FastLadderCheck {
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())
@@ -47,12 +47,14 @@ public class FastLadderCheck {
}
int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
int vlBeforeFlag = checksConfig.getInteger(CheckType.FASTLADDER, "vlBeforeFlag");
if (y > 0) {
// Check moving up
double max = magic.LADDER_Y_MAX();
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedUpMax");
// Check if going faster than max Y climbing speed
if (y - max > 0) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
if (vlCount++ > vlBeforeFlag) {
vlCount = 0;
return new CheckResult(Result.FAILED,
"tried to climb up too fast (speed=" + y + ", max=" + max + ")");
@@ -63,11 +65,12 @@ public class FastLadderCheck {
}
} else if (y < 0) {
// Check moving down
if (Math.abs(y) > magic.LADDER_DOWN_MAX() + 6E-9) {
if (vlCount++ > magic.FASTLADDER_MAX_FLAGS()) {
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedDownMax");
if (Math.abs(y) > max + 6E-9) {
if (vlCount++ > vlBeforeFlag) {
vlCount = 0;
return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
+ ", max=" + magic.LADDER_DOWN_MAX() + ")");
+ ", max=" + max + ")");
}
} else {
if (vlCount > 0)
@@ -27,6 +27,7 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
@@ -42,8 +43,10 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FlightCheck {
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
public static final Map<UUID, Integer> GRAVITY_VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
private static final double GRAVITY_FRICTION = 0.9800000190734863D;
public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) {
@@ -51,33 +54,37 @@ public class FlightCheck {
// about it.
return PASS;
}
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
MovementManager movementManager = user.getMovementManager();
Backend backend = AntiCheatReloaded.getManager().getBackend();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (Utilities.isNearWater(player) || movementManager.halfMovement
|| Utilities.isClimbableBlock(distance.getFrom().getBlock())
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.UP)))
return PASS;
int minAirTicks = 13;
if (player.hasPotionEffect(PotionEffectType.JUMP) ) {
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
minAirTicks += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 3;
}
if (movementManager.halfMovementHistoryCounter > 25)
minAirTicks += 5;
// Start AirFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks) {
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
&& !backend.justVelocity(player)) {
// Config default base is 1200ms
// Ping clamped to max. 1000 to prevent spoofing for an advantage
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight", "accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
"accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
// Config default account is 250ms
if (AntiCheatReloaded.getPlugin().getTPS() < 18.0)
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight", "accountForTpsDrops");
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
"accountForTpsDrops");
long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
.containsKey(player.getUniqueId())
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
@@ -89,33 +96,38 @@ public class FlightCheck {
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01
&& !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& !VersionUtil.isSlowFalling(player))
return new CheckResult(CheckResult.Result.FAILED, "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
}
// End AirFlight
// Start AirClimb
// TODO two hardcoded values here shouldn't be there, temp against false positive
// TODO two hardcoded values here shouldn't be there, temp against false
// positive
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
&& movementManager.motionY > 0 && movementManager.airTicks == 2
&& Math.round(movementManager.lastMotionY * 1000) != 420
&& !(Math.round(movementManager.motionY * 1000) == 333 && Math.round(movementManager.lastMotionY * 1000) != 333)
&& !(Math.round(movementManager.motionY * 1000) == 333
&& Math.round(movementManager.lastMotionY * 1000) != 333)
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")))
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")))
return new CheckResult(CheckResult.Result.FAILED,
"tried to climb air (mY=" + movementManager.motionY + ")");
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
&& movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")))
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")))
return new CheckResult(CheckResult.Result.FAILED,
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
// End AirClimb
// Start GroundFlight
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
@@ -125,7 +137,27 @@ public class FlightCheck {
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
}
// End GroundFlight
// Start Gravity
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
&& movementManager.motionY < 0 && !backend.justVelocity(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))) {
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
double offset = Math.abs(gravitatedY - movementManager.motionY);
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
if (offset > maxOffset && movementManager.airTicks > 2) {
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
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 + ")");
} else {
GRAVITY_VIOLATIONS.remove(player.getUniqueId());
}
}
// End Gravity
return PASS;
}
@@ -1,100 +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.check.movement;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class GlideCheck {
public static final Map<UUID, Double> LAST_MOTION_Y = new HashMap<UUID, Double>();
public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>();
public static final Map<UUID, Integer> AIR_TICKS = new HashMap<UUID, Integer>();
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, Distance distance) {
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player) || FlightCheck.isMovingExempt(player)) {
VIOLATIONS.put(player.getUniqueId(), 0);
return PASS;
}
if (player.getLocation().getBlock().getType() == Material.LADDER
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
return PASS;
}
if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) {
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
return PASS;
}
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
double motionY = distance.getYDifference();
float fallDistance = player.getFallDistance();
if (motionY == LAST_MOTION_Y.get(player.getUniqueId())
&& fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId())) {
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
VIOLATIONS.put(player.getUniqueId(), 0);
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
Location prev = player.getLocation().clone();
prev.setY(prev.getY() - distanceToFall(prev));
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getGoodLocation(prev));
}
return new CheckResult(CheckResult.Result.FAILED,
"had gliding behaviour (amt=" + Utilities.roundDouble(motionY, 5) + ")");
} else {
VIOLATIONS.put(player.getUniqueId(), violations + 1);
return PASS;
}
}
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
if (violations > Math.round(AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT() / 2)) {
VIOLATIONS.put(player.getUniqueId(), violations - 1);
}
return PASS;
}
private static double distanceToFall(Location location) {
location = location.clone();
double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D;
return location.getY() - highestY;
}
}
@@ -67,11 +67,14 @@ public class SpeedCheck {
if (iceIncrement > 0.18D)
iceIncrement = 0.18D;
if (boxedIn)
iceIncrement += 0.5D;
iceIncrement += 0.45D;
if (!Utilities.couldBeOnIce(movingTowards))
iceIncrement *= 2.5D;
predict += iceIncrement;
}
// Leniency when boxed in
if (boxedIn && movementManager.airTicks < 3)
limit *= 1.2D;
// Adjust for slime
if (movementManager.slimeInfluenceTicks > 0) {
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
@@ -111,8 +114,8 @@ public class SpeedCheck {
predict *= 0.8D;
if (distanceXZ - predict > limit) {
return new CheckResult(CheckResult.Result.FAILED,
"moved too fast in air (speed=" + distanceXZ + ", limit=" + predict + ", blocking=" + player.isBlocking() + ")");
return new CheckResult(CheckResult.Result.FAILED, "moved too fast in air (speed=" + distanceXZ
+ ", limit=" + predict + ", block=" + player.isBlocking() + ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")");
}
}
@@ -123,6 +126,9 @@ public class SpeedCheck {
&& movementManager.elytraEffectTicks <= 0) {
double initialAcceleration = movementManager.acceleration;
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
// Slight increase when boxed in
if (boxedIn)
limit *= 1.05D;
// Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.0225D;
@@ -164,6 +170,9 @@ public class SpeedCheck {
// Slab leniency
if (movementManager.halfMovementHistoryCounter > 8)
limit += 0.2D;
// Leniency when boxed in
if (boxedIn)
limit *= 1.1D;
// Adjust for speed effects
if (player.hasPotionEffect(PotionEffectType.SPEED))
limit += (player.getPotionEffect(PotionEffectType.SPEED).getAmplifier() + 1) * 0.06D;
@@ -206,7 +215,7 @@ public class SpeedCheck {
return PASS;
if (player.isInsideVehicle() || player.isSleeping()
|| backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME()) || VersionUtil.isFlying(player)
|| backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_SCHETIME()) || VersionUtil.isFlying(player)
|| VersionUtil.isRiptiding(player)) {
return PASS;
}
@@ -30,6 +30,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.Backend;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.User;
@@ -51,8 +52,9 @@ public class BadPacketsCheck {
}
// TODO more precise checking for this
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double tps = AntiCheatReloaded.getPlugin().getTPS();
if (user.isLagging() || tps < 18) {
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
return;
}
@@ -64,7 +66,7 @@ public class BadPacketsCheck {
Location previous = player.getLocation();
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
double distance = previous.distanceSquared(current);
double maxDistance = backend.getMagic().BADPACKETS_MAX_DISTANCE();
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
boolean hasNewLocation = packet.getBooleans().read(0);
if (distance > maxDistance) {
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
@@ -30,8 +30,8 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.event.EventListener;
import com.rammelkast.anticheatreloaded.util.User;
/**
* @author Rammelkast
@@ -44,15 +44,19 @@ public class MorePacketsCheck {
public static void runCheck(Player player, PacketEvent event) {
// Confirm if we should even check for MorePackets
// Upped TPS min to 17.5, need to add lag-based compensation to combat falses
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double tps = AntiCheatReloaded.getPlugin().getTPS();
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS) || tps < 17.5) {
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS)
|| tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
return;
}
UUID uuid = player.getUniqueId();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
int maxPing = checksConfig.getInteger(CheckType.MOREPACKETS, "maxPing");
boolean disableForLagging = checksConfig.getBoolean(CheckType.MOREPACKETS, "disableForLagging");
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)
|| (maxPing > 0 && user.getPing() > maxPing) || (disableForLagging && user.isLagging())) {
return;
}
long packetTimeNow = System.currentTimeMillis();
@@ -92,9 +96,9 @@ public class MorePacketsCheck {
public static void compensate(Player player) {
UUID uuid = player.getUniqueId();
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
PACKET_BALANCE.put(uuid, packetBalance - magic.MOREPACKETS_TELEPORT_COMPENSATION());
PACKET_BALANCE.put(uuid, packetBalance - checksConfig.getInteger(CheckType.MOREPACKETS, "teleportCompensation"));
}
}
@@ -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.player;
import org.bukkit.GameMode;
@@ -26,11 +25,15 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.config.providers.Magic;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
@@ -39,10 +42,33 @@ public class IllegalInteract {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult performCheck(Player player, Event event) {
if (event instanceof BlockPlaceEvent) {
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (event instanceof BlockPlaceEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "place")) {
return checkBlockPlace(player, (BlockPlaceEvent) event);
} else if (event instanceof BlockBreakEvent) {
} else if (event instanceof BlockBreakEvent
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
return checkBlockBreak(player, (BlockBreakEvent) event);
} else if (event instanceof PlayerInteractEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
return checkInteract(player, (PlayerInteractEvent) event);
}
return PASS;
}
private static CheckResult checkInteract(Player player, PlayerInteractEvent event) {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double distance = player.getEyeLocation().toVector().distance(event.getClickedBlock().getLocation().toVector());
double maxDistance = player.getGameMode() == GameMode.CREATIVE
? checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "creativeRange")
: checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "survivalRange");
maxDistance += user.isLagging() ? 0.12 : 0;
maxDistance += user.getPing()
* checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "interact", "pingCompensation");
maxDistance += player.getVelocity().length()
* checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
if (distance > maxDistance) {
return new CheckResult(CheckResult.Result.FAILED, "tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
}
return PASS;
}
@@ -63,6 +89,7 @@ public class IllegalInteract {
private static boolean isValidTarget(Player player, Block block) {
Magic magic = AntiCheatReloaded.getManager().getConfiguration().getMagic();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: magic.BLOCK_MAX_DISTANCE();
@@ -86,7 +113,7 @@ public class IllegalInteract {
double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
double playerYaw = player.getEyeLocation().getYaw();
double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
if (Math.round(angleDifference) > magic.ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE()) {
if (Math.round(angleDifference) > checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "maxAngleDifference")) {
return false;
}
return true;
@@ -42,7 +42,7 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override
public boolean getBoolean(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getConfigurationSection(subcheck)
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getBoolean(name);
}
@@ -53,29 +53,29 @@ public class YamlChecksHolder extends ConfigurationFile implements Checks {
@Override
public double getDouble(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getConfigurationSection(subcheck)
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getDouble(name);
}
@Override
public int getInteger(CheckType checkType, String subcheck, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getConfigurationSection(subcheck)
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck)
.getInt(name);
}
@Override
public boolean getBoolean(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getBoolean(name);
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean(name);
}
@Override
public double getDouble(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getDouble(name);
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getDouble(name);
}
@Override
public int getInteger(CheckType checkType, String name) {
return this.getConfigFile().getConfigurationSection(checkType.name().toLowerCase()).getInt(name);
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getInt(name);
}
@Override
@@ -42,10 +42,6 @@ public interface Magic {
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
*/
public int ENTERED_EXITED_TIME();
/**
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=SYSTEM, Leniency=INCREASE.
*/
public int SNEAK_TIME();
/**
* Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
*/
@@ -114,14 +110,6 @@ public interface Magic {
* Time a player is forced to wait after fastbreak has been detected; Type=SYSTEM, Leniency=DECREASE.
*/
public int FASTBREAK_MAXVIOLATIONTIME();
/**
* Number of blocks that can be broken without being hit before taking action; Type=INTEGER, Leniency=INCREASE.
*/
public int FASTPLACE_ZEROLIMIT();
/**
* Minimum time in between block places; Type=SYSTEM, Leniency=DECREASE.
*/
public int FASTPLACE_TIMEMIN();
/**
* Number of times fastplace can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
*/
@@ -154,22 +142,6 @@ public interface Magic {
* Number of chat spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE.
*/
public int CHAT_ACTION_TWO_LEVEL();
/**
* Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
public int GLIDE_LIMIT();
/**
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
public double FLIGHT_BLOCK_LIMIT();
/**
* Maximum speed that a player can climb a waterfall; Type=DOUBLE, Leniency=INCREASE.
*/
public double WATER_CLIMB_MAX();
/**
* Number of times a player can fail a velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
public int VELOCITY_TIME();
/**
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
*/
@@ -186,10 +158,6 @@ public interface Magic {
* Number of times a player can fail the velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
public int VELOCITY_MAXTIMES();
/**
* Number of times a player can fail the nofall check before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
public int NOFALL_LIMIT();
/**
* Number of times a player can sprint without proper food level before action is taken; Type=INTEGER, Leniency=INCREASE.
*/
@@ -262,14 +230,6 @@ 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 forwards or backwards while sneaking; Type=DOUBLE, Leniency=INCREASE.
*/
public double XZ_SPEED_MAX_SNEAK();
/**
* The number of clicks we should wait before checking if the player has used fast inventory; Type=INTEGER; Leniency=INCREASE.
*/
@@ -282,46 +242,6 @@ public interface Magic {
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
*/
public int TELEPORT_MIN();
/**
* The amount of milliseconds to compensate for a teleport; Type=INTEGER, Leniency=INCREASE.
*/
public int MOREPACKETS_TELEPORT_COMPENSATION();
/**
* The amount of milliseconds that were offset to flag for MorePackets; Type=INTEGER, Leniency=INCREASE.
*/
public int MOREPACKETS_TRIGGER_BALANCE();
/**
* The maximum amount of overall lag compensating in milliseconds; Type=INTEGER, Leniency=INCREASE.
*/
public int MOREPACKETS_MINIMUM_CLAMP();
/**
* Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE.
*/
public int VELOCITY_MAX_FLAGS();
/**
* The maximum angle difference allowed when attacking; TYPE=INTEGER, Leniency=INCREASE
*/
public int KILLAURA_MAX_ANGLE_DIFFERENCE();
/**
* The maximum amount of violations before flagging player as a cheater; TYPE=INTEGER, Leniency=INCREASE
*/
public int KILLAURA_MAX_ANGLE_VIOLATIONS();
/**
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
*/
public int ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE();
/**
* The minimum time it takes to regenerate health; TYPE=INTEGER, Leniency=DECREASE
*/
public int MIN_HEAL_TIME();
/**
* 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();
/**
* The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
*/
@@ -31,6 +31,7 @@ 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 {
@@ -102,16 +103,6 @@ public class BlockListener extends EventListener {
noHack = false;
}
}
// TODO fix
/* if (getCheckManager().willCheck(player, CheckType.LONG_REACH)) {
Distance distance = new Distance(player.getLocation(), block.getLocation());
result = getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.LONG_REACH);
noHack = false;
}
}*/
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
result = IllegalInteract.performCheck(player, event);
if (result.failed()) {
@@ -63,9 +63,9 @@ import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
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;
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
import com.rammelkast.anticheatreloaded.check.player.IllegalInteract;
import com.rammelkast.anticheatreloaded.util.Distance;
import com.rammelkast.anticheatreloaded.util.Permission;
import com.rammelkast.anticheatreloaded.util.User;
@@ -289,13 +289,18 @@ public class PlayerListener extends EventListener {
}
}
}
Block block = event.getClickedBlock();
if (block != null) {
Distance distance = new Distance(player.getLocation(), block.getLocation());
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
if (block != null && (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
CheckResult result = IllegalInteract.performCheck(player, event);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT);
}
}
}
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
@@ -375,12 +380,6 @@ public class PlayerListener extends EventListener {
log(result.getMessage(), player, CheckType.FLIGHT);
}
}
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
CheckResult result = GlideCheck.runCheck(player, distance);
if (result.failed()) {
log(result.getMessage(), player, CheckType.FLIGHT);
}
}
if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
CheckResult result = ElytraCheck.runCheck(player, distance);
if (result.failed()) {
@@ -55,7 +55,7 @@ public class MovementManager {
public boolean bottomSolid;
// If the current movement is up a slab or stair
public boolean halfMovement;
// If the player is on the ground
// If the player is on the ground (determined clientside!)
public boolean onGround;
// Ticks counter for last halfMovement
public int halfMovementHistoryCounter = 0;
@@ -66,7 +66,10 @@ public class MovementManager {
@SuppressWarnings("deprecation")
public void handle(Player player, Location from, Location to, Distance distance) {
this.onGround = player.isOnGround(); // TODO temp solution, can be spoofed
// TODO as of now, we "trust" the client to send the right thing
// This is checked for spoofing by "GroundFlight"
// Also seems to make NoFall cheats flag for speed lmao
this.onGround = player.isOnGround();
double x = distance.getXDifference();
double z = distance.getZDifference();
@@ -26,7 +26,8 @@ public enum Permission {
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_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;