|
1 | 1 | package ac.grim.grimac.events.packets; |
2 | 2 |
|
| 3 | +import ac.grim.grimac.GrimAPI; |
3 | 4 | import ac.grim.grimac.checks.Check; |
4 | 5 | import ac.grim.grimac.checks.type.PacketCheck; |
5 | 6 | import ac.grim.grimac.player.GrimPlayer; |
@@ -47,6 +48,9 @@ public class PacketEntityReplication extends Check implements PacketCheck { |
47 | 48 | // Another valid solution is to simply spam more transactions, but let's not waste bandwidth. |
48 | 49 | private final List<Integer> despawnedEntitiesThisTransaction = new ArrayList<>(); |
49 | 50 |
|
| 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 | + |
50 | 54 | public PacketEntityReplication(GrimPlayer player) { |
51 | 55 | super(player); |
52 | 56 | } |
@@ -300,12 +304,26 @@ public void onPacketSend(PacketSendEvent event) { |
300 | 304 | } |
301 | 305 | } |
302 | 306 |
|
303 | | - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> { |
| 307 | + final int destroyTransaction = player.lastTransactionSent.get() + 1; |
| 308 | + player.latencyUtils.addRealTimeTask(destroyTransaction, () -> { |
304 | 309 | for (int integer : destroyEntityIds) { |
305 | 310 | player.compensatedEntities.removeEntity(integer); |
306 | 311 | player.compensatedFireworks.removeFirework(integer); |
307 | 312 | } |
308 | 313 | }); |
| 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); |
309 | 327 | } |
310 | 328 | } |
311 | 329 |
|
|
0 commit comments