Skip to content

Commit 0318693

Browse files
committed
Prevent firework abuse
1 parent 7d2cd5a commit 0318693

File tree

11 files changed

+72
-7
lines changed

11 files changed

+72
-7
lines changed

src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ac.grim.grimac.events.packets;
22

3+
import ac.grim.grimac.GrimAPI;
34
import ac.grim.grimac.checks.Check;
45
import ac.grim.grimac.checks.type.PacketCheck;
56
import ac.grim.grimac.player.GrimPlayer;
@@ -47,6 +48,9 @@ public class PacketEntityReplication extends Check implements PacketCheck {
4748
// Another valid solution is to simply spam more transactions, but let's not waste bandwidth.
4849
private final List<Integer> despawnedEntitiesThisTransaction = new ArrayList<>();
4950

51+
// Maximum ping when a firework boost is removed from the player.
52+
private final int maxFireworkBoostPing = GrimAPI.INSTANCE.getConfigManager().getConfig().getIntElse("max-ping-firework-boost", 1000);
53+
5054
public PacketEntityReplication(GrimPlayer player) {
5155
super(player);
5256
}
@@ -300,12 +304,26 @@ public void onPacketSend(PacketSendEvent event) {
300304
}
301305
}
302306

303-
player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> {
307+
final int destroyTransaction = player.lastTransactionSent.get() + 1;
308+
player.latencyUtils.addRealTimeTask(destroyTransaction, () -> {
304309
for (int integer : destroyEntityIds) {
305310
player.compensatedEntities.removeEntity(integer);
306311
player.compensatedFireworks.removeFirework(integer);
307312
}
308313
});
314+
315+
// Don't let the player freeze transactions to keep the firework boost velocity + uncertainty
316+
// Also generally prevents people with high ping gaining too high an advantage in firework use
317+
player.runNettyTaskInMs(() -> {
318+
if (player.lastTransactionReceived.get() >= destroyTransaction) return;
319+
for (int entityID : destroyEntityIds) {
320+
// If the player has a firework boosting them, setback
321+
if (player.compensatedFireworks.hasFirework(entityID)) {
322+
player.getSetbackTeleportUtil().executeViolationSetback();
323+
break;
324+
}
325+
}
326+
}, maxFireworkBoostPing);
309327
}
310328
}
311329

src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import ac.grim.grimac.checks.type.PostPredictionCheck;
55
import ac.grim.grimac.player.GrimPlayer;
66
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
7-
import it.unimi.dsi.fastutil.ints.IntArrayList;
8-
import it.unimi.dsi.fastutil.ints.IntList;
7+
8+
import java.util.HashSet;
9+
import java.util.Set;
910

1011
public class CompensatedFireworks extends Check implements PostPredictionCheck {
12+
1113
// As this is sync to one player, this does not have to be concurrent
12-
IntList activeFireworks = new IntArrayList();
13-
IntList fireworksToRemoveNextTick = new IntArrayList();
14+
private final Set<Integer> activeFireworks = new HashSet<>();
15+
private final Set<Integer> fireworksToRemoveNextTick = new HashSet<>();
1416

1517
public CompensatedFireworks(GrimPlayer player) {
1618
super(player);
@@ -24,6 +26,10 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
2426
fireworksToRemoveNextTick.clear();
2527
}
2628

29+
public boolean hasFirework(int entityId) {
30+
return activeFireworks.contains(entityId);
31+
}
32+
2733
public void addNewFirework(int entityID) {
2834
activeFireworks.add(entityID);
2935
}

src/main/resources/config/de.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,8 @@ packet-spam-threshold: 100
175175
# Dies liegt daran, dass Grim derzeit fliegende Spieler nicht überprüft.
176176
max-ping-out-of-flying: 1000
177177

178+
# Maximum ping when a firework boost is removed from the player.
179+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
180+
max-ping-firework-boost: 1000
181+
178182
config-version: 9

src/main/resources/config/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,8 @@ packet-spam-threshold: 100
178178
# This is due to Grim not currently checking flying players
179179
max-ping-out-of-flying: 1000
180180

181+
# Maximum ping when a firework boost is removed from the player.
182+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
183+
max-ping-firework-boost: 1000
184+
181185
config-version: 9

src/main/resources/config/es.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,8 @@ packet-spam-threshold: 100
180180
# Esto se debe a que Grim actualmente no revisa a los jugadores que están volando.
181181
max-ping-out-of-flying: 1000
182182

183+
# Maximum ping when a firework boost is removed from the player.
184+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
185+
max-ping-firework-boost: 1000
186+
183187
config-version: 9

src/main/resources/config/fr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,8 @@ packet-spam-threshold: 100
175175
# Cela est dû au fait que Grim ne vérifie pas actuellement les joueurs en vol.
176176
max-ping-out-of-flying: 1000
177177

178+
# Maximum ping when a firework boost is removed from the player.
179+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
180+
max-ping-firework-boost: 1000
181+
178182
config-version: 9

src/main/resources/config/it.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,22 @@ exploit:
141141
# Distanza per controllare i ghost blocks
142142
distance-to-check-if-ghostblocks: 2
143143

144+
# Enable logging plugins who have injected into netty on join to debug compatibility issues
144145
debug-pipeline-on-join: false
145146

147+
# Enables experimental checks
146148
experimental-checks: false
147149

150+
# Grim sometimes cancels illegal packets such as with timer, after X packets in a second cancelled, when should
151+
# we simply kick the player? This is required as some packet limiters don't count packets cancelled by grim.
148152
packet-spam-threshold: 100
149153

150-
max-ping-out-of-flying: 1000
151154
# Grim is able to enforce that a player set out of flying state cannot have more than X milliseconds of ping
152155
# This is due to Grim not currently checking flying players
153-
max-ping-out-of-flying: 1000
156+
max-ping-out-of-flying: 1000
157+
158+
# Maximum ping when a firework boost is removed from the player.
159+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
160+
max-ping-firework-boost: 1000
161+
162+
config-version: 9

src/main/resources/config/nl.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,8 @@ packet-spam-threshold: 100
178178
# Dit komt doordat Grim momenteel vliegende spelers niet controleert
179179
max-ping-out-of-flying: 1000
180180

181+
# Maximum ping when a firework boost is removed from the player.
182+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
183+
max-ping-firework-boost: 1000
184+
181185
config-version: 9

src/main/resources/config/pt.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,8 @@ packet-spam-threshold: 100
185185
# Isso ocorre porque o Grim atualmente não verifica os jogadores que estão voando.
186186
max-ping-out-of-flying: 1000
187187

188+
# Maximum ping when a firework boost is removed from the player.
189+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
190+
max-ping-firework-boost: 1000
191+
188192
config-version: 9

src/main/resources/config/ru.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,8 @@ packet-spam-threshold: 100
174174
# Это связано с тем, что Грим в настоящее время не проверяет летающих игроков.
175175
max-ping-out-of-flying: 1000
176176

177+
# Maximum ping when a firework boost is removed from the player.
178+
# This prevents high latency players from being able to use 1 firework boost with an elytra forever.
179+
max-ping-firework-boost: 1000
180+
177181
config-version: 9

0 commit comments

Comments
 (0)