Blink is now MorePackets, fix #67

This commit is contained in:
Rammelkast committed 2020-04-19 17:19:07 +02:00
1 parent 80b5e64924
commit 91f5fcd31c
9 files changed
+64 -60

No files matched your search

@@ -33,7 +33,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
import com.rammelkast.anticheatreloaded.check.movement.MorePacketsCheck;
import com.rammelkast.anticheatreloaded.command.CommandHandler;
import com.rammelkast.anticheatreloaded.config.Configuration;
import com.rammelkast.anticheatreloaded.event.BlockListener;
@@ -95,8 +95,8 @@ public class AntiCheatReloaded extends JavaPlugin {
getLogger().info("Enabling checks that use ProtcolLib");
// Enable packetlisteners
BlinkCheck.startTimer();
BlinkCheck.listenPackets();
MorePacketsCheck.startTimer();
MorePacketsCheck.listenPackets();
updateManager = new UpdateManager();
@@ -39,7 +39,7 @@ 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.MorePacketsCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
@@ -121,7 +121,7 @@ public class Backend {
UUID pU = player.getUniqueId();
VelocityCheck.cleanPlayer(player);
BlinkCheck.MOVE_COUNT.remove(player.getUniqueId());
MorePacketsCheck.MOVE_COUNT.remove(player.getUniqueId());
blocksDropped.remove(pU);
blockTime.remove(pU);
FlightCheck.MOVING_EXEMPT.remove(pU);
@@ -690,7 +690,7 @@ public class Backend {
public CheckResult checkFastHeal(Player player) {
if (lastHeal.containsKey(player.getUniqueId())) // Otherwise it was modified by a plugin, don't worry about it.
{
long healTime = VersionUtil.getHealTime();
long healTime = magic.MIN_HEAL_TIME();
long l = lastHeal.get(player.getUniqueId());
lastHeal.remove(player.getUniqueId());
if ((System.currentTimeMillis() - l) < healTime) {
@@ -59,7 +59,7 @@ public enum CheckType {
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
AUTOTOOL(Permission.CHECK_AUTOTOOL),
BLINK(Permission.CHECK_BLINK),
MOREPACKETS(Permission.CHECK_MOREPACKETS),
VELOCITY(Permission.CHECK_VELOCITY),
CRITICALS(Permission.CHECK_CRITICALS),
CHAT_UNICODE(Permission.CHECK_UNICODE),
@@ -40,7 +40,7 @@ import com.rammelkast.anticheatreloaded.util.VersionUtil;
/**
* @author Rammelkast
*/
public class BlinkCheck {
public class MorePacketsCheck {
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
@@ -59,48 +59,49 @@ public class BlinkCheck {
new PacketType[] { PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK }) {
@Override
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
Player player = e.getPlayer();
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player,
CheckType.MOREPACKETS)) {
return;
}
Location cur = e.getPlayer().getLocation();
if (!MOVE_COUNT.containsKey(p.getUniqueId())) {
MOVE_COUNT.put(p.getUniqueId(), 1);
if (!MOVE_COUNT.containsKey(player.getUniqueId())) {
MOVE_COUNT.put(player.getUniqueId(), 1);
} else {
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
if (AntiCheatReloaded.getManager().getCheckManager().checkInWorld(p)
&& !AntiCheatReloaded.getManager().getCheckManager().isOpExempt(p)
&& !AntiCheatReloaded.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
int ping = VersionUtil.getPlayerPing(p);
int blinkMagic = AntiCheatReloaded.getManager().getBackend().getMagic().BLINK_PACKET();
int averagePing = AntiCheatReloaded.getManager().getBackend().getMagic()
.BLINK_AVERAGE_PING();
float pingLeniency = (float) ((ping / averagePing));
if (pingLeniency < 1)
pingLeniency = 1;
if (pingLeniency > 2.5F)
pingLeniency = 2.5F;
blinkMagic = Math.round(pingLeniency * blinkMagic);
final float finalPingLeniency = pingLeniency;
try {
if (MOVE_COUNT.get(p.getUniqueId()) > blinkMagic) {
final int packets = MOVE_COUNT.get(p.getUniqueId());
MOVE_COUNT.remove(p.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()
.BLINK_PACKET()
+ ", leniency=" + finalPingLeniency + ", ping=" + ping
+ ")").getMessage(),
p, CheckType.BLINK);
e.setCancelled(true);
e.getPlayer().teleport(cur);
}
});
}
} catch (NullPointerException nullPointer) {
// TODO this is thrown sometimes, might have something to do with line 83
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
}
}
}
@@ -365,11 +365,11 @@ public interface Magic {
/**
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
*/
public int BLINK_PACKET();
public int MOREPACKETS_LIMIT();
/**
* The average ping settings used to account for lag; TYPE=INTEGER, Leniency=INCREASE
*/
public int BLINK_AVERAGE_PING();
public int MOREPACKETS_AVERAGE_PING();
/**
* Maximum amount of low/zero velocity moments before flagging; Type=INTEGER, Leniency=INCREASE.
*/
@@ -390,4 +390,8 @@ public interface Magic {
* The maximum angle difference allowed when breaking or placing blocks; TYPE=INTEGER, Leniency=INCREASE
*/
public int ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE();
/**
* The minimum time it takes to regenerate health; TYPE=INTEGER, Leniency=DECREASE
*/
public int MIN_HEAL_TIME();
}
@@ -26,7 +26,7 @@ public enum Permission {
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_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_BLINK, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT,
/* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,
@@ -70,10 +70,6 @@ public class VersionUtil {
return p.isFlying() || p.isGliding() || p.hasPotionEffect(PotionEffectType.LEVITATION);
}
public static long getHealTime() {
return 495;
}
public static boolean isFrostWalk(Player player) {
if (player.getInventory().getBoots() == null || isBountifulUpdate()) {
return false;
+7 -4
View File
@@ -246,10 +246,10 @@ Y_TIME: 800
GLIDE_LIMIT: 8
# Maximum amount of movement packets allowed per second
# Increase this in case of false positives
BLINK_PACKET: 30
MOREPACKETS_LIMIT: 30
# 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 150 or higher than 300
BLINK_AVERAGE_PING: 200
# Not a good idea to use a value lower than 75 or higher than 250
MOREPACKETS_AVERAGE_PING: 80
# Maximum amount zero-velocity moments before a player is suspected
# Increase this in case of false positives
VELOCITY_MAX_FLAGS: 5
@@ -265,4 +265,7 @@ KILLAURA_MAX_ANGLE_VIOLATIONS: 3
KILLAURA_FIGHTSPEED_MINDIFF: 3
# The maximum angle difference allowed when placing or breaking a block
# Increase this in case of false positives, can be slightly decreased to tighten check
ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75
ILLEGALINTERACT_MAX_ANGLE_DIFFERENCE: 75
# The minimum time it takes to regenerate health
# Decrease this in case of false positives
MIN_HEAL_TIME: 490
+2 -2
View File
@@ -118,7 +118,7 @@ permissions:
anticheat.check.autotool:
description: Allow players to use autotool to switch tools quickly
default: false
anticheat.check.blink:
anticheat.check.morepackets:
description: Allow players to send lots of movement packets
default: false
anticheat.check.velocity:
@@ -160,7 +160,7 @@ permissions:
anticheat.check.fastinventory: true
anticheat.check.autotool: true
anticheat.check.fastanimation: true
anticheat.check.blink: true
anticheat.check.morepackets: true
anticheat.check.velocity: true
anticheat.check.criticals: true
anticheat.check.unicode: true