mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
False positive fixes: Nofall false with shulkers, flight false positive with snow, speed false positive with snow, waterwalk false positive with boats and KillAura false positive with thorns
This commit is contained in:
1 parent
4deb8ae0fb
commit
e9a99f0463
7 files changed
+76
-43
No files matched your search
@@ -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);
|
||||
|
||||
@@ -92,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 + ")");
|
||||
@@ -123,9 +127,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 {
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -80,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, true) && !Utilities.isSubmersed(player))
|
||||
this.onGround = true;
|
||||
|
||||
|
||||
this.touchedGroundThisTick = false;
|
||||
this.halfMovement = false;
|
||||
if (!this.onGround) {
|
||||
@@ -102,7 +102,7 @@ public class MovementManager {
|
||||
this.airTicks = 0;
|
||||
this.groundTicks++;
|
||||
}
|
||||
|
||||
|
||||
if (Utilities.couldBeOnIce(to)) {
|
||||
this.iceTicks++;
|
||||
this.iceInfluenceTicks = 60;
|
||||
@@ -111,7 +111,7 @@ public class MovementManager {
|
||||
if (this.iceInfluenceTicks > 0)
|
||||
this.iceInfluenceTicks--;
|
||||
}
|
||||
|
||||
|
||||
if (Utilities.couldBeOnSlime(to)) {
|
||||
this.slimeTicks++;
|
||||
this.slimeInfluenceTicks = 40;
|
||||
@@ -120,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 {
|
||||
@@ -141,29 +141,30 @@ 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);
|
||||
}
|
||||
|
||||
@@ -176,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
|
||||
*
|
||||
@@ -201,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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user