Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0' into merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowC.java
#	src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowD.java
#	src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowE.java
#	src/main/java/ac/grim/grimac/checks/impl/post/Post.java
#	src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java
#	src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java
#	src/main/java/ac/grim/grimac/manager/CheckManager.java
  • Loading branch information
Axionize committed Dec 14, 2024
2 parents 0c8b4c2 + 6a1a5f8 commit baa3380
Show file tree
Hide file tree
Showing 84 changed files with 323 additions and 306 deletions.
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ val relocate: Boolean = project.findProperty("relocate")?.toString()?.toBoolean(

repositories {
mavenLocal()
maven("https://repo.booky.dev/releases/") { // TODO remove when Adventure 4.18 releases
content {
includeGroup("net.kyori")
}
}
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") // Spigot
maven("https://jitpack.io/") { // Grim API
content {
Expand All @@ -58,6 +53,7 @@ repositories {
maven("https://repo.opencollab.dev/maven-releases/") // Cumulus (for Floodgate)
maven("https://repo.codemc.io/repository/maven-releases/") // PacketEvents
maven("https://repo.codemc.io/repository/maven-snapshots/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
mavenCentral()
// FastUtil, Discord-Webhooks
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;

@CheckData(name = "BadPacketsA")
@CheckData(name = "BadPacketsA", description = "Sent duplicate slot id")
public class BadPacketsA extends Check implements PacketCheck {
int lastSlot = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientSteerVehicle;

@CheckData(name = "BadPacketsB")
@CheckData(name = "BadPacketsB", description = "Sent impossible steer vehicle packet")
public class BadPacketsB extends Check implements PacketCheck {
public BadPacketsB(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;

@CheckData(name = "BadPacketsC")
@CheckData(name = "BadPacketsC", description = "Interacted with self")
public class BadPacketsC extends Check implements PacketCheck {
public BadPacketsC(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;

@CheckData(name = "BadPacketsF")
@CheckData(name = "BadPacketsF", description = "Sent duplicate sprinting status")
public class BadPacketsF extends Check implements PacketCheck {
public boolean lastSprinting;
public boolean exemptNext = true; // Support 1.14+ clients starting on either true or false sprinting, we don't know
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction;

@CheckData(name = "BadPacketsG")
@CheckData(name = "BadPacketsG", description = "Sent duplicate sneaking status")
public class BadPacketsG extends Check implements PacketCheck {
private boolean lastSneaking, respawn;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerAbilities;

@CheckData(name = "BadPacketsI")
@CheckData(name = "BadPacketsI", description = "Claimed to be flying while unable to fly")
public class BadPacketsI extends Check implements PacketCheck {
public BadPacketsI(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;

@CheckData(name = "BadPacketsJ")
@CheckData(name = "BadPacketsJ", description = "Sent steer vehicle packets while not in a vehicle")
public class BadPacketsJ extends Check implements PacketCheck {
public BadPacketsJ(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.GameMode;

@CheckData(name = "BadPacketsK")
@CheckData(name = "BadPacketsK", description = "Sent spectate packets while not in spectator mode")
public class BadPacketsK extends Check implements PacketCheck {
public BadPacketsK(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

import java.util.Locale;

// checks for impossible dig packets
@CheckData(name = "BadPacketsL")
@CheckData(name = "BadPacketsL", description = "Sent impossible dig packet")
public class BadPacketsL extends Check implements PacketCheck {

public BadPacketsL(GrimPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import com.github.retrooper.packetevents.event.PacketSendEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.WindowClickType;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow;


@CheckData(name = "BadPacketsP", experimental = true)
public class BadPacketsP extends Check implements PacketCheck {

Expand All @@ -33,35 +35,39 @@ public void onPacketSend(final PacketSendEvent event) {
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) {
WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event);
int clickType = wrapper.getWindowClickType().ordinal();
WindowClickType clickType = wrapper.getWindowClickType();
int button = wrapper.getButton();

boolean flag = false;

//TODO: Adjust for containers
// TODO: Adjust for containers
boolean flag;
switch (clickType) {
case 0:
case 1:
case 4:
if (button != 0 && button != 1) flag = true;
case PICKUP:
case QUICK_MOVE:
case THROW:
flag = button != 0 && button != 1;
break;
case SWAP:
flag = (button > 8 || button < 0) && button != 40;
break;
case 2:
if ((button > 8 || button < 0) && button != 40) flag = true;
case CLONE:
flag = button != 2;
break;
case 3:
if (button != 2) flag = true;
case QUICK_CRAFT:
flag = button == 3 || button == 7 || button > 10 || button < 0;
break;
case 5:
if (button == 3 || button == 7 || button > 10 || button < 0) flag = true;
case PICKUP_ALL:
flag = button != 0;
break;
case 6:
if (button != 0) flag = true;
case UNKNOWN:
flag = false;
break;
default:
throw new IllegalStateException("Impossible clickType; Compiler does not know this is unreachable!");
}

//Allowing this to false flag to debug and find issues faster
// Allowing this to false flag to debug and find issues faster
if (flag) {
if (flagAndAlert("clickType=" + clickType + " button=" + button + (wrapper.getWindowId() == containerId ? " container=" + containerType : "")) && shouldModifyPackets()) {
if (flagAndAlert("clickType=" + clickType.toString().toLowerCase() + ", button=" + button + (wrapper.getWindowId() == containerId ? ", container=" + containerType : "")) && shouldModifyPackets()) {
event.setCancelled(true);
player.onPacketCancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void onPacketReceive(final PacketReceiveEvent event) {
// 27/12/2023 - Dynamic values for more than just one entity type?
// 28/12/2023 - Player-only is fine
// 30/12/2023 - Expansions differ in 1.9+
final float scale = (float) packetEntity.getAttributeValue(Attributes.GENERIC_SCALE);
final float scale = (float) packetEntity.getAttributeValue(Attributes.SCALE);
if (targetVector.y > (minVerticalDisplacement * scale) && targetVector.y < (maxVerticalDisplacement * scale)
&& Math.abs(targetVector.x) < (maxHorizontalDisplacement * scale)
&& Math.abs(targetVector.z) < (maxHorizontalDisplacement * scale)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.github.retrooper.packetevents.util.Vector3i;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement;

@CheckData(name = "BadPacketsU", experimental = true)
@CheckData(name = "BadPacketsU", description = "Sent impossible use item packet", experimental = true)
public class BadPacketsU extends Check implements PacketCheck {
public BadPacketsU(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;

@CheckData(name = "BadPacketsW", experimental = true)
@CheckData(name = "BadPacketsW", description = "Interacted with non-existent entity", experimental = true)
public class BadPacketsW extends Check implements PacketCheck {
public BadPacketsW(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ac.grim.grimac.GrimAPI;
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.BlockBreakCheck;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
Expand All @@ -14,7 +14,7 @@
import com.github.retrooper.packetevents.util.Vector3i;

@CheckData(name = "BadPacketsX")
public class BadPacketsX extends Check implements PacketCheck {
public class BadPacketsX extends Check implements BlockBreakCheck {
public BadPacketsX(GrimPlayer player) {
super(player);
}
Expand All @@ -26,7 +26,8 @@ public BadPacketsX(GrimPlayer player) {

public final boolean noFireHitbox = player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_15_2);

public final void handle(BlockBreak blockBreak) {
@Override
public void onBlockBreak(BlockBreak blockBreak) {
if (blockBreak.action != DiggingAction.START_DIGGING && blockBreak.action != DiggingAction.FINISHED_DIGGING)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange;

/**
* Checks for out of bounds slot changes
*/
@CheckData(name = "BadPacketsY")
@CheckData(name = "BadPacketsY", description = "Sent out of bounds slot id")
public class BadPacketsY extends Check implements PacketCheck {
public BadPacketsY(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.BlockBreakCheck;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.MessageUtil;
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
Expand All @@ -12,11 +12,10 @@
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.util.Vector3i;

import static ac.grim.grimac.events.packets.patch.ResyncWorldUtil.resyncPosition;
import static ac.grim.grimac.utils.nmsutil.BlockBreakSpeed.getBlockDamage;

@CheckData(name = "BadPacketsZ")
public class BadPacketsZ extends Check implements PacketCheck {
public class BadPacketsZ extends Check implements BlockBreakCheck {
public BadPacketsZ(final GrimPlayer player) {
super(player);
}
Expand All @@ -39,7 +38,8 @@ private boolean shouldExempt(final Vector3i pos) {
return player.getClientVersion().isOlderThan(ClientVersion.V_1_14_4) || getBlockDamage(player, pos) < 1;
}

public void handle(BlockBreak blockBreak) {
@Override
public void onBlockBreak(BlockBreak blockBreak) {
if (blockBreak.action == DiggingAction.START_DIGGING) {
final Vector3i pos = blockBreak.position;

Expand All @@ -65,7 +65,6 @@ public void handle(BlockBreak blockBreak) {
if (flagAndAlert("action=CANCELLED_DIGGING" + ", last=" + MessageUtil.toUnlabledString(lastBlock) + ", pos=" + MessageUtil.toUnlabledString(pos))) {
if (shouldModifyPackets()) {
blockBreak.cancel();
resyncPosition(player, pos);
}
}
}
Expand All @@ -85,7 +84,6 @@ public void handle(BlockBreak blockBreak) {
if (flagAndAlert("action=FINISHED_DIGGING" + ", last=" + MessageUtil.toUnlabledString(lastBlock) + ", pos=" + MessageUtil.toUnlabledString(pos))) {
if (shouldModifyPackets()) {
blockBreak.cancel();
resyncPosition(player, pos);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.ArrayList;

@CheckData(name = "MultiInteractA", experimental = true)
@CheckData(name = "MultiInteractA", description = "Interacted with multiple entities in the same tick", experimental = true)
public class MultiInteractA extends Check implements PostPredictionCheck {
public MultiInteractA(final GrimPlayer player) {
super(player);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private boolean isKnownInvalid(PacketEntity reachEntity) {
if (reachEntity.getType() == EntityTypes.END_CRYSTAL) {
targetBox = new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
}
return ReachUtils.getMinReachToBox(player, targetBox) > player.compensatedEntities.getSelf().getAttributeValue(Attributes.PLAYER_ENTITY_INTERACTION_RANGE);
return ReachUtils.getMinReachToBox(player, targetBox) > player.compensatedEntities.getSelf().getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre
// We raytrace for > the player's reach distance so in the case a player is hacking
// We can return in the flag the distance of the reach hit instead of a generic "player failed reach check"
// +3 would be 3 + 3 = 6, which is the pre-1.20.5 behaviour, preventing "Missed Hitbox"
final double distance = player.compensatedEntities.getSelf().getAttributeValue(Attributes.PLAYER_ENTITY_INTERACTION_RANGE) + 3;
final double distance = player.compensatedEntities.getSelf().getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE) + 3;
final double[] possibleEyeHeights = player.getPossibleEyeHeights();
for (Vector lookVec : possibleLookDirs) {
for (double eye : possibleEyeHeights) {
Expand Down Expand Up @@ -283,7 +283,7 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre
} else if (minDistance == Double.MAX_VALUE) {
cancelBuffer = 1;
return "Missed hitbox";
} else if (minDistance > player.compensatedEntities.getSelf().getAttributeValue(Attributes.PLAYER_ENTITY_INTERACTION_RANGE)) {
} else if (minDistance > player.compensatedEntities.getSelf().getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE)) {
cancelBuffer = 1;
return String.format("%.5f", minDistance) + " blocks";
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/checks/impl/crash/CrashB.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.GameMode;

@CheckData(name = "CrashB")
@CheckData(name = "CrashB", description = "Sent creative mode inventory click packets while not in creative mode")
public class CrashB extends Check implements PacketCheck {
public CrashB(GrimPlayer player) {
super(player);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/checks/impl/crash/CrashC.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.world.Location;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;

@CheckData(name = "CrashC")
@CheckData(name = "CrashC", description = "Sent non-finite position or rotation")
public class CrashC extends Check implements PacketCheck {
public CrashC(GrimPlayer playerData) {
super(playerData);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow;

@CheckData(name = "CrashD", experimental = false)
@CheckData(name = "CrashD", description = "Clicking slots in lectern window")
public class CrashD extends Check implements PacketCheck {

public CrashD(GrimPlayer playerData) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/checks/impl/crash/CrashG.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem;

@CheckData(name = "CrashG")
@CheckData(name = "CrashG", description = "Sent negative sequence id")
public class CrashG extends Check implements PacketCheck {

public CrashG(GrimPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEditBook;

@CheckData(name = "ExploitC")
@CheckData(name = "ExploitC", description = "Too long book title")
public class ExploitC extends Check implements PacketCheck {
public ExploitC(GrimPlayer playerData) {
super(playerData);
Expand Down
Loading

0 comments on commit baa3380

Please sign in to comment.