Add BoatFly check, fix WaterWalk false positive

This commit is contained in:
Rammelkast committed 2020-10-17 13:46:54 +02:00
1 parent ab2fcc5521
commit 619c8efae1
4 files changed
+55 -2

No files matched your search

@@ -18,10 +18,50 @@
*/
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.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
import com.rammelkast.anticheatreloaded.config.providers.Checks;
import com.rammelkast.anticheatreloaded.util.MovementManager;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class BoatFlyCheck {
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, MovementManager movementManager, Location to) {
if (movementManager.distanceXZ <= 0 || movementManager.motionY <= 1E-3
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 50) || VersionUtil.isFlying(player)
|| !player.isInsideVehicle())
return PASS;
UUID uuid = player.getUniqueId();
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (player.getVehicle().getType() == EntityType.BOAT) {
Block bottom = player.getWorld().getBlockAt(to.getBlockX(), to.getBlockY() - 1, to.getBlockZ());
if (!Utilities.cantStandAt(bottom))
return PASS;
int violations = VIOLATIONS.getOrDefault(uuid, 1);
if (violations++ >= checksConfig.getInteger(CheckType.BOATFLY, "vlBeforeFlag")) {
violations = 0;
return new CheckResult(Result.FAILED, "tried to fly in a boat (mY=" + movementManager.motionY
+ ", bottom=" + bottom.getType().name().toLowerCase() + ")");
}
VIOLATIONS.put(uuid, violations);
}
return PASS;
}
}
@@ -72,7 +72,8 @@ public class WaterWalkCheck {
&& Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
&& movementManager.lastMotionY > -0.25)
&& movementManager.lastMotionY > -0.25
&& !Utilities.couldBeOnBoat(player, 0.3, false))
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
@@ -398,6 +398,16 @@ public class PlayerListener extends EventListener {
log(result.getMessage(), player, CheckType.ELYTRAFLY, result.getSubCheck());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.BOATFLY)) {
CheckResult result = BoatFlyCheck.runCheck(player, user.getMovementManager(), to);
if (result.failed()) {
if (!silentMode()) {
player.eject();
event.setTo(user.getGoodLocation(from.clone()));
}
log(result.getMessage(), player, CheckType.BOATFLY, result.getSubCheck());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
&& event.getFrom().getY() > event.getTo().getY()) {
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));