Updated Metrics, made small code changes

This commit is contained in:
Rammelkast committed 2020-02-28 12:40:27 +01:00
1 parent a140afe33e
commit c9c3b2397f
16 files changed
+448 -683

No files matched your search

@@ -23,6 +23,7 @@ import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Callable;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -32,7 +33,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
import com.rammelkast.anticheatreloaded.command.CommandHandler;
import com.rammelkast.anticheatreloaded.config.Configuration;
@@ -92,7 +92,6 @@ public class AntiCheatReloaded extends JavaPlugin {
}
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
// Enable packetlisteners
KillAuraCheck.listenPackets();
BlinkCheck.startTimer();
BlinkCheck.listenPackets();
@@ -149,46 +148,38 @@ public class AntiCheatReloaded extends JavaPlugin {
// Metrics
try {
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked") {
Metrics metrics = new Metrics(this, 202);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() {
@Override
public int getValue() {
public Integer call() throws Exception {
int kicked = playersKicked;
// Reset so we don't keep sending the same value
playersKicked = 0;
return kicked;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("killaura_violations") {
}));
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations", new Callable<Integer>() {
@Override
public int getValue() {
int violations = killauraViolations;
// Reset so we don't keep sending the same value
killauraViolations = 0;
return violations;
}
});
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations") {
@Override
public int getValue() {
public Integer call() throws Exception {
int violations = glideViolations;
// Reset so we don't keep sending the same value
glideViolations = 0;
return violations;
}
});
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version") {
}));
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version", new Callable<String>() {
@Override
public String getValue() {
public String call() throws Exception {
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
}
});
metrics.addCustomChart(new Metrics.SimplePie("nms_version") {
}));
metrics.addCustomChart(new Metrics.SimplePie("nms_version", new Callable<String>() {
@Override
public String getValue() {
public String call() throws Exception {
return VersionUtil.getVersion();
}
});
}));
} catch (Exception e) {
e.printStackTrace();
}
@@ -309,10 +300,6 @@ public class AntiCheatReloaded extends JavaPlugin {
* Amount of players kicked since start
*/
private int playersKicked = 0;
/**
* Amount of killaura violations since start
*/
private int killauraViolations = 0;
/**
* Amount of glide violations since start
*/
@@ -322,10 +309,6 @@ public class AntiCheatReloaded extends JavaPlugin {
this.playersKicked++;
}
public void onKillAuraViolation() {
this.killauraViolations++;
}
public void onGlideViolation() {
this.glideViolations++;
}
@@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerToggleSprintEvent;
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.BlinkCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
@@ -121,29 +120,28 @@ public class Backend {
UUID pU = player.getUniqueId();
VelocityCheck.cleanPlayer(player);
KillAuraCheck.cleanPlayer(player);
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
blocksDropped.remove(pU);
blockTime.remove(pU);
FlightCheck.movingExempt.remove(pU);
FlightCheck.MOVING_EXEMPT.remove(pU);
brokenBlock.remove(pU);
placedBlock.remove(pU);
bowWindUp.remove(pU);
startEat.remove(pU);
lastHeal.remove(pU);
sprinted.remove(pU);
WaterWalkCheck.isInWater.remove(pU);
WaterWalkCheck.isInWaterCache.remove(pU);
WaterWalkCheck.IS_IN_WATER.remove(pU);
WaterWalkCheck.IS_IN_WATER_CACHE.remove(pU);
instantBreakExempt.remove(pU);
isAscending.remove(player.getUniqueId());
ascensionCount.remove(player.getUniqueId());
FlightCheck.blocksOverFlight.remove(pU);
FlightCheck.BLOCKS_OVER_FLIGHT.remove(pU);
nofallViolation.remove(pU);
fastBreakViolation.remove(pU);
YAxisCheck.yAxisViolations.remove(pU);
YAxisCheck.yAxisLastViolation.remove(pU);
YAxisCheck.lastYcoord.remove(pU);
YAxisCheck.lastYtime.remove(pU);
YAxisCheck.Y_AXIS_VIOLATIONS.remove(pU);
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(pU);
YAxisCheck.LAST_Y_COORD_CACHE.remove(pU);
YAxisCheck.LAST_Y_TIME.remove(pU);
fastBreaks.remove(pU);
blockBreakHolder.remove(pU);
lastBlockBroken.remove(pU);
@@ -151,8 +149,8 @@ public class Backend {
lastBlockPlaced.remove(pU);
lastBlockPlaceTime.remove(pU);
blockPunches.remove(pU);
WaterWalkCheck.waterAscensionViolation.remove(pU);
WaterWalkCheck.waterSpeedViolation.remove(pU);
WaterWalkCheck.WATER_ASCENSION_VIOLATIONS.remove(pU);
WaterWalkCheck.WATER_SPEED_VIOLATIONS.remove(pU);
projectilesShot.remove(pU);
velocitized.remove(pU);
velocitytrack.remove(pU);
@@ -164,17 +162,17 @@ public class Backend {
sprinted.remove(pU);
brokenBlock.remove(pU);
placedBlock.remove(pU);
FlightCheck.movingExempt.remove(pU);
FlightCheck.MOVING_EXEMPT.remove(pU);
blockTime.remove(pU);
blocksDropped.remove(pU);
lastInventoryTime.remove(pU);
inventoryTime.remove(pU);
inventoryClicks.remove(pU);
lastFallPacket.remove(pU);
GlideCheck.lastDiff.remove(pU);
GlideCheck.lastFallDistance.remove(pU);
GlideCheck.violations.remove(pU);
SpeedCheck.speedViolation.remove(player.getUniqueId());
GlideCheck.LAST_DIFFERENCE.remove(pU);
GlideCheck.LAST_FALL_DISTANCE.remove(pU);
GlideCheck.VIOLATIONS.remove(pU);
SpeedCheck.SPEED_VIOLATIONS.remove(player.getUniqueId());
}
public CheckResult checkFastBow(Player player, float force) {
@@ -703,8 +701,8 @@ public class Backend {
}
public boolean isHoveringOverWaterAfterViolation(Player player) {
if (WaterWalkCheck.waterSpeedViolation.containsKey(player.getUniqueId())) {
if (WaterWalkCheck.waterSpeedViolation.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) {
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX() && Utilities.isHoveringOverWater(player.getLocation())) {
return true;
}
}
@@ -771,43 +769,43 @@ public class Backend {
break;
}
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + time);
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + time);
// Only map in which termination time is calculated beforehand.
}
public void logEnterExit(final Player player) {
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.ENTERED_EXITED_TIME());
}
public void logToggleSneak(final Player player) {
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME());
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.SNEAK_TIME());
}
public void logTeleport(final Player player) {
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME());
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.TELEPORT_TIME());
/* Data for fly/speed should be reset */
nofallViolation.remove(player.getUniqueId());
FlightCheck.blocksOverFlight.remove(player.getUniqueId());
YAxisCheck.yAxisViolations.remove(player.getUniqueId());
YAxisCheck.yAxisLastViolation.remove(player.getUniqueId());
YAxisCheck.lastYcoord.remove(player.getUniqueId());
YAxisCheck.lastYtime.remove(player.getUniqueId());
GlideCheck.lastFallDistance.remove(player.getUniqueId());
GlideCheck.lastDiff.remove(player.getUniqueId());
GlideCheck.violations.remove(player.getUniqueId());
FlightCheck.BLOCKS_OVER_FLIGHT.remove(player.getUniqueId());
YAxisCheck.Y_AXIS_VIOLATIONS.remove(player.getUniqueId());
YAxisCheck.LAST_Y_AXIS_VIOLATION.remove(player.getUniqueId());
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.VIOLATIONS.remove(player.getUniqueId());
}
public void logExitFly(final Player player) {
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.EXIT_FLY_TIME());
}
public void logJoin(final Player player) {
FlightCheck.movingExempt.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
FlightCheck.MOVING_EXEMPT.put(player.getUniqueId(), System.currentTimeMillis() + magic.JOIN_TIME());
}
public boolean isMovingExempt(Player player) {
return isDoing(player, FlightCheck.movingExempt, -1);
return isDoing(player, FlightCheck.MOVING_EXEMPT, -1);
}
public boolean isAscending(Player player) {
@@ -62,7 +62,6 @@ public enum CheckType {
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
AUTOTOOL(Permission.CHECK_AUTOTOOL),
KILLAURA(Permission.CHECK_KILLAURA),
BLINK(Permission.CHECK_BLINK),
VELOCITY(Permission.CHECK_VELOCITY),
CRITICALS(Permission.CHECK_CRITICALS),
@@ -1,100 +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.combat;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
/**
* @author Rammelkast
*/
@Deprecated
public class KillAuraCheck {
//private static final Map<UUID, NPC_1_12> NPC_LIST = new HashMap<UUID, NPC_1_12>();
//private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) {
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return;
}
NPC_LIST.remove(p.getUniqueId());*/
}
public static void listenPackets() {
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return;
}
AntiCheatReloaded.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheatReloaded.getPlugin(),
ListenerPriority.NORMAL, new PacketType[] { PacketType.Play.Client.USE_ENTITY }) {
@Override
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if (!NPC_LIST.containsKey(p.getUniqueId()))
return;
int id = e.getPacket().getIntegers().read(0);
if (NPC_LIST.containsKey(p.getUniqueId())) {
if (NPC_LIST.get(p.getUniqueId()).getID() != id) {
return;
}
}
if (!VL_COUNT.containsKey(p.getUniqueId())) {
VL_COUNT.put(p.getUniqueId(), 1);
NPC_LIST.get(p.getUniqueId()).damage();
} else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) >= 5) {
EventListener.log(
new CheckResult(CheckResult.Result.FAILED,
p.getName() + " failed KillAura (botcheck), hit the bot "
+ VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(),
p, CheckType.KILLAURA);
AntiCheatReloaded.getPlugin().onKillAuraViolation();
VL_COUNT.remove(p.getUniqueId());
}
}
}
});*/
}
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return;
}
if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p);
else {
NPC_1_12 npc = new NPC_1_12(p);
NPC_LIST.put(p.getUniqueId(), npc);
npc.spawn();
}*/
}
public static void doMove(PlayerMoveEvent e) {
/*if (!VersionUtil.getVersion().equals("v1_12_R1")) {
return;
}
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) {
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
}*/
}
}
@@ -51,7 +51,7 @@ public class BlinkCheck {
public void run() {
MOVE_COUNT.clear();
}
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 100, 20);
}.runTaskTimer(AntiCheatReloaded.getPlugin(), 20, 20);
}
public static void listenPackets() {
@@ -38,11 +38,10 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
*/
public class FlightCheck {
public static final Map<UUID, Double> BLOCKS_OVER_FLIGHT = new HashMap<UUID, Double>();
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> blocksOverFlight = new HashMap<UUID, Double>();
public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>();
public static CheckResult runCheck(Player player, Distance distance) {
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|| VersionUtil.isFlying(player)) {
@@ -62,32 +61,32 @@ public class FlightCheck {
"FENCE_GATE"
})) {
if (!blocksOverFlight.containsKey(uuid)) {
blocksOverFlight.put(uuid, 0D);
if (!BLOCKS_OVER_FLIGHT.containsKey(uuid)) {
BLOCKS_OVER_FLIGHT.put(uuid, 0D);
}
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) + distance.getXDifference()
BLOCKS_OVER_FLIGHT.put(uuid, (BLOCKS_OVER_FLIGHT.get(uuid) + distance.getXDifference()
+ distance.getYDifference() + distance.getZDifference()));
if (y1 > y2) {
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference()));
BLOCKS_OVER_FLIGHT.put(uuid, (BLOCKS_OVER_FLIGHT.get(uuid) - distance.getYDifference()));
}
if (blocksOverFlight.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT()
if (BLOCKS_OVER_FLIGHT.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT()
&& (y1 <= y2)) {
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max="
player.getName() + " flew over " + BLOCKS_OVER_FLIGHT.get(uuid) + " blocks (max="
+ AntiCheatReloaded.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
}
} else {
blocksOverFlight.put(uuid, 0D);
BLOCKS_OVER_FLIGHT.put(uuid, 0D);
}
return PASS;
}
public static boolean isMovingExempt(Player player) {
return isDoing(player, movingExempt, -1);
return isDoing(player, MOVING_EXEMPT, -1);
}
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
@@ -20,6 +20,7 @@
package com.rammelkast.anticheatreloaded.check.movement;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -35,36 +36,37 @@ 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, 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 Map<UUID, Double> lastDiff = new HashMap<UUID, Double>();
public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>();
public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>();
public static CheckResult runCheck(Player player, Distance distance) {
if (VersionUtil.isFlying(player)) {
return PASS;
}
if (player.getLocation().getBlock().getType() == Material.LADDER || player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
if (player.getLocation().getBlock().getType() == Material.LADDER
|| player.getLocation().getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
return PASS;
}
if (!lastDiff.containsKey(player.getUniqueId())) {
lastDiff.put(player.getUniqueId(), distance.getYDifference());
if (!LAST_DIFFERENCE.containsKey(player.getUniqueId())) {
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
return PASS;
}
if (!lastFallDistance.containsKey(player.getUniqueId())) {
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
if (!LAST_FALL_DISTANCE.containsKey(player.getUniqueId())) {
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
double yDiff = distance.getYDifference();
float fallDistance = player.getFallDistance();
if (yDiff == lastDiff.get(player.getUniqueId()) && fallDistance > lastFallDistance.get(player.getUniqueId())) {
if (!violations.containsKey(player.getUniqueId())) {
violations.put(player.getUniqueId(), 1);
if (yDiff == LAST_DIFFERENCE.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()
if (VIOLATIONS.get(player.getUniqueId()) + 1 >= AntiCheatReloaded.getManager().getBackend().getMagic()
.GLIDE_LIMIT()) {
violations.remove(player.getUniqueId());
VIOLATIONS.remove(player.getUniqueId());
Location to = player.getLocation();
to.setY(to.getY() - distanceToFall(to));
player.teleport(to);
@@ -72,16 +74,16 @@ public class GlideCheck {
AntiCheatReloaded.getPlugin().onGlideViolation();
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " was set back for gliding (yDiff="
+ new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")");
+ new BigDecimal(yDiff).setScale(2, RoundingMode.HALF_UP) + ")");
} else {
violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1);
VIOLATIONS.put(player.getUniqueId(), VIOLATIONS.get(player.getUniqueId()) + 1);
}
}
} else {
// TODO more sophisticated check
}
lastDiff.put(player.getUniqueId(), distance.getYDifference());
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
LAST_DIFFERENCE.put(player.getUniqueId(), distance.getYDifference());
LAST_FALL_DISTANCE.put(player.getUniqueId(), player.getFallDistance());
return PASS;
}
@@ -32,8 +32,8 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
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 Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>();
public static boolean isSpeedExempt(Player player) {
return AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)
@@ -75,7 +75,7 @@ public class SpeedCheck {
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if (x > max || z > max) {
int num = AntiCheatReloaded.getManager().getBackend().increment(player, speedViolation,
int num = AntiCheatReloaded.getManager().getBackend().increment(player, SPEED_VIOLATIONS,
AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX());
if (num >= AntiCheatReloaded.getManager().getBackend().getMagic().SPEED_MAX()) {
return new CheckResult(CheckResult.Result.FAILED,
@@ -86,7 +86,7 @@ public class SpeedCheck {
return PASS;
}
} else {
speedViolation.put(player.getUniqueId(), 0);
SPEED_VIOLATIONS.put(player.getUniqueId(), 0);
return PASS;
}
} else {
@@ -40,21 +40,20 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
*/
public class WaterWalkCheck {
public static final List<UUID> IS_IN_WATER = new ArrayList<UUID>();
public static final List<UUID> IS_IN_WATER_CACHE = new ArrayList<UUID>();
public static final Map<UUID, Integer> WATER_SPEED_VIOLATIONS = new HashMap<UUID, Integer>();
public static final Map<UUID, Integer> WATER_ASCENSION_VIOLATIONS = new HashMap<UUID, Integer>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static List<UUID> isInWater = new ArrayList<UUID>();
public static List<UUID> isInWaterCache = new ArrayList<UUID>();
public static Map<UUID, Integer> waterSpeedViolation = new HashMap<UUID, Integer>();
public static Map<UUID, Integer> waterAscensionViolation = new HashMap<UUID, Integer>();
public static CheckResult runCheck(Player player, double x, double y, double z) {
Block block = player.getLocation().getBlock();
UUID uuid = player.getUniqueId();
if (player.getVehicle() == null && !player.isFlying() && !VersionUtil.isFrostWalk(player)) {
if (block.isLiquid()) {
if (isInWater.contains(uuid)) {
if (isInWaterCache.contains(uuid)) {
if (IS_IN_WATER.contains(uuid)) {
if (IS_IN_WATER_CACHE.contains(uuid)) {
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
boolean b;
if (!Utilities.sprintFly(player)) {
@@ -73,50 +72,50 @@ public class WaterWalkCheck {
b = true;
}
if (b) {
if (waterSpeedViolation.containsKey(uuid)) {
int v = waterSpeedViolation.get(uuid);
if (WATER_SPEED_VIOLATIONS.containsKey(uuid)) {
int v = WATER_SPEED_VIOLATIONS.get(uuid);
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic()
.WATER_SPEED_VIOLATION_MAX()) {
waterSpeedViolation.put(uuid, 0);
WATER_SPEED_VIOLATIONS.put(uuid, 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(uuid, v + 1);
WATER_SPEED_VIOLATIONS.put(uuid, v + 1);
}
} else {
waterSpeedViolation.put(uuid, 1);
WATER_SPEED_VIOLATIONS.put(uuid, 1);
}
}
}
} else {
isInWaterCache.add(uuid);
IS_IN_WATER_CACHE.add(uuid);
return PASS;
}
} else {
isInWater.add(uuid);
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))) {
if (waterAscensionViolation.containsKey(uuid)) {
int v = waterAscensionViolation.get(uuid);
if (WATER_ASCENSION_VIOLATIONS.containsKey(uuid)) {
int v = WATER_ASCENSION_VIOLATIONS.get(uuid);
if (v >= AntiCheatReloaded.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
waterAscensionViolation.put(uuid, 0);
WATER_ASCENSION_VIOLATIONS.put(uuid, 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(uuid, v + 1);
WATER_ASCENSION_VIOLATIONS.put(uuid, v + 1);
}
} else {
waterAscensionViolation.put(uuid, 1);
WATER_ASCENSION_VIOLATIONS.put(uuid, 1);
}
} else {
isInWater.remove(uuid);
isInWaterCache.remove(uuid);
IS_IN_WATER.remove(uuid);
IS_IN_WATER_CACHE.remove(uuid);
}
}
return PASS;
@@ -37,13 +37,12 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
public class YAxisCheck {
public static final Map<UUID, Double> LAST_Y_COORD_CACHE = new HashMap<UUID, Double>();
public static final Map<UUID, Long> LAST_Y_TIME = new HashMap<UUID, Long>();
public static final Map<UUID, Integer> Y_AXIS_VIOLATIONS = new HashMap<UUID, Integer>();
public static final Map<UUID, Long> LAST_Y_AXIS_VIOLATION = new HashMap<UUID, Long>();
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static Map<UUID, Double> lastYcoord = new HashMap<UUID, Double>();
public static Map<UUID, Long> lastYtime = new HashMap<UUID, Long>();
public static Map<UUID, Integer> yAxisViolations = new HashMap<UUID, Integer>();
public static Map<UUID, Long> yAxisLastViolation = new HashMap<UUID, Long>();
private static boolean hasJumpPotion(Player player) {
return player.hasPotionEffect(PotionEffectType.JUMP);
}
@@ -61,49 +60,49 @@ public class YAxisCheck {
double y1 = player.getLocation().getY();
UUID uuid = player.getUniqueId();
// Fix Y axis spam.
if (!lastYcoord.containsKey(uuid) || !lastYtime.containsKey(uuid)
|| !yAxisLastViolation.containsKey(uuid)) {
lastYcoord.put(uuid, y1);
yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L);
lastYtime.put(uuid, System.currentTimeMillis());
if (!LAST_Y_COORD_CACHE.containsKey(uuid) || !LAST_Y_TIME.containsKey(uuid)
|| !LAST_Y_AXIS_VIOLATION.containsKey(uuid)) {
LAST_Y_COORD_CACHE.put(uuid, y1);
Y_AXIS_VIOLATIONS.put(uuid, 0);
LAST_Y_AXIS_VIOLATION.put(uuid, 0L);
LAST_Y_TIME.put(uuid, System.currentTimeMillis());
} else {
if (y1 > lastYcoord.get(uuid)
&& yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
if (y1 > LAST_Y_COORD_CACHE.get(uuid)
&& Y_AXIS_VIOLATIONS.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
.Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheatReloaded.getManager()
&& (System.currentTimeMillis() - LAST_Y_AXIS_VIOLATION.get(uuid)) < AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_MAXVIOTIME()) {
Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
Y_AXIS_VIOLATIONS.put(uuid, Y_AXIS_VIOLATIONS.get(uuid) + 1);
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
g.setY(LAST_Y_COORD_CACHE.get(uuid));
if (g.getBlock().getType() == Material.AIR) {
player.teleport(g);
}
}
return new CheckResult(CheckResult.Result.FAILED,
player.getName() + " tried to fly on y-axis " + yAxisViolations.get(uuid) + " times (max ="
player.getName() + " tried to fly on y-axis " + Y_AXIS_VIOLATIONS.get(uuid) + " times (max ="
+ AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
} else {
if (yAxisViolations.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
if (Y_AXIS_VIOLATIONS.get(uuid) > AntiCheatReloaded.getManager().getBackend().getMagic()
.Y_MAXVIOLATIONS()
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheatReloaded
&& (System.currentTimeMillis() - LAST_Y_AXIS_VIOLATION.get(uuid)) > AntiCheatReloaded
.getManager().getBackend().getMagic().Y_MAXVIOTIME()) {
yAxisViolations.put(uuid, 0);
yAxisLastViolation.put(uuid, 0L);
Y_AXIS_VIOLATIONS.put(uuid, 0);
LAST_Y_AXIS_VIOLATION.put(uuid, 0L);
}
}
long i = System.currentTimeMillis() - lastYtime.get(uuid);
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);
if ((y1 - lastYcoord.get(uuid)) > diff
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > diff
&& i < AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME()) {
Location g = player.getLocation();
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
yAxisLastViolation.put(uuid, System.currentTimeMillis());
Y_AXIS_VIOLATIONS.put(uuid, Y_AXIS_VIOLATIONS.get(uuid) + 1);
LAST_Y_AXIS_VIOLATION.put(uuid, System.currentTimeMillis());
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
g.setY(lastYcoord.get(uuid));
g.setY(LAST_Y_COORD_CACHE.get(uuid));
if (g.getBlock().getType() == Material.AIR) {
player.teleport(g);
}
@@ -111,12 +110,12 @@ public class YAxisCheck {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in "
+ i + " ms (min =" + AntiCheatReloaded.getManager().getBackend().getMagic().Y_TIME() + ")");
} else {
if ((y1 - lastYcoord.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
if ((y1 - LAST_Y_COORD_CACHE.get(uuid)) > AntiCheatReloaded.getManager().getBackend().getMagic().Y_MAXDIFF()
+ 1
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheatReloaded.getManager()
|| (System.currentTimeMillis() - LAST_Y_TIME.get(uuid)) > AntiCheatReloaded.getManager()
.getBackend().getMagic().Y_TIME()) {
lastYtime.put(uuid, System.currentTimeMillis());
lastYcoord.put(uuid, y1);
LAST_Y_TIME.put(uuid, System.currentTimeMillis());
LAST_Y_COORD_CACHE.put(uuid, y1);
}
}
}
@@ -29,18 +29,16 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
import com.rammelkast.anticheatreloaded.util.Distance;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
public class EntityListener extends EventListener {
@EventHandler
@@ -105,9 +103,6 @@ public class EntityListener extends EventListener {
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if (e.getDamager() instanceof Player) {
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.KILLAURA)) {
KillAuraCheck.doDamageEvent(e, (Player)e.getDamager());
}
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
}
@@ -118,7 +113,7 @@ public class EntityListener extends EventListener {
if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager();
getBackend().logDamage(p, 1);
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
int value = p.getInventory().getItemInMainHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
getBackend().logDamage(player, value);
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
Distance distance = new Distance(player.getLocation(), p.getLocation());
File diff suppressed because it is too large. Load diff
@@ -26,7 +26,7 @@ public enum Permission {
CHECK_ZOMBE_FLY, CHECK_ZOMBE_NOCLIP, CHECK_ZOMBE_CHEAT, CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_FORCEFIELD, CHECK_LONGREACH,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_KILLAURA, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_UNICODE,
/* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_SPY, SYSTEM_HELP, SYSTEM_UPDATE, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,