Skip to content

Commit

Permalink
remove config name
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Dec 13, 2024
1 parent 4c21c11 commit 9d00e5f
Show file tree
Hide file tree
Showing 29 changed files with 97 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencies {

//implementation("com.github.grimanticheat:grimapi:1193c4fa41")
// Used for local testing: implementation("ac.grim.grimac:GRIMAPI:1.0")
implementation("com.github.grimanticheat:grimapi:fc5634e444")
implementation("com.github.grimanticheat:grimapi:4e50368")

implementation("org.jetbrains:annotations:24.1.0")
compileOnly("org.geysermc.floodgate:api:2.0-SNAPSHOT")
Expand Down
21 changes: 8 additions & 13 deletions src/main/java/ac/grim/grimac/checks/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class Check implements AbstractCheck, ConfigReloadObserver {
private double setbackVL;

private String checkName;
private String configName;
private String alternativeName;
private String displayName;
private String description;
Expand All @@ -35,11 +34,6 @@ public class Check implements AbstractCheck, ConfigReloadObserver {
private boolean isEnabled;
private boolean exempted;

@Override
public boolean isExperimental() {
return experimental;
}

public Check(final GrimPlayer player) {
this.player = player;

Expand All @@ -48,17 +42,14 @@ public Check(final GrimPlayer player) {
if (checkClass.isAnnotationPresent(CheckData.class)) {
final CheckData checkData = checkClass.getAnnotation(CheckData.class);
this.checkName = checkData.name();
this.configName = checkData.configName();
// Fall back to check name
if (this.configName.equals("DEFAULT")) this.configName = this.checkName;
this.decay = checkData.decay();
this.setbackVL = checkData.setback();
this.alternativeName = checkData.alternativeName();
this.experimental = checkData.experimental();
this.description = checkData.description();
this.displayName = this.checkName;
}
//

reload();
}

Expand Down Expand Up @@ -114,9 +105,9 @@ public final void reward() {

@Override
public void reload(ConfigManager configuration) {
decay = configuration.getDoubleElse(configName + ".decay", decay);
setbackVL = configuration.getDoubleElse(configName + ".setbackvl", setbackVL);
displayName = configuration.getStringElse(configName + ".displayname", checkName);
decay = configuration.getDoubleElse(checkName + ".decay", decay);
setbackVL = configuration.getDoubleElse(checkName + ".setbackvl", setbackVL);
displayName = configuration.getStringElse(checkName + ".displayname", checkName);

if (setbackVL == -1) setbackVL = Double.MAX_VALUE;
updateExempted();
Expand Down Expand Up @@ -190,4 +181,8 @@ public void reload() {
reload(GrimAPI.INSTANCE.getConfigManager().getConfig());
}

@Override
public String getConfigName() {
return checkName;
}
}
2 changes: 0 additions & 2 deletions src/main/java/ac/grim/grimac/checks/CheckData.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

String alternativeName() default "UNKNOWN";

String configName() default "DEFAULT";

String description() default "No description provided";

double decay() default 0.05;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.*;

// You may not copy the check unless you are licensed under GPL
@CheckData(name = "Reach", configName = "Reach", setback = 10)
@CheckData(name = "Reach", setback = 10)
public class Reach extends Check implements PacketCheck {
// Only one flag per reach attack, per entity, per tick.
// We store position because lastX isn't reliable on teleports.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// Catches NoFalls for LOOK and GROUND packets
// This check runs AFTER the predictions
@CheckData(name = "NoFall", configName = "nofall", setback = 10)
@CheckData(name = "NoFall", setback = 10)
public class NoFallA extends Check implements PacketCheck {

public boolean flipPlayerGroundStatus = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ac.grim.grimac.checks.type.PostPredictionCheck;
import ac.grim.grimac.player.GrimPlayer;

@CheckData(name = "Entity control", configName = "EntityControl")
@CheckData(name = "EntityControl")
public class EntityControl extends Check implements PostPredictionCheck {
public EntityControl(GrimPlayer player) {
super(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;

@CheckData(name = "NegativeTimer", configName = "NegativeTimer", setback = -1, experimental = true)
@CheckData(name = "NegativeTimer", setback = -1, experimental = true)
public class NegativeTimerCheck extends TimerCheck implements PostPredictionCheck {

public NegativeTimerCheck(GrimPlayer player) {
Expand Down Expand Up @@ -37,6 +37,6 @@ public void doCheck(final PacketReceiveEvent event) {

@Override
public void onReload(ConfigManager config) {
clockDrift = (long) (config.getDoubleElse(getConfigName() + ".drift", 1200.0) * 1e6);
clockDrift = (long) (config.getDoubleElse(getCheckName() + ".drift", 1200.0) * 1e6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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)
@CheckData(name = "NoSlowA", description = "Was not slowed while using an item", setback = 5)
public class NoSlowA extends Check implements PostPredictionCheck {
double offsetToFlag;
double bestOffset = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;

@CheckData(name = "Timer", configName = "TimerA", setback = 10)
@CheckData(name = "Timer", setback = 10)
public class TimerCheck extends Check implements PacketCheck {
long timerBalanceRealTime = 0;

Expand Down Expand Up @@ -111,7 +111,7 @@ public boolean shouldCountPacketForTimer(PacketTypeCommon packetType) {

@Override
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);
clockDrift = (long) (config.getDoubleElse(getCheckName() + ".drift", 120.0) * 1e6);
limitAbuseOverPing = (long) (config.getDoubleElse(getCheckName() + ".ping-abuse-limit-threshold", 1000) * 1e6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;

@CheckData(name = "Timer - Vehicle", configName = "TimerVehicle", setback = 10)
@CheckData(name = "VehicleTimer", setback = 10)
public class VehicleTimer extends TimerCheck {
boolean isDummy = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.player.GameMode;

@CheckData(name = "GroundSpoof", configName = "GroundSpoof", setback = 10, decay = 0.01)
@CheckData(name = "GroundSpoof", setback = 10, decay = 0.01)
public class NoFallB extends Check implements PostPredictionCheck {

public NoFallB(GrimPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.util.concurrent.atomic.AtomicInteger;

@CheckData(name = "Simulation", configName = "Simulation", decay = 0.02)
@CheckData(name = "Simulation", decay = 0.02)
public class OffsetHandler extends Check implements PostPredictionCheck {
// Config
double setbackDecayMultiplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.ArrayList;
import java.util.List;

@CheckData(name = "Phase", configName = "Phase", setback = 1, decay = 0.005)
@CheckData(name = "Phase", setback = 1, decay = 0.005)
public class Phase extends Check implements PostPredictionCheck {
SimpleCollisionBox oldBB;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public void onBlockPlace(final BlockPlace place) {

@Override
public void onReload(ConfigManager config) {
this.cancelVL = config.getIntElse(getConfigName() + ".cancelVL", 0);
this.cancelVL = config.getIntElse(getCheckName() + ".cancelVL", 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Deque;
import java.util.LinkedList;

@CheckData(name = "AntiExplosion", configName = "Explosion", setback = 10)
@CheckData(name = "AntiExplosion", setback = 10)
public class ExplosionHandler extends Check implements PostPredictionCheck {
Deque<VelocityData> firstBreadMap = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.LinkedList;

// 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)
@CheckData(name = "AntiKB", alternativeName = "AntiKnockback", setback = 10, decay = 0.025)
public class KnockbackHandler extends Check implements PostPredictionCheck {
Deque<VelocityData> firstBreadMap = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onPostFlyingBlockPlace(BlockPlace place) {

@Override
public void onReload(ConfigManager config) {
this.cancelVL = config.getIntElse(getConfigName() + ".cancelVL", 5);
this.cancelVL = config.getIntElse(getCheckName() + ".cancelVL", 5);
}

protected boolean shouldCancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -292,6 +294,11 @@ public String getStringElse(String key, String otherwise) {
return config.getStringElse(key, otherwise);
}

@Override
public @Nullable String getString(String key) {
return config.getString(key);
}

@Override
public List<String> getStringList(String key) {
return config.getStringList(key);
Expand Down Expand Up @@ -327,4 +334,18 @@ public <T> T get(String key) {
return config.get(key);
}

@Override
public <T> @Nullable T getElse(String key, T otherwise) {
return config.getElse(key, otherwise);
}

@Override
public @Nullable <K, V> Map<K, V> getMap(String key) {
return config.getMap(key);
}

@Override
public @Nullable <K, V> Map<K, V> getMapElse(String key, Map<K, V> otherwise) {
return config.getMapElse(key, otherwise);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/config/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ NoSlowA:
# Verfall ist, wenn der Spieler einen Gegenstand benutzt UND dadurch verlangsamt wird
decay: 0.05

Knockback:
AntiKB:
# Mit wie viel soll der Gesamtvorteil multipliziert werden, wenn der Spieler legitim ist.
setback-decay-multiplier: 0.999
# Wie groß sollte der Abstand zur Bewegung des Spielers sein, um eine Verletzung zu erzeugen?
Expand All @@ -112,7 +112,7 @@ Knockback:
# Dies soll verhindern, dass der Spieler zu viele Verstöße sammelt und nie in der Lage ist, sie alle zu beseitigen.
max-ceiling: 4

Explosion:
AntiExplosion:
threshold: 0.001
setbackvl: 3

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/config/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ NoSlowA:
# Decay's when the player uses an item AND is slowed by it
decay: 0.05

Knockback:
AntiKB:
# How much should we multiply total advantage by when the player is legit
setback-decay-multiplier: 0.999
# How large of an offset from the player's velocity should we create a violation for?
Expand All @@ -112,11 +112,11 @@ Knockback:
# This is to stop the player from gathering too many violations and never being able to clear them all
max-ceiling: 4

Explosion:
AntiExplosion:
threshold: 0.001
setbackvl: 3

TimerA:
Timer:
setbackvl: 10
# Milliseconds that the player can accumulate for later use when they fall behind
# Could potentially allow 1.8 fast use/fast heal/fast bow bypasses if set too high, 120 ms seems like a good balance
Expand All @@ -130,7 +130,7 @@ NegativeTimer:
# Number of milliseconds lost while moving before we should start flagging
drift: 1200

# Same check method as TimerA, but for vehicles
# Same check method as Timer, but for vehicles
TimerVehicle:
# Target 1.005 timer
setbackvl: 10
Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/config/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ NoSlowA:
# Decadencia cuando un jugador usa un item Y se ralentiza por el
decay: 0.05

Knockback:
AntiKB:
# Por cuanto deberíamos multiplicar la ventaja total cuando el jugador es legítimo
setback-decay-multiplier: 0.999
# ¿Cuánta debería ser la compensacion del movimiento del jugador como para que creemos una violación?
Expand All @@ -115,12 +115,11 @@ Knockback:
# Esto es para prevenir que el jugador obtenga muchas violaciones y no pueda ser capaz de borrarlas
max-ceiling: 4


Explosion:
AntiExplosion:
threshold: 0.001
setbackvl: 3

TimerA:
Timer:
setbackvl: 10
# Milisegundos que el jugador puede acumular para ser usados mas tarde cuando se quedan por detrás
# Podría llegar a permitir pasos por alto de fast use/fast heal/fast bow en 1.8 si esta muy alto, 120 ms
Expand All @@ -135,8 +134,8 @@ NegativeTimer:
# Number of milliseconds lost while moving before we should start flagging
drift: 1200

# La misma comprobación que TimerA, pero para vehiculos
TimerVehicle:
# La misma comprobación que Timer, pero para vehiculos
VehicleTimer:
# Target 1.005 timer
setbackvl: 10

Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/config/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ NoSlowA:
# Décroissance lorsque le joueur utilise un objet ET est ralenti par celui-ci.
decay: 0.05

Knockback:
AntiKB:
# De combien devons-nous multiplier l'avantage total lorsque le joueur est légitime ?
setback-decay-multiplier: 0.999
# Quel est l'écart maximal par rapport au mouvement du joueur pour lequel nous devrions créer une violation ?
Expand All @@ -112,12 +112,11 @@ Knockback:
# Cela vise à empêcher le joueur d'accumuler trop de violations et de ne jamais pouvoir toutes les réinitialiser.
max-ceiling: 4


Explosion:
AntiExplosion:
threshold: 0.001
setbackvl: 3

TimerA:
Timer:
setbackvl: 10
# Le nombre de millisecondes que le joueur peut accumuler pour une utilisation ultérieure lorsqu'il prend du retard.
# Si la valeur est trop élevée, cela pourrait potentiellement permettre de contourner les mécaniques 1.8, comme l'utilisation rapide, la guérison rapide et le tir à l'arc rapide. Une valeur de 120 ms semble être un bon équilibre.
Expand All @@ -131,8 +130,8 @@ NegativeTimer:
# Le nombre de millisecondes perdus pendant le déplacement avant de commencer à signaler des infractions.
drift: 1200

# Même méthode de vérification que TimerA, mais pour les véhicules.
TimerVehicle:
# Même méthode de vérification que Timer, mais pour les véhicules.
VehicleTimer:
# Cibler un chronomètre de 1,005.
setbackvl: 10

Expand Down
Loading

0 comments on commit 9d00e5f

Please sign in to comment.