Skip to content

Commit

Permalink
Add PacketOrderM
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Sep 16, 2024
1 parent 72c5bee commit a06083f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ac.grim.grimac.checks.impl.packetorder;

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;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;

@CheckData(name = "PacketOrderM", experimental = true)
public class PacketOrderM extends Check implements PacketCheck {
public PacketOrderM(final GrimPlayer player) {
super(player);
}

private boolean opened, clickedOrClosed;

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) {
if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) {
opened = true;
if (clickedOrClosed) {
flagAndAlert();
}
}
}

if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) {
clickedOrClosed = true;
if (opened && flagAndAlert() && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
}

if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport) {
opened = clickedOrClosed = false;
}
}
}
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 @@ -95,6 +95,7 @@ public CheckManager(GrimPlayer player) {
.put(PacketOrderB.class, new PacketOrderB(player))
.put(PacketOrderC.class, new PacketOrderC(player))
.put(PacketOrderD.class, new PacketOrderD(player))
.put(PacketOrderM.class, new PacketOrderM(player))
.put(NoSlowB.class, new NoSlowB(player))
.put(SetbackBlocker.class, new SetbackBlocker(player)) // Must be last class otherwise we can't check while blocking packets
.build();
Expand Down

0 comments on commit a06083f

Please sign in to comment.