mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fix riptide false positives, improved performance
This commit is contained in:
1 parent
bd1db83a98
commit
7e1f0d83ce
7 files changed
+29
-76
No files matched your search
@@ -51,8 +51,7 @@ public class FlightCheck {
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| VersionUtil.isFlying(player) || player.getVehicle() != null
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|
||||
|| VersionUtil.isRiptiding(player)) {
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
|
||||
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
|
||||
// care
|
||||
// about it.
|
||||
@@ -64,7 +63,8 @@ public class FlightCheck {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player))
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player)
|
||||
|| movementManager.riptideTicks > 0)
|
||||
return PASS;
|
||||
|
||||
int minAirTicks = 13;
|
||||
@@ -104,7 +104,8 @@ public class FlightCheck {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
|
||||
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||
|
||||
if (Math.abs(movementManager.motionY - movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
|
||||
if (Math.abs(movementManager.motionY
|
||||
- movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
|
||||
&& !Utilities.couldBeOnBoat(player)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
||||
|
||||
@@ -46,12 +46,14 @@ public class SpeedCheck {
|
||||
|
||||
public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)
|
||||
|| VersionUtil.isRiptiding(player))
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player))
|
||||
return PASS;
|
||||
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
// Riptiding exemption
|
||||
if (movementManager.riptideTicks > 0)
|
||||
return PASS;
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
double distanceXZ = movementManager.distanceXZ;
|
||||
boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||
@@ -257,10 +259,13 @@ public class SpeedCheck {
|
||||
public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|
||||
|| VersionUtil.isRiptiding(player) || Utilities.isNearWater(player))
|
||||
|| Utilities.isNearWater(player))
|
||||
return PASS;
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
// Riptiding exemption
|
||||
if (movementManager.riptideTicks > 0)
|
||||
return PASS;
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
|
||||
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.isFlying(player))
|
||||
|| movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player))
|
||||
return PASS;
|
||||
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
@@ -22,14 +22,10 @@ package com.rammelkast.anticheatreloaded.event;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class InventoryListener extends EventListener {
|
||||
|
||||
@@ -55,18 +51,4 @@ public class InventoryListener extends EventListener {
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (event.getInventory().getType() != InventoryType.BEACON) {
|
||||
getUserManager().getUser(event.getPlayer().getUniqueId()).setInventorySnapshot(event.getInventory().getContents());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||
if (user != null) {
|
||||
user.removeInventorySnapshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,8 @@ public class MovementManager {
|
||||
public boolean hasIncreasingEffect = false;
|
||||
// If the player had a speed increasing effect previous tick
|
||||
public boolean hadIncreasingEffect = false;
|
||||
// Riptiding ticks
|
||||
public int riptideTicks;
|
||||
// Time of last update
|
||||
public long lastUpdate;
|
||||
|
||||
@@ -182,6 +184,17 @@ public class MovementManager {
|
||||
this.nearLiquidTicks = 0;
|
||||
}
|
||||
|
||||
if (VersionUtil.CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
if (player.isRiptiding()) {
|
||||
this.riptideTicks = 30;
|
||||
} else {
|
||||
if (this.riptideTicks > 0)
|
||||
this.riptideTicks--;
|
||||
else
|
||||
this.riptideTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.hadSpeedEffect = this.hasSpeedEffect;
|
||||
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
|
||||
|
||||
|
||||
@@ -20,15 +20,12 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
@@ -41,7 +38,6 @@ public class User {
|
||||
private final int id;
|
||||
private int level = 0;
|
||||
private Location goodLocation;
|
||||
private List<ItemStack> inventorySnapshot = null;
|
||||
private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
|
||||
private int toX, toY, toZ;
|
||||
private String[] messages = new String[2];
|
||||
@@ -245,44 +241,7 @@ public class User {
|
||||
goodLocation = location;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a copy of the player's inventory, for use in resetting
|
||||
*
|
||||
* @param is ItemStack list to store
|
||||
*/
|
||||
public void setInventorySnapshot(ItemStack[] is) {
|
||||
inventorySnapshot = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < is.length; i++) {
|
||||
if (is[i] != null) {
|
||||
inventorySnapshot.add(is[i].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the current inventory snapshot
|
||||
*/
|
||||
public void removeInventorySnapshot() {
|
||||
inventorySnapshot = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the player's inventory with the current inventory snapshot
|
||||
*
|
||||
* @param inventory Player's inventory
|
||||
*/
|
||||
public void restoreInventory(Inventory inventory) {
|
||||
if (inventorySnapshot != null) {
|
||||
inventory.clear();
|
||||
for (ItemStack is : inventorySnapshot) {
|
||||
if (is != null) {
|
||||
inventory.addItem(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the player's to location
|
||||
*
|
||||
|
||||
@@ -35,8 +35,8 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
public static final MinecraftVersion CURRENT_VERSION;
|
||||
private static final List<String> SUPPORTED_VERSIONS;
|
||||
private static final MinecraftVersion CURRENT_VERSION;
|
||||
|
||||
public static String getVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
@@ -73,13 +73,6 @@ public class VersionUtil {
|
||||
|| AntiCheatReloaded.getManager().getBackend().justLevitated(player);
|
||||
}
|
||||
|
||||
public static boolean isRiptiding(Player player) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
}
|
||||
return player.isRiptiding();
|
||||
}
|
||||
|
||||
public static boolean isSlowFalling(Player player) {
|
||||
if (!CURRENT_VERSION.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user