forked from GrimAnticheat/Grim
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'maninmyvan/packetorder' into merge
# Conflicts: # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderN.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java # src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java # src/main/java/ac/grim/grimac/manager/CheckManager.java
- Loading branch information
Showing
14 changed files
with
86 additions
and
82 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
75 changes: 39 additions & 36 deletions
75
src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.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 |
---|---|---|
@@ -1,60 +1,63 @@ | ||
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.BlockPlaceCheck; | ||
import ac.grim.grimac.checks.type.PacketCheck; | ||
import ac.grim.grimac.player.GrimPlayer; | ||
import ac.grim.grimac.utils.anticheat.update.BlockPlace; | ||
import com.github.retrooper.packetevents.PacketEvents; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.manager.server.ServerVersion; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.protocol.player.ClientVersion; | ||
import com.github.retrooper.packetevents.protocol.player.InteractionHand; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity.InteractAction; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; | ||
|
||
@CheckData(name = "PacketOrderO", experimental = true) | ||
public class PacketOrderO extends BlockPlaceCheck { | ||
@CheckData(name = "PacketOrderP", experimental = true) | ||
public class PacketOrderO extends Check implements PacketCheck { | ||
public PacketOrderO(final GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private boolean sentMainhand; | ||
private int requiredEntity; | ||
private boolean requiredSneaking; | ||
|
||
@Override | ||
public void onBlockPlace(BlockPlace place) { | ||
if (!isSupported()) { | ||
return; | ||
} | ||
|
||
if (place.getHand() == InteractionHand.OFF_HAND) { | ||
if (!sentMainhand) { | ||
if (flagAndAlert("Skipped Mainhand") && shouldModifyPackets() && shouldCancel()) { | ||
place.resync(); | ||
} | ||
} | ||
|
||
sentMainhand = false; | ||
} else { | ||
if (sentMainhand) { | ||
if (flagAndAlert("Skipped Offhand") && shouldModifyPackets() && shouldCancel()) { | ||
place.resync(); | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (event.getPacketType() == PacketType.Play.Client.INTERACT_ENTITY && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)) { | ||
final WrapperPlayClientInteractEntity packet = new WrapperPlayClientInteractEntity(event); | ||
InteractAction action = packet.getAction(); | ||
if (action != InteractAction.ATTACK) { | ||
final boolean sneaking = packet.isSneaking().orElse(false); | ||
final int entity = packet.getEntityId(); | ||
|
||
if (packet.getHand() == InteractionHand.OFF_HAND) { | ||
if (action == InteractAction.INTERACT) { | ||
if (!sentMainhand) { | ||
if (flagAndAlert("Skipped Mainhand") && shouldModifyPackets()) { | ||
event.setCancelled(true); | ||
player.onPacketCancel(); | ||
} | ||
} | ||
sentMainhand = false; | ||
} else if (sneaking != requiredSneaking || entity != requiredEntity) { | ||
String verbose = "requiredEntity=" + requiredEntity + ", entity=" + entity | ||
+ ", requiredSneaking=" + requiredSneaking + ", sneaking=" + sneaking; | ||
if (flagAndAlert(verbose) && shouldModifyPackets()) { | ||
event.setCancelled(true); | ||
player.onPacketCancel(); | ||
} | ||
} | ||
} else { | ||
requiredEntity = entity; | ||
requiredSneaking = sneaking; | ||
sentMainhand = true; | ||
} | ||
} | ||
|
||
sentMainhand = !place.isBlock(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && !player.packetStateData.lastPacketWasTeleport && !player.packetStateData.lastPacketWasOnePointSeventeenDuplicate) { | ||
if (sentMainhand) { | ||
sentMainhand = false; | ||
flagAndAlert("Skipped Offhand (Tick)"); | ||
} | ||
sentMainhand = false; | ||
} | ||
} | ||
|
||
private boolean isSupported() { | ||
return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9); | ||
} | ||
} |
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
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