mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
Fixed YAxis false positive, added BadPackets check and cleaned up code and README .
This commit is contained in:
1 parent
76c595e255
commit
9771387909
20 files changed
+600
-323
No files matched your search
@@ -39,13 +39,13 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.MorePacketsCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
@@ -56,6 +56,7 @@ import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class Backend {
|
||||
public Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||
private List<UUID> isAscending = new ArrayList<UUID>();
|
||||
private Map<UUID, Integer> ascensionCount = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> chatLevel = new HashMap<UUID, Integer>();
|
||||
@@ -70,7 +71,6 @@ public class Backend {
|
||||
private Map<UUID, Long> lastBlockPlaceTime = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Integer> blockPunches = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Integer> projectilesShot = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Long> velocitized = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Integer> velocitytrack = new HashMap<UUID, Integer>();
|
||||
private Map<UUID, Long> startEat = new HashMap<UUID, Long>();
|
||||
private Map<UUID, Long> lastHeal = new HashMap<UUID, Long>();
|
||||
@@ -171,7 +171,7 @@ public class Backend {
|
||||
inventoryClicks.remove(pU);
|
||||
lastFallPacket.remove(pU);
|
||||
fastSneakViolations.remove(player.getUniqueId().toString());
|
||||
GlideCheck.LAST_DIFFERENCE.remove(pU);
|
||||
GlideCheck.LAST_MOTION_Y.remove(pU);
|
||||
GlideCheck.LAST_FALL_DISTANCE.remove(pU);
|
||||
GlideCheck.VIOLATIONS.remove(pU);
|
||||
SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId());
|
||||
@@ -392,7 +392,7 @@ public class Backend {
|
||||
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !VersionUtil.isFlying(player)
|
||||
&& !justBroke(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
&& !player.isInsideVehicle() && !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
||||
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -1.5, 0).getBlock())) {
|
||||
&& !YAxisCheck.isMoveUpBlock(player.getLocation().add(0, -0.5, 0).getBlock())) {
|
||||
// TODO isMoveUpBlock does not seem to be a success with stairs
|
||||
if (y1 < y2) {
|
||||
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid()
|
||||
@@ -803,7 +803,7 @@ public class Backend {
|
||||
YAxisCheck.LAST_Y_COORD_CACHE.remove(player.getUniqueId());
|
||||
YAxisCheck.LAST_Y_TIME.remove(player.getUniqueId());
|
||||
GlideCheck.LAST_FALL_DISTANCE.remove(player.getUniqueId());
|
||||
GlideCheck.LAST_DIFFERENCE.remove(player.getUniqueId());
|
||||
GlideCheck.LAST_MOTION_Y.remove(player.getUniqueId());
|
||||
GlideCheck.VIOLATIONS.remove(player.getUniqueId());
|
||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId().toString());
|
||||
}
|
||||
@@ -824,7 +824,7 @@ public class Backend {
|
||||
return isAscending.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
private boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||
public boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||
if (map.containsKey(player.getUniqueId())) {
|
||||
if (max != -1) {
|
||||
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
||||
|
||||
@@ -60,6 +60,7 @@ public enum CheckType {
|
||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||
MOREPACKETS(Permission.CHECK_MOREPACKETS),
|
||||
BADPACKETS(Permission.CHECK_BADPACKETS),
|
||||
VELOCITY(Permission.CHECK_VELOCITY),
|
||||
CRITICALS(Permission.CHECK_CRITICALS),
|
||||
CHAT_UNICODE(Permission.CHECK_UNICODE),
|
||||
|
||||
@@ -32,63 +32,92 @@ import org.bukkit.entity.Player;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class GlideCheck {
|
||||
|
||||
public static final Map<UUID, Double> LAST_DIFFERENCE = new HashMap<UUID, Double>();
|
||||
public static final Map<UUID, Double> LAST_MOTION_Y = new HashMap<UUID, Double>();
|
||||
public static final Map<UUID, Float> LAST_FALL_DISTANCE = new HashMap<UUID, Float>();
|
||||
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, Distance distance) {
|
||||
if (VersionUtil.isFlying(player)) {
|
||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| VersionUtil.isFlying(player) || FlightCheck.isMovingExempt(player)) {
|
||||
VIOLATIONS.put(player.getUniqueId(), 0);
|
||||
return PASS;
|
||||
}
|
||||
if (player.getLocation().getBlock().getType() == Material.LADDER
|
||||
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||
return PASS;
|
||||
}
|
||||
if (!LAST_DIFFERENCE.containsKey(player.getUniqueId())) {
|
||||
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
|
||||
if (!LAST_MOTION_Y.containsKey(player.getUniqueId())) {
|
||||
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||
return PASS;
|
||||
}
|
||||
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
|
||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||
return PASS;
|
||||
}
|
||||
double yDiff = distance.getYDifference();
|
||||
int violations = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||
double motionY = distance.getYDifference();
|
||||
float fallDistance = player.getFallDistance();
|
||||
if (yDiff == LAST_DIFFERENCE.get(player.getUniqueId())
|
||||
if (motionY == LAST_MOTION_Y.get(player.getUniqueId())
|
||||
&& fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId())) {
|
||||
if (!VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||
} else {
|
||||
if (VIOLATIONS.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.GLIDE_LIMIT()) {
|
||||
VIOLATIONS.remove(player.getUniqueId());
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location prev = player.getLocation();
|
||||
prev.setY(prev.getY() - distanceToFall(prev));
|
||||
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getGoodLocation(prev));
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"type=glide, desc_amount=" + new BigDecimal(yDiff).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||
} else {
|
||||
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
|
||||
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
|
||||
VIOLATIONS.put(player.getUniqueId(), 0);
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location prev = player.getLocation().clone();
|
||||
prev.setY(prev.getY() - distanceToFall(prev));
|
||||
player.teleport(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getGoodLocation(prev));
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"type=glide, desc_amount=" + new BigDecimal(motionY).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||
} else {
|
||||
VIOLATIONS.put(player.getUniqueId(), violations + 1);
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()) {
|
||||
// TODO check gravity
|
||||
if (fallDistance > LAST_FALL_DISTANCE.get(player.getUniqueId()) && !player.isOnGround()
|
||||
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5) {
|
||||
// TODO that fallDistance check is a horrible way to prevent a certain false positive
|
||||
// Needs to be fixed since this only works for slight above ground movements
|
||||
float predicted = calculateNextMotionY(LAST_MOTION_Y.get(player.getUniqueId()).floatValue());
|
||||
float actual = Double.valueOf(motionY).floatValue();
|
||||
float scaledDifference = Math.abs((predicted - actual) + 0.1568f);
|
||||
if (scaledDifference > 3E-8) {
|
||||
if (violations + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT()
|
||||
&& !Utilities.canStand(distance.getTo().getBlock())) {
|
||||
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location prev = player.getLocation().clone();
|
||||
prev.setY(prev.getY() - distanceToFall(prev));
|
||||
player.teleport(AntiCheatReloaded.getManager().getUserManager()
|
||||
.getUser(player.getUniqueId()).getGoodLocation(prev));
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED, "type=gravity, offset="
|
||||
+ new BigDecimal(scaledDifference).setScale(2, RoundingMode.HALF_UP) + ")");
|
||||
} else {
|
||||
VIOLATIONS.put(player.getUniqueId(), violations + 1);
|
||||
return PASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
|
||||
LAST_MOTION_Y.put(player.getUniqueId(), distance.getYDifference());
|
||||
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
|
||||
if (violations > Math.round(AntiCheatReloaded.getManager().getBackend().getMagic().GLIDE_LIMIT() / 2)) {
|
||||
VIOLATIONS.put(player.getUniqueId(), violations - 1);
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static float calculateNextMotionY(float motionY) {
|
||||
return (motionY - 0.08f) * 0.98f;
|
||||
}
|
||||
|
||||
private static double distanceToFall(Location location) {
|
||||
location = location.clone();
|
||||
double highestY = location.getWorld().getHighestBlockYAt(location) + 1.02D;
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* 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.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class MorePacketsCheck {
|
||||
|
||||
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void startTimer() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MOVE_COUNT.clear();
|
||||
}
|
||||
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
AntiCheatReloaded.getProtocolManager()
|
||||
.addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(), ListenerPriority.LOWEST,
|
||||
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player,
|
||||
CheckType.MOREPACKETS)) {
|
||||
return;
|
||||
}
|
||||
Location cur = e.getPlayer().getLocation();
|
||||
if (!MOVE_COUNT.containsKey(player.getUniqueId())) {
|
||||
MOVE_COUNT.put(player.getUniqueId(), 1);
|
||||
} else {
|
||||
MOVE_COUNT.put(player.getUniqueId(), MOVE_COUNT.get(player.getUniqueId()) + 1);
|
||||
int ping = VersionUtil.getPlayerPing(player);
|
||||
int limit = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_LIMIT();
|
||||
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.MOREPACKETS_AVERAGE_PING();
|
||||
float pingLeniency = (float) ((ping / averagePing));
|
||||
if (pingLeniency < 1)
|
||||
pingLeniency = 1;
|
||||
if (pingLeniency > 2.5F)
|
||||
pingLeniency = 2.5F;
|
||||
limit = Math.round(pingLeniency * limit);
|
||||
final float finalPingLeniency = pingLeniency;
|
||||
try {
|
||||
if (MOVE_COUNT.get(player.getUniqueId()) > limit) {
|
||||
final int packets = MOVE_COUNT.get(player.getUniqueId());
|
||||
MOVE_COUNT.remove(player.getUniqueId());
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(
|
||||
new CheckResult(CheckResult.Result.FAILED,
|
||||
"sent " + packets + " packets in one second (max="
|
||||
+ AntiCheatReloaded.getManager().getBackend()
|
||||
.getMagic().MOREPACKETS_LIMIT()
|
||||
+ ", leniency=" + finalPingLeniency + ", ping="
|
||||
+ ping + ")").getMessage(),
|
||||
player, CheckType.MOREPACKETS);
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().teleport(cur);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (NullPointerException nullPointer) {
|
||||
// TODO this is thrown sometimes, might have something to do with line 83
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
@@ -39,36 +41,36 @@ public class SpeedCheck {
|
||||
public static final Map<UUID, Integer> SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static boolean isSpeedExempt(Player player) {
|
||||
return AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
|
||||
|| AntiCheatReloaded.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
|
||||
public static boolean isSpeedExempt(Player player, Backend backend) {
|
||||
return backend.isMovingExempt(player) || backend.justVelocity(player) || VersionUtil.isFlying(player);
|
||||
}
|
||||
|
||||
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
||||
if (!isSpeedExempt(player) && player.getVehicle() == null) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (!isSpeedExempt(player, backend) && player.getVehicle() == null) {
|
||||
String reason = "";
|
||||
double max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX();
|
||||
double max = backend.getMagic().XZ_SPEED_MAX();
|
||||
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
||||
if (player.isSprinting()) {
|
||||
reason = "on soulsand while sprinting ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
reason = "on soulsand with speed potion ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
||||
} else {
|
||||
reason = "on soulsand ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SOULSAND();
|
||||
}
|
||||
} else if (VersionUtil.isFlying(player)) {
|
||||
reason = "while flying ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_FLY();
|
||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
if (player.isSprinting()) {
|
||||
reason = "with speed potion while sprinting ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
||||
} else {
|
||||
reason = "with speed potion ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_POTION();
|
||||
}
|
||||
} else if (player.isSprinting()) {
|
||||
String blockDownName = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().name();
|
||||
@@ -77,16 +79,16 @@ public class SpeedCheck {
|
||||
if (player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")) {
|
||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ")
|
||||
+ " and trapdoor";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
+ (blockDownName.equals("BLUE_ICE") ? 0.35925D : 0.35D);
|
||||
} else {
|
||||
reason = "while boosting on " + blockDownName.toLowerCase().replaceAll("_", " ") + " ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT()
|
||||
+ (blockDownName.equals("BLUE_ICE") ? 0.20925D : 0.2D);
|
||||
}
|
||||
} else {
|
||||
reason = "while sprinting ";
|
||||
max = AntiCheatReloaded.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
|
||||
max = backend.getMagic().XZ_SPEED_MAX_SPRINT();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +96,12 @@ public class SpeedCheck {
|
||||
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
||||
|
||||
if (x > max || z > max) {
|
||||
int num = AntiCheatReloaded.getManager().getBackend().increment(player, SPEED_VIOLATIONS,
|
||||
AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX());
|
||||
if (num >= AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_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="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX() + ", speed="
|
||||
+ (x > z ? x : z) + ", max speed=" + max + ")");
|
||||
+ backend.getMagic().SPEED_MAX() + ", speed=" + (x > z ? x : z) + ", max speed="
|
||||
+ max + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
@@ -113,4 +114,19 @@ public class SpeedCheck {
|
||||
}
|
||||
}
|
||||
|
||||
public CheckResult checkYSpeed(Player player, double y) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (!backend.isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping()
|
||||
&& (y > backend.getMagic().Y_SPEED_MAX())
|
||||
&& !backend.isDoing(player, backend.velocitized, backend.getMagic().VELOCITY_TIME())
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)
|
||||
&& !Utilities.isSlime(AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getGoodLocation(player.getLocation()).getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"y speed was too high (speed=" + y + ", max=" + backend.getMagic().Y_SPEED_MAX() + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
@@ -46,6 +47,7 @@ public class WaterWalkCheck {
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
Block block = player.getLocation().getBlock();
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
@@ -56,15 +58,11 @@ public class WaterWalkCheck {
|
||||
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
||||
boolean violation;
|
||||
if (!Utilities.sprintFly(player)) {
|
||||
violation = x > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.XZ_SPEED_MAX_WATER()
|
||||
|| z > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.XZ_SPEED_MAX_WATER();
|
||||
violation = x > backend.getMagic().XZ_SPEED_MAX_WATER()
|
||||
|| z > backend.getMagic().XZ_SPEED_MAX_WATER();
|
||||
} else {
|
||||
violation = x > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.XZ_SPEED_MAX_WATER_SPRINT()
|
||||
|| z > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.XZ_SPEED_MAX_WATER_SPRINT();
|
||||
violation = x > backend.getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|
||||
|| z > backend.getMagic().XZ_SPEED_MAX_WATER_SPRINT();
|
||||
}
|
||||
if (!violation && !Utilities.isFullyInWater(player.getLocation())
|
||||
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
|
||||
@@ -74,8 +72,7 @@ public class WaterWalkCheck {
|
||||
if (violation) {
|
||||
if (WATER_SPEED_VIOLATIONS.containsKey(uuid)) {
|
||||
int v = WATER_SPEED_VIOLATIONS.get(uuid);
|
||||
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.WATER_SPEED_VIOLATION_MAX()) {
|
||||
if (v >= backend.getMagic().WATER_SPEED_VIOLATION_MAX()) {
|
||||
WATER_SPEED_VIOLATIONS.put(uuid, 0);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"stood on water " + v + " times (can't stand on " + block.getType()
|
||||
@@ -96,13 +93,13 @@ public class WaterWalkCheck {
|
||||
IS_IN_WATER.add(uuid);
|
||||
return PASS;
|
||||
}
|
||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid()
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block)
|
||||
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN)) && (y < 0.025
|
||||
|| y == 0.09999999999999964 || y == 0.14999999999999947 || y == 0.04999999999999982)) {
|
||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid() && !backend.isAscending(player)
|
||||
&& Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))
|
||||
&& (y < 0.025 || y == 0.09999999999999964 || y == 0.14999999999999947
|
||||
|| y == 0.04999999999999982)) {
|
||||
if (WATER_ASCENSION_VIOLATIONS.containsKey(uuid)) {
|
||||
int v = WATER_ASCENSION_VIOLATIONS.get(uuid);
|
||||
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||
if (v >= backend.getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||
WATER_ASCENSION_VIOLATIONS.put(uuid, 0);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"stood on water " + v + " times (can't stand on " + block.getType() + " or "
|
||||
|
||||
@@ -77,12 +77,12 @@ public class YAxisCheck {
|
||||
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
||||
if (g.getBlock().getType() == Material.AIR || g.getBlock().getType() == Material.CAVE_AIR) {
|
||||
if (g.getBlock().getType() == Material.AIR) {
|
||||
player.teleport(g);
|
||||
}
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to fly on y-axis " + Y_AXIS_VIOLATIONS.get(uuid) + " times (max ="
|
||||
"tried to fly on y-axis " + Y_AXIS_VIOLATIONS.get(uuid) + " times (max="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
|
||||
} else {
|
||||
if (Y_AXIS_VIOLATIONS.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
@@ -95,7 +95,7 @@ public class YAxisCheck {
|
||||
}
|
||||
long i = System.currentTimeMillis() - LAST_Y_TIME.get(uuid);
|
||||
double diff = AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
|
||||
+ (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
|
||||
+ ((Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) || Utilities.isStair(player.getLocation().add(0, -0.5, 0).getBlock())) ? 0.5 : 0.0);
|
||||
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > diff
|
||||
&& i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) {
|
||||
Location g = player.getLocation();
|
||||
@@ -103,11 +103,11 @@ public class YAxisCheck {
|
||||
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
g.setY(LAST_Y_COORD_CACHE.get(uuid));
|
||||
if (g.getBlock().getType() == Material.AIR || g.getBlock().getType() == Material.CAVE_AIR) {
|
||||
if (g.getBlock().getType() == Material.AIR) {
|
||||
player.teleport(g);
|
||||
}
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to fly on y-axis in " + i + " ms (min ="
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to fly on y-axis in " + i + " ms (min="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME() + ")");
|
||||
} else {
|
||||
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
@@ -125,8 +125,7 @@ public class YAxisCheck {
|
||||
}
|
||||
|
||||
public static boolean isMoveUpBlock(Block block) {
|
||||
Material type = block.getType();
|
||||
return type.name().endsWith("STAIRS"); // TODO slabs/others?
|
||||
return Utilities.isStair(block);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.check.packet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
|
||||
public class BadPacketsCheck {
|
||||
|
||||
public static void runCheck(Player player, PacketEvent event) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||
|| backend.isMovingExempt(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
float pitch = packet.getFloat().read(1);
|
||||
// Check for derp
|
||||
if (Math.abs(pitch) > 90) {
|
||||
flag(player, event, "had an illegal pitch");
|
||||
return;
|
||||
}
|
||||
|
||||
double x = packet.getDoubles().read(0);
|
||||
double y = packet.getDoubles().read(1);
|
||||
double z = packet.getDoubles().read(2);
|
||||
float yaw = packet.getFloat().read(0);
|
||||
// Create location from new data
|
||||
Location previous = player.getLocation();
|
||||
Location current = new Location(previous.getWorld(), x, y, z, yaw, pitch);
|
||||
double distance = previous.distanceSquared(current);
|
||||
double maxDistance = backend.getMagic().BADPACKETS_MAX_DISTANCE();
|
||||
if (distance > maxDistance) {
|
||||
flag(player, event, "moved too far between packets (distance=" + new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void flag(Player player, PacketEvent event, String message) {
|
||||
event.setCancelled(true);
|
||||
// We are currently not in the main server thread, so switch
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.MOREPACKETS);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.check.packet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class MorePacketsCheck {
|
||||
|
||||
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void startTimer() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MOVE_COUNT.clear();
|
||||
}
|
||||
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
|
||||
}
|
||||
|
||||
public static void runCheck(Player player, PacketEvent event) {
|
||||
// Confirm if we should even check for MorePackets
|
||||
// If your TPS is lower than 15 you are running a shitshow
|
||||
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS) || tps < 15) {
|
||||
return;
|
||||
}
|
||||
Location currentLocation = event.getPlayer().getLocation();
|
||||
if (!MOVE_COUNT.containsKey(player.getUniqueId())) {
|
||||
MOVE_COUNT.put(player.getUniqueId(), 1);
|
||||
} else {
|
||||
MOVE_COUNT.put(player.getUniqueId(), MOVE_COUNT.get(player.getUniqueId()) + 1);
|
||||
int ping = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).getPing();
|
||||
int limit = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_LIMIT();
|
||||
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic().MOREPACKETS_AVERAGE_PING();
|
||||
float pingLeniency = (float) ((ping / averagePing));
|
||||
if (pingLeniency < 1)
|
||||
pingLeniency = 1;
|
||||
if (pingLeniency > 2)
|
||||
pingLeniency = 2;
|
||||
float tpsLeniency = (float) ((19 / tps));
|
||||
if (tps > 19) {
|
||||
tpsLeniency = 1;
|
||||
}
|
||||
float leniency = pingLeniency * tpsLeniency;
|
||||
limit = Math.round(leniency * limit);
|
||||
final float finalLeniency = leniency;
|
||||
try {
|
||||
if (MOVE_COUNT.get(player.getUniqueId()) > limit) {
|
||||
final int packets = MOVE_COUNT.get(player.getUniqueId());
|
||||
MOVE_COUNT.remove(player.getUniqueId());
|
||||
event.setCancelled(true);
|
||||
// We are currently not in the main server thread, so switch
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener
|
||||
.log(new CheckResult(CheckResult.Result.FAILED,
|
||||
"sent " + packets + " packets in one second (max="
|
||||
+ AntiCheatReloaded.getManager().getBackend().getMagic()
|
||||
.MOREPACKETS_LIMIT()
|
||||
+ ", leniency=" + finalLeniency + ")").getMessage(),
|
||||
player, CheckType.MOREPACKETS);
|
||||
player.teleport(currentLocation);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (NullPointerException nullPointer) {
|
||||
// TODO this is thrown sometimes, might have something to do with line 83
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user