Update to 1.16.2, fix #102, fix #104, fix strafe & reach false positives

This commit is contained in:
Rammelkast committed 2020-08-27 11:05:28 +02:00
1 parent 1f48785d1d
commit 768331011e
11 files changed
+69 -76

No files matched your search

@@ -152,5 +152,4 @@ public class AntiCheatAPI {
return AntiCheatReloaded.getManager();
}
}
@@ -619,10 +619,6 @@ public class Backend {
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
}
public void logExitFly(final Player player) {
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
}
public void logBoatCollision(final Player player) {
// TODO config??
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + 100 /* 2 ticks */);
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@@ -59,6 +60,8 @@ public class KillAuraCheck {
double allowedReach = target.getVelocity().length() < 0.08
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
if (player.getGameMode() == GameMode.CREATIVE)
allowedReach += 1.5D;
// Lag compensation
double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach", "lagCompensation.lagExtraReach");
double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
@@ -19,6 +19,7 @@
package com.rammelkast.anticheatreloaded.check.movement;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@@ -42,7 +43,8 @@ public class StrafeCheck {
public static CheckResult runCheck(Player player, double x, double z, Location from, Location to) {
if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player)
|| Utilities.isNearClimbable(player) || VersionUtil.isFlying(player) || player.isDead())
|| Utilities.isNearClimbable(player) || VersionUtil.isFlying(player) || player.isDead()
|| Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)))
return PASS;
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
@@ -50,7 +52,8 @@ public class StrafeCheck {
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
if (System.currentTimeMillis() - movementManager.lastTeleport <= checksConfig.getInteger(CheckType.STRAFE,
"accountForTeleports") || movementManager.elytraEffectTicks >= 20)
"accountForTeleports") || movementManager.elytraEffectTicks >= 20
|| movementManager.halfMovementHistoryCounter >= 20)
return PASS;
Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
@@ -58,9 +61,9 @@ public class StrafeCheck {
float angle = newAcceleration.angle(oldAcceleration);
double distance = newAcceleration.lengthSquared();
if (angle > checksConfig
.getDouble(CheckType.STRAFE, "maxAngleChange") && distance > checksConfig
.getDouble(CheckType.STRAFE, "minActivationDistance") && Utilities.cantStandFar(to.getBlock()))
if (angle > checksConfig.getDouble(CheckType.STRAFE, "maxAngleChange")
&& distance > checksConfig.getDouble(CheckType.STRAFE, "minActivationDistance")
&& Utilities.cantStandFar(to.getBlock()))
return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
return PASS;
}
@@ -44,7 +44,7 @@ public class WaterWalkCheck {
MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player))
|| VersionUtil.isRiptiding(player) || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player))
return PASS;
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
@@ -46,10 +46,6 @@ public interface Magic {
* Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
*/
public int TELEPORT_TIME();
/**
* Time to exempt a player from moving because of exiting fly mode; Type=SYSTEM, Leniency=INCREASE.
*/
public int EXIT_FLY_TIME();
/**
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
*/
@@ -46,7 +46,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.PlayerToggleSprintEvent;
@@ -48,7 +48,7 @@ public final class Utilities {
public static final Material LILY_PAD;
public static final Material COB_WEB;
public static final double JUMP_MOTION_Y = 0.41999998688697815;
/**
@@ -117,16 +117,17 @@ public final class Utilities {
public static boolean canStand(Block block) {
return !(block.isLiquid() || block.getType() == Material.AIR);
}
public static boolean isNotNearSlime(Block block) {
return !isSlime(block.getRelative(BlockFace.NORTH)) && !isSlime(block.getRelative(BlockFace.EAST))
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST)) && !isSlime(block.getRelative(BlockFace.DOWN));
&& !isSlime(block.getRelative(BlockFace.SOUTH)) && !isSlime(block.getRelative(BlockFace.WEST))
&& !isSlime(block.getRelative(BlockFace.DOWN));
}
public static boolean couldBeOnBoat(Player player) {
return couldBeOnBoat(player, 0.35, false);
}
public static boolean couldBeOnBoat(Player player, double range, boolean checkY) {
for (Entity entity : player.getNearbyEntities(range, range, range)) {
if (entity instanceof Boat) {
@@ -148,11 +149,11 @@ public final class Utilities {
*/
public static boolean couldBeOnIce(Location location) {
return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
location.getBlockZ())) || isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
location.getBlockZ()))
|| isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.26D,
location.getBlockZ()));
}
/**
* Determine whether a block is a type of ice
*
@@ -163,10 +164,9 @@ public final class Utilities {
Material type = block.getType();
return type.name().endsWith("ICE");
}
public static boolean isNearIce(Location location) {
return isIce(location.getBlock())
|| isIce(location.getBlock().getRelative(BlockFace.NORTH))
return isIce(location.getBlock()) || isIce(location.getBlock().getRelative(BlockFace.NORTH))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH))
|| isIce(location.getBlock().getRelative(BlockFace.EAST))
|| isIce(location.getBlock().getRelative(BlockFace.WEST))
@@ -175,7 +175,7 @@ public final class Utilities {
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a block is a shulker box
*
@@ -186,12 +186,11 @@ public final class Utilities {
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))
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))
@@ -200,7 +199,7 @@ public final class Utilities {
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isShulkerBox(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a player could be standing on a halfblock
*
@@ -208,14 +207,14 @@ public final class Utilities {
* @return true if the player could be standing on a halfblock
*/
public static boolean couldBeOnHalfblock(Location location) {
return isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.01D,
location.getBlockZ())) || isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
return isNearHalfblock(
new Location(location.getWorld(), location.getX(), location.getY() - 0.01D, location.getBlockZ()))
|| isNearHalfblock(new Location(location.getWorld(), location.getX(), location.getY() - 0.51D,
location.getBlockZ()));
}
public static boolean isNearHalfblock(Location location) {
return isHalfblock(location.getBlock())
|| isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
return isHalfblock(location.getBlock()) || isHalfblock(location.getBlock().getRelative(BlockFace.NORTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH))
|| isHalfblock(location.getBlock().getRelative(BlockFace.EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.WEST))
@@ -224,7 +223,7 @@ public final class Utilities {
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isHalfblock(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
public static boolean isHalfblock(Block block) {
if (!VersionUtil.isBountifulUpdate()) {
BoundingBox box = block.getBoundingBox();
@@ -232,10 +231,10 @@ public final class Utilities {
if (height > 0.42 && height <= 0.6 && block.getType().isSolid())
return true;
}
return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW;
return isSlab(block) || isStair(block) || isWall(block) || block.getType() == Material.SNOW
|| block.getType().name().endsWith("HEAD");
}
/**
* Determine whether a player could be standing on slime
*
@@ -244,11 +243,11 @@ public final class Utilities {
*/
public static boolean couldBeOnSlime(Location location) {
return isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
location.getBlockZ())) || isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
location.getBlockZ()))
|| isNearSlime(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.51D,
location.getBlockZ()));
}
/**
* Determine whether a block is a type of slime
*
@@ -259,10 +258,9 @@ public final class Utilities {
Material type = block.getType();
return type.equals(XMaterial.SLIME_BLOCK.parseMaterial());
}
public static boolean isNearSlime(Location location) {
return isSlime(location.getBlock())
|| isSlime(location.getBlock().getRelative(BlockFace.NORTH))
return isSlime(location.getBlock()) || isSlime(location.getBlock().getRelative(BlockFace.NORTH))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH))
|| isSlime(location.getBlock().getRelative(BlockFace.EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.WEST))
@@ -271,7 +269,7 @@ public final class Utilities {
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|| isSlime(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
}
/**
* Determine whether a player is fully submerged in water
*
@@ -370,7 +368,7 @@ public final class Utilities {
Material type = block.getType();
return type.name().endsWith("SLAB");
}
/**
* Determine whether a block is a bed
*
@@ -381,10 +379,9 @@ public final class Utilities {
Material type = block.getType();
return type.name().endsWith("BED");
}
public static boolean isNearBed(Location location) {
return isBed(location.getBlock())
|| isBed(location.getBlock().getRelative(BlockFace.NORTH))
return isBed(location.getBlock()) || isBed(location.getBlock().getRelative(BlockFace.NORTH))
|| isBed(location.getBlock().getRelative(BlockFace.SOUTH))
|| isBed(location.getBlock().getRelative(BlockFace.EAST))
|| isBed(location.getBlock().getRelative(BlockFace.WEST))
@@ -404,7 +401,7 @@ public final class Utilities {
Material type = block.getType();
return type.name().endsWith("STAIRS");
}
/**
* Determine whether a block is a wall
*
@@ -489,7 +486,7 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|| player.getLocation().getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
}
/**
* Determine whether a player is surrounded by liquid blocks
*
@@ -498,8 +495,7 @@ public final class Utilities {
*/
public static boolean isSurroundedByWater(Player player) {
Location location = player.getLocation().clone().subtract(0, 0.1, 0);
return location.getBlock().isLiquid()
&& location.getBlock().getRelative(BlockFace.NORTH).isLiquid()
return location.getBlock().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()
@@ -520,7 +516,7 @@ public final class Utilities {
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == COB_WEB
|| player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == COB_WEB;
}
/**
* Determine whether a player is near a climbable block
*
@@ -536,7 +532,7 @@ public final class Utilities {
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|| isClimbableBlock(player.getLocation().getBlock().getRelative(BlockFace.WEST));
}
/**
* Determine whether a location is near a climbable block
*
@@ -730,6 +726,7 @@ public final class Utilities {
/**
* Rounds a float value to a scale
*
* @param value Value to round
* @param scale Scale
* @return rounded value
@@ -737,9 +734,10 @@ public final class Utilities {
public static float roundFloat(float value, int scale) {
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).floatValue();
}
/**
* Rounds a double value to a scale
*
* @param value Value to round
* @param scale Scale
* @return rounded value
@@ -747,12 +745,12 @@ public final class Utilities {
public static double roundDouble(double value, int scale) {
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP).doubleValue();
}
public static int floor(double value) {
int rounded = (int) value;
return value < rounded ? rounded - 1 : rounded;
}
int rounded = (int) value;
return value < rounded ? rounded - 1 : rounded;
}
public static boolean isHoneyBlock(Block block) {
if (!VersionUtil.isOfVersion("v1_15")) {
return false;
@@ -836,7 +834,7 @@ public final class Utilities {
COMBO.put(Material.STONE_SWORD, COB_WEB);
COMBO.put(XMaterial.WOODEN_SWORD.parseMaterial(), COB_WEB);
// End combos
// Start climbable
CLIMBABLE.add(Material.VINE);
CLIMBABLE.add(Material.LADDER);
@@ -848,7 +846,7 @@ public final class Utilities {
else {
LILY_PAD = Material.LILY_PAD;
COB_WEB = Material.COBWEB;
// Start instant break materials
INSTANT_BREAK.add(Material.COMPARATOR);
INSTANT_BREAK.add(Material.REPEATER);
@@ -893,7 +891,8 @@ public final class Utilities {
INSTANT_BREAK.add(Material.TALL_SEAGRASS);
INSTANT_BREAK.add(Material.WHEAT);
// Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|| VersionUtil.isOfVersion("v1_16")) {
INSTANT_BREAK.add(Material.BAMBOO_SAPLING);
INSTANT_BREAK.add(Material.CORNFLOWER);
}
@@ -944,7 +943,8 @@ public final class Utilities {
FOOD.add(Material.SPIDER_EYE);
FOOD.add(Material.TROPICAL_FISH);
// Start 1.14 objects
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15") || VersionUtil.isOfVersion("v1_16")) {
if (VersionUtil.isOfVersion("v1_14") || VersionUtil.isOfVersion("v1_15")
|| VersionUtil.isOfVersion("v1_16")) {
FOOD.add(Material.SUSPICIOUS_STEW);
FOOD.add(Material.SWEET_BERRIES);
}
@@ -980,7 +980,7 @@ public final class Utilities {
COMBO.put(Material.STONE_SWORD, Material.COBWEB);
COMBO.put(Material.WOODEN_SWORD, Material.COBWEB);
// End combos
// Start climbable
CLIMBABLE.add(Material.VINE);
CLIMBABLE.add(Material.LADDER);
@@ -991,7 +991,7 @@ public final class Utilities {
CLIMBABLE.add(Material.SCAFFOLDING);
}
// End 1.14 objects
// Start 1.16 objects
if (VersionUtil.isOfVersion("v1_16")) {
CLIMBABLE.add(XMaterial.TWISTING_VINES.parseMaterial());