Compare commits

...
5 Commits
14 changed files with 130 additions and 84 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId>
<version>1.9.0</version>
<version>1.9.1</version>
<name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties>
@@ -29,6 +29,7 @@ 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.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.potion.PotionEffectType;
@@ -229,7 +230,8 @@ public class Backend {
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
&& !VersionUtil.isSlowFalling(player)) {
&& !VersionUtil.isSlowFalling(player) && !Utilities
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1);
@@ -49,8 +49,10 @@ public class FlightCheck {
public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) {
// This was a teleport or user is flying/using elytra, so we don't care
|| VersionUtil.isFlying(player) || player.getVehicle() != null
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
// care
// about it.
return PASS;
}
@@ -90,6 +92,10 @@ public class FlightCheck {
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
: (blockPlaceAccountingTime + 1);
double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
// Fixes snow false positive
if (movementManager.motionY < 0.004 && Utilities
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
maxMotionY = 0.004D;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0)
return new CheckResult(CheckResult.Result.FAILED,
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
@@ -105,11 +111,12 @@ public class FlightCheck {
// End AirFlight
// Start AirClimb
// TODO two hardcoded values here shouldn't be there, temp against false
// TODO three 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) != 248
&& !(Math.round(movementManager.motionY * 1000) == 333
&& Math.round(movementManager.lastMotionY * 1000) != 333)
&& !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
@@ -121,9 +128,11 @@ public class FlightCheck {
return new CheckResult(CheckResult.Result.FAILED,
"tried to climb air (mY=" + movementManager.motionY + ")");
// TODO hardcoded value against false again..
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
&& movementManager.airTicks > 2 && !AntiCheatReloaded.getManager().getBackend().justVelocity(player)
&& !player.hasPotionEffect(PotionEffectType.JUMP)
&& !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")))
return new CheckResult(CheckResult.Result.FAILED,
@@ -36,7 +36,6 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast
* TODO soulsand speed
* TODO fix false positive with water weeds
*/
public class SpeedCheck {
@@ -100,7 +99,7 @@ public class SpeedCheck {
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0)
predict *= 1.25D;
// Boats sometimes give a false positive
if (Utilities.couldBeOnBoat(player, 0.5))
if (Utilities.couldBeOnBoat(player, 0.5, true))
predict *= 1.25D;
// Strafing in air when nearing terminal velocity gives false positives
// This fixes the issue but gives hackers some leniency which means we need another check for this
@@ -229,18 +228,15 @@ public class SpeedCheck {
public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
Backend backend = AntiCheatReloaded.getManager().getBackend();
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
.getMovementManager();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
return PASS;
if (player.isInsideVehicle() || player.isSleeping()
|| backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_EXTENSION()) || VersionUtil.isFlying(player)
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player)) {
return PASS;
}
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
Utilities.couldBeOnBoat(player), Utilities.isClimbableBlock(distance.getFrom().getBlock())
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)), movementManager.halfMovement, checksConfig);
@@ -260,9 +256,9 @@ public class SpeedCheck {
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
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
base += player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() * 0.2D;
}
if (player.hasPotionEffect(PotionEffectType.JUMP))
base += (player.getPotionEffect(PotionEffectType.JUMP).getAmplifier() + 1) * 0.2D;
return base;
}
@@ -42,7 +42,7 @@ public class WaterWalkCheck {
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0)
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null)
return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
@@ -50,14 +50,17 @@ public class WaterWalkCheck {
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player)
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0) || movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ"))
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
|| movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
return new CheckResult(Result.FAILED,
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && movementManager.onGround
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY"))
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
&& !Utilities.couldBeOnBoat(player, 0.3, false))
return new CheckResult(Result.FAILED,
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
@@ -51,6 +51,7 @@ public class Config extends ConfigurationFile {
public ConfigValue<List<String>> disabledWorlds;
public ConfigValue<Integer> notifyEveryVl;
public ConfigValue<Integer> maxSetbackDistance;
public Config(AntiCheatReloaded plugin, Configuration config) {
super(plugin, config, FILENAME);
@@ -85,5 +86,10 @@ public class Config extends ConfigurationFile {
if (notifyEveryVl.getValue() < 1) {
notifyEveryVl.setValue(5);
}
maxSetbackDistance = new ConfigValue<Integer>("system.max-setback-distance");
if (maxSetbackDistance.getValue() < 5) {
maxSetbackDistance.setValue(50);
}
}
}
@@ -32,6 +32,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
@@ -134,29 +135,28 @@ public class EntityListener extends EventListener {
}
}
}
if (e.getDamager() instanceof Player) {
Player player = (Player) e.getDamager();
getBackend().logDamage(player, 1);
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkAngle(player, event);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (noHack) {
decrease(player);
}
}
if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
Player player = (Player) e.getDamager();
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkAngle(player, event);
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
if (result.failed()) {
event.setCancelled(!silentMode());
log(result.getMessage(), player, CheckType.KILLAURA);
noHack = false;
}
}
if (noHack) {
decrease(player);
}
}
}
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
@@ -52,6 +52,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@@ -256,9 +257,6 @@ public class PlayerListener extends EventListener {
@EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
Player player = event.getPlayer();
if (!event.isSprinting()) {
getBackend().logEnterExit(player);
}
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
CheckResult result = getBackend().checkSprintHungry(event);
if (result.failed()) {
@@ -436,7 +434,6 @@ public class PlayerListener extends EventListener {
}
}
boolean changed = false;
if (event.getTo() != event.getFrom()) {
double x = distance.getXDifference();
double z = distance.getZDifference();
@@ -449,7 +446,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.SPEED);
changed = true;
}
}
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
@@ -458,7 +454,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.SPEED);
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
@@ -469,7 +464,6 @@ public class PlayerListener extends EventListener {
player.teleport(player.getLocation().clone().subtract(0, 0.52, 0));
}
log(result.getMessage(), player, CheckType.WATER_WALK);
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
@@ -479,7 +473,6 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.SPIDER);
changed = true;
}
}
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
@@ -491,12 +484,8 @@ public class PlayerListener extends EventListener {
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.FASTLADDER);
changed = true;
}
}
if (!changed) {
user.setGoodLocation(event.getFrom());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
CheckResult result = AimbotCheck.runCheck(player, event);
@@ -21,6 +21,8 @@ package com.rammelkast.anticheatreloaded.util;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
public class MovementManager {
// Ticks in air
@@ -78,16 +80,16 @@ public class MovementManager {
// 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();
this.lastDistanceXZ = this.distanceXZ;
double z = distance.getZDifference();
this.lastDistanceXZ = this.distanceXZ;
this.distanceXZ = Math.sqrt(x * x + z * z);
// Account for standing on boat
if (Utilities.couldBeOnBoat(player, 0.25))
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player))
this.onGround = true;
this.touchedGroundThisTick = false;
this.halfMovement = false;
if (!this.onGround) {
@@ -100,7 +102,7 @@ public class MovementManager {
this.airTicks = 0;
this.groundTicks++;
}
if (Utilities.couldBeOnIce(to)) {
this.iceTicks++;
this.iceInfluenceTicks = 60;
@@ -109,7 +111,7 @@ public class MovementManager {
if (this.iceInfluenceTicks > 0)
this.iceInfluenceTicks--;
}
if (Utilities.couldBeOnSlime(to)) {
this.slimeTicks++;
this.slimeInfluenceTicks = 40;
@@ -118,19 +120,19 @@ public class MovementManager {
if (this.slimeInfluenceTicks > 0)
this.slimeInfluenceTicks--;
}
if (VersionUtil.isGliding(player)) {
this.elytraEffectTicks = 30;
} else {
if (this.elytraEffectTicks > 0)
this.elytraEffectTicks--;
}
if (player.isSneaking())
this.sneakingTicks++;
else
this.sneakingTicks = 0;
if (Utilities.isNearWater(player))
this.nearLiquidTicks = 8;
else {
@@ -139,27 +141,31 @@ public class MovementManager {
else
this.nearLiquidTicks = 0;
}
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
+ distance.getZDifference() * distance.getZDifference());
this.acceleration = currentDistanceSq - lastDistanceSq;
this.lastMotionY = this.motionY;
this.motionY = to.getY() - from.getY();
Location top = to.clone().add(0, 2, 0);
this.topSolid = top.getBlock().getType().isSolid();
Location bottom = to.clone().add(0, -1, 0);
this.bottomSolid = bottom.getBlock().getType().isSolid();
if ((this.motionY > 0.464D && this.motionY <= 0.5625D) && (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
if ((this.motionY > 0.42D && this.motionY <= 0.5625D)
&& (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
this.halfMovement = true;
this.halfMovementHistoryCounter = 30;
} else {
if (this.halfMovementHistoryCounter > 0)
this.halfMovementHistoryCounter--;
}
// Update "good location"
AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).setGoodLocation(from);
}
}
@@ -217,7 +217,8 @@ public class User {
* @return last known valid location
*/
public Location getGoodLocation(Location location) {
if (goodLocation == null) {
if (goodLocation == null || !location.getWorld().equals(goodLocation.getWorld())
|| location.distance(goodLocation) > config.getConfig().maxSetbackDistance.getValue()) {
return location;
}
@@ -124,17 +124,22 @@ public final class Utilities {
}
public static boolean couldBeOnBoat(Player player) {
return couldBeOnBoat(player, 0.35);
return couldBeOnBoat(player, 0.35, false);
}
public static boolean couldBeOnBoat(Player player, double range) {
public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity instanceof Boat)
return true;
if (entity instanceof Boat) {
if (((Boat) entity).getLocation().getY() < player.getLocation().getY() + 0.25) {
return true;
} else if (!checkY) {
return true;
}
}
}
return false;
}
/**
* Determine whether a player could be standing on ice
*
@@ -171,6 +176,31 @@ public final class Utilities {
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a block is a shulker box
*
* @param block block to check
* @return true if block is a shulker box
*/
public static boolean isShulkerBox(Block block) {
Material type = block.getType();
return type.name().endsWith("SHULKER_BOX");
}
public static boolean isNearShulkerBox(Location location) {
if (VersionUtil.isBountifulUpdate())
return false;
return isShulkerBox(location.getBlock())
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a player could be standing on a halfblock
*
@@ -196,7 +226,7 @@ public final class Utilities {
}
public static boolean isHalfblock(Block block) {
return isSlab(block) || isStair(block) || isWall(block);
return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW;
}
+1 -1
View File
@@ -192,7 +192,7 @@ velocity:
# Should this check be enabled?
enabled: true
# Minimum percentage of the given knockback a player has to meet
minimumPercentage: 98
minimumPercentage: 75
# Amount of low-velocity moments before flagging
vlBeforeFlag: 2
+5 -1
View File
@@ -38,7 +38,11 @@ system:
# Minimum value is 1, default is 8
# Example with 5: notifications after 5 vl, 10vl, 15vl, etc.
notify-every-vl: 8
# Use /AntiCheatReloaded checks for a list of valid checks
# Maximum distance a player can be set back
# If the last known valid location is further away than this,
# the player will be rubberbanded at their current location
# Minimum value is 5, default is 50
max-setback-distance: 50
disable-in:
- example-world
- example-world-2
+4 -4
View File
@@ -1,9 +1,9 @@
# Time to exempt a player from moving because of entering/exiting a vehicle
# Increase in case of false positives
ENTERED_EXITED_TIME: 1000
ENTERED_EXITED_TIME: 250
# Time to exempt a player from moving because of teleporting
# Increase in case of false positives
TELEPORT_TIME: 1000
TELEPORT_TIME: 1500
# Time to exempt a player from moving because of exiting fly mode
# Changing this value is almost never required
EXIT_FLY_TIME: 2000
@@ -26,9 +26,9 @@ EXPLOSION_DAMAGE_TIME: 5000
# Amount of seconds to extend a players velocitized state after receiving velocity again
VELOCITY_EXTENSION: 2
# Time a player is considered to have a change in velocity
VELOCITY_TIME: 2000
VELOCITY_TIME: 1000
# This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_PREVENT: 5000
VELOCITY_PREVENT: 2000
# This is a set value and shouldn't be changed unless you know what you're doing
VELOCITY_MAXTIMES: 2
# Minimum travel distance for move to be considered a teleport and subsequently be ignored