mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 14:38:47 +00:00
Moved WaterWalk check to seperate class, check seems to be outdated
This commit is contained in:
1 parent
05af9c4cde
commit
8317465a14
4 files changed
+97
-73
No files matched your search
@@ -38,6 +38,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import net.gravitydevelopment.anticheat.AntiCheat;
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
||||||
|
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
||||||
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.gravitydevelopment.anticheat.config.providers.Lang;
|
import net.gravitydevelopment.anticheat.config.providers.Lang;
|
||||||
@@ -48,8 +49,6 @@ import net.gravitydevelopment.anticheat.util.User;
|
|||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
|
|
||||||
public class Backend {
|
public class Backend {
|
||||||
private List<String> isInWater = new ArrayList<String>();
|
|
||||||
private List<String> isInWaterCache = new ArrayList<String>();
|
|
||||||
private List<String> isAscending = new ArrayList<String>();
|
private List<String> isAscending = new ArrayList<String>();
|
||||||
private Map<String, Integer> interactionCount = new HashMap<String, Integer>();
|
private Map<String, Integer> interactionCount = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> ascensionCount = new HashMap<String, Integer>();
|
private Map<String, Integer> ascensionCount = new HashMap<String, Integer>();
|
||||||
@@ -65,8 +64,6 @@ public class Backend {
|
|||||||
private Map<String, Long> lastBlockPlaced = new HashMap<String, Long>();
|
private Map<String, Long> lastBlockPlaced = new HashMap<String, Long>();
|
||||||
private Map<String, Long> lastBlockPlaceTime = new HashMap<String, Long>();
|
private Map<String, Long> lastBlockPlaceTime = new HashMap<String, Long>();
|
||||||
private Map<String, Integer> blockPunches = new HashMap<String, Integer>();
|
private Map<String, Integer> blockPunches = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> waterAscensionViolation = new HashMap<String, Integer>();
|
|
||||||
private Map<String, Integer> waterSpeedViolation = new HashMap<String, Integer>();
|
|
||||||
private Map<String, Integer> projectilesShot = new HashMap<String, Integer>();
|
private Map<String, Integer> projectilesShot = new HashMap<String, Integer>();
|
||||||
private Map<String, Long> velocitized = new HashMap<String, Long>();
|
private Map<String, Long> velocitized = new HashMap<String, Long>();
|
||||||
private Map<String, Integer> velocitytrack = new HashMap<String, Integer>();
|
private Map<String, Integer> velocitytrack = new HashMap<String, Integer>();
|
||||||
@@ -127,8 +124,8 @@ public class Backend {
|
|||||||
startEat.remove(pN);
|
startEat.remove(pN);
|
||||||
lastHeal.remove(pN);
|
lastHeal.remove(pN);
|
||||||
sprinted.remove(pN);
|
sprinted.remove(pN);
|
||||||
isInWater.remove(pN);
|
WaterWalkCheck.isInWater.remove(pN);
|
||||||
isInWaterCache.remove(pN);
|
WaterWalkCheck.isInWaterCache.remove(pN);
|
||||||
instantBreakExempt.remove(pN);
|
instantBreakExempt.remove(pN);
|
||||||
isAscending.remove(pN);
|
isAscending.remove(pN);
|
||||||
ascensionCount.remove(pN);
|
ascensionCount.remove(pN);
|
||||||
@@ -146,8 +143,8 @@ public class Backend {
|
|||||||
lastBlockPlaced.remove(pN);
|
lastBlockPlaced.remove(pN);
|
||||||
lastBlockPlaceTime.remove(pN);
|
lastBlockPlaceTime.remove(pN);
|
||||||
blockPunches.remove(pN);
|
blockPunches.remove(pN);
|
||||||
waterAscensionViolation.remove(pN);
|
WaterWalkCheck.waterAscensionViolation.remove(pN);
|
||||||
waterSpeedViolation.remove(pN);
|
WaterWalkCheck.waterSpeedViolation.remove(pN);
|
||||||
projectilesShot.remove(pN);
|
projectilesShot.remove(pN);
|
||||||
velocitized.remove(pN);
|
velocitized.remove(pN);
|
||||||
velocitytrack.remove(pN);
|
velocitytrack.remove(pN);
|
||||||
@@ -372,65 +369,6 @@ public class Backend {
|
|||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckResult checkWaterWalk(Player player, double x, double y, double z) {
|
|
||||||
Block block = player.getLocation().getBlock();
|
|
||||||
|
|
||||||
if (player.getVehicle() == null && !player.isFlying()) {
|
|
||||||
if (block.isLiquid()) {
|
|
||||||
if (isInWater.contains(player.getName())) {
|
|
||||||
if (isInWaterCache.contains(player.getName())) {
|
|
||||||
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
|
||||||
boolean b;
|
|
||||||
if (!Utilities.sprintFly(player)) {
|
|
||||||
b = x > magic.XZ_SPEED_MAX_WATER() || z > magic.XZ_SPEED_MAX_WATER();
|
|
||||||
} else {
|
|
||||||
b = x > magic.XZ_SPEED_MAX_WATER_SPRINT() || z > magic.XZ_SPEED_MAX_WATER_SPRINT();
|
|
||||||
}
|
|
||||||
if (!b && !Utilities.isFullyInWater(player.getLocation()) && Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D && !block.getType().equals(Material.WATER_LILY)) {
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
if (b) {
|
|
||||||
if (waterSpeedViolation.containsKey(player.getName())) {
|
|
||||||
int v = waterSpeedViolation.get(player.getName());
|
|
||||||
if (v >= magic.WATER_SPEED_VIOLATION_MAX()) {
|
|
||||||
waterSpeedViolation.put(player.getName(), 0);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
|
||||||
} else {
|
|
||||||
waterSpeedViolation.put(player.getName(), v + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
waterSpeedViolation.put(player.getName(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWaterCache.add(player.getName());
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWater.add(player.getName());
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
|
||||||
if (waterAscensionViolation.containsKey(player.getName())) {
|
|
||||||
int v = waterAscensionViolation.get(player.getName());
|
|
||||||
if (v >= magic.WATER_ASCENSION_VIOLATION_MAX()) {
|
|
||||||
waterAscensionViolation.put(player.getName(), 0);
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
|
||||||
} else {
|
|
||||||
waterAscensionViolation.put(player.getName(), v + 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
waterAscensionViolation.put(player.getName(), 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isInWater.remove(player.getName());
|
|
||||||
isInWaterCache.remove(player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckResult checkVClip(Player player, Distance distance) {
|
public CheckResult checkVClip(Player player, Distance distance) {
|
||||||
double from = Math.round(distance.fromY());
|
double from = Math.round(distance.fromY());
|
||||||
double to = Math.round(distance.toY());
|
double to = Math.round(distance.toY());
|
||||||
@@ -817,8 +755,8 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHoveringOverWaterAfterViolation(Player player) {
|
public boolean isHoveringOverWaterAfterViolation(Player player) {
|
||||||
if (waterSpeedViolation.containsKey(player.getName())) {
|
if (WaterWalkCheck.waterSpeedViolation.containsKey(player.getName())) {
|
||||||
if (waterSpeedViolation.get(player.getName()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
|
if (WaterWalkCheck.waterSpeedViolation.get(player.getName()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package net.gravitydevelopment.anticheat.check.movement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.gravitydevelopment.anticheat.AntiCheat;
|
||||||
|
import net.gravitydevelopment.anticheat.check.CheckResult;
|
||||||
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This check seems to be broken/outdated
|
||||||
|
*/
|
||||||
|
public class WaterWalkCheck {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
public static List<String> isInWater = new ArrayList<String>();
|
||||||
|
public static List<String> isInWaterCache = new ArrayList<String>();
|
||||||
|
public static Map<String, Integer> waterSpeedViolation = new HashMap<String, Integer>();
|
||||||
|
public static Map<String, Integer> waterAscensionViolation = new HashMap<String, Integer>();
|
||||||
|
|
||||||
|
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
||||||
|
Block block = player.getLocation().getBlock();
|
||||||
|
|
||||||
|
if (player.getVehicle() == null && !player.isFlying()) {
|
||||||
|
if (block.isLiquid()) {
|
||||||
|
if (isInWater.contains(player.getName())) {
|
||||||
|
if (isInWaterCache.contains(player.getName())) {
|
||||||
|
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
||||||
|
boolean b;
|
||||||
|
if (!Utilities.sprintFly(player)) {
|
||||||
|
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER() || z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
|
||||||
|
} else {
|
||||||
|
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT() || z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT();
|
||||||
|
}
|
||||||
|
if (!b && !Utilities.isFullyInWater(player.getLocation()) && Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D && !block.getType().equals(Material.WATER_LILY)) {
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
if (b) {
|
||||||
|
if (waterSpeedViolation.containsKey(player.getName())) {
|
||||||
|
int v = waterSpeedViolation.get(player.getName());
|
||||||
|
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_SPEED_VIOLATION_MAX()) {
|
||||||
|
waterSpeedViolation.put(player.getName(), 0);
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
||||||
|
} else {
|
||||||
|
waterSpeedViolation.put(player.getName(), v + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
waterSpeedViolation.put(player.getName(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isInWaterCache.add(player.getName());
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isInWater.add(player.getName());
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && AntiCheat.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
||||||
|
if (waterAscensionViolation.containsKey(player.getName())) {
|
||||||
|
int v = waterAscensionViolation.get(player.getName());
|
||||||
|
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||||
|
waterAscensionViolation.put(player.getName(), 0);
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " stood on water " + v + " times (can't stand on " + block.getType() + " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
||||||
|
} else {
|
||||||
|
waterAscensionViolation.put(player.getName(), v + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
waterAscensionViolation.put(player.getName(), 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isInWater.remove(player.getName());
|
||||||
|
isInWaterCache.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,9 +17,6 @@ import net.gravitydevelopment.anticheat.check.CheckResult;
|
|||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
import net.gravitydevelopment.anticheat.util.Distance;
|
||||||
import net.gravitydevelopment.anticheat.util.Utilities;
|
import net.gravitydevelopment.anticheat.util.Utilities;
|
||||||
|
|
||||||
/**
|
|
||||||
* The suckishness and false-positives of this check are killing me. TODO TODO TODO FIX THIS!!!1!
|
|
||||||
*/
|
|
||||||
public class YAxisCheck {
|
public class YAxisCheck {
|
||||||
|
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import net.gravitydevelopment.anticheat.check.CheckResult;
|
|||||||
import net.gravitydevelopment.anticheat.check.CheckType;
|
import net.gravitydevelopment.anticheat.check.CheckType;
|
||||||
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
import net.gravitydevelopment.anticheat.check.movement.FlightCheck;
|
||||||
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
import net.gravitydevelopment.anticheat.check.movement.GlideCheck;
|
||||||
|
import net.gravitydevelopment.anticheat.check.movement.WaterWalkCheck;
|
||||||
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
import net.gravitydevelopment.anticheat.check.movement.YAxisCheck;
|
||||||
import net.gravitydevelopment.anticheat.util.Distance;
|
import net.gravitydevelopment.anticheat.util.Distance;
|
||||||
import net.gravitydevelopment.anticheat.util.Permission;
|
import net.gravitydevelopment.anticheat.util.Permission;
|
||||||
@@ -418,7 +419,7 @@ public class PlayerListener extends EventListener {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||||
CheckResult result = getBackend().checkWaterWalk(player, x, y, z);
|
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1, 0)));
|
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1, 0)));
|
||||||
|
|||||||
Reference in new issue
Block a user