Fix FastLadder false with elytra, fix speed & flight false positive with trident, fix #122 and fix #119, fix illegalinteract false positive with torches

This commit is contained in:
Rammelkast committed 2020-11-07 17:06:50 +01:00
1 parent 9473781a26
commit 646e906ada
9 files changed
+83 -23

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.rammelkast.anticheatreloaded</groupId> <groupId>com.rammelkast.anticheatreloaded</groupId>
<artifactId>AntiCheatReloaded</artifactId> <artifactId>AntiCheatReloaded</artifactId>
<version>1.9.5</version> <version>1.9.6-PRE</version>
<name>AntiCheatReloaded</name> <name>AntiCheatReloaded</name>
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url> <url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
<properties> <properties>
@@ -231,8 +231,11 @@ public class Backend {
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player) && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isNearWater(player)
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR") && !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
&& !VersionUtil.isSlowFalling(player) && !Utilities && !VersionUtil.isSlowFalling(player)
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation()) && !Utilities.isNearClimbable(player)) { && !Utilities
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())
&& !Utilities.isNearClimbable(player)
&& !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))) {
if (player.getFallDistance() == 0) { if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) { if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1); nofallViolation.put(uuid, 1);
@@ -244,8 +247,8 @@ public class Backend {
int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
if (i >= vlBeforeFlag) { if (i >= vlBeforeFlag) {
nofallViolation.put(player.getUniqueId(), 1); nofallViolation.put(player.getUniqueId(), 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " return new CheckResult(CheckResult.Result.FAILED,
+ i + " times in a row, max=" + vlBeforeFlag + ")"); "tried to avoid fall damage (" + i + " times in a row, max=" + vlBeforeFlag + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.rammelkast.anticheatreloaded.check.movement; package com.rammelkast.anticheatreloaded.check.movement;
import java.util.HashMap; import java.util.HashMap;
@@ -31,6 +30,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.check.CheckType; import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.config.providers.Checks; import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class FastLadderCheck { public class FastLadderCheck {
@@ -38,11 +38,11 @@ public class FastLadderCheck {
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED); private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult runCheck(Player player, double y) { public static CheckResult runCheck(Player player, double y) {
// Only check if fully on ladder // Only check if fully on ladder and not flying
// Liquids are climbable blocks, so we have to add a seperate check // Liquids are climbable blocks, so we have to add a seperate check
if (!Utilities.isClimbableBlock(player.getLocation().getBlock()) if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock()) || !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|| player.getLocation().getBlock().isLiquid()) { || player.getLocation().getBlock().isLiquid() || VersionUtil.isFlying(player)) {
return PASS; return PASS;
} }
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@@ -50,7 +51,8 @@ public class FlightCheck {
public static CheckResult runCheck(Player player, Distance distance) { public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN() if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player) || player.getVehicle() != null || VersionUtil.isFlying(player) || player.getVehicle() != null
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) { || AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|| VersionUtil.isRiptiding(player)) {
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't // This was a teleport or user is flying/using elytra/in a vehicle, so we don't
// care // care
// about it. // about it.
@@ -91,18 +93,26 @@ public class FlightCheck {
// Fixes snow false positive // Fixes snow false positive
if (movementManager.motionY < 0.004 && Utilities if (movementManager.motionY < 0.004 && Utilities
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation())) .isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation()))
maxMotionY = 0.004D; maxMotionY += 0.004D;
if (Utilities.isNearWater(player) || Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)))
maxMotionY += 0.05;
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0 if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))) && !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 0.75, 0))
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")"); "tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 0.01 if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < 5E-3
&& !Utilities.couldBeOnBoat(player) && !Utilities.couldBeOnBoat(player)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
&& !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player) && !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player)
&& movementManager.elytraEffectTicks <= 25) && movementManager.elytraEffectTicks <= 25
&& !Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
&& !Utilities.isNearWater(player)
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0)))
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff=" return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")"); + Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
} }
@@ -121,8 +131,9 @@ public class FlightCheck {
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !player.hasPotionEffect(PotionEffectType.JUMP)
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig && (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports")) .getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
&& (!Utilities.isNearBed(distance.getTo()) && (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
|| (Utilities.isNearBed(distance.getTo()) && movementManager.motionY > 0.12675)) || Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
&& movementManager.motionY > 0.15))
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) && movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25)
return new CheckResult(CheckResult.Result.FAILED, "AirClimb", return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
"tried to climb air (mY=" + movementManager.motionY + ")"); "tried to climb air (mY=" + movementManager.motionY + ")");
@@ -160,13 +171,20 @@ public class FlightCheck {
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION; double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
double offset = Math.abs(gravitatedY - movementManager.motionY); double offset = Math.abs(gravitatedY - movementManager.motionY);
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset"); double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
if (Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|| Utilities.isNearClimbable(distance.getFrom()) || Utilities.isNearWater(player)
|| (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
maxOffset += 0.15D;
if (offset > maxOffset && movementManager.airTicks > 2) { if (offset > maxOffset && movementManager.airTicks > 2) {
int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1; int vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl); GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag"); int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
if (vl >= vlBeforeFlag) if (vl >= vlBeforeFlag) {
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
return new CheckResult(CheckResult.Result.FAILED, "Gravity", return new CheckResult(CheckResult.Result.FAILED, "Gravity",
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")"); "ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
}
} else { } else {
GRAVITY_VIOLATIONS.remove(player.getUniqueId()); GRAVITY_VIOLATIONS.remove(player.getUniqueId());
} }
@@ -34,7 +34,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
/** /**
* @author Rammelkast TODO soulsand speed * @author Rammelkast TODO soulsand speed TODO buffer system
*/ */
public class SpeedCheck { public class SpeedCheck {
@@ -46,7 +46,8 @@ public class SpeedCheck {
public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) { public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
Backend backend = AntiCheatReloaded.getManager().getBackend(); Backend backend = AntiCheatReloaded.getManager().getBackend();
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)) if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)
|| VersionUtil.isRiptiding(player))
return PASS; return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()) MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
@@ -201,6 +202,10 @@ public class SpeedCheck {
limit *= 1.4D; limit *= 1.4D;
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
limit *= 1.2D; limit *= 1.2D;
// Adjust for other effects
if ((movementManager.hasFireResistanceEffect || movementManager.hasBadOmenEffect)
&& movementManager.groundTicks > 3)
limit *= 1.2D;
if (movementManager.iceInfluenceTicks >= 50) { if (movementManager.iceInfluenceTicks >= 50) {
// When moving off ice // When moving off ice
if (!Utilities.couldBeOnIce(movingTowards)) if (!Utilities.couldBeOnIce(movingTowards))
@@ -82,7 +82,7 @@ public class IllegalInteract {
} }
private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) { private static CheckResult checkBlockPlace(Player player, BlockPlaceEvent event) {
if (!isValidTarget(player, event.getBlock())) { if (event.getBlock().getType().isSolid() && !isValidTarget(player, event.getBlock())) {
return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view"); return new CheckResult(CheckResult.Result.FAILED, "Place", "tried to place a block out of their view");
} }
return PASS; return PASS;
@@ -89,6 +89,14 @@ public class MovementManager {
public boolean hasSpeedEffect = false; public boolean hasSpeedEffect = false;
// If the player had speed effect previous tick // If the player had speed effect previous tick
public boolean hadSpeedEffect = false; public boolean hadSpeedEffect = false;
// If the player has a fire resistance effect
public boolean hasFireResistanceEffect = false;
// If the player had fire resistance effect previous tick
public boolean hadFireResistanceEffect = false;
// If the player has a bad omen effect
public boolean hasBadOmenEffect = false;
// If the player had bad omen effect previous tick
public boolean hadBadOmenEffect = false;
// Time of last update // Time of last update
public long lastUpdate; public long lastUpdate;
@@ -181,6 +189,12 @@ public class MovementManager {
this.hadSpeedEffect = this.hasSpeedEffect; this.hadSpeedEffect = this.hasSpeedEffect;
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED); this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
this.hadFireResistanceEffect = this.hasFireResistanceEffect;
this.hasFireResistanceEffect = player.hasPotionEffect(PotionEffectType.FIRE_RESISTANCE);
this.hadBadOmenEffect = this.hasBadOmenEffect;
this.hasBadOmenEffect = player.hasPotionEffect(PotionEffectType.BAD_OMEN);
double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference() double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference()); + this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference() double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
@@ -488,6 +488,26 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid(); || player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
} }
/**
* Determine whether a location is near a liquid block
*
* @param location Location to check
* @return true if near liquid block
*/
public static boolean isNearWater(Location location) {
return location.getBlock().isLiquid()
|| location.getBlock().getRelative(BlockFace.UP).isLiquid()
|| location.getBlock().getRelative(BlockFace.DOWN).isLiquid()
|| location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
|| location.getBlock().getRelative(BlockFace.SOUTH).isLiquid()
|| location.getBlock().getRelative(BlockFace.EAST).isLiquid()
|| location.getBlock().getRelative(BlockFace.WEST).isLiquid()
|| location.getBlock().getRelative(BlockFace.NORTH_EAST).isLiquid()
|| location.getBlock().getRelative(BlockFace.NORTH_WEST).isLiquid()
|| location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|| location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
}
/** /**
* Determine whether a player is surrounded by liquid blocks * Determine whether a player is surrounded by liquid blocks
* *
+4 -4
View File
@@ -18,7 +18,7 @@ flight:
accountForTpsDrops: 250 accountForTpsDrops: 250
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'had too little Y dropoff' after teleports # Increase this is you debug 'had too little Y dropoff' after teleports
accountForTeleports: 150 accountForTeleports: 400
# Checks for climbing behaviour in air # Checks for climbing behaviour in air
# Debugs as 'tried to climb air' # Debugs as 'tried to climb air'
airClimb: airClimb:
@@ -26,7 +26,7 @@ flight:
enabled: true enabled: true
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'tried to climb air' after teleports # Increase this is you debug 'tried to climb air' after teleports
accountForTeleports: 50 accountForTeleports: 150
# Checks if a player is faking it's ground status to fly # Checks if a player is faking it's ground status to fly
# Debugs as 'faked ground to fly' # Debugs as 'faked ground to fly'
groundFlight: groundFlight:
@@ -41,7 +41,7 @@ flight:
maxOffset: 0.005 maxOffset: 0.005
# How many milliseconds to account for teleports # How many milliseconds to account for teleports
# Increase this is you debug 'ignored gravity' after teleports # Increase this is you debug 'ignored gravity' after teleports
accountForTeleports: 100 accountForTeleports: 150
# Amount of illegal moves before flagging # Amount of illegal moves before flagging
vlBeforeFlag: 5 vlBeforeFlag: 5
@@ -108,7 +108,7 @@ strafe:
# Maximum angle change when moving in air # Maximum angle change when moving in air
maxAngleChange: 0.50 maxAngleChange: 0.50
# Minimum movement distance for the strafe check to be active # Minimum movement distance for the strafe check to be active
minActivationDistance: 0.025 minActivationDistance: 0.04
# WaterWalk check settings # WaterWalk check settings
# Checks if a player is walking on water # Checks if a player is walking on water