Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.0' into merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java
#	src/main/java/ac/grim/grimac/player/GrimPlayer.java
  • Loading branch information
Axionize committed Nov 2, 2024
2 parents 89b6c83 + b65f42a commit 8b9bc35
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/main/java/ac/grim/grimac/checks/Check.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Check implements AbstractCheck, ConfigReloadObserver {
private String checkName;
private String configName;
private String alternativeName;
private String displayName;
private String description;

private boolean experimental;
Expand Down Expand Up @@ -53,6 +54,7 @@ public Check(final GrimPlayer player) {
this.alternativeName = checkData.alternativeName();
this.experimental = checkData.experimental();
this.description = checkData.description();
this.displayName = this.checkName;
}
//
reload();
Expand Down Expand Up @@ -112,6 +114,8 @@ public final void reward() {
public void reload(ConfigManager configuration) {
decay = configuration.getDoubleElse(configName + ".decay", decay);
setbackVL = configuration.getDoubleElse(configName + ".setbackvl", setbackVL);
displayName = configuration.getStringElse(configName + ".displayname", checkName);

if (setbackVL == -1) setbackVL = Double.MAX_VALUE;
updateExempted();
onReload(configuration);
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 = 10, experimental = true)
@CheckData(name = "NegativeTimer", configName = "NegativeTimer", setback = -1, experimental = true)
public class NegativeTimerCheck extends TimerCheck implements PostPredictionCheck {

public NegativeTimerCheck(GrimPlayer player) {
Expand All @@ -24,7 +24,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {

if (timerBalanceRealTime < lastMovementPlayerClock - clockDrift) {
int lostMS = (int) ((System.nanoTime() - timerBalanceRealTime) / 1e6);
flagAndAlert("-" + lostMS);
if (flagAndAlert("-" + lostMS)) setbackIfAboveSetbackVL();
timerBalanceRealTime += 50e6;
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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;
Expand Down Expand Up @@ -333,11 +334,16 @@ public <T extends PostPredictionCheck> T getPostPredictionCheck(Class<T> check)

private void init() {
if (inited) return;

for (AbstractCheck check : allChecks.values()) {
if (check.getCheckName() != null) {
Permission permission = new Permission("grim.exempt." + check.getCheckName().toLowerCase(), PermissionDefault.FALSE);
Bukkit.getPluginManager().addPermission(permission);
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);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ac/grim/grimac/manager/PunishmentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private String replaceAlertPlaceholders(String original, PunishGroup group, Chec
original = MessageUtil.format(original
.replace("[alert]", alertString)
.replace("[proxy]", alertString)
.replace("%check_name%", check.getCheckName())
.replace("%check_name%", check.getDisplayName())
.replace("%experimental%", check.isExperimental() ? experimentalSymbol : "")
.replace("%vl%", vl)
.replace("%verbose%", verbose)
Expand Down Expand Up @@ -149,7 +149,7 @@ public boolean handleAlert(GrimPlayer player, String verbose, Check check) {

if (command.command.equals("[webhook]")) {
String vl = group.violations.values().stream().filter((e) -> e == check).count() + "";
GrimAPI.INSTANCE.getDiscordManager().sendAlert(player, verbose, check.getCheckName(), vl);
GrimAPI.INSTANCE.getDiscordManager().sendAlert(player, verbose, check.getDisplayName(), vl);
} else if (command.command.equals("[proxy]")) {
ProxyAlertMessenger.sendPluginMessage(replaceAlertPlaceholders(command.getCommand(), group, check, proxyAlertString, verbose));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -259,6 +258,7 @@ public GrimPlayer(User user) {
possibleEyeHeights[1] = new double[]{(double) (1.62f - 0.08f), (double) (1.62f)}; // sneaking, standing
possibleEyeHeights[0] = new double[]{(double) (1.62f), (double) (1.62f - 0.08f)}; // standing, sneaking
}

// reload last
reload();
}
Expand Down

0 comments on commit 8b9bc35

Please sign in to comment.