Skip to content

Commit

Permalink
Merge remote-tracking branch 'maninmyvan/packetorder' into merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Axionize committed Nov 20, 2024
2 parents b84b21a + a4decb5 commit f638772
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
return;
}

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
if (flagAndAlert() && setback) {
setback = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
setbackIfAboveSetbackVL();
setback = false;
}
} else if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
} else if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
if (flagAndAlert(verbose) && setback) {
setbackIfAboveSetbackVL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,63 @@

import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.checks.type.PostPredictionCheck;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;

import java.util.ArrayDeque;

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

private final ArrayDeque<String> flags = new ArrayDeque<>();

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) {
if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) {
if (player.packetOrderProcessor.isClickingInInventory() || player.packetOrderProcessor.isClosingInventory()) {
flagAndAlert();
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
flagAndAlert("open");
} else {
flags.add("open");
}
}
}
}

if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW || event.getPacketType() == PacketType.Play.Client.CLOSE_WINDOW) {
if (player.packetOrderProcessor.isOpeningInventory() && flagAndAlert() && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
if (player.packetOrderProcessor.isOpeningInventory()) {
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
if (flagAndAlert(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close") && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add(event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW ? "click" : "close");
}
}
}
}

@Override
public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
}

flags.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,37 @@
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClientStatus;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;

import java.util.ArrayDeque;

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

private int invalid;
private final ArrayDeque<String> flags = new ArrayDeque<>();

@Override
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLIENT_STATUS) {
if (new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClientStatus.Action.OPEN_INVENTORY_ACHIEVEMENT) {
if (player.packetOrderProcessor.isDropping() && flagAndAlert("inventory") && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
if (player.packetOrderProcessor.isDropping()) {
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
if (flagAndAlert("inventory") && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
} else {
flags.add("inventory");
}
}
}
}

if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) {
if (new WrapperPlayClientPlayerDigging(event).getAction() == DiggingAction.SWAP_ITEM_WITH_OFFHAND) {
if (player.packetOrderProcessor.isDropping()) {
invalid++;
flags.add("swap");
}
}
}
Expand All @@ -45,12 +53,12 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement && predictionComplete.isChecked()) {
for (; invalid >= 1; invalid--) {
flagAndAlert("swap");
if (player.isTickingReliablyFor(3)) {
for (String verbose : flags) {
flagAndAlert(verbose);
}
}

invalid = 0;
flags.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void onPredictionComplete(PredictionComplete predictionComplete) {
// we don't need to check pre-1.9 players here (no tick skipping)
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return;

if (!player.skippedTickInActualMovement) {
if (player.isTickingReliablyFor(3)) {
for (; invalid >= 1; invalid--) {
flagAndAlert();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public CheckManager(GrimPlayer player) {
.put(PacketOrderB.class, new PacketOrderB(player))
.put(PacketOrderC.class, new PacketOrderC(player))
.put(PacketOrderD.class, new PacketOrderD(player))
.put(PacketOrderK.class, new PacketOrderK(player))
.put(PacketOrderP.class, new PacketOrderP(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
Expand Down Expand Up @@ -143,6 +142,7 @@ public CheckManager(GrimPlayer player) {
.put(PacketOrderH.class, new PacketOrderH(player))
.put(PacketOrderI.class, new PacketOrderI(player))
.put(PacketOrderJ.class, new PacketOrderJ(player))
.put(PacketOrderK.class, new PacketOrderK(player))
.put(PacketOrderL.class, new PacketOrderL(player))
.put(PacketOrderM.class, new PacketOrderM(player))
.put(NoFallB.class, new NoFallB(player))
Expand Down

0 comments on commit f638772

Please sign in to comment.