diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java index d41cb71ca5..25d049d380 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java @@ -1,5 +1,6 @@ package ac.grim.grimac.events.packets; +import ac.grim.grimac.GrimAPI; import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.type.PacketCheck; import ac.grim.grimac.player.GrimPlayer; @@ -47,6 +48,9 @@ public class PacketEntityReplication extends Check implements PacketCheck { // Another valid solution is to simply spam more transactions, but let's not waste bandwidth. private final List despawnedEntitiesThisTransaction = new ArrayList<>(); + // Maximum ping when a firework boost is removed from the player. + private final int maxFireworkBoostPing = GrimAPI.INSTANCE.getConfigManager().getConfig().getIntElse("max-ping-firework-boost", 1000); + public PacketEntityReplication(GrimPlayer player) { super(player); } @@ -300,12 +304,26 @@ public void onPacketSend(PacketSendEvent event) { } } - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> { + final int destroyTransaction = player.lastTransactionSent.get() + 1; + player.latencyUtils.addRealTimeTask(destroyTransaction, () -> { for (int integer : destroyEntityIds) { player.compensatedEntities.removeEntity(integer); player.compensatedFireworks.removeFirework(integer); } }); + + // Don't let the player freeze transactions to keep the firework boost velocity + uncertainty + // Also generally prevents people with high ping gaining too high an advantage in firework use + player.runNettyTaskInMs(() -> { + if (player.lastTransactionReceived.get() >= destroyTransaction) return; + for (int entityID : destroyEntityIds) { + // If the player has a firework boosting them, setback + if (player.compensatedFireworks.hasFirework(entityID)) { + player.getSetbackTeleportUtil().executeViolationSetback(); + break; + } + } + }, maxFireworkBoostPing); } } diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java index 6ff4382c81..37b1b0ca65 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java @@ -4,13 +4,15 @@ import ac.grim.grimac.checks.type.PostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; + +import java.util.HashSet; +import java.util.Set; public class CompensatedFireworks extends Check implements PostPredictionCheck { + // As this is sync to one player, this does not have to be concurrent - IntList activeFireworks = new IntArrayList(); - IntList fireworksToRemoveNextTick = new IntArrayList(); + private final Set activeFireworks = new HashSet<>(); + private final Set fireworksToRemoveNextTick = new HashSet<>(); public CompensatedFireworks(GrimPlayer player) { super(player); @@ -24,6 +26,10 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) { fireworksToRemoveNextTick.clear(); } + public boolean hasFirework(int entityId) { + return activeFireworks.contains(entityId); + } + public void addNewFirework(int entityID) { activeFireworks.add(entityID); } diff --git a/src/main/resources/config/de.yml b/src/main/resources/config/de.yml index 847331dfc0..68772682f9 100644 --- a/src/main/resources/config/de.yml +++ b/src/main/resources/config/de.yml @@ -175,4 +175,8 @@ packet-spam-threshold: 100 # Dies liegt daran, dass Grim derzeit fliegende Spieler nicht überprüft. max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/en.yml b/src/main/resources/config/en.yml index 5037f3103d..0b887461a6 100644 --- a/src/main/resources/config/en.yml +++ b/src/main/resources/config/en.yml @@ -178,4 +178,8 @@ packet-spam-threshold: 100 # This is due to Grim not currently checking flying players max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/es.yml b/src/main/resources/config/es.yml index 5358ed562e..043586a3b9 100644 --- a/src/main/resources/config/es.yml +++ b/src/main/resources/config/es.yml @@ -180,4 +180,8 @@ packet-spam-threshold: 100 # Esto se debe a que Grim actualmente no revisa a los jugadores que están volando. max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/fr.yml b/src/main/resources/config/fr.yml index 7df140c1b0..52a4b1d5be 100644 --- a/src/main/resources/config/fr.yml +++ b/src/main/resources/config/fr.yml @@ -175,4 +175,8 @@ packet-spam-threshold: 100 # Cela est dû au fait que Grim ne vérifie pas actuellement les joueurs en vol. max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/it.yml b/src/main/resources/config/it.yml index 21be985be2..8e47e7ae49 100644 --- a/src/main/resources/config/it.yml +++ b/src/main/resources/config/it.yml @@ -141,13 +141,22 @@ exploit: # Distanza per controllare i ghost blocks distance-to-check-if-ghostblocks: 2 +# Enable logging plugins who have injected into netty on join to debug compatibility issues debug-pipeline-on-join: false +# Enables experimental checks experimental-checks: false +# Grim sometimes cancels illegal packets such as with timer, after X packets in a second cancelled, when should +# we simply kick the player? This is required as some packet limiters don't count packets cancelled by grim. packet-spam-threshold: 100 -max-ping-out-of-flying: 1000 # Grim is able to enforce that a player set out of flying state cannot have more than X milliseconds of ping # This is due to Grim not currently checking flying players -max-ping-out-of-flying: 1000 \ No newline at end of file +max-ping-out-of-flying: 1000 + +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + +config-version: 9 diff --git a/src/main/resources/config/nl.yml b/src/main/resources/config/nl.yml index e3dd8ec697..1d95241526 100644 --- a/src/main/resources/config/nl.yml +++ b/src/main/resources/config/nl.yml @@ -178,4 +178,8 @@ packet-spam-threshold: 100 # Dit komt doordat Grim momenteel vliegende spelers niet controleert max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/pt.yml b/src/main/resources/config/pt.yml index 4e2e7f48c3..4d7fc30fbc 100644 --- a/src/main/resources/config/pt.yml +++ b/src/main/resources/config/pt.yml @@ -185,4 +185,8 @@ packet-spam-threshold: 100 # Isso ocorre porque o Grim atualmente não verifica os jogadores que estão voando. max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/ru.yml b/src/main/resources/config/ru.yml index 5e23f8aabc..ce124a969a 100644 --- a/src/main/resources/config/ru.yml +++ b/src/main/resources/config/ru.yml @@ -174,4 +174,8 @@ packet-spam-threshold: 100 # Это связано с тем, что Грим в настоящее время не проверяет летающих игроков. max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9 diff --git a/src/main/resources/config/zh.yml b/src/main/resources/config/zh.yml index da46868a9f..07eb4ecd22 100644 --- a/src/main/resources/config/zh.yml +++ b/src/main/resources/config/zh.yml @@ -172,4 +172,8 @@ packet-spam-threshold: 100 # Grim 能够强制执行一个规则:被设置为非飞行状态的玩家的 ping 值不能超过 X 毫秒。这是因为 Grim 目前不检查处于飞行状态的玩家。 max-ping-out-of-flying: 1000 +# Maximum ping when a firework boost is removed from the player. +# This prevents high latency players from being able to use 1 firework boost with an elytra forever. +max-ping-firework-boost: 1000 + config-version: 9