From edbb5b367949911f1417aaaf9ca8038fd623813e Mon Sep 17 00:00:00 2001 From: AoElite <20812471+AoElite@users.noreply.github.com> Date: Wed, 27 Dec 2023 05:10:59 -0500 Subject: [PATCH] BadPacketsS --- .../grimac/checks/impl/badpackets/BadPacketsS.java | 14 ++++++++++++++ .../grimac/events/packets/PacketPingListener.java | 9 +++++++-- .../java/ac/grim/grimac/manager/CheckManager.java | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java new file mode 100644 index 0000000000..3fd6b5c50d --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java @@ -0,0 +1,14 @@ +package ac.grim.grimac.checks.impl.badpackets; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.player.GrimPlayer; + +@CheckData(name = "BadPacketsS") +public class BadPacketsS extends Check implements PacketCheck { + public BadPacketsS(GrimPlayer player) { + super(player); + } + +} diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPingListener.java b/src/main/java/ac/grim/grimac/events/packets/PacketPingListener.java index f7efc2f1bd..13d21c0a56 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPingListener.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPingListener.java @@ -1,8 +1,7 @@ package ac.grim.grimac.events.packets; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.impl.misc.TransactionOrder; +import ac.grim.grimac.checks.impl.badpackets.BadPacketsS; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.data.Pair; import com.github.retrooper.packetevents.event.PacketListenerAbstract; @@ -35,6 +34,12 @@ public void onPacketReceive(PacketReceiveEvent event) { // Vanilla always uses an ID starting from 1 if (id <= 0) { + // check if accepted + if (!transaction.isAccepted()) { + player.checkManager.getPacketCheck(BadPacketsS.class).flag(); + event.setCancelled(true); + return; + } // Check if we sent this packet before cancelling it if (player.addTransactionResponse(id)) { player.packetStateData.lastTransactionPacketWasValid = true; diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index abc6b3b71f..156aad73e0 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -82,6 +82,7 @@ public CheckManager(GrimPlayer player) { .put(BadPacketsP.class, new BadPacketsP(player)) .put(BadPacketsQ.class, new BadPacketsQ(player)) .put(BadPacketsR.class, new BadPacketsR(player)) + .put(BadPacketsS.class, new BadPacketsS(player)) .put(FastBreak.class, new FastBreak(player)) .put(TransactionOrder.class, new TransactionOrder(player)) .put(NoSlowB.class, new NoSlowB(player))