Skip to content

Commit

Permalink
Merge pull request #1449 from ManInMyVan/bpW
Browse files Browse the repository at this point in the history
Add BadPacketsW
  • Loading branch information
AoElite authored Apr 30, 2024
2 parents 9872675 + 6267f6a commit 0865e91
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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 = "BadPacketsW", experimental = true)
public class BadPacketsW extends Check implements PacketCheck {
public BadPacketsW(GrimPlayer player) {
super(player);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ac.grim.grimac.events.packets;

import ac.grim.grimac.GrimAPI;
import ac.grim.grimac.checks.impl.badpackets.BadPacketsW;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
import com.github.retrooper.packetevents.PacketEvents;
Expand Down Expand Up @@ -31,6 +32,15 @@ public void onPacketReceive(PacketReceiveEvent event) {

if (player == null) return;

// The entity does not exist
if (!player.compensatedEntities.entityMap.containsKey(interact.getEntityId()) && !player.compensatedEntities.serverPositionsMap.containsKey(interact.getEntityId())) {
if (player.checkManager.getPacketCheck(BadPacketsW.class).flagAndAlert("entityId=" + interact.getEntityId()) && player.checkManager.getPacketCheck(BadPacketsW.class).shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
return;
}

if (interact.getAction() == WrapperPlayClientInteractEntity.InteractAction.ATTACK) {
ItemStack heldItem = player.getInventory().getHeldItem();
PacketEntity entity = player.compensatedEntities.getEntity(interact.getEntityId());
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 @@ -89,6 +89,7 @@ public CheckManager(GrimPlayer player) {
.put(BadPacketsT.class, new BadPacketsT(player))
.put(BadPacketsU.class, new BadPacketsU(player))
.put(BadPacketsV.class, new BadPacketsV(player))
.put(BadPacketsW.class, new BadPacketsW(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 0865e91

Please sign in to comment.