Fixed WaterWalk false positive with carpets, fixed 1.17-related Speed false positive

This commit is contained in:
Rammelkast committed 2021-10-24 11:12:30 +02:00
1 parent 5c596f5e2f
commit 6af50e5a33
3 files changed
+37 -15

No files matched your search

@@ -36,6 +36,7 @@ import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities; import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VelocityTracker; import com.rammelkast.anticheatreloaded.util.VelocityTracker;
import com.rammelkast.anticheatreloaded.util.VersionUtil; import com.rammelkast.anticheatreloaded.util.VersionUtil;
import com.rammelkast.anticheatreloaded.util.XMaterial;
/** /**
* @author Rammelkast TODO soulsand speed TODO buffer system * @author Rammelkast TODO soulsand speed TODO buffer system
@@ -384,6 +385,11 @@ public final class SpeedCheck {
maxMotionY *= 1.0525D; maxMotionY *= 1.0525D;
} }
// Adjust for powdered snow
if (distance.getFrom().getBlock().getType() == XMaterial.POWDER_SNOW.parseMaterial()) {
maxMotionY += 0.17D;
}
// Adjust for velocity // Adjust for velocity
maxMotionY += velocityTracker.getVertical(); maxMotionY += velocityTracker.getVertical();
@@ -43,10 +43,10 @@ public final class WaterWalkCheck {
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid); final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
final MovementManager movementManager = user.getMovementManager(); final MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player) if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player) || Utilities.isOnCarpet(player)
|| movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player) || movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player)) {
|| player.getLocation().getBlock().getType().name().endsWith("CARPET"))
return PASS; return PASS;
}
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks(); final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
final Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock(); final Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
@@ -55,30 +55,30 @@ public final class WaterWalkCheck {
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0) && ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
|| movementManager.motionY == Utilities.JUMP_MOTION_Y) || movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ") && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false)) && !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false)) {
return new CheckResult(Result.FAILED, "Walk", return new CheckResult(Result.FAILED, "Walk",
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")"); "tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
}
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && movementManager.onGround && 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)) && !Utilities.couldBeOnBoat(player, 0.3, false)) {
return new CheckResult(Result.FAILED, "Hop", return new CheckResult(Result.FAILED, "Hop",
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")"); "tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
}
double minAbsMotionY = 0.12D; final double minAbsMotionY = 0.12D + (VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D);
if (player.hasPotionEffect(PotionEffectType.SPEED))
minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid() if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY && Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ") && movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
&& movementManager.lastMotionY > -0.25 && movementManager.lastMotionY > -0.25
&& !Utilities.couldBeOnBoat(player, 0.3, false)) && !Utilities.couldBeOnBoat(player, 0.3, false)) {
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz=" return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")"); + Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
}
return PASS; return PASS;
} }
@@ -464,8 +464,8 @@ public final class Utilities {
* @param player player to check * @param player player to check
* @return true if on lily pad * @return true if on lily pad
*/ */
public static boolean isOnLilyPad(Player player) { public static boolean isOnLilyPad(final Player player) {
Block block = player.getLocation().getBlock(); final Block block = player.getLocation().getBlock();
return block.getType() == XMaterial.LILY_PAD.parseMaterial() return block.getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial() || block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial() || block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
@@ -473,13 +473,28 @@ public final class Utilities {
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial(); || block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
} }
/**
* Determine whether a player is standing on a carpet
*
* @param player player to check
* @return true if on carpet
*/
public static boolean isOnCarpet(final Player player) {
final Block block = player.getLocation().getBlock();
return block.getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.NORTH).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.SOUTH).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.EAST).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.WEST).getType().name().endsWith("CARPET");
}
/** /**
* Determine whether a player is fully submersed in liquid * Determine whether a player is fully submersed in liquid
* *
* @param player player to check * @param player player to check
* @return true if submersed * @return true if submersed
*/ */
public static boolean isSubmersed(Player player) { public static boolean isSubmersed(final Player player) {
return player.getLocation().getBlock().isLiquid() return player.getLocation().getBlock().isLiquid()
&& player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid(); && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
} }
@@ -638,7 +653,7 @@ public final class Utilities {
* @param block block to check * @param block block to check
* @return true if climbable * @return true if climbable
*/ */
public static boolean isClimbableBlock(Block block) { public static boolean isClimbableBlock(final Block block) {
return CLIMBABLE.contains(block.getType()); return CLIMBABLE.contains(block.getType());
} }
@@ -648,7 +663,7 @@ public final class Utilities {
* @param player to check * @param player to check
* @return true if on vine * @return true if on vine
*/ */
public static boolean isOnVine(Player player) { public static boolean isOnVine(final Player player) {
return player.getLocation().getBlock().getType() == XMaterial.VINE.parseMaterial(); return player.getLocation().getBlock().getType() == XMaterial.VINE.parseMaterial();
} }
@@ -1034,6 +1049,7 @@ public final class Utilities {
CLIMBABLE.add(XMaterial.CAVE_VINES.parseMaterial()); CLIMBABLE.add(XMaterial.CAVE_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.CAVE_VINES_PLANT.parseMaterial()); CLIMBABLE.add(XMaterial.CAVE_VINES_PLANT.parseMaterial());
CLIMBABLE.add(XMaterial.GLOW_BERRIES.parseMaterial()); CLIMBABLE.add(XMaterial.GLOW_BERRIES.parseMaterial());
CLIMBABLE.add(XMaterial.POWDER_SNOW.parseMaterial());
} }
// End 1.17 objects // End 1.17 objects
// End climbable // End climbable