UnicodeChat fix for other European languages (possible more?) as described in #59.

Also added more default leniancy for blink check.
This commit is contained in:
Rammelkast committed 2020-04-06 17:28:22 +02:00
1 parent 3af7bde9db
commit 7c9a05ff92
6 files changed
+119 -63

No files matched your search

+1 -1
View File
@@ -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.0</version> <version>1.8.1-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>
@@ -255,7 +255,7 @@ public class AntiCheatReloaded extends JavaPlugin {
} }
public static void sendToMainThread(Runnable runnable) { public static void sendToMainThread(Runnable runnable) {
Bukkit.getServer().getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable); Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
} }
public void sendToStaff(String message) { public void sendToStaff(String message) {
@@ -21,6 +21,7 @@ package com.rammelkast.anticheatreloaded.check;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -194,7 +195,8 @@ public class Backend {
f = (f * f + f * 2.0F) / 3.0F; f = (f * f + f * 2.0F) / 3.0F;
f = f > 1.0F ? 1.0F : f; f = f > 1.0F ? 1.0F : f;
if (Math.abs(force - f) > magic.BOW_ERROR()) { if (Math.abs(force - f) > magic.BOW_ERROR()) {
return new CheckResult(CheckResult.Result.FAILED, "fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")"); return new CheckResult(CheckResult.Result.FAILED,
"fired their bow too fast (actual force=" + force + ", calculated force=" + f + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -210,7 +212,8 @@ public class Backend {
projectileTime.remove(player.getUniqueId()); projectileTime.remove(player.getUniqueId());
projectilesShot.remove(player.getUniqueId()); projectilesShot.remove(player.getUniqueId());
if (time < magic.PROJECTILE_TIME_MIN()) { if (time < magic.PROJECTILE_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, "wound up a bow too fast (actual time=" + time + ", min time=" + magic.PROJECTILE_TIME_MIN() + ")"); return new CheckResult(CheckResult.Result.FAILED, "wound up a bow too fast (actual time=" + time
+ ", min time=" + magic.PROJECTILE_TIME_MIN() + ")");
} }
} }
return PASS; return PASS;
@@ -226,7 +229,8 @@ public class Backend {
blockTime.remove(player.getUniqueId()); blockTime.remove(player.getUniqueId());
blocksDropped.remove(player.getUniqueId()); blocksDropped.remove(player.getUniqueId());
if (time < magic.DROP_TIME_MIN()) { if (time < magic.DROP_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED,"dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")"); return new CheckResult(CheckResult.Result.FAILED,
"dropped an item too fast (actual time=" + time + ", min time=" + magic.DROP_TIME_MIN() + ")");
} }
} }
return PASS; return PASS;
@@ -237,13 +241,13 @@ public class Backend {
return new CheckResult(CheckResult.Result.PASSED); return new CheckResult(CheckResult.Result.PASSED);
} else { } else {
String string = "reached too far for a block"; String string = "reached too far for a block";
double distance = double distance = player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
player.getGameMode() == GameMode.CREATIVE ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE() : player.getLocation().getDirection().getY() > 0.9 ? magic.BLOCK_MAX_DISTANCE_CREATIVE()
: magic.BLOCK_MAX_DISTANCE(); : magic.BLOCK_MAX_DISTANCE();
double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1; double i = x >= distance ? x : y > distance ? y : z > distance ? z : -1;
if (i != -1) { if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")"); return new CheckResult(CheckResult.Result.FAILED,
string + " (distance=" + i + ", max=" + magic.BLOCK_MAX_DISTANCE() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -252,25 +256,32 @@ public class Backend {
public CheckResult checkLongReachDamage(Player player, double x, double y, double z) { public CheckResult checkLongReachDamage(Player player, double x, double y, double z) {
String string = "reached too far for an entity"; String string = "reached too far for an entity";
double i = x >= magic.ENTITY_MAX_DISTANCE() ? x : y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1; double i = x >= magic.ENTITY_MAX_DISTANCE() ? x
: y > magic.ENTITY_MAX_DISTANCE() ? y : z > magic.ENTITY_MAX_DISTANCE() ? z : -1;
if (i != -1) { if (i != -1) {
return new CheckResult(CheckResult.Result.FAILED, string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")"); return new CheckResult(CheckResult.Result.FAILED,
string + " (distance=" + i + ", max=" + magic.ENTITY_MAX_DISTANCE() + ")");
} else { } else {
return PASS; return PASS;
} }
} }
public CheckResult checkSpider(Player player, double y) { public CheckResult checkSpider(Player player, double y) {
if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN() && !Utilities.isClimbableBlock(player.getLocation().getBlock())) { if (y <= magic.LADDER_Y_MAX() && y >= magic.LADDER_Y_MIN()
return new CheckResult(CheckResult.Result.FAILED, "tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")"); && !Utilities.isClimbableBlock(player.getLocation().getBlock())) {
return new CheckResult(CheckResult.Result.FAILED,
"tried to climb a non-ladder (" + player.getLocation().getBlock().getType() + ")");
} else { } else {
return PASS; return PASS;
} }
} }
public CheckResult checkYSpeed(Player player, double y) { public CheckResult checkYSpeed(Player player, double y) {
if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX()) && !isDoing(player, velocitized, magic.VELOCITY_TIME()) && !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) { if (!isMovingExempt(player) && !player.isInsideVehicle() && !player.isSleeping() && (y > magic.Y_SPEED_MAX())
return new CheckResult(CheckResult.Result.FAILED, "y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")"); && !isDoing(player, velocitized, magic.VELOCITY_TIME())
&& !player.hasPotionEffect(PotionEffectType.JUMP) && !VersionUtil.isFlying(player)) {
return new CheckResult(CheckResult.Result.FAILED,
"y speed was too high (speed=" + y + ", max=" + magic.Y_SPEED_MAX() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -278,7 +289,9 @@ public class Backend {
public CheckResult checkNoFall(Player player, double y) { public CheckResult checkNoFall(Player player, double y) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player) && !Utilities.isInWeb(player)) { if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
&& !isMovingExempt(player) && !justPlaced(player) && !Utilities.isInWater(player)
&& !Utilities.isInWeb(player)) {
if (player.getFallDistance() == 0) { if (player.getFallDistance() == 0) {
if (nofallViolation.get(uuid) == null) { if (nofallViolation.get(uuid) == null) {
nofallViolation.put(uuid, 1); nofallViolation.put(uuid, 1);
@@ -289,7 +302,8 @@ public class Backend {
int i = nofallViolation.get(uuid); int i = nofallViolation.get(uuid);
if (i >= magic.NOFALL_LIMIT()) { if (i >= magic.NOFALL_LIMIT()) {
nofallViolation.put(player.getUniqueId(), 1); nofallViolation.put(player.getUniqueId(), 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 " + i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")"); return new CheckResult(CheckResult.Result.FAILED, "tried to avoid fall damage (fall distance = 0 "
+ i + " times in a row, max=" + magic.NOFALL_LIMIT() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -302,13 +316,15 @@ public class Backend {
} }
public CheckResult checkSneak(Player player, Location location, double x, double z) { public CheckResult checkSneak(Player player, Location location, double x, double z) {
if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle() && !Utilities.cantStandAtExp(location)) { if (player.isSneaking() && !VersionUtil.isFlying(player) && !isMovingExempt(player) && !player.isInsideVehicle()
&& !Utilities.cantStandAtExp(location)) {
double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1; double i = x > magic.XZ_SPEED_MAX_SNEAK() ? x : z > magic.XZ_SPEED_MAX_SNEAK() ? z : -1;
if (i != -1) { if (i != -1) {
if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) { if (this.fastSneakViolations.containsKey(player.getUniqueId().toString())) {
int flags = this.fastSneakViolations.get(player.getUniqueId().toString()); int flags = this.fastSneakViolations.get(player.getUniqueId().toString());
if (flags >= 3) { // TODO possible config if (flags >= 3) { // TODO possible config
return new CheckResult(CheckResult.Result.FAILED, "was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")"); return new CheckResult(CheckResult.Result.FAILED,
"was sneaking too fast (speed=" + i + ", max=" + magic.XZ_SPEED_MAX_SNEAK() + ")");
} }
this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1); this.fastSneakViolations.put(player.getUniqueId().toString(), flags + 1);
return PASS; return PASS;
@@ -328,8 +344,10 @@ public class Backend {
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) { public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) { if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE
return new CheckResult(CheckResult.Result.FAILED, "sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")"); && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
return new CheckResult(CheckResult.Result.FAILED,
"sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -344,9 +362,11 @@ public class Backend {
} }
for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) { for (int i = 0; i < (Math.round(distance.getYDifference())) + 1; i++) {
Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i, player.getLocation().getZ()).getBlock(); Block block = new Location(player.getWorld(), player.getLocation().getX(), to + i,
player.getLocation().getZ()).getBlock();
if (block.getType() != Material.AIR && block.getType().isSolid()) { if (block.getType() != Material.AIR && block.getType().isSolid()) {
return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block", (int) from + 3); return new CheckResult(CheckResult.Result.FAILED, "tried to move through a solid block",
(int) from + 3);
} }
} }
@@ -367,7 +387,8 @@ public class Backend {
long time = System.currentTimeMillis() - stepTime.get(uuid); long time = System.currentTimeMillis() - stepTime.get(uuid);
steps.put(uuid, 0); steps.put(uuid, 0);
if (time < magic.TIMER_TIMEMIN()) { if (time < magic.TIMER_TIMEMIN()) {
return new CheckResult(CheckResult.Result.FAILED, "tried to alter their timer, took " + step + " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "tried to alter their timer, took " + step
+ " steps in " + time + " ms (min = " + magic.TIMER_TIMEMIN() + " ms)");
} }
} }
return PASS; return PASS;
@@ -401,8 +422,8 @@ public class Backend {
increment(player, ascensionCount, max); increment(player, ascensionCount, max);
if (ascensionCount.get(player.getUniqueId()) >= max) { if (ascensionCount.get(player.getUniqueId()) >= max) {
return new CheckResult(CheckResult.Result.FAILED, return new CheckResult(CheckResult.Result.FAILED,
"ascended " + ascensionCount.get(player.getUniqueId()) "ascended " + ascensionCount.get(player.getUniqueId()) + " times in a row (max = " + max
+ " times in a row (max = " + max + string + ")"); + string + ")");
} }
} }
} else { } else {
@@ -415,11 +436,14 @@ public class Backend {
public CheckResult checkSwing(Player player, Block block) { public CheckResult checkSwing(Player player, Block block) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (!isInstantBreakExempt(player)) { if (!isInstantBreakExempt(player)) {
if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED) && !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS && block.getType().name().endsWith("LEAVES"))) { if (!VersionUtil.getItemInHand(player).containsEnchantment(Enchantment.DIG_SPEED)
&& !(VersionUtil.getItemInHand(player).getType() == Material.SHEARS
&& block.getType().name().endsWith("LEAVES"))) {
if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) { if (blockPunches.get(uuid) != null && player.getGameMode() != GameMode.CREATIVE) {
int i = blockPunches.get(uuid); int i = blockPunches.get(uuid);
if (i < magic.BLOCK_PUNCH_MIN()) { if (i < magic.BLOCK_PUNCH_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType() + " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")"); return new CheckResult(CheckResult.Result.FAILED, "tried to break a block of " + block.getType()
+ " after only " + i + " punches (min=" + magic.BLOCK_PUNCH_MIN() + ")");
} else { } else {
blockPunches.put(uuid, 0); // it should reset after EACH block break. blockPunches.put(uuid, 0); // it should reset after EACH block break.
} }
@@ -431,7 +455,8 @@ public class Backend {
public CheckResult checkFastBreak(Player player, Block block) { public CheckResult checkFastBreak(Player player, Block block) {
int violations = magic.FASTBREAK_MAXVIOLATIONS(); int violations = magic.FASTBREAK_MAXVIOLATIONS();
long timemax = isInstantBreakExempt(player) ? 0 : Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType()); long timemax = isInstantBreakExempt(player) ? 0
: Utilities.calcSurvivalFastBreak(VersionUtil.getItemInHand(player), block.getType());
if (player.getGameMode() == GameMode.CREATIVE) { if (player.getGameMode() == GameMode.CREATIVE) {
violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE(); violations = magic.FASTBREAK_MAXVIOLATIONS_CREATIVE();
timemax = magic.FASTBREAK_TIMEMAX_CREATIVE(); timemax = magic.FASTBREAK_TIMEMAX_CREATIVE();
@@ -444,7 +469,8 @@ public class Backend {
int i = fastBreakViolation.get(uuid); int i = fastBreakViolation.get(uuid);
if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) { if (i > violations && math < magic.FASTBREAK_MAXVIOLATIONTIME()) {
lastBlockBroken.put(uuid, System.currentTimeMillis()); lastBlockBroken.put(uuid, System.currentTimeMillis());
return new CheckResult(CheckResult.Result.FAILED, "broke blocks too fast " + i + " times in a row (max=" + violations + ")"); return new CheckResult(CheckResult.Result.FAILED,
"broke blocks too fast " + i + " times in a row (max=" + violations + ")");
} else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) { } else if (fastBreakViolation.get(uuid) > 0 && math > magic.FASTBREAK_MAXVIOLATIONTIME()) {
fastBreakViolation.put(uuid, 0); fastBreakViolation.put(uuid, 0);
} }
@@ -471,7 +497,8 @@ public class Backend {
int i = fastBreaks.get(uuid); int i = fastBreaks.get(uuid);
fastBreaks.put(uuid, 0); fastBreaks.put(uuid, 0);
fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1); fastBreakViolation.put(uuid, fastBreakViolation.get(uuid) + 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math + " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "tried to break " + i + " blocks in " + math
+ " ms (max=" + magic.FASTBREAK_LIMIT() + " in " + timemax + " ms)");
} else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) { } else if (fastBreaks.get(uuid) >= magic.FASTBREAK_LIMIT() || fastBreakViolation.get(uuid) > 0) {
if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) { if (!blockBreakHolder.containsKey(uuid) || !blockBreakHolder.get(uuid)) {
blockBreakHolder.put(uuid, true); blockBreakHolder.put(uuid, true);
@@ -491,7 +518,8 @@ public class Backend {
} }
public CheckResult checkFastPlace(Player player) { public CheckResult checkFastPlace(Player player) {
int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE() : magic.FASTPLACE_MAXVIOLATIONS(); int violations = player.getGameMode() == GameMode.CREATIVE ? magic.FASTPLACE_MAXVIOLATIONS_CREATIVE()
: magic.FASTPLACE_MAXVIOLATIONS();
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) { if (!lastBlockPlaceTime.containsKey(uuid) || !fastPlaceViolation.containsKey(uuid)) {
@@ -500,12 +528,14 @@ public class Backend {
fastPlaceViolation.put(uuid, 0); fastPlaceViolation.put(uuid, 0);
} }
} else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) { } else if (fastPlaceViolation.containsKey(uuid) && fastPlaceViolation.get(uuid) > violations) {
AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value " + fastPlaceViolation.get(uuid)); AntiCheatReloaded.debugLog("Noted that fastPlaceViolation contains key " + uuid + " with value "
+ fastPlaceViolation.get(uuid));
Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid); Long math = System.currentTimeMillis() - lastBlockPlaced.get(uuid);
AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math); AntiCheatReloaded.debugLog("Player lastBlockPlaced value = " + lastBlockPlaced + ", diff=" + math);
if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) { if (lastBlockPlaced.get(uuid) > 0 && math < magic.FASTPLACE_MAXVIOLATIONTIME()) {
lastBlockPlaced.put(uuid, time); lastBlockPlaced.put(uuid, time);
return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast " + fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")"); return new CheckResult(CheckResult.Result.FAILED, "placed blocks too fast "
+ fastBreakViolation.get(uuid) + " times in a row (max=" + violations + ")");
} else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) { } else if (lastBlockPlaced.get(uuid) > 0 && math > magic.FASTPLACE_MAXVIOLATIONTIME()) {
AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid); AntiCheatReloaded.debugLog("Reset facePlaceViolation for " + uuid);
fastPlaceViolation.put(uuid, 0); fastPlaceViolation.put(uuid, 0);
@@ -519,7 +549,8 @@ public class Backend {
lastBlockPlaceTime.put(uuid, (time - last)); lastBlockPlaceTime.put(uuid, (time - last));
lastBlockPlaced.put(uuid, time); lastBlockPlaced.put(uuid, time);
fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1); fastPlaceViolation.put(uuid, fastPlaceViolation.get(uuid) + 1);
return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime + " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "tried to place a block " + thisTime
+ " ms after the last one (min=" + magic.FASTPLACE_TIMEMIN() + " ms)");
} }
lastBlockPlaceTime.put(uuid, (time - last)); lastBlockPlaceTime.put(uuid, (time - last));
} }
@@ -554,10 +585,12 @@ public class Backend {
user.clearMessages(); user.clearMessages();
break; break;
} else { } else {
if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue() && m.equalsIgnoreCase(msg) && i == 1) { if (manager.getConfiguration().getConfig().blockChatSpamRepetition.getValue()
&& m.equalsIgnoreCase(msg) && i == 1) {
manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\""); manager.getLoggingManager().logFineInfo(player.getName() + " spam-repeated \"" + msg + "\"");
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
} else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.CHAT_MIN()) { } else if (manager.getConfiguration().getConfig().blockChatSpamSpeed.getValue()
&& System.currentTimeMillis() - user.getLastCommandTime() < magic.CHAT_MIN()) {
manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\""); manager.getLoggingManager().logFineInfo(player.getName() + " spammed quickly \"" + msg + "\"");
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
} }
@@ -571,17 +604,18 @@ public class Backend {
public CheckResult checkChatUnicode(Player player, String msg) { public CheckResult checkChatUnicode(Player player, String msg) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
User user = manager.getUserManager().getUser(uuid); User user = manager.getUserManager().getUser(uuid);
if (!isPureAscii(msg)) { for (char ch : msg.toCharArray()) {
if (Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.BASIC_LATIN
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_1_SUPPLEMENT
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.LATIN_EXTENDED_A
&& Character.UnicodeBlock.of(ch) != Character.UnicodeBlock.GENERAL_PUNCTUATION) {
return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed."); return new CheckResult(CheckResult.Result.FAILED, "Unicode chat is not allowed.");
} }
}
user.addMessage(msg); user.addMessage(msg);
return PASS; return PASS;
} }
private boolean isPureAscii(String v) {
return StandardCharsets.US_ASCII.newEncoder().canEncode(v.replaceAll("¡", "!").replaceAll("¿", "?"));
}
public CheckResult checkCommandSpam(Player player, String cmd) { public CheckResult checkCommandSpam(Player player, String cmd) {
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
User user = manager.getUserManager().getUser(uuid); User user = manager.getUserManager().getUser(uuid);
@@ -597,9 +631,11 @@ public class Backend {
user.clearCommands(); user.clearCommands();
break; break;
} else { } else {
if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue() && m.equalsIgnoreCase(cmd) && i == 1) { if (manager.getConfiguration().getConfig().blockCommandSpamRepetition.getValue()
&& m.equalsIgnoreCase(cmd) && i == 1) {
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
} else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue() && System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN()) { } else if (manager.getConfiguration().getConfig().blockCommandSpamSpeed.getValue()
&& System.currentTimeMillis() - user.getLastCommandTime() < magic.COMMAND_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING()); return new CheckResult(CheckResult.Result.FAILED, lang.SPAM_WARNING());
} }
} }
@@ -625,15 +661,19 @@ public class Backend {
long time = System.currentTimeMillis() - inventoryTime.get(uuid); long time = System.currentTimeMillis() - inventoryTime.get(uuid);
inventoryClicks.put(uuid, 0); inventoryClicks.put(uuid, 0);
if (time < magic.INVENTORY_TIMEMIN()) { if (time < magic.INVENTORY_TIMEMIN()) {
return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in " + time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "clicked inventory slots " + clicks + " times in "
+ time + " ms (max=" + magic.INVENTORY_CHECK() + " in " + magic.INVENTORY_TIMEMIN() + " ms)");
} }
} }
return PASS; return PASS;
} }
public CheckResult checkAutoTool(Player player) { public CheckResult checkAutoTool(Player player) {
if (itemInHand.containsKey(player.getUniqueId()) && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) { if (itemInHand.containsKey(player.getUniqueId())
return new CheckResult(CheckResult.Result.FAILED, "switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has " + VersionUtil.getItemInHand(player).getType() + ")"); && itemInHand.get(player.getUniqueId()) != VersionUtil.getItemInHand(player).getType()) {
return new CheckResult(CheckResult.Result.FAILED,
"switched tools too fast (had " + itemInHand.get(player.getUniqueId()) + ", has "
+ VersionUtil.getItemInHand(player).getType() + ")");
} else { } else {
return PASS; return PASS;
} }
@@ -641,7 +681,8 @@ public class Backend {
public CheckResult checkSprintDamage(Player player) { public CheckResult checkSprintDamage(Player player) {
if (isDoing(player, sprinted, magic.SPRINT_MAX())) { if (isDoing(player, sprinted, magic.SPRINT_MAX())) {
return new CheckResult(CheckResult.Result.FAILED, "sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)"); return new CheckResult(CheckResult.Result.FAILED,
"sprinted and damaged an entity too fast (min sprint=" + magic.SPRINT_MAX() + " ms)");
} else { } else {
return PASS; return PASS;
} }
@@ -654,7 +695,8 @@ public class Backend {
long l = lastHeal.get(player.getUniqueId()); long l = lastHeal.get(player.getUniqueId());
lastHeal.remove(player.getUniqueId()); lastHeal.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < healTime) { if ((System.currentTimeMillis() - l) < healTime) {
return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "healed too quickly (time="
+ (System.currentTimeMillis() - l) + " ms, min=" + healTime + " ms)");
} }
} }
return PASS; return PASS;
@@ -666,7 +708,8 @@ public class Backend {
long l = startEat.get(player.getUniqueId()); long l = startEat.get(player.getUniqueId());
startEat.remove(player.getUniqueId()); startEat.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) { if ((System.currentTimeMillis() - l) < magic.EAT_TIME_MIN()) {
return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time=" + (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)"); return new CheckResult(CheckResult.Result.FAILED, "ate too quickly (time="
+ (System.currentTimeMillis() - l) + " ms, min=" + magic.EAT_TIME_MIN() + " ms)");
} }
} }
return PASS; return PASS;
@@ -686,7 +729,8 @@ public class Backend {
public boolean isHoveringOverWaterAfterViolation(Player player) { public boolean isHoveringOverWaterAfterViolation(Player player) {
if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.containsKey(player.getUniqueId())) { 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())) { if (WaterWalkCheck.WATER_SPEED_VIOLATIONS.get(player.getUniqueId()) >= magic.WATER_SPEED_VIOLATION_MAX()
&& Utilities.isHoveringOverWater(player.getLocation())) {
return true; return true;
} }
} }
@@ -706,7 +750,9 @@ public class Backend {
} }
public boolean justVelocity(Player player) { public boolean justVelocity(Player player) {
return (velocitized.containsKey(player.getUniqueId()) ? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME() : false); return (velocitized.containsKey(player.getUniqueId())
? (System.currentTimeMillis() - velocitized.get(player.getUniqueId())) < magic.VELOCITY_CHECKTIME()
: false);
} }
public boolean extendVelocityTime(final Player player) { public boolean extendVelocityTime(final Player player) {
@@ -714,7 +760,8 @@ public class Backend {
velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1); velocitytrack.put(player.getUniqueId(), velocitytrack.get(player.getUniqueId()) + 1);
if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) { if (velocitytrack.get(player.getUniqueId()) > magic.VELOCITY_MAXTIMES()) {
velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT()); velocitized.put(player.getUniqueId(), System.currentTimeMillis() + magic.VELOCITY_PREVENT());
manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(), new Runnable() { manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(manager.getPlugin(),
new Runnable() {
@Override @Override
public void run() { public void run() {
velocitytrack.put(player.getUniqueId(), 0); velocitytrack.put(player.getUniqueId(), 0);
@@ -736,6 +783,7 @@ public class Backend {
public boolean justPlaced(Player player) { public boolean justPlaced(Player player) {
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN()); return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
} }
public void logDamage(final Player player, int type) { public void logDamage(final Player player, int type) {
long time; long time;
switch (type) { switch (type) {
@@ -832,8 +880,12 @@ public class Backend {
User user = manager.getUserManager().getUser(player.getUniqueId()); User user = manager.getUserManager().getUser(player.getUniqueId());
int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0; int level = chatLevel.containsKey(user.getUUID()) ? chatLevel.get(user.getUUID()) : 0;
if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) { if (player != null && player.isOnline() && level >= magic.CHAT_ACTION_ONE_LEVEL()) {
String event = level >= magic.CHAT_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue() : manager.getConfiguration().getConfig().chatSpamActionOne.getValue(); String event = level >= magic.CHAT_ACTION_TWO_LEVEL()
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); ? manager.getConfiguration().getConfig().chatSpamActionTwo.getValue()
: manager.getConfiguration().getConfig().chatSpamActionOne.getValue();
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
Utilities.stringToList(event), CheckType.CHAT_SPAM, lang.SPAM_KICK_REASON(),
Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
} }
chatLevel.put(user.getUUID(), level + 1); chatLevel.put(user.getUUID(), level + 1);
} }
@@ -842,8 +894,12 @@ public class Backend {
User user = manager.getUserManager().getUser(player.getUniqueId()); User user = manager.getUserManager().getUser(player.getUniqueId());
int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0; int level = commandLevel.containsKey(user.getUUID()) ? commandLevel.get(user.getUUID()) : 0;
if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) { if (player != null && player.isOnline() && level >= magic.COMMAND_ACTION_ONE_LEVEL()) {
String event = level >= magic.COMMAND_ACTION_TWO_LEVEL() ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue() : manager.getConfiguration().getConfig().commandSpamActionOne.getValue(); String event = level >= magic.COMMAND_ACTION_TWO_LEVEL()
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()), Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(), Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON()); ? manager.getConfiguration().getConfig().commandSpamActionTwo.getValue()
: manager.getConfiguration().getConfig().commandSpamActionOne.getValue();
manager.getUserManager().execute(manager.getUserManager().getUser(player.getUniqueId()),
Utilities.stringToList(event), CheckType.COMMAND_SPAM, lang.SPAM_KICK_REASON(),
Utilities.stringToList(lang.SPAM_WARNING()), lang.SPAM_BAN_REASON());
} }
commandLevel.put(user.getUUID(), level + 1); commandLevel.put(user.getUUID(), level + 1);
} }
@@ -345,9 +345,6 @@ 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());
//KillAuraCheck.doMove(event);
//TODO
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);
if (result.failed()) { if (result.failed()) {
@@ -360,7 +357,6 @@ public class PlayerListener extends EventListener {
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) { if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionUtil.isFlying(player)) {
CheckResult result = GlideCheck.runCheck(player, distance); CheckResult result = GlideCheck.runCheck(player, distance);
if (result.failed()) { if (result.failed()) {
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
log(result.getMessage(), player, CheckType.FLIGHT); log(result.getMessage(), player, CheckType.FLIGHT);
} }
} }
@@ -457,6 +453,7 @@ public class PlayerListener extends EventListener {
} }
} }
} }
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners()); AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
} }
@@ -19,10 +19,13 @@
package com.rammelkast.anticheatreloaded.util; package com.rammelkast.anticheatreloaded.util;
import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
+3 -3
View File
@@ -246,10 +246,10 @@ Y_TIME: 800
GLIDE_LIMIT: 10 GLIDE_LIMIT: 10
# Maximum amount of movement packets allowed per second # Maximum amount of movement packets allowed per second
# Increase this in case of false positives # Increase this in case of false positives
BLINK_PACKET: 25 BLINK_PACKET: 30
# If the blink check gives false positives replace this with the average user ping on your server # If the blink check gives false positives replace this with the average user ping on your server
# Not a good idea to use a value lower than 100 or higher than 200 # Not a good idea to use a value lower than 150 or higher than 300
BLINK_AVERAGE_PING: 120 BLINK_AVERAGE_PING: 200
# Maximum amount zero-velocity moments before a player is suspected # Maximum amount zero-velocity moments before a player is suspected
# Increase this in case of false positives # Increase this in case of false positives
VELOCITY_MAX_FLAGS: 5 VELOCITY_MAX_FLAGS: 5