-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72c5bee
commit a06083f
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters