mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Started on movement check recode. First up: speed check!
This commit is contained in:
1 parent
610d53550f
commit
636f94b408
11 files changed
+240
-102
No files matched your search
@@ -21,29 +21,32 @@ Please include the following information with your issue, this allows me to fix
|
|||||||
|
|
||||||
Hacks blocked
|
Hacks blocked
|
||||||
-------
|
-------
|
||||||
* Flight
|
* Flight/Glide
|
||||||
* Glide
|
* ElytraFly
|
||||||
* FastLadder
|
* WaterWalk/Jesus
|
||||||
* Jesus
|
* NoSwing
|
||||||
* Step
|
|
||||||
* Criticals
|
|
||||||
* Anti-Knockback
|
|
||||||
* FastBow
|
|
||||||
* FastDrop
|
|
||||||
* Reach
|
|
||||||
* Spider
|
|
||||||
* Speed
|
|
||||||
* NoFall
|
|
||||||
* Sneak
|
|
||||||
* vClip
|
|
||||||
* FastBreak
|
* FastBreak
|
||||||
* FastPlace
|
* FastPlace
|
||||||
* Spam
|
* Chat spam
|
||||||
|
* Command spam
|
||||||
|
* Sprint
|
||||||
|
* (Packet)Sneak
|
||||||
|
* Speed
|
||||||
|
* Vclip
|
||||||
|
* Spider
|
||||||
|
* NoFall
|
||||||
|
* FastBow
|
||||||
* FastEat
|
* FastEat
|
||||||
* ElytraFly
|
* FastHeal
|
||||||
|
* KillAura (Aimbot)
|
||||||
|
* Reach
|
||||||
* Unicode chat
|
* Unicode chat
|
||||||
* GhostHand
|
* FastProjectile
|
||||||
* KillAura
|
* ItemSpam
|
||||||
* Scaffold
|
* FastInventory
|
||||||
* MorePackets
|
* AutoTool
|
||||||
|
* MorePackets/Timer
|
||||||
* BadPackets
|
* BadPackets
|
||||||
|
* Velocity/Anti-Knockback
|
||||||
|
* IllegalInteract (Scaffold)
|
||||||
|
* FastLadder
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||||
<artifactId>AntiCheatReloaded</artifactId>
|
<artifactId>AntiCheatReloaded</artifactId>
|
||||||
<version>1.8.2-PRE</version>
|
<version>1.9.0-PRE</version>
|
||||||
<name>AntiCheatReloaded</name>
|
<name>AntiCheatReloaded</name>
|
||||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class Backend {
|
|||||||
GlideCheck.LAST_MOTION_Y.remove(uuid);
|
GlideCheck.LAST_MOTION_Y.remove(uuid);
|
||||||
GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
|
GlideCheck.LAST_FALL_DISTANCE.remove(uuid);
|
||||||
GlideCheck.VIOLATIONS.remove(uuid);
|
GlideCheck.VIOLATIONS.remove(uuid);
|
||||||
SpeedCheck.SPEED_VIOLATIONS.remove(uuid);
|
SpeedCheck.JUMPBEHAVIOUR_VIOLATIONS.remove(uuid);
|
||||||
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
||||||
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||||
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||||
@@ -780,7 +780,8 @@ public class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void logTeleport(final Player player) {
|
public void logTeleport(final Player player) {
|
||||||
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME());
|
// TODO check this
|
||||||
|
//FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME());
|
||||||
|
|
||||||
/* Data for fly/speed should be reset */
|
/* Data for fly/speed should be reset */
|
||||||
nofallViolation.remove(player.getUniqueId());
|
nofallViolation.remove(player.getUniqueId());
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
@@ -31,88 +30,92 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|||||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||||
|
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This check is an outdated mess which needs to be replaced
|
* @author Rammelkast
|
||||||
|
*
|
||||||
|
* Features:
|
||||||
|
* + AirSpeed A
|
||||||
|
* + AirAcceleration A
|
||||||
|
* + JumpBehaviour A
|
||||||
|
*
|
||||||
|
* Planned:
|
||||||
|
* + GroundSpeed A
|
||||||
|
* + GroundAcceleration A
|
||||||
|
* + AirSpeed B
|
||||||
|
* + JumpBehaviour B
|
||||||
*/
|
*/
|
||||||
public class SpeedCheck {
|
public class SpeedCheck {
|
||||||
|
|
||||||
public static final Map<UUID, Integer> SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
|
public static final Map<UUID, Integer> JUMPBEHAVIOUR_VIOLATIONS = new HashMap<UUID, Integer>();
|
||||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
public static boolean isSpeedExempt(Player player, Backend backend) {
|
public static boolean isSpeedExempt(Player player, Backend backend) {
|
||||||
return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|
return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
public static CheckResult checkXZSpeed(Player player, double x, double z, Location movingTowards) {
|
||||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||||
if (!isSpeedExempt(player, backend) && player.getVehicle() == null) {
|
if (isSpeedExempt(player, backend) || player.getVehicle() != null)
|
||||||
String reason = "";
|
|
||||||
double max = backend.getMagic().XZ_SPEED_MAX();
|
|
||||||
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
|
||||||
if (player.isSprinting()) {
|
|
||||||
reason = "on soulsand while sprinting ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
|
||||||
reason = "on soulsand with speed potion ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
|
||||||
} else {
|
|
||||||
reason = "on soulsand ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND();
|
|
||||||
}
|
|
||||||
} else if (VersionUtil.isFlying(player)) {
|
|
||||||
reason = "while flying ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_FLY();
|
|
||||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
|
||||||
if (player.isSprinting()) {
|
|
||||||
reason = "with speed potion while sprinting ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
|
||||||
} else {
|
|
||||||
reason = "with speed potion ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_POTION();
|
|
||||||
}
|
|
||||||
} else if (player.isSprinting()) {
|
|
||||||
String blockDownName = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().name();
|
|
||||||
if (blockDownName.endsWith("ICE")
|
|
||||||
&& (player.getEyeLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.AIR)) {
|
|
||||||
if (player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
|
||||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ")
|
|
||||||
+ " and trapdoor";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
|
||||||
+ (blockDownName.equals("BLUE_ICE") ? 0.35925D : 0.35D);
|
|
||||||
} else {
|
|
||||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
|
||||||
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.2D);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
reason = "while sprinting ";
|
|
||||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float speed = player.getWalkSpeed();
|
|
||||||
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
|
||||||
|
|
||||||
if (x > max || z > max) {
|
|
||||||
int num = backend.increment(player, SPEED_VIOLATIONS, backend.getMagic().SPEED_MAX());
|
|
||||||
if (num >= backend.getMagic().SPEED_MAX()) {
|
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
|
||||||
"speed was too high " + reason + num + " times in a row (max="
|
|
||||||
+ backend.getMagic().SPEED_MAX() + ", speed=" + (x > z ? x : z) + ", max speed="
|
|
||||||
+ max + ")");
|
|
||||||
} else {
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SPEED_VIOLATIONS.put(player.getUniqueId(), 0);
|
|
||||||
return PASS;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return PASS;
|
return PASS;
|
||||||
|
|
||||||
|
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getMovementManager();
|
||||||
|
double distanceXZ = Math.sqrt(x * x + z * z);
|
||||||
|
|
||||||
|
// AirSpeed A
|
||||||
|
// As of right now, this falses with speed effects and slimes
|
||||||
|
if (movementManager.airTicks > 1) {
|
||||||
|
double multiplier = 0.9808305131D;
|
||||||
|
double predict = 0.3597320645 * Math.pow(multiplier, movementManager.airTicks + 1);
|
||||||
|
// Adjust for ice boost
|
||||||
|
if (movementManager.iceInfluenceTicks > 0) {
|
||||||
|
predict += 0.105 * Math.pow(1.09, movementManager.iceInfluenceTicks);
|
||||||
|
}
|
||||||
|
if (distanceXZ - predict > 0.03075) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"moved too fast in air (speed=" + distanceXZ + ", predict=" + predict + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AirAcceleration A
|
||||||
|
// As of right now, this falses with speed effects and slimes
|
||||||
|
if (movementManager.airTicks > 1 && movementManager.iceInfluenceTicks <= 0) {
|
||||||
|
double initialAcceleration = movementManager.acceleration;
|
||||||
|
// TODO calculate instead of defined value
|
||||||
|
if (initialAcceleration > 0.36) {
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=0.36)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JumpBehaviour A
|
||||||
|
// Has a rare false positive when sprintjumping around corners
|
||||||
|
// Works against YPorts and mini jumps
|
||||||
|
if (movementManager.touchedGroundThisTick) {
|
||||||
|
// This happens naturally as well when walking next to walls
|
||||||
|
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||||
|
boolean movingFreely = Utilities.cantStandClose(movingTowards.getBlock())
|
||||||
|
&& Utilities.cantStandFar(movingTowards.getBlock());
|
||||||
|
if (movingFreely) {
|
||||||
|
int vl = JUMPBEHAVIOUR_VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||||
|
// TODO config for this value
|
||||||
|
if (vl++ > 1) {
|
||||||
|
JUMPBEHAVIOUR_VIOLATIONS.remove(player.getUniqueId());
|
||||||
|
return new CheckResult(CheckResult.Result.FAILED,
|
||||||
|
"had unexpected jumping behaviour");
|
||||||
|
}
|
||||||
|
JUMPBEHAVIOUR_VIOLATIONS.put(player.getUniqueId(), vl);
|
||||||
|
return PASS;
|
||||||
|
} else {
|
||||||
|
JUMPBEHAVIOUR_VIOLATIONS.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckResult checkYSpeed(Player player, Distance distance) {
|
public static CheckResult checkYSpeed(Player player, Distance distance) {
|
||||||
@@ -121,13 +124,12 @@ public class SpeedCheck {
|
|||||||
&& (distance.getYDifference() > backend.getMagic().Y_SPEED_MAX())
|
&& (distance.getYDifference() > backend.getMagic().Y_SPEED_MAX())
|
||||||
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
|
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
|
||||||
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||||
&& !VersionUtil.isRiptiding(player)
|
&& !VersionUtil.isRiptiding(player) && !Utilities.isNearBed(distance.getTo())
|
||||||
&& !Utilities.isNearBed(distance.getTo())
|
|
||||||
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||||
.getGoodLocation(player.getLocation()).getBlock())
|
.getGoodLocation(player.getLocation()).getBlock())
|
||||||
&& !Utilities.couldBeOnBoat(player)) {
|
&& !Utilities.couldBeOnBoat(player)) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED,
|
return new CheckResult(CheckResult.Result.FAILED, "y speed was too high (speed=" + distance.getYDifference()
|
||||||
"y speed was too high (speed=" + distance.getYDifference() + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
+ ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
||||||
} else {
|
} else {
|
||||||
return PASS;
|
return PASS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ public class PlayerListener extends EventListener {
|
|||||||
|
|
||||||
final User user = getUserManager().getUser(player.getUniqueId());
|
final User user = getUserManager().getUser(player.getUniqueId());
|
||||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||||
|
user.getMovementManager().handle(player, from, to, distance);
|
||||||
|
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
|
||||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||||
@@ -430,7 +431,7 @@ public class PlayerListener extends EventListener {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z);
|
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z, event.getTo());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
event.setTo(user.getGoodLocation(from.clone()));
|
||||||
|
|||||||
@@ -44,6 +44,18 @@ public class Distance {
|
|||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Distance() {
|
||||||
|
l1Y = 0;
|
||||||
|
l2Y = 0;
|
||||||
|
|
||||||
|
XDiff = 0;
|
||||||
|
ZDiff = 0;
|
||||||
|
YDiff = 0;
|
||||||
|
|
||||||
|
this.from = null;
|
||||||
|
this.to = null;
|
||||||
|
}
|
||||||
|
|
||||||
public double fromY() {
|
public double fromY() {
|
||||||
return l2Y;
|
return l2Y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MovementManager {
|
||||||
|
|
||||||
|
// Ticks in air
|
||||||
|
public int airTicks = 0;
|
||||||
|
// Ticks on ground
|
||||||
|
public int groundTicks = 0;
|
||||||
|
// Ticks on ice
|
||||||
|
public int iceTicks = 0;
|
||||||
|
// Ticks in air before last grounded moment
|
||||||
|
public int airTicksBeforeGrounded = 0;
|
||||||
|
// Ticks influenced by ice
|
||||||
|
public int iceInfluenceTicks = 0;
|
||||||
|
// If the player touched the ground again this tick
|
||||||
|
public boolean touchedGroundThisTick = false;
|
||||||
|
// Last recorded distance
|
||||||
|
public Distance lastDistance = new Distance();
|
||||||
|
// Movement acceleration
|
||||||
|
public double acceleration;
|
||||||
|
|
||||||
|
public void handle(Player player, Location from, Location to, Distance distance) {
|
||||||
|
boolean serverOnGround = !Utilities.cantStandAtExp(to) || Utilities.couldBeOnBoat(player);
|
||||||
|
this.touchedGroundThisTick = false;
|
||||||
|
if (!serverOnGround) {
|
||||||
|
this.groundTicks = 0;
|
||||||
|
this.airTicks++;
|
||||||
|
} else {
|
||||||
|
if (this.airTicks > 0)
|
||||||
|
this.touchedGroundThisTick = true;
|
||||||
|
this.airTicksBeforeGrounded = this.airTicks;
|
||||||
|
this.airTicks = 0;
|
||||||
|
this.groundTicks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utilities.couldBeOnIce(to)) {
|
||||||
|
this.iceTicks++;
|
||||||
|
this.iceInfluenceTicks = 14;
|
||||||
|
} else {
|
||||||
|
this.iceTicks = 0;
|
||||||
|
if (this.iceInfluenceTicks > 0)
|
||||||
|
this.iceInfluenceTicks--;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ public class PacketListener {
|
|||||||
public static void listenMovementPackets() {
|
public static void listenMovementPackets() {
|
||||||
AntiCheatReloaded.getProtocolManager()
|
AntiCheatReloaded.getProtocolManager()
|
||||||
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
|
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK, PacketType.Play.Server.POSITION }) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@@ -50,7 +50,6 @@ public class PacketListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event) {
|
public void onPacketSending(PacketEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
// Compensate for teleport
|
// Compensate for teleport
|
||||||
MorePacketsCheck.compensate(player);
|
MorePacketsCheck.compensate(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public class User {
|
|||||||
private int ping = -1;
|
private int ping = -1;
|
||||||
private int lastPing = -1;
|
private int lastPing = -1;
|
||||||
|
|
||||||
|
private MovementManager movementManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize an AntiCheat user
|
* Initialize an AntiCheat user
|
||||||
*
|
*
|
||||||
@@ -65,6 +67,7 @@ public class User {
|
|||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
||||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||||
|
this.movementManager = new MovementManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +221,12 @@ public class User {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
return goodLocation;
|
Location moveTo = goodLocation;
|
||||||
|
if (location != null) {
|
||||||
|
moveTo.setPitch(location.getPitch());
|
||||||
|
moveTo.setYaw(location.getYaw());
|
||||||
|
}
|
||||||
|
return moveTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,6 +461,10 @@ public class User {
|
|||||||
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION();
|
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MovementManager getMovementManager() {
|
||||||
|
return this.movementManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User {name = " + getName() + ", level = " + level + "}";
|
return "User {name = " + getName() + ", level = " + level + "}";
|
||||||
|
|||||||
@@ -131,6 +131,41 @@ public final class Utilities {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a player could be standing on ice
|
||||||
|
*
|
||||||
|
* @param location the location to check
|
||||||
|
* @return true if the player could be standing on ice
|
||||||
|
*/
|
||||||
|
public static boolean couldBeOnIce(Location location) {
|
||||||
|
return isNearIce(new Location(location.getWorld(), fixXAxis(location.getX()), location.getY() - 0.01D,
|
||||||
|
location.getBlockZ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a block is a type of ice
|
||||||
|
*
|
||||||
|
* @param block block to check
|
||||||
|
* @return true if block is a type of ice
|
||||||
|
*/
|
||||||
|
public static boolean isIce(Block block) {
|
||||||
|
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))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.EAST))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.WEST))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.NORTH_EAST))
|
||||||
|
|| isBed(location.getBlock().getRelative(BlockFace.NORTH_WEST))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_EAST))
|
||||||
|
|| isIce(location.getBlock().getRelative(BlockFace.SOUTH_WEST));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is fully submerged in water
|
* Determine whether a player is fully submerged in water
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -244,11 +244,11 @@ GLIDE_LIMIT: 5
|
|||||||
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
|
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
# Can be decreased in to tighten check
|
# Can be decreased in to tighten check
|
||||||
MOREPACKETS_TELEPORT_COMPENSATION: 200
|
MOREPACKETS_TELEPORT_COMPENSATION: 150
|
||||||
# The amount of milliseconds that were offset to flag for MorePackets (50ms = 1 tick)
|
# The amount of milliseconds that were offset to flag for MorePackets (50ms = 1 tick)
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
# Can be decreased in to tighten check
|
# Can be decreased in to tighten check
|
||||||
MOREPACKETS_TRIGGER_BALANCE: 100
|
MOREPACKETS_TRIGGER_BALANCE: 50
|
||||||
# The maximum amount of overall lag compensating in milliseconds (50ms = 1 tick)
|
# The maximum amount of overall lag compensating in milliseconds (50ms = 1 tick)
|
||||||
# Increase this in case of false positives
|
# Increase this in case of false positives
|
||||||
# Can be decreased in to tighten check
|
# Can be decreased in to tighten check
|
||||||
|
|||||||
Reference in new issue
Block a user