Skip to content

Commit

Permalink
BadPacketsS
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Dec 27, 2023
1 parent ce83748 commit edbb5b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit edbb5b3

Please sign in to comment.