diff --git a/build.gradle.kts b/build.gradle.kts index cdd1d94c87..67ae2eeac3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -67,8 +67,9 @@ dependencies { implementation("com.zaxxer:HikariCP:4.0.3") //implementation("com.github.grimanticheat:grimapi:1193c4fa41") - // Used for local testing: implementation("ac.grim.grimac:GRIMAPI:1.0") - implementation("com.github.grimanticheat:grimapi:fc5634e444") + // Used for local testing: + implementation("ac.grim.grimac:GrimAPI:1.0") +// implementation("com.github.grimanticheat:grimapi:fc5634e444") implementation("org.jetbrains:annotations:24.1.0") compileOnly("org.geysermc.floodgate:api:2.2.3-SNAPSHOT") diff --git a/settings.gradle.kts b/settings.gradle.kts index 1fcf0541e3..ba23872683 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,9 @@ +pluginManagement { + plugins { + kotlin("jvm") version "2.0.21" + } +} +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} rootProject.name = "grimac" diff --git a/src/main/java/ac/grim/grimac/GrimExternalAPI.java b/src/main/java/ac/grim/grimac/GrimExternalAPI.java index d97110b4ef..409c7c2b2b 100644 --- a/src/main/java/ac/grim/grimac/GrimExternalAPI.java +++ b/src/main/java/ac/grim/grimac/GrimExternalAPI.java @@ -114,6 +114,12 @@ public ConfigManager getConfigManager() { return configManager; } + @Override + public boolean hasStarted() { + // TODO implement this + throw new UnsupportedOperationException("Not implemented yet"); + } + private ConfigManager configManager = null; private final ConfigManagerFileImpl configManagerFile = new ConfigManagerFileImpl(); private boolean started = false; diff --git a/src/main/java/ac/grim/grimac/checks/Check.java b/src/main/java/ac/grim/grimac/checks/Check.java index 9821a9a7da..a101232c96 100644 --- a/src/main/java/ac/grim/grimac/checks/Check.java +++ b/src/main/java/ac/grim/grimac/checks/Check.java @@ -3,6 +3,8 @@ import ac.grim.grimac.GrimAPI; import ac.grim.grimac.api.AbstractCheck; import ac.grim.grimac.api.config.ConfigManager; +import ac.grim.grimac.api.dynamic.DefaultUnloadedBehavior; +import ac.grim.grimac.api.dynamic.UnloadedBehavior; import ac.grim.grimac.api.events.FlagEvent; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.common.ConfigReloadObserver; @@ -15,6 +17,8 @@ import lombok.Setter; import org.bukkit.Bukkit; +import java.lang.reflect.Method; + // Class from https://github.com/Tecnio/AntiCheatBase/blob/master/src/main/java/me/tecnio/anticheat/check/Check.java @Getter public class Check implements AbstractCheck, ConfigReloadObserver { @@ -40,6 +44,16 @@ public boolean isExperimental() { return experimental; } + @Override + public UnloadedBehavior getUnloadedBehavior() { + return DefaultUnloadedBehavior.INSTANCE; + } + + @Override + public int getMask() { + throw new UnsupportedOperationException("Override this method to show which check types your check is!"); + } + public Check(final GrimPlayer player) { this.player = player; @@ -112,7 +126,6 @@ public final void reward() { violations = Math.max(0, violations - decay); } - @Override public void reload(ConfigManager configuration) { decay = configuration.getDoubleElse(configName + ".decay", decay); setbackVL = configuration.getDoubleElse(configName + ".setbackvl", setbackVL); @@ -185,6 +198,28 @@ public boolean isTickPacketIncludingNonMovement(PacketTypeCommon packetType) { return isFlying(packetType); } + public interface UnloadedCheckHandler { + // Return what the check's methods should return when unloaded + Object handleUnloadedCall(Method method, Object[] args); + } + + // Default behavior - do nothing and return false/0/null + public static final UnloadedCheckHandler DEFAULT_HANDLER = (method, args) -> { + // Return appropriate "no-op" value based on return type + Class returnType = method.getReturnType(); + if (returnType == boolean.class) return false; + if (returnType == int.class) return 0; + if (returnType == void.class) return null; + // etc... + return null; + }; + + private UnloadedCheckHandler unloadedHandler = DEFAULT_HANDLER; + + public void setUnloadedHandler(UnloadedCheckHandler handler) { + this.unloadedHandler = handler; + } + @Override public void reload() { reload(GrimAPI.INSTANCE.getConfigManager().getConfig()); diff --git a/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java b/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java index 54090cef38..f3eded0b69 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java +++ b/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java @@ -1,13 +1,12 @@ package ac.grim.grimac.checks.impl.aim; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.RotationCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractRotationCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.RotationUpdate; @CheckData(name = "AimDuplicateLook") -public class AimDuplicateLook extends Check implements RotationCheck { +public class AimDuplicateLook extends AbstractRotationCheck { public AimDuplicateLook(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/aim/AimModulo360.java b/src/main/java/ac/grim/grimac/checks/impl/aim/AimModulo360.java index c2a141a906..cc88198f8d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/aim/AimModulo360.java +++ b/src/main/java/ac/grim/grimac/checks/impl/aim/AimModulo360.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.aim; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.RotationCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractRotationCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.RotationUpdate; @@ -10,7 +9,7 @@ // I also discovered this flaw before open source Kauri, but did not want to open source its detection. // It works on clients who % 360 their rotation. @CheckData(name = "AimModulo360", decay = 0.005) -public class AimModulo360 extends Check implements RotationCheck { +public class AimModulo360 extends AbstractRotationCheck { private float lastDeltaYaw; diff --git a/src/main/java/ac/grim/grimac/checks/impl/aim/processor/AimProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/aim/processor/AimProcessor.java index 52da60283d..2b9f372af7 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/aim/processor/AimProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/aim/processor/AimProcessor.java @@ -1,7 +1,6 @@ package ac.grim.grimac.checks.impl.aim.processor; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.RotationCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractRotationCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.RotationUpdate; import ac.grim.grimac.utils.data.Pair; @@ -9,7 +8,7 @@ import ac.grim.grimac.utils.math.GrimMath; -public class AimProcessor extends Check implements RotationCheck { +public class AimProcessor extends AbstractRotationCheck { private static final int SIGNIFICANT_SAMPLES_THRESHOLD = 15; private static final int TOTAL_SAMPLES_THRESHOLD = 80; diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsA.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsA.java index c3c8a71854..5fc1deb8bc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsA.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientHeldItemChange; @CheckData(name = "BadPacketsA", description = "Sent duplicate slot id") -public class BadPacketsA extends Check implements PacketCheck { +public class BadPacketsA extends AbstractPacketCheck { int lastSlot = -1; public BadPacketsA(final GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsB.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsB.java index 22707fb5f9..00f08371f1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsB.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientSteerVehicle; @CheckData(name = "BadPacketsB", description = "Sent impossible steer vehicle packet") -public class BadPacketsB extends Check implements PacketCheck { +public class BadPacketsB extends AbstractPacketCheck { public BadPacketsB(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsC.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsC.java index 3ab7ccd2e0..4369ef8446 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsC.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientInteractEntity; @CheckData(name = "BadPacketsC", description = "Interacted with self") -public class BadPacketsC extends Check implements PacketCheck { +public class BadPacketsC extends AbstractPacketCheck { public BadPacketsC(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsD.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsD.java index c3f6750a97..5a12216ccc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsD.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientPlayerFlying; @CheckData(name = "BadPacketsD") -public class BadPacketsD extends Check implements PacketCheck { +public class BadPacketsD extends AbstractPacketCheck { public BadPacketsD(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java index 7a5553a812..be8e166ff8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsE.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -10,7 +9,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "BadPacketsE") -public class BadPacketsE extends Check implements PacketCheck { +public class BadPacketsE extends AbstractPacketCheck { private int noReminderTicks; public BadPacketsE(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsF.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsF.java index 5cc6eb0f69..df54c54e01 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsF.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientEntityAction; @CheckData(name = "BadPacketsF", description = "Sent duplicate sprinting status") -public class BadPacketsF extends Check implements PacketCheck { +public class BadPacketsF extends AbstractPacketCheck { public boolean lastSprinting; public boolean exemptNext = true; // Support 1.14+ clients starting on either true or false sprinting, we don't know diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsG.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsG.java index 52c81dce94..24f5f92dfb 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsG.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientEntityAction; @CheckData(name = "BadPacketsG", description = "Sent duplicate sneaking status") -public class BadPacketsG extends Check implements PacketCheck { +public class BadPacketsG extends AbstractPacketCheck { private boolean lastSneaking, respawn; public BadPacketsG(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsI.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsI.java index 36dcb03ee4..3bca2b5b09 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsI.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientPlayerAbilities; @CheckData(name = "BadPacketsI", description = "Claimed to be flying while unable to fly") -public class BadPacketsI extends Check implements PacketCheck { +public class BadPacketsI extends AbstractPacketCheck { public BadPacketsI(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsJ.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsJ.java index 249a57671d..2729ff0c66 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsJ.java @@ -1,14 +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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @CheckData(name = "BadPacketsJ", description = "Sent steer vehicle packets while not in a vehicle") -public class BadPacketsJ extends Check implements PacketCheck { +public class BadPacketsJ extends AbstractPacketCheck { public BadPacketsJ(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsK.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsK.java index fdde9189b0..97435b6486 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsK.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.protocol.player.GameMode; @CheckData(name = "BadPacketsK", description = "Sent spectate packets while not in spectator mode") -public class BadPacketsK extends Check implements PacketCheck { +public class BadPacketsK extends AbstractPacketCheck { public BadPacketsK(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsL.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsL.java index 202f3e1ecf..120784f602 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsL.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -14,7 +13,7 @@ import java.util.Locale; @CheckData(name = "BadPacketsL", description = "Sent impossible dig packet") -public class BadPacketsL extends Check implements PacketCheck { +public class BadPacketsL extends AbstractPacketCheck { public BadPacketsL(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsN.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsN.java index 52c0559c2e..06431e376b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsN.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsN.java @@ -1,12 +1,11 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "BadPacketsN") -public class BadPacketsN extends Check implements PacketCheck { +public class BadPacketsN extends AbstractPacketCheck { public BadPacketsN(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsO.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsO.java index ab7b79760a..6e9113b4d7 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsO.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsO.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.data.Pair; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -15,7 +14,7 @@ import java.util.Queue; @CheckData(name = "BadPacketsO") -public class BadPacketsO extends Check implements PacketCheck { +public class BadPacketsO extends AbstractPacketCheck { Queue> keepaliveMap = new LinkedList<>(); public BadPacketsO(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsP.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsP.java index 763f2e3c99..6862c32349 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsP.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsP.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.event.PacketSendEvent; @@ -13,7 +12,7 @@ @CheckData(name = "BadPacketsP", experimental = true) -public class BadPacketsP extends Check implements PacketCheck { +public class BadPacketsP extends AbstractPacketCheck { public BadPacketsP(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsQ.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsQ.java index a2bf00e405..87b1574c7a 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsQ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsQ.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client; @@ -10,7 +9,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction.Action; @CheckData(name = "BadPacketsQ") -public class BadPacketsQ extends Check implements PacketCheck { +public class BadPacketsQ extends AbstractPacketCheck { public BadPacketsQ(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java index d9ac8e12ff..01429f8e54 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.protocol.player.GameMode; @CheckData(name = "BadPacketsR", decay = 0.25, experimental = true) -public class BadPacketsR extends Check implements PacketCheck { +public class BadPacketsR extends AbstractPacketCheck { public BadPacketsR(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java index 3fd6b5c50d..f3df76e8c1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsS.java @@ -1,12 +1,11 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "BadPacketsS") -public class BadPacketsS extends Check implements PacketCheck { +public class BadPacketsS extends AbstractPacketCheck { public BadPacketsS(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java index 872682f2e2..9ba3555af9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.data.packetentity.PacketEntity; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -13,7 +12,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; @CheckData(name = "BadPacketsT") -public class BadPacketsT extends Check implements PacketCheck { +public class BadPacketsT extends AbstractPacketCheck { public BadPacketsT(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsU.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsU.java index 47f9387458..9ae41aba97 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsU.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsU.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.item.ItemStack; @@ -15,7 +14,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; @CheckData(name = "BadPacketsU", description = "Sent impossible use item packet", experimental = true) -public class BadPacketsU extends Check implements PacketCheck { +public class BadPacketsU extends AbstractPacketCheck { public BadPacketsU(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsW.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsW.java index fa13325460..07735b2909 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsW.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsW.java @@ -1,12 +1,11 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "BadPacketsW", description = "Interacted with non-existent entity", experimental = true) -public class BadPacketsW extends Check implements PacketCheck { +public class BadPacketsW extends AbstractPacketCheck { public BadPacketsW(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsX.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsX.java index ad7e88ec61..0e5e61dc34 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsX.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsX.java @@ -1,9 +1,8 @@ package ac.grim.grimac.checks.impl.badpackets; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.BlockBreakCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractBlockBreakCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.BlockBreak; import ac.grim.grimac.utils.change.BlockModification; @@ -19,7 +18,7 @@ import java.util.stream.Stream; @CheckData(name = "BadPacketsX") -public class BadPacketsX extends Check implements BlockBreakCheck { +public class BadPacketsX extends AbstractBlockBreakCheck { public BadPacketsX(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsY.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsY.java index a48d12cead..c8ffa99e29 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsY.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsY.java @@ -1,15 +1,14 @@ 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.checks.type.abstracts.AbstractPacketCheck; 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.WrapperPlayClientHeldItemChange; @CheckData(name = "BadPacketsY", description = "Sent out of bounds slot id") -public class BadPacketsY extends Check implements PacketCheck { +public class BadPacketsY extends AbstractPacketCheck { public BadPacketsY(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsZ.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsZ.java index 8410d6fa6a..54e5a08a4b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsZ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsZ.java @@ -1,8 +1,7 @@ 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.BlockBreakCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractBlockBreakCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.MessageUtil; import ac.grim.grimac.utils.anticheat.update.BlockBreak; @@ -15,7 +14,7 @@ import static ac.grim.grimac.utils.nmsutil.BlockBreakSpeed.getBlockDamage; @CheckData(name = "BadPacketsZ") -public class BadPacketsZ extends Check implements BlockBreakCheck { +public class BadPacketsZ extends AbstractBlockBreakCheck { public BadPacketsZ(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/baritone/Baritone.java b/src/main/java/ac/grim/grimac/checks/impl/baritone/Baritone.java index 27a2e7f094..c190971886 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/baritone/Baritone.java +++ b/src/main/java/ac/grim/grimac/checks/impl/baritone/Baritone.java @@ -3,7 +3,7 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.impl.aim.processor.AimProcessor; -import ac.grim.grimac.checks.type.RotationCheck; +import ac.grim.grimac.checks.type.interfaces.RotationCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.RotationUpdate; import ac.grim.grimac.utils.data.HeadRotation; @@ -11,7 +11,7 @@ // This check has been patched by Baritone for a long time and it also seems to false with cinematic camera now, so it is disabled. @CheckData(name = "Baritone") -public class Baritone extends Check implements RotationCheck { +public class Baritone extends Check implements RotationCheckI { public Baritone(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxBlock.java b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxBlock.java index eef6fed53d..9f74681531 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxBlock.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxBlock.java @@ -1,12 +1,11 @@ package ac.grim.grimac.checks.impl.combat; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "HitboxBlock", configName = "HitboxBlock", setback = 20) -public class HitboxBlock extends Check implements PacketCheck { +public class HitboxBlock extends AbstractPacketCheck { public HitboxBlock(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxEntity.java b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxEntity.java index 065cd0b935..b95264a2ec 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxEntity.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxEntity.java @@ -1,12 +1,11 @@ package ac.grim.grimac.checks.impl.combat; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "HitboxEntity", configName = "HitboxEntity", setback = 30) -public class HitboxEntity extends Check implements PacketCheck { +public class HitboxEntity extends AbstractPacketCheck { public HitboxEntity(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxMiss.java b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxMiss.java index d987f95500..f75bf572ab 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxMiss.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/HitboxMiss.java @@ -1,12 +1,11 @@ package ac.grim.grimac.checks.impl.combat; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "HitboxMiss", configName = "HitboxMiss", setback = 10) -public class HitboxMiss extends Check implements PacketCheck { +public class HitboxMiss extends AbstractPacketCheck { public HitboxMiss(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractA.java b/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractA.java index d85a948251..e78c826913 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractA.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.combat; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -14,7 +13,7 @@ import java.util.ArrayList; @CheckData(name = "MultiInteractA", description = "Interacted with multiple entities in the same tick", experimental = true) -public class MultiInteractA extends Check implements PostPredictionCheck { +public class MultiInteractA extends AbstractPostPredictionCheck { public MultiInteractA(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractB.java b/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractB.java index dc686bfebc..06e5a467dc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/MultiInteractB.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.combat; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.MessageUtil; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; @@ -16,7 +15,7 @@ import java.util.ArrayList; @CheckData(name = "MultiInteractB", experimental = true) -public class MultiInteractB extends Check implements PostPredictionCheck { +public class MultiInteractB extends AbstractPostPredictionCheck { public MultiInteractB(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java b/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java index c39efe9848..f15752d210 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java @@ -18,7 +18,8 @@ import ac.grim.grimac.api.config.ConfigManager; 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.abstracts.AbstractPacketCheck; +import ac.grim.grimac.checks.type.interfaces.PacketCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; import ac.grim.grimac.utils.data.BlockHitData; @@ -55,7 +56,7 @@ // You may not copy the check unless you are licensed under GPL @CheckData(name = "Reach", configName = "Reach", setback = 10) -public class Reach extends Check implements PacketCheck { +public class Reach extends AbstractPacketCheck { // Only one flag per reach attack, per entity, per tick. // We store position because lastX isn't reliable on teleports. private final Int2ObjectMap playerAttackQueue = new Int2ObjectOpenHashMap<>(); @@ -171,9 +172,9 @@ private void tickBetterReachCheckWithAngle(boolean isFlying) { for (Int2ObjectMap.Entry attack : playerAttackQueue.int2ObjectEntrySet()) { PacketEntity reachEntity = player.compensatedEntities.entityMap.get(attack.getIntKey()); if (reachEntity != null) { - Pair, String> result = checkReach(reachEntity, attack.getValue(), false); + Pair, String> result = checkReach(reachEntity, attack.getValue(), false); if (result != null) { - PacketCheck check = player.checkManager.getPacketCheck(result.first()); + PacketCheckI check = player.checkManager.getPacketCheck(result.first()); if (reachEntity.getType() == EntityTypes.PLAYER) { ((Check)check).flagAndAlert(result.second()); } else { @@ -188,7 +189,7 @@ private void tickBetterReachCheckWithAngle(boolean isFlying) { if (isFlying) blocksChangedThisTick.clear(); } - private Pair, String> checkReach(PacketEntity reachEntity, Vector3d from, boolean isPrediction) { + private Pair, String> checkReach(PacketEntity reachEntity, Vector3d from, boolean isPrediction) { SimpleCollisionBox targetBox = reachEntity.getPossibleCollisionBoxes(); if (reachEntity.getType() == EntityTypes.END_CRYSTAL) { // Hardcode end crystal box diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashA.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashA.java index c70da81fc2..d003535408 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashA.java @@ -1,14 +1,13 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "CrashA") -public class CrashA extends Check implements PacketCheck { +public class CrashA extends AbstractPrePredictionCheck { private static final double HARD_CODED_BORDER = 2.9999999E7D; public CrashA(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashB.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashB.java index e26a6ede42..95647d2230 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashB.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; 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.protocol.player.GameMode; @CheckData(name = "CrashB", description = "Sent creative mode inventory click packets while not in creative mode") -public class CrashB extends Check implements PacketCheck { +public class CrashB extends AbstractPrePredictionCheck { public CrashB(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashC.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashC.java index 103adecdfa..7e5a7df713 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashC.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.world.Location; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "CrashC", description = "Sent non-finite position or rotation") -public class CrashC extends Check implements PacketCheck { +public class CrashC extends AbstractPrePredictionCheck { public CrashC(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java index b8ad013f50..a43bc424f8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.inventory.inventory.MenuType; import com.github.retrooper.packetevents.PacketEvents; @@ -14,7 +13,7 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow; @CheckData(name = "CrashD", description = "Clicking slots in lectern window") -public class CrashD extends Check implements PacketCheck { +public class CrashD extends AbstractPrePredictionCheck { public CrashD(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashE.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashE.java index c0caabf0fe..c238029ae0 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashE.java @@ -1,16 +1,15 @@ package ac.grim.grimac.checks.impl.crash; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.impl.exploit.ExploitA; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPrePredictionCheck; 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.WrapperPlayClientSettings; @CheckData(name = "CrashE", experimental = false) -public class CrashE extends Check implements PacketCheck { +public class CrashE extends AbstractPrePredictionCheck { public CrashE(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashF.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashF.java index b3f46f9c63..d3868c5763 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashF.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; 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.WrapperPlayClientClickWindow; @CheckData(name = "CrashF") -public class CrashF extends Check implements PacketCheck { +public class CrashF extends AbstractPrePredictionCheck { public CrashF(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashG.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashG.java index 8723441d37..7b825d589a 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashG.java @@ -1,8 +1,8 @@ package ac.grim.grimac.checks.impl.crash; -import ac.grim.grimac.checks.Check; +import ac.grim.grimac.api.GrimUser; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -14,7 +14,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUseItem; @CheckData(name = "CrashG", description = "Sent negative sequence id") -public class CrashG extends Check implements PacketCheck { +public class CrashG extends AbstractPrePredictionCheck { public CrashG(GrimPlayer player) { super(player); @@ -22,8 +22,6 @@ public CrashG(GrimPlayer player) { @Override public void onPacketReceive(final PacketReceiveEvent event) { - if (!isSupportedVersion()) return; - if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { WrapperPlayClientPlayerBlockPlacement place = new WrapperPlayClientPlayerBlockPlacement(event); if (place.getSequence() < 0) { @@ -53,8 +51,10 @@ public void onPacketReceive(final PacketReceiveEvent event) { } - private boolean isSupportedVersion() { - return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_19) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19); + @Override + public boolean supportsPlayer(GrimUser player) { + // TODO make this a part of GrimUser interface + // TODO server version check when we bypass via for listening for packets + return ((GrimPlayer) player).getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_19) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19); } - } diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java index 0aa7305767..1ec0f852fe 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.crash; -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.abstracts.AbstractPrePredictionCheck; 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.WrapperPlayClientTabComplete; @CheckData(name = "CrashH") -public class CrashH extends Check implements PacketCheck { +public class CrashH extends AbstractPrePredictionCheck { public CrashH(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitA.java b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitA.java index 3da67ecde2..f17d0f7b7d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitA.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.exploit; -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.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -12,7 +11,7 @@ import java.util.regex.Pattern; @CheckData(name = "ExploitA", experimental = true) -public class ExploitA extends Check implements PacketCheck { +public class ExploitA extends AbstractPrePredictionCheck { public ExploitA(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitB.java b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitB.java index 875b613f15..e2b0769003 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitB.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.exploit; -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.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,7 +10,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete; @CheckData(name = "ExploitB", experimental = true) -public class ExploitB extends Check implements PacketCheck { +public class ExploitB extends AbstractPrePredictionCheck { public ExploitB(GrimPlayer playerData) { super(playerData); diff --git a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitC.java b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitC.java index a08bd4dd9c..74874e94b9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/exploit/ExploitC.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.exploit; -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.abstracts.AbstractPrePredictionCheck; 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.WrapperPlayClientEditBook; @CheckData(name = "ExploitC", description = "Too long book title") -public class ExploitC extends Check implements PacketCheck { +public class ExploitC extends AbstractPrePredictionCheck { public ExploitC(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/flight/FlightA.java b/src/main/java/ac/grim/grimac/checks/impl/flight/FlightA.java index f50aa08f44..752aa3d0c3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/flight/FlightA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/flight/FlightA.java @@ -1,13 +1,12 @@ package ac.grim.grimac.checks.impl.flight; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; // This check catches 100% of cheaters. -public class FlightA extends Check implements PacketCheck { +public class FlightA extends AbstractPacketCheck { public FlightA(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFallA.java b/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFallA.java index 12bc91e689..35c90b3ea6 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFallA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFallA.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.groundspoof; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.predictionengine.GhostBlockDetector; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; @@ -18,7 +17,7 @@ // Catches NoFalls for LOOK and GROUND packets // This check runs AFTER the predictions @CheckData(name = "NoFall", configName = "nofall", setback = 10) -public class NoFallA extends Check implements PacketCheck { +public class NoFallA extends AbstractPacketCheck { public boolean flipPlayerGroundStatus = false; diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryA.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryA.java index 2c75c6cfeb..e424e62fd6 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryA.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -38,4 +39,9 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryB.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryB.java index 3e5f4d1f26..dbc1cd8ee4 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryB.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -30,4 +31,9 @@ public void handle(PacketReceiveEvent event, WrapperPlayClientPlayerDigging wrap reward(); } } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryD.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryD.java index 100d2aaa33..dc7bd0a78d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryD.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -81,4 +82,9 @@ private MoveVectorData findMovement(VectorData vectorData) { return null; } + + @Override + public int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryE.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryE.java index 65fc614351..1842c239fc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryE.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -45,4 +46,9 @@ public void onPacketSend(PacketSendEvent event) { this.lastTransaction = player.lastTransactionSent.get(); } } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryF.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryF.java index 042626f55d..1d866f1046 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryF.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -41,4 +42,9 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryG.java b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryG.java index 671def8627..0b40326b2e 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/inventory/InventoryG.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.impl.inventory; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.CheckData; import ac.grim.grimac.checks.type.InventoryCheck; import ac.grim.grimac.player.GrimPlayer; @@ -37,4 +38,9 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/misc/ClientBrand.java b/src/main/java/ac/grim/grimac/checks/impl/misc/ClientBrand.java index 9d705c2dc3..84203c630d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/misc/ClientBrand.java +++ b/src/main/java/ac/grim/grimac/checks/impl/misc/ClientBrand.java @@ -1,9 +1,8 @@ package ac.grim.grimac.checks.impl.misc; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.impl.exploit.ExploitA; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -12,7 +11,7 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; -public class ClientBrand extends Check implements PacketCheck { +public class ClientBrand extends AbstractPacketCheck { String brand = "vanilla"; boolean hasBrand = false; diff --git a/src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java b/src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java index 79e63dd83f..2cbc8152e9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java +++ b/src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.misc; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.BlockBreakCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractBlockBreakCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.BlockBreak; import ac.grim.grimac.utils.math.GrimMath; @@ -20,7 +19,7 @@ // Also based loosely off of NoCheatPlus FastBreak // Also based off minecraft wiki: https://minecraft.wiki/w/Breaking#Instant_breaking @CheckData(name = "FastBreak", description = "Breaking blocks too quickly") -public class FastBreak extends Check implements BlockBreakCheck { +public class FastBreak extends AbstractBlockBreakCheck { public FastBreak(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/EntityControl.java b/src/main/java/ac/grim/grimac/checks/impl/movement/EntityControl.java index 75dd93ddc5..07b9bf1614 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/EntityControl.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/EntityControl.java @@ -1,12 +1,11 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "Entity control", configName = "EntityControl") -public class EntityControl extends Check implements PostPredictionCheck { +public class EntityControl extends AbstractPostPredictionCheck { public EntityControl(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NegativeTimerCheck.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NegativeTimerCheck.java index 23235131ed..40013575f8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NegativeTimerCheck.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NegativeTimerCheck.java @@ -1,14 +1,15 @@ package ac.grim.grimac.checks.impl.movement; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.interfaces.PostPredictionCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @CheckData(name = "NegativeTimer", configName = "NegativeTimer", setback = -1, experimental = true) -public class NegativeTimerCheck extends TimerCheck implements PostPredictionCheck { +public class NegativeTimerCheck extends TimerCheck implements PostPredictionCheckI { public NegativeTimerCheck(GrimPlayer player) { super(player); @@ -39,4 +40,9 @@ public void doCheck(final PacketReceiveEvent event) { public void onReload(ConfigManager config) { clockDrift = (long) (config.getDoubleElse(getConfigName() + ".drift", 1200.0) * 1e6); } + + @Override + public int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowA.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowA.java index 113b439bf8..61be8f457f 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowA.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.movement; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.protocol.player.ClientVersion; @CheckData(name = "NoSlowA (Prediction)", configName = "NoSlowA", description = "Was not slowed while using an item", setback = 5) -public class NoSlowA extends Check implements PostPredictionCheck { +public class NoSlowA extends AbstractPostPredictionCheck { double offsetToFlag; double bestOffset = 1; // The player sends that they switched items the next tick if they switch from an item that can be used diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowB.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowB.java index 337e5c84e7..78fe4c965f 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowB.java @@ -1,14 +1,13 @@ package ac.grim.grimac.checks.impl.movement; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "NoSlowB", description = "Sprinting with too low hunger", setback = 5) -public class NoSlowB extends Check implements PacketCheck { +public class NoSlowB extends AbstractPacketCheck { public NoSlowB(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowC.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowC.java index 50ee8ab0d1..1aa6403e72 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowC.java @@ -1,9 +1,10 @@ package ac.grim.grimac.checks.impl.movement; +import ac.grim.grimac.api.CheckType; 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.checks.type.interfaces.PacketCheckI; +import ac.grim.grimac.checks.type.interfaces.PostPredictionCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -13,7 +14,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; @CheckData(name = "NoSlowC", description = "Sprinting while sneaking", setback = 5, experimental = true) -public class NoSlowC extends Check implements PostPredictionCheck, PacketCheck { +public class NoSlowC extends Check implements PostPredictionCheckI, PacketCheckI { public NoSlowC(GrimPlayer player) { super(player); } @@ -50,4 +51,9 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) { } else reward(); } } + + @Override + public int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowD.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowD.java index 555a5c2226..22cd97f811 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowD.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,7 +10,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; @CheckData(name = "NoSlowD", description = "Sprinting while using an item", setback = 5, experimental = true) -public class NoSlowD extends Check implements PostPredictionCheck { +public class NoSlowD extends AbstractPostPredictionCheck { public NoSlowD(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowE.java b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowE.java index d9ea6c1d8b..4c144cb9fa 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/NoSlowE.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import static com.github.retrooper.packetevents.protocol.potion.PotionTypes.BLINDNESS; @CheckData(name = "NoSlowE", description = "Started sprinting while having blindness", setback = 5, experimental = true) -public class NoSlowE extends Check implements PostPredictionCheck { +public class NoSlowE extends AbstractPostPredictionCheck { public NoSlowE(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/PredictionRunner.java b/src/main/java/ac/grim/grimac/checks/impl/movement/PredictionRunner.java index 709176ac21..cb6eeb4a33 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/PredictionRunner.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/PredictionRunner.java @@ -1,11 +1,10 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PositionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPositionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PositionUpdate; -public class PredictionRunner extends Check implements PositionCheck { +public class PredictionRunner extends AbstractPositionCheck { public PredictionRunner(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java b/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java index 5c816c7cf9..c2bdd6eb55 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java @@ -1,14 +1,13 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; 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.util.Vector3d; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; -public class SetbackBlocker extends Check implements PacketCheck { +public class SetbackBlocker extends AbstractPacketCheck { public SetbackBlocker(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/TickTimer.java b/src/main/java/ac/grim/grimac/checks/impl/movement/TickTimer.java index 4e687a2202..45d6056813 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/TickTimer.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/TickTimer.java @@ -1,15 +1,18 @@ package ac.grim.grimac.checks.impl.movement; -import ac.grim.grimac.checks.Check; +import ac.grim.grimac.api.GrimUser; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPrePredictionCheck; import ac.grim.grimac.player.GrimPlayer; +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; @CheckData(name = "TickTimer", setback = 1) -public class TickTimer extends Check implements PostPredictionCheck { +public class TickTimer extends AbstractPrePredictionCheck { private boolean receivedTickEnd = true; private int flyingPackets = 0; @@ -31,4 +34,11 @@ public void onPacketReceive(PacketReceiveEvent event) { flyingPackets = 0; } } + + @Override + public boolean supportsPlayer(GrimUser player) { + // TODO make this a part of GrimUser interface and remove the server version check when we bypass via + // TODO server version check when we bypass via for listening for packets + return ((GrimPlayer) player).getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21_2) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21_2); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/TimerCheck.java b/src/main/java/ac/grim/grimac/checks/impl/movement/TimerCheck.java index f43cb54f30..d4fef1da9c 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/TimerCheck.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/TimerCheck.java @@ -1,16 +1,16 @@ package ac.grim.grimac.checks.impl.movement; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.api.config.ConfigManager; -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.abstracts.AbstractPrePredictionCheck; 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.protocol.packettype.PacketTypeCommon; @CheckData(name = "Timer", configName = "TimerA", setback = 10) -public class TimerCheck extends Check implements PacketCheck { +public class TimerCheck extends AbstractPrePredictionCheck { long timerBalanceRealTime = 0; // Default value is real time minus max keep-alive time @@ -114,4 +114,9 @@ public void onReload(ConfigManager config) { clockDrift = (long) (config.getDoubleElse(getConfigName() + ".drift", 120.0) * 1e6); limitAbuseOverPing = (long) (config.getDoubleElse(getConfigName() + ".ping-abuse-limit-threshold", 1000) * 1e6); } + + @Override + public int getMask() { + return CheckType.PRE_PREDICTION.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/VehiclePredictionRunner.java b/src/main/java/ac/grim/grimac/checks/impl/movement/VehiclePredictionRunner.java index 0f40af342c..b3f7161d10 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/VehiclePredictionRunner.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/VehiclePredictionRunner.java @@ -1,12 +1,13 @@ package ac.grim.grimac.checks.impl.movement; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.VehicleCheck; +import ac.grim.grimac.checks.type.interfaces.VehicleCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PositionUpdate; import ac.grim.grimac.utils.anticheat.update.VehiclePositionUpdate; -public class VehiclePredictionRunner extends Check implements VehicleCheck { +public class VehiclePredictionRunner extends Check implements VehicleCheckI { public VehiclePredictionRunner(GrimPlayer playerData) { super(playerData); } @@ -17,4 +18,9 @@ public void process(final VehiclePositionUpdate vehicleUpdate) { // We don't do vehicle setbacks because vehicle netcode sucks. player.movementCheckRunner.processAndCheckMovementPacket(new PositionUpdate(vehicleUpdate.getFrom(), vehicleUpdate.getTo(), false, null, null, vehicleUpdate.isTeleport())); } + + @Override + public int getMask() { + return CheckType.VEHICLE.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsA.java b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsA.java index 77df407c99..84888bd0ee 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsA.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.multiactions; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -10,7 +9,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; @CheckData(name = "MultiActionsA", description = "Attacked while using an item", experimental = true) -public class MultiActionsA extends Check implements PacketCheck { +public class MultiActionsA extends AbstractPacketCheck { public MultiActionsA(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsB.java b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsB.java index 8bd563e7a3..72169a96e0 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsB.java @@ -1,10 +1,12 @@ package ac.grim.grimac.checks.impl.multiactions; -import ac.grim.grimac.checks.Check; +import ac.grim.grimac.api.GrimUser; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; +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.DiggingAction; @@ -14,7 +16,7 @@ import static ac.grim.grimac.events.packets.patch.ResyncWorldUtil.resyncPosition; @CheckData(name = "MultiActionsB", description = "Breaking blocks while using an item", experimental = true) -public class MultiActionsB extends Check implements PacketCheck { +public class MultiActionsB extends AbstractPacketCheck { public MultiActionsB(GrimPlayer player) { super(player); } @@ -38,4 +40,11 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } + + @Override + public boolean supportsPlayer(GrimUser player) { + // TODO make this a part of GrimUser interface + // TODO server version check when we bypass via for listening for packets + return ((GrimPlayer) player).getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_8); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsC.java b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsC.java index 223addbbb1..4e44a1607d 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsC.java @@ -1,15 +1,14 @@ package ac.grim.grimac.checks.impl.multiactions; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @CheckData(name = "MultiActionsC", description = "Clicked in inventory while performing other actions", experimental = true) -public class MultiActionsC extends Check implements PacketCheck { +public class MultiActionsC extends AbstractPacketCheck { public MultiActionsC(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsD.java b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsD.java index b5de3b910a..3433d0cd1b 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsD.java @@ -1,14 +1,13 @@ package ac.grim.grimac.checks.impl.multiactions; -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.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @CheckData(name = "MultiActionsD", description = "Closed inventory while performing other actions", experimental = true) -public class MultiActionsD extends Check implements PacketCheck { +public class MultiActionsD extends AbstractPacketCheck { public MultiActionsD(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsE.java b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsE.java index f5e221c3cd..c123e2a131 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/multiactions/MultiActionsE.java @@ -1,16 +1,18 @@ package ac.grim.grimac.checks.impl.multiactions; -import ac.grim.grimac.checks.Check; +import ac.grim.grimac.api.GrimUser; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; +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; @CheckData(name = "MultiActionsE", description = "Swinging while using an item", experimental = true) -public class MultiActionsE extends Check implements PacketCheck { +public class MultiActionsE extends AbstractPacketCheck { public MultiActionsE(GrimPlayer player) { super(player); } @@ -29,4 +31,11 @@ public void onPacketReceive(PacketReceiveEvent event) { } } } + + @Override + public boolean supportsPlayer(GrimUser player) { + // TODO make this a part of GrimUser interface + // TODO server version check when we bypass via for listening for packets + return ((GrimPlayer) player).getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_8) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_8); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java index a34120eb56..301a312cef 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderA.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,7 +10,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow.WindowClickType; @CheckData(name = "PacketOrderA", experimental = true) -public class PacketOrderA extends Check implements PostPredictionCheck { +public class PacketOrderA extends AbstractPostPredictionCheck { public PacketOrderA(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java index 6491bc8ade..9ce52950f8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderB.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; @CheckData(name = "PacketOrderB") -public class PacketOrderB extends Check implements PacketCheck { +public class PacketOrderB extends AbstractPacketCheck { // 1.9 packet order: INTERACT -> ANIMATION // 1.8 packet order: ANIMATION -> INTERACT diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java index 57c7572026..b5fbf8c575 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderC.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.data.packetentity.PacketEntity; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -14,7 +13,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderC", experimental = true) -public class PacketOrderC extends Check implements PacketCheck { +public class PacketOrderC extends AbstractPacketCheck { public PacketOrderC(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java index e103e89c98..a4e84c1534 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderD.java @@ -1,12 +1,11 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; @CheckData(name = "PacketOrderD") -public class PacketOrderD extends Check implements PacketCheck { +public class PacketOrderD extends AbstractPacketCheck { public PacketOrderD(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java index aaf111e4de..75e24d6b17 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderE.java @@ -1,15 +1,14 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; 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; @CheckData(name = "PacketOrderE", experimental = true) -public class PacketOrderE extends Check implements PostPredictionCheck { +public class PacketOrderE extends AbstractPostPredictionCheck { public PacketOrderE(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java index d5236b3389..eeea6e7ac5 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderF.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; @CheckData(name = "PacketOrderF", experimental = true) -public class PacketOrderF extends Check implements PostPredictionCheck { +public class PacketOrderF extends AbstractPostPredictionCheck { public PacketOrderF(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java index ac675e186e..01b697c4ce 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderG.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; @CheckData(name = "PacketOrderG", experimental = true) -public class PacketOrderG extends Check implements PostPredictionCheck { +public class PacketOrderG extends AbstractPostPredictionCheck { public PacketOrderG(GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java index 92156adc0a..0d4ad03972 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderH.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -11,7 +10,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEntityAction; @CheckData(name = "PacketOrderH", experimental = true) -public class PacketOrderH extends Check implements PostPredictionCheck { +public class PacketOrderH extends AbstractPostPredictionCheck { public PacketOrderH(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java index b6b373fb2a..f0e9bd3543 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderI.java @@ -1,9 +1,8 @@ package ac.grim.grimac.checks.impl.packetorder; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed; @@ -17,7 +16,7 @@ import java.util.ArrayDeque; @CheckData(name = "PacketOrderI", experimental = true) -public class PacketOrderI extends Check implements PostPredictionCheck { +public class PacketOrderI extends AbstractPostPredictionCheck { public PacketOrderI(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java index bdded5deb7..336800ffc3 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderJ.java @@ -1,15 +1,14 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; 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; @CheckData(name = "PacketOrderJ", experimental = true) -public class PacketOrderJ extends Check implements PostPredictionCheck { +public class PacketOrderJ extends AbstractPostPredictionCheck { public PacketOrderJ(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java index 82eef65b88..6d257579f8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderK.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import java.util.ArrayDeque; @CheckData(name = "PacketOrderK", experimental = true) -public class PacketOrderK extends Check implements PostPredictionCheck { +public class PacketOrderK extends AbstractPostPredictionCheck { public PacketOrderK(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java index a00a2c62b0..aa63a44b76 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderL.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -14,7 +13,7 @@ import java.util.ArrayDeque; @CheckData(name = "PacketOrderL", experimental = true) -public class PacketOrderL extends Check implements PostPredictionCheck { +public class PacketOrderL extends AbstractPostPredictionCheck { public PacketOrderL(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java index c2cbd3158c..f3fa1a7ce8 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderM.java @@ -1,8 +1,7 @@ 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.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -12,7 +11,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; @CheckData(name = "PacketOrderM", experimental = true) -public class PacketOrderM extends Check implements PostPredictionCheck { +public class PacketOrderM extends AbstractPostPredictionCheck { public PacketOrderM(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java index ff35be31d9..a67c1da14c 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderO.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -12,7 +11,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity.InteractAction; @CheckData(name = "PacketOrderO", experimental = true) -public class PacketOrderO extends Check implements PacketCheck { +public class PacketOrderO extends AbstractPacketCheck { public PacketOrderO(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java index e58f1e7e7d..33ede2c16e 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderP.java @@ -1,8 +1,7 @@ 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.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -13,7 +12,7 @@ import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; @CheckData(name = "PacketOrderP", experimental = true) -public class PacketOrderP extends Check implements PacketCheck { +public class PacketOrderP extends AbstractPacketCheck { public PacketOrderP(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java index 0506b96455..b3d988ec20 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java +++ b/src/main/java/ac/grim/grimac/checks/impl/packetorder/PacketOrderProcessor.java @@ -1,7 +1,6 @@ package ac.grim.grimac.checks.impl.packetorder; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -12,7 +11,7 @@ import org.jetbrains.annotations.Contract; @Getter -public final class PacketOrderProcessor extends Check implements PacketCheck { +public final class PacketOrderProcessor extends AbstractPacketCheck { public PacketOrderProcessor(final GrimPlayer player) { super(player); } diff --git a/src/main/java/ac/grim/grimac/checks/impl/post/Post.java b/src/main/java/ac/grim/grimac/checks/impl/post/Post.java index 8a5786a5f7..3981664864 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/post/Post.java +++ b/src/main/java/ac/grim/grimac/checks/impl/post/Post.java @@ -1,9 +1,10 @@ package ac.grim.grimac.checks.impl.post; +import ac.grim.grimac.api.CheckType; 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.checks.type.interfaces.PacketCheckI; +import ac.grim.grimac.checks.type.interfaces.PostPredictionCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.lists.EvictingQueue; @@ -24,7 +25,7 @@ import static com.github.retrooper.packetevents.protocol.packettype.PacketType.Play.Client.*; @CheckData(name = "Post") -public class Post extends Check implements PacketCheck, PostPredictionCheck { +public class Post extends Check implements PacketCheckI, PostPredictionCheckI { private final ArrayDeque post = new ArrayDeque<>(); // Due to 1.9+ missing the idle packet, we must queue flags // 1.8 clients will have the same logic for simplicity, although it's not needed @@ -103,4 +104,9 @@ public void onPacketReceive(final PacketReceiveEvent event) { } } } + + @Override + public int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/prediction/DebugHandler.java b/src/main/java/ac/grim/grimac/checks/impl/prediction/DebugHandler.java index 02585e3128..5d0a915ab9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/prediction/DebugHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/prediction/DebugHandler.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.prediction; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.LogUtil; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; @@ -16,7 +15,7 @@ import java.util.concurrent.CopyOnWriteArraySet; @CheckData(name = "Prediction (Debug)") -public class DebugHandler extends Check implements PostPredictionCheck { +public class DebugHandler extends AbstractPostPredictionCheck { Set listeners = new CopyOnWriteArraySet<>(new HashSet<>()); boolean outputToConsole = false; diff --git a/src/main/java/ac/grim/grimac/checks/impl/prediction/NoFallB.java b/src/main/java/ac/grim/grimac/checks/impl/prediction/NoFallB.java index ead538eec9..3d10ec2e9c 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/prediction/NoFallB.java +++ b/src/main/java/ac/grim/grimac/checks/impl/prediction/NoFallB.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.prediction; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import com.github.retrooper.packetevents.PacketEvents; @@ -10,7 +9,7 @@ import com.github.retrooper.packetevents.protocol.player.GameMode; @CheckData(name = "GroundSpoof", configName = "GroundSpoof", setback = 10, decay = 0.01) -public class NoFallB extends Check implements PostPredictionCheck { +public class NoFallB extends AbstractPostPredictionCheck { public NoFallB(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/checks/impl/prediction/OffsetHandler.java b/src/main/java/ac/grim/grimac/checks/impl/prediction/OffsetHandler.java index c1012078bc..97733cc103 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/prediction/OffsetHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/prediction/OffsetHandler.java @@ -2,9 +2,8 @@ import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.api.events.CompletePredictionEvent; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import org.bukkit.Bukkit; @@ -12,7 +11,7 @@ import java.util.concurrent.atomic.AtomicInteger; @CheckData(name = "Simulation", configName = "Simulation", decay = 0.02) -public class OffsetHandler extends Check implements PostPredictionCheck { +public class OffsetHandler extends AbstractPostPredictionCheck { // Config double setbackDecayMultiplier; double threshold; diff --git a/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java b/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java index 8cc332aa73..e4ddc1eee7 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java +++ b/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java @@ -1,8 +1,7 @@ package ac.grim.grimac.checks.impl.prediction; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; @@ -16,7 +15,7 @@ import java.util.List; @CheckData(name = "Phase", configName = "Phase", setback = 1, decay = 0.005) -public class Phase extends Check implements PostPredictionCheck { +public class Phase extends AbstractPostPredictionCheck { SimpleCollisionBox oldBB; public Phase(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java index c336fe3882..75e914bece 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java @@ -1,9 +1,8 @@ package ac.grim.grimac.checks.impl.velocity; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.data.VectorData; @@ -28,7 +27,7 @@ import java.util.LinkedList; @CheckData(name = "AntiExplosion", configName = "Explosion", setback = 10) -public class ExplosionHandler extends Check implements PostPredictionCheck { +public class ExplosionHandler extends AbstractPostPredictionCheck { Deque firstBreadMap = new LinkedList<>(); VelocityData lastExplosionsKnownTaken = null; @@ -274,5 +273,4 @@ public void onReload(ConfigManager config) { setbackVL = config.getDoubleElse("Explosion.setbackvl", 10); if (setbackVL == -1) setbackVL = Double.MAX_VALUE; } - } diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java index 3db83462b5..0c156bff54 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java @@ -2,9 +2,8 @@ import ac.grim.grimac.GrimAPI; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.CheckData; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.data.Pair; @@ -23,7 +22,7 @@ // We are making a velocity sandwich between two pieces of transaction packets (bread) @CheckData(name = "AntiKB", alternativeName = "AntiKnockback", configName = "Knockback", setback = 10, decay = 0.025) -public class KnockbackHandler extends Check implements PostPredictionCheck { +public class KnockbackHandler extends AbstractPostPredictionCheck { Deque firstBreadMap = new LinkedList<>(); Deque lastKnockbackKnownTaken = new LinkedList<>(); @@ -251,5 +250,4 @@ public void onReload(ConfigManager config) { if (maxAdv < 0) maxAdv = Double.MAX_VALUE; if (immediate < 0) immediate = Double.MAX_VALUE; } - } diff --git a/src/main/java/ac/grim/grimac/checks/type/BlockBreakCheck.java b/src/main/java/ac/grim/grimac/checks/type/BlockBreakCheck.java deleted file mode 100644 index ce3326c2c9..0000000000 --- a/src/main/java/ac/grim/grimac/checks/type/BlockBreakCheck.java +++ /dev/null @@ -1,7 +0,0 @@ -package ac.grim.grimac.checks.type; - -import ac.grim.grimac.utils.anticheat.update.BlockBreak; - -public interface BlockBreakCheck extends PostPredictionCheck { - default void onBlockBreak(final BlockBreak blockBreak) {} -} diff --git a/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java b/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java index 0247e5a14d..0bc69d612a 100644 --- a/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java +++ b/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java @@ -1,7 +1,11 @@ package ac.grim.grimac.checks.type; +import ac.grim.grimac.api.CheckType; import ac.grim.grimac.api.config.ConfigManager; import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.BlockPlaceCheckI; +import ac.grim.grimac.checks.type.interfaces.PostPredictionCheckI; +import ac.grim.grimac.checks.type.interfaces.RotationCheckI; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.BlockPlace; import ac.grim.grimac.utils.collisions.HitboxData; @@ -16,7 +20,7 @@ import java.util.ArrayList; import java.util.List; -public class BlockPlaceCheck extends Check implements RotationCheck, PostPredictionCheck { +public class BlockPlaceCheck extends Check implements RotationCheckI, PostPredictionCheckI, BlockPlaceCheckI { private static final List weirdBoxes = new ArrayList<>(); private static final List buggyBoxes = new ArrayList<>(); private final SimpleCollisionBox[] boxes = new SimpleCollisionBox[ComplexCollisionBox.DEFAULT_MAX_COLLISION_BOX_SIZE]; @@ -28,12 +32,10 @@ public BlockPlaceCheck(GrimPlayer player) { } // Method called immediately after a block is placed, before forwarding block place to server - public void onBlockPlace(final BlockPlace place) { - } + public void onBlockPlace(final BlockPlace place) {} // Method called the flying packet after the block place - public void onPostFlyingBlockPlace(BlockPlace place) { - } + public void onPostFlyingBlockPlace(BlockPlace place) {} @Override public void onReload(ConfigManager config) { @@ -97,4 +99,9 @@ protected SimpleCollisionBox getCombinedBox(final BlockPlace place) { return combined; } + + @Override + public int getMask() { + return CheckType.BLOCK_PLACE.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/type/InventoryCheck.java b/src/main/java/ac/grim/grimac/checks/type/InventoryCheck.java index 5c3f1ed94c..1e8ac69459 100644 --- a/src/main/java/ac/grim/grimac/checks/type/InventoryCheck.java +++ b/src/main/java/ac/grim/grimac/checks/type/InventoryCheck.java @@ -1,5 +1,6 @@ package ac.grim.grimac.checks.type; +import ac.grim.grimac.checks.type.interfaces.PacketCheckI; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketReceiveEvent; @@ -8,7 +9,7 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerCloseWindow; import org.jetbrains.annotations.MustBeInvokedByOverriders; -public class InventoryCheck extends BlockPlaceCheck implements PacketCheck { +public class InventoryCheck extends BlockPlaceCheck implements PacketCheckI { // Impossible transaction ID protected static final long NONE = Long.MAX_VALUE; diff --git a/src/main/java/ac/grim/grimac/checks/type/PositionCheck.java b/src/main/java/ac/grim/grimac/checks/type/PositionCheck.java deleted file mode 100644 index 85adf8e1d8..0000000000 --- a/src/main/java/ac/grim/grimac/checks/type/PositionCheck.java +++ /dev/null @@ -1,10 +0,0 @@ -package ac.grim.grimac.checks.type; - -import ac.grim.grimac.api.AbstractCheck; -import ac.grim.grimac.utils.anticheat.update.PositionUpdate; - -public interface PositionCheck extends AbstractCheck { - - default void onPositionUpdate(final PositionUpdate positionUpdate) { - } -} diff --git a/src/main/java/ac/grim/grimac/checks/type/PostPredictionCheck.java b/src/main/java/ac/grim/grimac/checks/type/PostPredictionCheck.java deleted file mode 100644 index ec66449226..0000000000 --- a/src/main/java/ac/grim/grimac/checks/type/PostPredictionCheck.java +++ /dev/null @@ -1,9 +0,0 @@ -package ac.grim.grimac.checks.type; - -import ac.grim.grimac.utils.anticheat.update.PredictionComplete; - -public interface PostPredictionCheck extends PacketCheck { - - default void onPredictionComplete(final PredictionComplete predictionComplete) { - } -} diff --git a/src/main/java/ac/grim/grimac/checks/type/RotationCheck.java b/src/main/java/ac/grim/grimac/checks/type/RotationCheck.java deleted file mode 100644 index 5b1a0b847c..0000000000 --- a/src/main/java/ac/grim/grimac/checks/type/RotationCheck.java +++ /dev/null @@ -1,10 +0,0 @@ -package ac.grim.grimac.checks.type; - -import ac.grim.grimac.api.AbstractCheck; -import ac.grim.grimac.utils.anticheat.update.RotationUpdate; - -public interface RotationCheck extends AbstractCheck { - - default void process(final RotationUpdate rotationUpdate) { - } -} diff --git a/src/main/java/ac/grim/grimac/checks/type/VehicleCheck.java b/src/main/java/ac/grim/grimac/checks/type/VehicleCheck.java deleted file mode 100644 index adfbb07de4..0000000000 --- a/src/main/java/ac/grim/grimac/checks/type/VehicleCheck.java +++ /dev/null @@ -1,9 +0,0 @@ -package ac.grim.grimac.checks.type; - -import ac.grim.grimac.api.AbstractCheck; -import ac.grim.grimac.utils.anticheat.update.VehiclePositionUpdate; - -public interface VehicleCheck extends AbstractCheck { - - void process(final VehiclePositionUpdate vehicleUpdate); -} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractBlockBreakCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractBlockBreakCheck.java new file mode 100644 index 0000000000..74a2488b8f --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractBlockBreakCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.BlockBreakCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractBlockBreakCheck extends Check implements BlockBreakCheckI { + public AbstractBlockBreakCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.BLOCK_BREAK.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPacketCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPacketCheck.java new file mode 100644 index 0000000000..77e8ef08e8 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPacketCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.PacketCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractPacketCheck extends Check implements PacketCheckI { + public AbstractPacketCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.PACKET.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPositionCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPositionCheck.java new file mode 100644 index 0000000000..430fae4c88 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPositionCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.PositionCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractPositionCheck extends Check implements PositionCheckI { + public AbstractPositionCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.POSITION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPostPredictionCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPostPredictionCheck.java new file mode 100644 index 0000000000..2b45ed5e47 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPostPredictionCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.PostPredictionCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractPostPredictionCheck extends Check implements PostPredictionCheckI { + public AbstractPostPredictionCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPrePredictionCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPrePredictionCheck.java new file mode 100644 index 0000000000..d9a7b139f9 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractPrePredictionCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.PacketCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractPrePredictionCheck extends Check implements PacketCheckI { + public AbstractPrePredictionCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.PRE_PREDICTION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractRotationCheck.java b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractRotationCheck.java new file mode 100644 index 0000000000..a0287f86c3 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/abstracts/AbstractRotationCheck.java @@ -0,0 +1,17 @@ +package ac.grim.grimac.checks.type.abstracts; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.type.interfaces.RotationCheckI; +import ac.grim.grimac.player.GrimPlayer; + +public abstract class AbstractRotationCheck extends Check implements RotationCheckI { + public AbstractRotationCheck(GrimPlayer player) { + super(player); + } + + @Override + public int getMask() { + return CheckType.ROTATION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockBreakCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockBreakCheckI.java new file mode 100644 index 0000000000..46c66352a9 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockBreakCheckI.java @@ -0,0 +1,13 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.BlockBreak; + +public interface BlockBreakCheckI extends PostPredictionCheckI { + default void onBlockBreak(final BlockBreak blockBreak) {} + + @Override + default int getMask() { + return CheckType.BLOCK_BREAK.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockPlaceCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockPlaceCheckI.java new file mode 100644 index 0000000000..ad22ec229c --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/BlockPlaceCheckI.java @@ -0,0 +1,15 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.BlockPlace; + +public interface BlockPlaceCheckI extends PostPredictionCheckI { + void onBlockPlace(final BlockPlace place); + + void onPostFlyingBlockPlace(BlockPlace place); + + @Override + default int getMask() { + return CheckType.BLOCK_PLACE.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/PacketCheck.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/PacketCheckI.java similarity index 57% rename from src/main/java/ac/grim/grimac/checks/type/PacketCheck.java rename to src/main/java/ac/grim/grimac/checks/type/interfaces/PacketCheckI.java index c9a09c4fe1..2ab680ab13 100644 --- a/src/main/java/ac/grim/grimac/checks/type/PacketCheck.java +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/PacketCheckI.java @@ -1,10 +1,15 @@ -package ac.grim.grimac.checks.type; +package ac.grim.grimac.checks.type.interfaces; import ac.grim.grimac.api.AbstractCheck; +import ac.grim.grimac.api.CheckType; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.event.PacketSendEvent; -public interface PacketCheck extends AbstractCheck { +public interface PacketCheckI extends AbstractCheck { default void onPacketReceive(final PacketReceiveEvent event) {} default void onPacketSend(final PacketSendEvent event) {} + @Override + default int getMask() { + return CheckType.PACKET.getMask(); + } } diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/PositionCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/PositionCheckI.java new file mode 100644 index 0000000000..dce514b3a0 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/PositionCheckI.java @@ -0,0 +1,15 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.AbstractCheck; +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.PositionUpdate; + +public interface PositionCheckI extends AbstractCheck { + + default void onPositionUpdate(final PositionUpdate positionUpdate) { + } + @Override + default int getMask() { + return CheckType.POSITION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/PostPredictionCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/PostPredictionCheckI.java new file mode 100644 index 0000000000..b67f34e435 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/PostPredictionCheckI.java @@ -0,0 +1,15 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.PredictionComplete; + +public interface PostPredictionCheckI extends PacketCheckI { + + default void onPredictionComplete(final PredictionComplete predictionComplete) { + } + + @Override + default int getMask() { + return CheckType.POST_PREDICTION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/RotationCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/RotationCheckI.java new file mode 100644 index 0000000000..754b8f6857 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/RotationCheckI.java @@ -0,0 +1,15 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.AbstractCheck; +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.RotationUpdate; + +public interface RotationCheckI extends AbstractCheck { + + default void process(final RotationUpdate rotationUpdate) { + } + @Override + default int getMask() { + return CheckType.ROTATION.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/checks/type/interfaces/VehicleCheckI.java b/src/main/java/ac/grim/grimac/checks/type/interfaces/VehicleCheckI.java new file mode 100644 index 0000000000..96da103680 --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/type/interfaces/VehicleCheckI.java @@ -0,0 +1,15 @@ +package ac.grim.grimac.checks.type.interfaces; + +import ac.grim.grimac.api.AbstractCheck; +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.utils.anticheat.update.VehiclePositionUpdate; + +public interface VehicleCheckI extends AbstractCheck { + + void process(final VehiclePositionUpdate vehicleUpdate); + + @Override + default int getMask() { + return CheckType.VEHICLE.getMask(); + } +} diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketChangeGameState.java b/src/main/java/ac/grim/grimac/events/packets/PacketChangeGameState.java index 56d22eaf53..09d7c4c4a0 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketChangeGameState.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketChangeGameState.java @@ -1,15 +1,14 @@ package ac.grim.grimac.events.packets; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.player.GameMode; import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerChangeGameState; -public class PacketChangeGameState extends Check implements PacketCheck { +public class PacketChangeGameState extends AbstractPacketCheck { public PacketChangeGameState(GrimPlayer playerData) { super(playerData); } diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java index 112af71bc0..e61ddafb6c 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java @@ -1,8 +1,7 @@ package ac.grim.grimac.events.packets; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.LogUtil; import ac.grim.grimac.utils.data.TrackerData; @@ -29,7 +28,7 @@ import java.util.List; import java.util.UUID; -public class PacketEntityReplication extends Check implements PacketCheck { +public class PacketEntityReplication extends AbstractPacketCheck { private boolean hasSentPreWavePacket = true; diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAbilities.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAbilities.java index d60eabe0de..dd09ad7a6a 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAbilities.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAbilities.java @@ -1,8 +1,7 @@ package ac.grim.grimac.events.packets; import ac.grim.grimac.api.config.ConfigManager; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.event.PacketSendEvent; @@ -13,7 +12,7 @@ // The client can send ability packets out of order due to Mojang's excellent netcode design. // We must delay the second ability packet until the tick after the first is received // Else the player will fly for a tick, and we won't know about it, which is bad. -public class PacketPlayerAbilities extends Check implements PacketCheck { +public class PacketPlayerAbilities extends AbstractPacketCheck { public PacketPlayerAbilities(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketWorldBorder.java b/src/main/java/ac/grim/grimac/events/packets/PacketWorldBorder.java index 6e23ea5bd8..0401016346 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketWorldBorder.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketWorldBorder.java @@ -1,14 +1,13 @@ package ac.grim.grimac.events.packets; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.math.GrimMath; import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.wrapper.play.server.*; -public class PacketWorldBorder extends Check implements PacketCheck { +public class PacketWorldBorder extends AbstractPacketCheck { double centerX; double centerZ; double oldDiameter; diff --git a/src/main/java/ac/grim/grimac/manager/ActionManager.java b/src/main/java/ac/grim/grimac/manager/ActionManager.java index 3bb0694386..049e31858b 100644 --- a/src/main/java/ac/grim/grimac/manager/ActionManager.java +++ b/src/main/java/ac/grim/grimac/manager/ActionManager.java @@ -1,7 +1,6 @@ package ac.grim.grimac.manager; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; @@ -9,7 +8,7 @@ import lombok.Getter; @Getter -public class ActionManager extends Check implements PacketCheck { +public class ActionManager extends AbstractPacketCheck { private boolean attacking = false; private long lastAttack = 0; diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index 08dcef49f3..a7b1044642 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -1,6 +1,9 @@ package ac.grim.grimac.manager; import ac.grim.grimac.api.AbstractCheck; +import ac.grim.grimac.api.CheckType; +import ac.grim.grimac.api.dynamic.DefaultUnloadedBehavior; +import ac.grim.grimac.api.dynamic.UnloadedBehavior; import ac.grim.grimac.checks.impl.aim.AimDuplicateLook; import ac.grim.grimac.checks.impl.aim.AimModulo360; import ac.grim.grimac.checks.impl.aim.processor.AimProcessor; @@ -18,9 +21,7 @@ import ac.grim.grimac.checks.impl.movement.*; import ac.grim.grimac.checks.impl.packetorder.*; import ac.grim.grimac.checks.impl.multiactions.*; -import ac.grim.grimac.checks.impl.packetorder.*; import ac.grim.grimac.checks.impl.post.Post; -import ac.grim.grimac.checks.impl.multiactions.*; import ac.grim.grimac.checks.impl.prediction.DebugHandler; import ac.grim.grimac.checks.impl.prediction.NoFallB; import ac.grim.grimac.checks.impl.prediction.OffsetHandler; @@ -29,6 +30,7 @@ import ac.grim.grimac.checks.impl.velocity.ExplosionHandler; import ac.grim.grimac.checks.impl.velocity.KnockbackHandler; import ac.grim.grimac.checks.type.*; +import ac.grim.grimac.checks.type.interfaces.*; import ac.grim.grimac.events.packets.PacketChangeGameState; import ac.grim.grimac.events.packets.PacketEntityReplication; import ac.grim.grimac.events.packets.PacketPlayerAbilities; @@ -37,6 +39,7 @@ import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.predictionengine.GhostBlockDetector; import ac.grim.grimac.predictionengine.SneakingEstimator; +import ac.grim.grimac.utils.anticheat.LogUtil; import ac.grim.grimac.utils.anticheat.update.*; import ac.grim.grimac.utils.latency.CompensatedCooldown; import ac.grim.grimac.utils.latency.CompensatedFireworks; @@ -44,287 +47,519 @@ import ac.grim.grimac.utils.team.TeamHandler; import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.event.PacketSendEvent; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; import org.bukkit.Bukkit; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; +import java.lang.reflect.Proxy; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + public class CheckManager { private static boolean inited; private static final AtomicBoolean initedAtomic = new AtomicBoolean(false); - ClassToInstanceMap packetChecks; - ClassToInstanceMap positionCheck; - ClassToInstanceMap rotationCheck; - ClassToInstanceMap vehicleCheck; - ClassToInstanceMap prePredictionChecks; - ClassToInstanceMap blockBreakChecks; - ClassToInstanceMap blockPlaceCheck; - ClassToInstanceMap postPredictionCheck; + private final GrimPlayer player; - public ClassToInstanceMap allChecks; + // Fast arrays for iteration + private PacketCheckI[] packetChecks; + private PositionCheckI[] positionChecks; + private RotationCheckI[] rotationChecks; + private VehicleCheckI[] vehicleChecks; + private PacketCheckI[] prePredictionChecks; + private BlockBreakCheckI[] blockBreakChecks; + private BlockPlaceCheck[] blockPlaceChecks; + private PostPredictionCheckI[] postPredictionChecks; + + // Lookup map for getting specific checks + public Map, AbstractCheck> loadedChecks = new HashMap<>(); + public Map, AbstractCheck> unloadedProxies = new HashMap<>(); + public Map, UnloadedBehavior> unloadedBehaviors = new HashMap<>(); public CheckManager(GrimPlayer player) { - // Include post checks in the packet check too - packetChecks = new ImmutableClassToInstanceMap.Builder() - .put(PacketOrderProcessor.class, player.packetOrderProcessor) - .put(Reach.class, new Reach(player)) - .put(HitboxMiss.class, new HitboxMiss(player)) - .put(HitboxBlock.class, new HitboxBlock(player)) - .put(HitboxEntity.class, new HitboxEntity(player)) - .put(PacketEntityReplication.class, new PacketEntityReplication(player)) - .put(PacketChangeGameState.class, new PacketChangeGameState(player)) - .put(CompensatedInventory.class, new CompensatedInventory(player)) - .put(PacketPlayerAbilities.class, new PacketPlayerAbilities(player)) - .put(PacketWorldBorder.class, new PacketWorldBorder(player)) - .put(ActionManager.class, player.actionManager) - .put(TeamHandler.class, new TeamHandler(player)) - .put(ClientBrand.class, new ClientBrand(player)) - .put(NoFallA.class, new NoFallA(player)) - .put(BadPacketsO.class, new BadPacketsO(player)) - .put(BadPacketsA.class, new BadPacketsA(player)) - .put(BadPacketsB.class, new BadPacketsB(player)) - .put(BadPacketsC.class, new BadPacketsC(player)) - .put(BadPacketsD.class, new BadPacketsD(player)) - .put(BadPacketsE.class, new BadPacketsE(player)) - .put(BadPacketsF.class, new BadPacketsF(player)) - .put(BadPacketsG.class, new BadPacketsG(player)) - .put(BadPacketsI.class, new BadPacketsI(player)) - .put(BadPacketsJ.class, new BadPacketsJ(player)) - .put(BadPacketsK.class, new BadPacketsK(player)) - .put(BadPacketsL.class, new BadPacketsL(player)) - .put(BadPacketsN.class, new BadPacketsN(player)) - .put(BadPacketsP.class, new BadPacketsP(player)) - .put(BadPacketsQ.class, new BadPacketsQ(player)) - .put(BadPacketsR.class, new BadPacketsR(player)) - .put(BadPacketsS.class, new BadPacketsS(player)) - .put(BadPacketsT.class, new BadPacketsT(player)) - .put(BadPacketsU.class, new BadPacketsU(player)) - .put(BadPacketsW.class, new BadPacketsW(player)) - .put(BadPacketsY.class, new BadPacketsY(player)) - .put(InventoryA.class, new InventoryA(player)) - .put(InventoryB.class, new InventoryB(player)) - .put(InventoryE.class, new InventoryE(player)) - .put(InventoryF.class, new InventoryF(player)) - .put(InventoryG.class, new InventoryG(player)) - .put(MultiActionsA.class, new MultiActionsA(player)) - .put(MultiActionsB.class, new MultiActionsB(player)) - .put(MultiActionsC.class, new MultiActionsC(player)) - .put(MultiActionsD.class, new MultiActionsD(player)) - .put(MultiActionsE.class, new MultiActionsE(player)) - .put(PacketOrderB.class, new PacketOrderB(player)) - .put(PacketOrderC.class, new PacketOrderC(player)) - .put(PacketOrderD.class, new PacketOrderD(player)) - .put(PacketOrderO.class, new PacketOrderO(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 - .build(); - positionCheck = new ImmutableClassToInstanceMap.Builder() - .put(PredictionRunner.class, new PredictionRunner(player)) - .put(CompensatedCooldown.class, new CompensatedCooldown(player)) - .build(); - rotationCheck = new ImmutableClassToInstanceMap.Builder() - .put(AimProcessor.class, new AimProcessor(player)) - .put(AimModulo360.class, new AimModulo360(player)) - .put(AimDuplicateLook.class, new AimDuplicateLook(player)) -// .put(Baritone.class, new Baritone(player)) - .build(); - vehicleCheck = new ImmutableClassToInstanceMap.Builder() - .put(VehiclePredictionRunner.class, new VehiclePredictionRunner(player)) - .build(); - - postPredictionCheck = new ImmutableClassToInstanceMap.Builder() - .put(NegativeTimerCheck.class, new NegativeTimerCheck(player)) - .put(ExplosionHandler.class, new ExplosionHandler(player)) - .put(KnockbackHandler.class, new KnockbackHandler(player)) - .put(GhostBlockDetector.class, new GhostBlockDetector(player)) - .put(InventoryD.class, new InventoryD(player)) - .put(Phase.class, new Phase(player)) - .put(Post.class, new Post(player)) - .put(PacketOrderA.class, new PacketOrderA(player)) - .put(PacketOrderE.class, new PacketOrderE(player)) - .put(PacketOrderF.class, new PacketOrderF(player)) - .put(PacketOrderG.class, new PacketOrderG(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)) - .put(OffsetHandler.class, new OffsetHandler(player)) - .put(SuperDebug.class, new SuperDebug(player)) - .put(DebugHandler.class, new DebugHandler(player)) - .put(EntityControl.class, new EntityControl(player)) - .put(NoSlowA.class, new NoSlowA(player)) - .put(NoSlowC.class, new NoSlowC(player)) - .put(NoSlowD.class, new NoSlowD(player)) - .put(NoSlowE.class, new NoSlowE(player)) - .put(MultiInteractA.class, new MultiInteractA(player)) - .put(MultiInteractB.class, new MultiInteractB(player)) - .put(SetbackTeleportUtil.class, new SetbackTeleportUtil(player)) // Avoid teleporting to new position, update safe pos last - .put(CompensatedFireworks.class, player.compensatedFireworks) - .put(SneakingEstimator.class, new SneakingEstimator(player)) - .put(LastInstanceManager.class, player.lastInstanceManager) - .build(); - - blockPlaceCheck = new ImmutableClassToInstanceMap.Builder() - .put(InventoryC.class, new InventoryC(player)) - .put(InvalidPlaceA.class, new InvalidPlaceA(player)) - .put(InvalidPlaceB.class, new InvalidPlaceB(player)) - .put(AirLiquidPlace.class, new AirLiquidPlace(player)) - .put(MultiPlace.class, new MultiPlace(player)) - .put(MultiActionsF.class, new MultiActionsF(player)) - .put(FarPlace.class, new FarPlace(player)) - .put(FabricatedPlace.class, new FabricatedPlace(player)) - .put(PositionPlace.class, new PositionPlace(player)) - .put(PacketOrderN.class, new PacketOrderN(player)) - .put(DuplicateRotPlace.class, new DuplicateRotPlace(player)) - .put(LineOfSightPlace.class, new LineOfSightPlace(player)) - .put(GhostBlockMitigation.class, new GhostBlockMitigation(player)) - .build(); - - prePredictionChecks = new ImmutableClassToInstanceMap.Builder() - .put(TimerCheck.class, new TimerCheck(player)) - .put(TickTimer.class, new TickTimer(player)) - .put(CrashA.class, new CrashA(player)) - .put(CrashB.class, new CrashB(player)) - .put(CrashC.class, new CrashC(player)) - .put(CrashD.class, new CrashD(player)) - .put(CrashE.class, new CrashE(player)) - .put(CrashF.class, new CrashF(player)) - .put(CrashG.class, new CrashG(player)) - .put(CrashH.class, new CrashH(player)) - .put(ExploitA.class, new ExploitA(player)) - .put(ExploitB.class, new ExploitB(player)) - .put(ExploitC.class, new ExploitC(player)) - .put(VehicleTimer.class, new VehicleTimer(player)) - .build(); - - blockBreakChecks = new ImmutableClassToInstanceMap.Builder() - .put(BadPacketsX.class, new BadPacketsX(player)) - .put(BadPacketsZ.class, new BadPacketsZ(player)) - .put(FastBreak.class, new FastBreak(player)) - .build(); - - allChecks = new ImmutableClassToInstanceMap.Builder() - .putAll(packetChecks) - .putAll(positionCheck) - .putAll(rotationCheck) - .putAll(vehicleCheck) - .putAll(postPredictionCheck) - .putAll(blockPlaceCheck) - .putAll(prePredictionChecks) - .putAll(blockBreakChecks) - .build(); + this.player = player; + // Packet Checks + Map, PacketCheckI> packetCheckMap = new HashMap<>(); + addCheck(PacketOrderProcessor.class, player.packetOrderProcessor, packetCheckMap); + addCheck(Reach.class, new Reach(player), packetCheckMap); + addCheck(HitboxMiss.class, new HitboxMiss(player), packetCheckMap); + addCheck(HitboxBlock.class, new HitboxBlock(player), packetCheckMap); + addCheck(HitboxEntity.class, new HitboxEntity(player), packetCheckMap); + addCheck(PacketEntityReplication.class, new PacketEntityReplication(player), packetCheckMap); + addCheck(PacketChangeGameState.class, new PacketChangeGameState(player), packetCheckMap); + addCheck(CompensatedInventory.class, new CompensatedInventory(player), packetCheckMap); + addCheck(PacketPlayerAbilities.class, new PacketPlayerAbilities(player), packetCheckMap); + addCheck(PacketWorldBorder.class, new PacketWorldBorder(player), packetCheckMap); + addCheck(ActionManager.class, player.actionManager, packetCheckMap); + addCheck(TeamHandler.class, new TeamHandler(player), packetCheckMap); + addCheck(ClientBrand.class, new ClientBrand(player), packetCheckMap); + addCheck(NoFallA.class, new NoFallA(player), packetCheckMap); + addCheck(BadPacketsO.class, new BadPacketsO(player), packetCheckMap); + addCheck(BadPacketsA.class, new BadPacketsA(player), packetCheckMap); + addCheck(BadPacketsB.class, new BadPacketsB(player), packetCheckMap); + addCheck(BadPacketsC.class, new BadPacketsC(player), packetCheckMap); + addCheck(BadPacketsD.class, new BadPacketsD(player), packetCheckMap); + addCheck(BadPacketsE.class, new BadPacketsE(player), packetCheckMap); + addCheck(BadPacketsF.class, new BadPacketsF(player), packetCheckMap); + addCheck(BadPacketsG.class, new BadPacketsG(player), packetCheckMap); + addCheck(BadPacketsI.class, new BadPacketsI(player), packetCheckMap); + addCheck(BadPacketsJ.class, new BadPacketsJ(player), packetCheckMap); + addCheck(BadPacketsK.class, new BadPacketsK(player), packetCheckMap); + addCheck(BadPacketsL.class, new BadPacketsL(player), packetCheckMap); + addCheck(BadPacketsN.class, new BadPacketsN(player), packetCheckMap); + addCheck(BadPacketsP.class, new BadPacketsP(player), packetCheckMap); + addCheck(BadPacketsQ.class, new BadPacketsQ(player), packetCheckMap); + addCheck(BadPacketsR.class, new BadPacketsR(player), packetCheckMap); + addCheck(BadPacketsS.class, new BadPacketsS(player), packetCheckMap); + addCheck(BadPacketsT.class, new BadPacketsT(player), packetCheckMap); + addCheck(BadPacketsU.class, new BadPacketsU(player), packetCheckMap); + addCheck(BadPacketsW.class, new BadPacketsW(player), packetCheckMap); + addCheck(BadPacketsY.class, new BadPacketsY(player), packetCheckMap); + addCheck(InventoryA.class, new InventoryA(player), packetCheckMap); + addCheck(InventoryB.class, new InventoryB(player), packetCheckMap); + addCheck(InventoryE.class, new InventoryE(player), packetCheckMap); + addCheck(InventoryF.class, new InventoryF(player), packetCheckMap); + addCheck(InventoryG.class, new InventoryG(player), packetCheckMap); + addCheck(MultiActionsA.class, new MultiActionsA(player), packetCheckMap); + addCheck(MultiActionsB.class, new MultiActionsB(player), packetCheckMap); + addCheck(MultiActionsC.class, new MultiActionsC(player), packetCheckMap); + addCheck(MultiActionsD.class, new MultiActionsD(player), packetCheckMap); + addCheck(MultiActionsE.class, new MultiActionsE(player), packetCheckMap); + addCheck(PacketOrderB.class, new PacketOrderB(player), packetCheckMap); + addCheck(PacketOrderC.class, new PacketOrderC(player), packetCheckMap); + addCheck(PacketOrderD.class, new PacketOrderD(player), packetCheckMap); + addCheck(PacketOrderO.class, new PacketOrderO(player), packetCheckMap); + addCheck(NoSlowB.class, new NoSlowB(player), packetCheckMap); + addCheck(SetbackBlocker.class, new SetbackBlocker(player), packetCheckMap); + packetChecks = packetCheckMap.values().toArray(new PacketCheckI[0]); + loadedChecks.putAll(packetCheckMap); + + // Position Checks + Map, PositionCheckI> positionCheckMap = new HashMap<>(); + addCheck(PredictionRunner.class, new PredictionRunner(player), positionCheckMap); + addCheck(CompensatedCooldown.class, new CompensatedCooldown(player), positionCheckMap); + positionChecks = positionCheckMap.values().toArray(new PositionCheckI[0]); + loadedChecks.putAll(positionCheckMap); + + // Rotation Checks + Map, RotationCheckI> rotationCheckMap = new HashMap<>(); + addCheck(AimProcessor.class, new AimProcessor(player), rotationCheckMap); + addCheck(AimModulo360.class, new AimModulo360(player), rotationCheckMap); + addCheck(AimDuplicateLook.class, new AimDuplicateLook(player), rotationCheckMap); + rotationChecks = rotationCheckMap.values().toArray(new RotationCheckI[0]); + loadedChecks.putAll(rotationCheckMap); + + // Vehicle Checks + Map, VehicleCheckI> vehicleCheckMap = new HashMap<>(); + addCheck(VehiclePredictionRunner.class, new VehiclePredictionRunner(player), vehicleCheckMap); + vehicleChecks = vehicleCheckMap.values().toArray(new VehicleCheckI[0]); + loadedChecks.putAll(vehicleCheckMap); + + // Pre Prediction Checks + Map, PacketCheckI> prePredictionCheckMap = new HashMap<>(); + addCheck(TimerCheck.class, new TimerCheck(player), prePredictionCheckMap); + addCheck(TickTimer.class, new TickTimer(player), prePredictionCheckMap); + addCheck(CrashA.class, new CrashA(player), prePredictionCheckMap); + addCheck(CrashB.class, new CrashB(player), prePredictionCheckMap); + addCheck(CrashC.class, new CrashC(player), prePredictionCheckMap); + addCheck(CrashD.class, new CrashD(player), prePredictionCheckMap); + addCheck(CrashE.class, new CrashE(player), prePredictionCheckMap); + addCheck(CrashF.class, new CrashF(player), prePredictionCheckMap); + addCheck(CrashG.class, new CrashG(player), prePredictionCheckMap); + addCheck(CrashH.class, new CrashH(player), prePredictionCheckMap); + addCheck(ExploitA.class, new ExploitA(player), prePredictionCheckMap); + addCheck(ExploitB.class, new ExploitB(player), prePredictionCheckMap); + addCheck(ExploitC.class, new ExploitC(player), prePredictionCheckMap); + addCheck(VehicleTimer.class, new VehicleTimer(player), prePredictionCheckMap); + prePredictionChecks = prePredictionCheckMap.values().toArray(new PacketCheckI[0]); + loadedChecks.putAll(prePredictionCheckMap); + + // Block Break Checks + Map, BlockBreakCheckI> blockBreakCheckMap = new HashMap<>(); + addCheck(BadPacketsX.class, new BadPacketsX(player), blockBreakCheckMap); + addCheck(BadPacketsZ.class, new BadPacketsZ(player), blockBreakCheckMap); + addCheck(FastBreak.class, new FastBreak(player), blockBreakCheckMap); + blockBreakChecks = blockBreakCheckMap.values().toArray(new BlockBreakCheckI[0]); + loadedChecks.putAll(blockBreakCheckMap); + + // Block Place Checks + Map, BlockPlaceCheck> blockPlaceCheckMap = new HashMap<>(); + addCheck(InventoryC.class, new InventoryC(player), blockPlaceCheckMap); + addCheck(InvalidPlaceA.class, new InvalidPlaceA(player), blockPlaceCheckMap); + addCheck(InvalidPlaceB.class, new InvalidPlaceB(player), blockPlaceCheckMap); + addCheck(AirLiquidPlace.class, new AirLiquidPlace(player), blockPlaceCheckMap); + addCheck(MultiPlace.class, new MultiPlace(player), blockPlaceCheckMap); + addCheck(MultiActionsF.class, new MultiActionsF(player), blockPlaceCheckMap); + addCheck(FarPlace.class, new FarPlace(player), blockPlaceCheckMap); + addCheck(FabricatedPlace.class, new FabricatedPlace(player), blockPlaceCheckMap); + addCheck(PositionPlace.class, new PositionPlace(player), blockPlaceCheckMap); + addCheck(PacketOrderN.class, new PacketOrderN(player), blockPlaceCheckMap); + addCheck(DuplicateRotPlace.class, new DuplicateRotPlace(player), blockPlaceCheckMap); + addCheck(LineOfSightPlace.class, new LineOfSightPlace(player), blockPlaceCheckMap); + addCheck(GhostBlockMitigation.class, new GhostBlockMitigation(player), blockPlaceCheckMap); + blockPlaceChecks = blockPlaceCheckMap.values().toArray(new BlockPlaceCheck[0]); + loadedChecks.putAll(blockPlaceCheckMap); + + // Post Prediction Checks + Map, PostPredictionCheckI> postPredictionCheckMap = new HashMap<>(); + addCheck(NegativeTimerCheck.class, new NegativeTimerCheck(player), postPredictionCheckMap); + addCheck(ExplosionHandler.class, new ExplosionHandler(player), postPredictionCheckMap); + addCheck(KnockbackHandler.class, new KnockbackHandler(player), postPredictionCheckMap); + addCheck(GhostBlockDetector.class, new GhostBlockDetector(player), postPredictionCheckMap); + addCheck(InventoryD.class, new InventoryD(player), postPredictionCheckMap); + addCheck(Phase.class, new Phase(player), postPredictionCheckMap); + addCheck(Post.class, new Post(player), postPredictionCheckMap); + addCheck(PacketOrderA.class, new PacketOrderA(player), postPredictionCheckMap); + addCheck(PacketOrderE.class, new PacketOrderE(player), postPredictionCheckMap); + addCheck(PacketOrderF.class, new PacketOrderF(player), postPredictionCheckMap); + addCheck(PacketOrderG.class, new PacketOrderG(player), postPredictionCheckMap); + addCheck(PacketOrderH.class, new PacketOrderH(player), postPredictionCheckMap); + addCheck(PacketOrderI.class, new PacketOrderI(player), postPredictionCheckMap); + addCheck(PacketOrderJ.class, new PacketOrderJ(player), postPredictionCheckMap); + addCheck(PacketOrderK.class, new PacketOrderK(player), postPredictionCheckMap); + addCheck(PacketOrderL.class, new PacketOrderL(player), postPredictionCheckMap); + addCheck(PacketOrderM.class, new PacketOrderM(player), postPredictionCheckMap); + addCheck(NoFallB.class, new NoFallB(player), postPredictionCheckMap); + addCheck(OffsetHandler.class, new OffsetHandler(player), postPredictionCheckMap); + addCheck(SuperDebug.class, new SuperDebug(player), postPredictionCheckMap); + addCheck(DebugHandler.class, new DebugHandler(player), postPredictionCheckMap); + addCheck(EntityControl.class, new EntityControl(player), postPredictionCheckMap); + addCheck(NoSlowA.class, new NoSlowA(player), postPredictionCheckMap); + addCheck(NoSlowC.class, new NoSlowC(player), postPredictionCheckMap); + addCheck(NoSlowD.class, new NoSlowD(player), postPredictionCheckMap); + addCheck(NoSlowE.class, new NoSlowE(player), postPredictionCheckMap); + addCheck(MultiInteractA.class, new MultiInteractA(player), postPredictionCheckMap); + addCheck(MultiInteractB.class, new MultiInteractB(player), postPredictionCheckMap); + addCheck(SetbackTeleportUtil.class, new SetbackTeleportUtil(player), postPredictionCheckMap); + addCheck(CompensatedFireworks.class, player.compensatedFireworks, postPredictionCheckMap); + addCheck(SneakingEstimator.class, new SneakingEstimator(player), postPredictionCheckMap); + addCheck(LastInstanceManager.class, player.lastInstanceManager, postPredictionCheckMap); + postPredictionChecks = postPredictionCheckMap.values().toArray(new PostPredictionCheckI[0]); + loadedChecks.putAll(postPredictionCheckMap); init(); } + /** + * Adds a check to the appropriate map if the player is not exempt. + */ + private void addCheck( + Class checkClass, // The class type of the check + T checkInstance, // The instance of the check + Map, T> checkMap // The map to store the check + ) { + if (checkMap.get(checkClass) != null) { + LogUtil.warn("Attempted to add " + checkClass + " twice to the same checktype map for player + " + player.getName() + ", ignoring!"); +// } else if (checkInstance.getCheckName() == null || checkInstance.getCheckName() == "") { +// LogUtil.warn("Attempted to add a check with no or null name for player " + player.getName() + ", ignoring!"); + } else { + // existing behaviour has essentially been to always treat checks with null names and as core/non-unloadable and with no exempt permissions + // should we change how to handle this? + if (checkInstance.getCheckName() != null) { + // register permissions here to prevent NPE when checking if player is exempt + String permissionName = "grim.exempt." + checkInstance.getCheckName().toLowerCase(); + Permission permission = Bukkit.getPluginManager().getPermission(permissionName); + if (permission == null) { + Bukkit.getPluginManager().addPermission(new Permission(permissionName, PermissionDefault.FALSE)); + } else { + permission.setDefault(PermissionDefault.FALSE); + } + + // returns true if the check is exempt for the player + // Currently only checks for permission, in the future we will not add to map if: + // 1. Permission exempts player + // 2. Client version exempts player + if (!isExempt(checkInstance)) { + checkMap.put(checkClass, checkInstance); + } + } else { + // Adds checks without name (currently these are core checks) to map, we really need to change this behavior + checkMap.put(checkClass, checkInstance); + } + // Do re really need to put unloaded behaviours for in a map for *all* checks? + // What about core ones or even ones that we know will have default behaviour? + unloadedBehaviors.put(checkClass, checkInstance.getUnloadedBehavior()); + } + } + + /** + * Performs a topological sort of checks based on their dependencies + */ + private List topologicalSort(Collection checks) throws IllegalStateException { + Map, Set>> graph = new HashMap<>(); + Map, Integer> inDegree = new HashMap<>(); + + // Build dependency graph + for (AbstractCheck check : checks) { + Class checkClass = check.getClass(); + graph.putIfAbsent(checkClass, new HashSet<>()); + inDegree.putIfAbsent(checkClass, 0); + + // Add loadAfter dependencies + for (Class dep : check.getLoadAfter()) { + graph.computeIfAbsent(dep, k -> new HashSet<>()).add(checkClass); + inDegree.merge(checkClass, 1, Integer::sum); + } + + // Add loadBefore reverse dependencies + for (Class dep : check.getLoadBefore()) { + graph.computeIfAbsent(checkClass, k -> new HashSet<>()).add(dep); + inDegree.merge(dep, 1, Integer::sum); + } + + // Add direct dependencies + for (Class dep : check.getDependencies()) { + graph.computeIfAbsent(dep, k -> new HashSet<>()).add(checkClass); + inDegree.merge(checkClass, 1, Integer::sum); + } + } + + // Perform topological sort using Kahn's algorithm + Queue> queue = new LinkedList<>(); + Map, AbstractCheck> checkMap = checks.stream() + .collect(Collectors.toMap(AbstractCheck::getClass, c -> c)); + + inDegree.forEach((check, degree) -> { + if (degree == 0) queue.add(check); + }); + + List sorted = new ArrayList<>(); + while (!queue.isEmpty()) { + Class current = queue.poll(); + AbstractCheck check = checkMap.get(current); + if (check != null) { + sorted.add(check); + } + + for (Class dependent : graph.getOrDefault(current, Collections.emptySet())) { + inDegree.merge(dependent, -1, Integer::sum); + if (inDegree.get(dependent) == 0) { + queue.add(dependent); + } + } + } + + if (sorted.size() != checks.size()) { + throw new IllegalStateException("Circular dependency detected in checks"); + } + + return sorted; + } + + /** + * Rebuilds all check arrays maintaining dependency order + */ + private void rebuildCheckArrays() { + // TODO catch illegal state exception, and DO NOT change check arrays, instead throw error and tell player + List sorted = topologicalSort(loadedChecks.values()); + + // Use lists first since we don't know final size + List newPacketChecks = new ArrayList<>(); + List newPositionChecks = new ArrayList<>(); + List newRotationChecks = new ArrayList<>(); + List newVehicleChecks = new ArrayList<>(); + List newPrePredictionChecks = new ArrayList<>(); + List newBlockBreakChecks = new ArrayList<>(); + List newBlockPlaceChecks = new ArrayList<>(); + List newPostPredictionChecks = new ArrayList<>(); + + // Single pass, add to all applicable lists + for (AbstractCheck check : sorted) { + // A check can be multiple types, so no else-if + if (check.is(CheckType.PACKET)) newPacketChecks.add((PacketCheckI) check); + if (check.is(CheckType.POSITION)) newPositionChecks.add((PositionCheckI) check); + if (check.is(CheckType.ROTATION)) newRotationChecks.add((RotationCheckI) check); + if (check.is(CheckType.VEHICLE)) newVehicleChecks.add((VehicleCheckI) check); + if (check.is(CheckType.PRE_PREDICTION)) newPrePredictionChecks.add((PacketCheckI) check); + if (check.is(CheckType.BLOCK_BREAK)) newBlockBreakChecks.add((BlockBreakCheckI) check); + if (check.is(CheckType.BLOCK_PLACE)) newBlockPlaceChecks.add((BlockPlaceCheck) check); + if (check.is(CheckType.POST_PREDICTION)) newPostPredictionChecks.add((PostPredictionCheckI) check); + + } + + // Convert lists to arrays atomically + this.packetChecks = newPacketChecks.toArray(new PacketCheckI[0]); + this.positionChecks = newPositionChecks.toArray(new PositionCheckI[0]); + this.rotationChecks = newRotationChecks.toArray(new RotationCheckI[0]); + this.vehicleChecks = newVehicleChecks.toArray(new VehicleCheckI[0]); + this.prePredictionChecks = newPrePredictionChecks.toArray(new PacketCheckI[0]); + this.blockBreakChecks = newBlockBreakChecks.toArray(new BlockBreakCheckI[0]); + this.blockPlaceChecks = newBlockPlaceChecks.toArray(new BlockPlaceCheck[0]); + this.postPredictionChecks = newPostPredictionChecks.toArray(new PostPredictionCheckI[0]); + } + + /** + * Registers and loads a check, resolving dependencies + * @throws IllegalStateException if dependencies cannot be satisfied + */ + public void registerCheck(AbstractCheck check) { + Class checkClass = check.getClass(); + + // Verify dependencies are loaded + for (Class dep : check.getDependencies()) { + if (!isCheckLoaded(dep)) { + throw new IllegalStateException("Missing required dependency: " + dep.getSimpleName()); + } + } + + // Load the check + if (!check.onLoad()) { + throw new IllegalStateException("Failed to load " + checkClass.getSimpleName()); + } + + loadedChecks.put(checkClass, check); + rebuildCheckArrays(); + } + + private boolean isCheckLoaded(Class dep) { + return loadedChecks.containsKey(dep); + } + + /** + * Unloads a check and its dependents + */ + public void unregisterCheck(Class checkClass) { + AbstractCheck check = loadedChecks.remove(checkClass); + if (check != null) { + // Unload dependents first + for (AbstractCheck other : loadedChecks.values()) { + if (other.getDependencies().contains(checkClass)) { + unregisterCheck(other.getClass()); + } + } + check.onUnload(); + rebuildCheckArrays(); + } + } + + /** + * Reloads a check and its dependents + */ + public void reloadCheck(Class checkClass) { + AbstractCheck check = loadedChecks.get(checkClass); + if (check != null) { + unregisterCheck(checkClass); + registerCheck(check); + } + } + + /** + * Check if a player is exempt from a specific check type. + */ + private boolean isExempt(AbstractCheck checkInstance) { + // Example logic for exemptions + String permission = "grim.exempt." + checkInstance.getClass().getSimpleName().toLowerCase(); + return +// this.player.bukkitPlayer.hasPermission(permission) || + !checkInstance.supportsPlayer(this.player); + } + @SuppressWarnings("unchecked") - public T getPositionCheck(Class check) { - return (T) positionCheck.get(check); + public T getPositionCheck(Class check) { +// return (T) positionCheck.get(check); + return (T) loadedChecks.get(check); } @SuppressWarnings("unchecked") - public T getRotationCheck(Class check) { - return (T) rotationCheck.get(check); + public T getRotationCheck(Class check) { +// return (T) rotationCheck.get(check); + return (T) loadedChecks.get(check); } @SuppressWarnings("unchecked") - public T getVehicleCheck(Class check) { - return (T) vehicleCheck.get(check); + public T getVehicleCheck(Class check) { +// return (T) vehicleCheck.get(check); + return (T) loadedChecks.get(check); } public void onPrePredictionReceivePacket(final PacketReceiveEvent packet) { - for (PacketCheck check : prePredictionChecks.values()) { + for (PacketCheckI check : prePredictionChecks) { check.onPacketReceive(packet); } } public void onPacketReceive(final PacketReceiveEvent packet) { - for (PacketCheck check : packetChecks.values()) { + for (PacketCheckI check : packetChecks) { check.onPacketReceive(packet); } - for (PostPredictionCheck check : postPredictionCheck.values()) { + for (PostPredictionCheckI check : postPredictionChecks) { check.onPacketReceive(packet); } - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.onPacketReceive(packet); } - for (BlockBreakCheck check : blockBreakChecks.values()) { + for (BlockBreakCheckI check : blockBreakChecks) { check.onPacketReceive(packet); } } public void onPacketSend(final PacketSendEvent packet) { - for (PacketCheck check : prePredictionChecks.values()) { + for (PacketCheckI check : prePredictionChecks) { check.onPacketSend(packet); } - for (PacketCheck check : packetChecks.values()) { + for (PacketCheckI check : packetChecks) { check.onPacketSend(packet); } - for (PostPredictionCheck check : postPredictionCheck.values()) { + for (PostPredictionCheckI check : postPredictionChecks) { check.onPacketSend(packet); } - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.onPacketSend(packet); } - for (BlockBreakCheck check : blockBreakChecks.values()) { + for (BlockBreakCheckI check : blockBreakChecks) { check.onPacketSend(packet); } } public void onPositionUpdate(final PositionUpdate position) { - for (PositionCheck check : positionCheck.values()) { + for (PositionCheckI check : positionChecks) { check.onPositionUpdate(position); } } public void onRotationUpdate(final RotationUpdate rotation) { - for (RotationCheck check : rotationCheck.values()) { + for (RotationCheckI check : rotationChecks) { check.process(rotation); } - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.process(rotation); } } public void onVehiclePositionUpdate(final VehiclePositionUpdate update) { - for (VehicleCheck check : vehicleCheck.values()) { + for (VehicleCheckI check : vehicleChecks) { check.process(update); } } public void onPredictionFinish(final PredictionComplete complete) { - for (PostPredictionCheck check : postPredictionCheck.values()) { + for (PostPredictionCheckI check : postPredictionChecks) { check.onPredictionComplete(complete); } - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.onPredictionComplete(complete); } - for (BlockBreakCheck check : blockBreakChecks.values()) { + for (BlockBreakCheckI check : blockBreakChecks) { check.onPredictionComplete(complete); } } public void onBlockPlace(final BlockPlace place) { - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.onBlockPlace(place); } } public void onPostFlyingBlockPlace(final BlockPlace place) { - for (BlockPlaceCheck check : blockPlaceCheck.values()) { + for (BlockPlaceCheck check : blockPlaceChecks) { check.onPostFlyingBlockPlace(place); } } public void onBlockBreak(final BlockBreak blockBreak) { - for (BlockBreakCheck check : blockBreakChecks.values()) { + for (BlockBreakCheckI check : blockBreakChecks) { check.onBlockBreak(blockBreak); } } @@ -334,18 +569,23 @@ public ExplosionHandler getExplosionHandler() { } @SuppressWarnings("unchecked") - public T getPacketCheck(Class check) { - return (T) packetChecks.get(check); + public T getPacketCheck(Class check) { + return getCheck(check); } @SuppressWarnings("unchecked") public T getBlockPlaceCheck(Class check) { - return (T) blockPlaceCheck.get(check); + return getCheck(check); + } + + @SuppressWarnings("unchecked") + public T getPrePredictionCheck(Class check) { + return getCheck(check); } @SuppressWarnings("unchecked") - public T getPrePredictionCheck(Class check) { - return (T) prePredictionChecks.get(check); + public T getPostPredictionCheck(Class check) { + return getCheck(check); } private PacketEntityReplication packetEntityReplication = null; @@ -390,9 +630,40 @@ public OffsetHandler getOffsetHandler() { return getPostPredictionCheck(OffsetHandler.class); } + /** + * Gets a check instance, creating an unloaded proxy if the check isn't loaded. + * This ensures calls to unloaded checks fail gracefully rather than throwing exceptions. + * + * @param checkClass The class of check to retrieve + * @return The check instance or an unloaded proxy + */ + // Type-safe check access with unloaded handling @SuppressWarnings("unchecked") - public T getPostPredictionCheck(Class check) { - return (T) postPredictionCheck.get(check); + public T getCheck(Class checkClass) { + T check = (T) loadedChecks.get(checkClass); + if (check == null) { + return (T) unloadedProxies.computeIfAbsent(checkClass, + this::createUnloadedProxy); + } + return check; + } + + /** + * Creates a proxy that handles calls to an unloaded check. + * The proxy uses the check's provider to determine unloaded behavior. + * + * @param checkClass The check class to create a proxy for + * @return A proxy implementing the check's interface + */ + private T createUnloadedProxy(Class checkClass) { + // Get the unloaded behavior from a cached instance or use default + UnloadedBehavior behavior = unloadedBehaviors.getOrDefault(checkClass, DefaultUnloadedBehavior.INSTANCE); + + return (T) Proxy.newProxyInstance( + checkClass.getClassLoader(), + new Class[] { checkClass }, + (proxy, method, args) -> behavior.handleUnloadedCall(method, args) + ); } private void init() { @@ -401,18 +672,5 @@ private void init() { // Slow thread safe check if (!initedAtomic.compareAndSet(false, true)) return; inited = true; - - for (AbstractCheck check : allChecks.values()) { - if (check.getCheckName() != null) { - String permissionName = "grim.exempt." + check.getCheckName().toLowerCase(); - Permission permission = Bukkit.getPluginManager().getPermission(permissionName); - - if (permission == null) { - Bukkit.getPluginManager().addPermission(new Permission(permissionName, PermissionDefault.FALSE)); - } else { - permission.setDefault(PermissionDefault.FALSE); - } - } - } } } diff --git a/src/main/java/ac/grim/grimac/manager/LastInstanceManager.java b/src/main/java/ac/grim/grimac/manager/LastInstanceManager.java index 0f838c8940..6d134cba88 100644 --- a/src/main/java/ac/grim/grimac/manager/LastInstanceManager.java +++ b/src/main/java/ac/grim/grimac/manager/LastInstanceManager.java @@ -1,7 +1,6 @@ package ac.grim.grimac.manager; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.data.LastInstance; @@ -9,7 +8,7 @@ import java.util.ArrayList; import java.util.List; -public class LastInstanceManager extends Check implements PostPredictionCheck { +public class LastInstanceManager extends AbstractPostPredictionCheck { private final List instances = new ArrayList<>(); public LastInstanceManager(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/manager/PunishmentManager.java b/src/main/java/ac/grim/grimac/manager/PunishmentManager.java index 0b2a63817b..978d9f3480 100644 --- a/src/main/java/ac/grim/grimac/manager/PunishmentManager.java +++ b/src/main/java/ac/grim/grimac/manager/PunishmentManager.java @@ -43,7 +43,8 @@ public void reload(ConfigManager config) { groups.clear(); // To support reloading - for (AbstractCheck check : player.checkManager.allChecks.values()) { + // TODO unloaded checks? + for (AbstractCheck check : player.checkManager.loadedChecks.values()) { check.setEnabled(false); } @@ -64,7 +65,8 @@ public void reload(ConfigManager config) { exclude = true; command = command.substring(1); } - for (AbstractCheck check : player.checkManager.allChecks.values()) { // o(n) * o(n)? + // TODO unloaded checks? + for (AbstractCheck check : player.checkManager.loadedChecks.values()) { // o(n) * o(n)? if (check.getCheckName() != null && (check.getCheckName().toLowerCase(Locale.ROOT).contains(command) || check.getAlternativeName().toLowerCase(Locale.ROOT).contains(command))) { // Some checks have equivalent names like AntiKB and AntiKnockback diff --git a/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java b/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java index 534a5ebcec..2a43805092 100644 --- a/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java +++ b/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java @@ -1,9 +1,8 @@ package ac.grim.grimac.manager; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.impl.badpackets.BadPacketsN; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.events.packets.patch.ResyncWorldUtil; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.predictionengine.predictions.PredictionEngine; @@ -38,7 +37,7 @@ import java.util.Random; import java.util.concurrent.ConcurrentLinkedQueue; -public class SetbackTeleportUtil extends Check implements PostPredictionCheck { +public class SetbackTeleportUtil extends AbstractPostPredictionCheck { // Sync to netty public final ConcurrentLinkedQueue pendingTeleports = new ConcurrentLinkedQueue<>(); // Sync to netty, a player MUST accept a teleport to spawn into the world diff --git a/src/main/java/ac/grim/grimac/manager/config/ConfigManagerFileImpl.java b/src/main/java/ac/grim/grimac/manager/config/ConfigManagerFileImpl.java index 2a7837a1ae..0f0e467650 100644 --- a/src/main/java/ac/grim/grimac/manager/config/ConfigManagerFileImpl.java +++ b/src/main/java/ac/grim/grimac/manager/config/ConfigManagerFileImpl.java @@ -7,11 +7,13 @@ import ac.grim.grimac.utils.anticheat.LogUtil; import github.scarsz.configuralize.DynamicConfig; import github.scarsz.configuralize.Language; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.List; +import java.util.Map; public class ConfigManagerFileImpl implements ConfigManager, BasicReloadable { @@ -318,6 +320,11 @@ public String getStringElse(String key, String otherwise) { return config.getStringElse(key, otherwise); } + @Override + public @Nullable String getString(String s) { + return ""; + } + @Override public List getStringList(String key) { return config.getStringList(key); @@ -353,4 +360,28 @@ public T get(String key) { return config.get(key); } + @Override + public @Nullable T getElse(String s, T t) { + // TODO implement this + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public @Nullable Map getMap(String s) { + // TODO implement this + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public @Nullable Map getMapElse(String s, Map map) { + // TODO implement this + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public boolean hasLoaded() { + // TODO implement this + throw new UnsupportedOperationException("Not implemented yet"); + } + } diff --git a/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java b/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java index 68727e7c4c..5895455ad1 100644 --- a/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java +++ b/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java @@ -1,8 +1,7 @@ package ac.grim.grimac.manager.init.start; import ac.grim.grimac.GrimAPI; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.predictionengine.UncertaintyHandler; import ac.grim.grimac.predictionengine.predictions.PredictionEngine; @@ -19,7 +18,7 @@ import java.util.*; -public final class SuperDebug extends Check implements PostPredictionCheck { +public final class SuperDebug extends AbstractPostPredictionCheck { private static final StringBuilder[] flags = new StringBuilder[256]; // 17 MB of logs in memory Object2IntMap continuedDebug = new Object2IntOpenHashMap<>(); diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index 66ea19a9ea..b2f4e904e2 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -537,7 +537,8 @@ public void updatePermissions() { this.noModifyPacketPermission = bukkitPlayer.hasPermission("grim.nomodifypacket"); this.noSetbackPermission = bukkitPlayer.hasPermission("grim.nosetback"); FoliaScheduler.getAsyncScheduler().runNow(GrimAPI.INSTANCE.getPlugin(), t -> { - for (AbstractCheck check : checkManager.allChecks.values()) { + // todo, do we care about updating perms on unloaded checks? + for (AbstractCheck check : checkManager.loadedChecks.values()) { if (check instanceof Check) { ((Check) check).updateExempted(); } @@ -764,9 +765,10 @@ public boolean isVanillaMath() { return trigHandler.isVanillaMath(); } + // TODO rename to getLoadedChecks() ? @Override public Collection getChecks() { - return checkManager.allChecks.values(); + return checkManager.loadedChecks.values(); } public void runNettyTaskInMs(Runnable runnable, int ms) { @@ -789,7 +791,8 @@ public void reload(ConfigManager config) { cancelDuplicatePacket = config.getBooleanElse("cancel-duplicate-packet", true); exemptElytra = config.getBooleanElse("exempt-elytra", false); // reload all checks - for (AbstractCheck value : checkManager.allChecks.values()) value.reload(config); + // TODO, reload unloaded checks? + for (AbstractCheck check : checkManager.loadedChecks.values()) check.reload(); // reload punishment manager punishmentManager.reload(config); } diff --git a/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java b/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java index c6d37c9108..5fd9796f51 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java +++ b/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java @@ -1,14 +1,13 @@ package ac.grim.grimac.predictionengine; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; import ac.grim.grimac.utils.data.packetentity.PacketEntity; import com.github.retrooper.packetevents.protocol.player.ClientVersion; -public class GhostBlockDetector extends Check implements PostPredictionCheck { +public class GhostBlockDetector extends AbstractPostPredictionCheck { public GhostBlockDetector(GrimPlayer player) { super(player); diff --git a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java index e38fffc470..f73e4df850 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java +++ b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java @@ -4,7 +4,7 @@ import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.impl.movement.EntityControl; import ac.grim.grimac.checks.impl.prediction.Phase; -import ac.grim.grimac.checks.type.PositionCheck; +import ac.grim.grimac.checks.type.interfaces.PositionCheckI; import ac.grim.grimac.manager.SetbackTeleportUtil; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.predictionengine.movementtick.MovementTickerHorse; @@ -40,7 +40,7 @@ import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes; import org.bukkit.util.Vector; -public class MovementCheckRunner extends Check implements PositionCheck { +public class MovementCheckRunner extends Check implements PositionCheckI { // Averaged over 500 predictions (Defaults set slightly above my 3600x results) public static double predictionNanos = 0.3 * 1e6; // Averaged over 20000 predictions diff --git a/src/main/java/ac/grim/grimac/predictionengine/SneakingEstimator.java b/src/main/java/ac/grim/grimac/predictionengine/SneakingEstimator.java index 32225e794e..14baf58350 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/SneakingEstimator.java +++ b/src/main/java/ac/grim/grimac/predictionengine/SneakingEstimator.java @@ -1,7 +1,6 @@ package ac.grim.grimac.predictionengine; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import ac.grim.grimac.utils.collisions.datatypes.SimpleCollisionBox; @@ -30,7 +29,7 @@ *

* So, this is a value patch like 0.03 because it can be "close enough" that it's better just to not skip ticks **/ -public class SneakingEstimator extends Check implements PostPredictionCheck { +public class SneakingEstimator extends AbstractPostPredictionCheck { SimpleCollisionBox sneakingPotentialHiddenVelocity = new SimpleCollisionBox(); List possible = new ArrayList<>(); diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedCooldown.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedCooldown.java index 3c1ee9dc3e..e66222819d 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedCooldown.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedCooldown.java @@ -1,7 +1,6 @@ package ac.grim.grimac.utils.latency; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PositionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPositionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PositionUpdate; import ac.grim.grimac.utils.data.CooldownData; @@ -16,7 +15,7 @@ // although the client will end the cooldown automatically. Can be applied to any item, // note that interactions still get sent to the server with the item but the client does not play the animation // nor attempt to predict results (i.e block placing). -public class CompensatedCooldown extends Check implements PositionCheck { +public class CompensatedCooldown extends AbstractPositionCheck { private final ConcurrentHashMap itemCooldownMap = new ConcurrentHashMap<>(); public CompensatedCooldown(GrimPlayer playerData) { diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java index 37b1b0ca65..b905d06e78 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedFireworks.java @@ -1,14 +1,13 @@ package ac.grim.grimac.utils.latency; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PostPredictionCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPostPredictionCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.PredictionComplete; import java.util.HashSet; import java.util.Set; -public class CompensatedFireworks extends Check implements PostPredictionCheck { +public class CompensatedFireworks extends AbstractPostPredictionCheck { // As this is sync to one player, this does not have to be concurrent private final Set activeFireworks = new HashSet<>(); diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java index 83390eb9c7..364c0f6200 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedInventory.java @@ -1,7 +1,6 @@ package ac.grim.grimac.utils.latency; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.anticheat.update.BlockPlace; import ac.grim.grimac.utils.inventory.EquipmentType; @@ -34,7 +33,7 @@ import java.util.Optional; // Updated to support modern 1.17 protocol -public class CompensatedInventory extends Check implements PacketCheck { +public class CompensatedInventory extends AbstractPacketCheck { // "Temporarily" public for debugging public Inventory inventory; // "Temporarily" public for debugging diff --git a/src/main/java/ac/grim/grimac/utils/team/TeamHandler.java b/src/main/java/ac/grim/grimac/utils/team/TeamHandler.java index c5fb963080..aa0bf5f713 100644 --- a/src/main/java/ac/grim/grimac/utils/team/TeamHandler.java +++ b/src/main/java/ac/grim/grimac/utils/team/TeamHandler.java @@ -1,7 +1,6 @@ package ac.grim.grimac.utils.team; -import ac.grim.grimac.checks.Check; -import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.checks.type.abstracts.AbstractPacketCheck; import ac.grim.grimac.player.GrimPlayer; import ac.grim.grimac.utils.data.packetentity.PacketEntity; import com.github.retrooper.packetevents.event.PacketSendEvent; @@ -13,7 +12,7 @@ import java.util.Optional; import java.util.UUID; -public class TeamHandler extends Check implements PacketCheck { +public class TeamHandler extends AbstractPacketCheck { private final Map entityTeams = new Object2ObjectOpenHashMap<>(); private final Map entityToTeam = new Object2ObjectOpenHashMap<>();