diff --git a/build.gradle.kts b/build.gradle.kts index ca9ab819d6..8f156b5cbc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { implementation("it.unimi.dsi:fastutil:8.5.13") implementation("github.scarsz:configuralize:1.4.0") - implementation("com.github.grimanticheat:grimapi:f10e6fd1b0") + implementation("com.github.grimanticheat:grimapi:f3c5eed2e7") // Used for local testing: implementation("ac.grim.grimac:grimapi:1.0") implementation("org.jetbrains:annotations:24.1.0") diff --git a/src/main/java/ac/grim/grimac/GrimAPI.java b/src/main/java/ac/grim/grimac/GrimAPI.java index f22fb490ae..da65c244f6 100644 --- a/src/main/java/ac/grim/grimac/GrimAPI.java +++ b/src/main/java/ac/grim/grimac/GrimAPI.java @@ -12,7 +12,7 @@ public enum GrimAPI { INSTANCE; - private final AlertManager alertManager = new AlertManager(); + private final AlertManagerImpl alertManager = new AlertManagerImpl(); private final SpectateManager spectateManager = new SpectateManager(); private final DiscordManager discordManager = new DiscordManager(); private final PlayerDataManager playerDataManager = new PlayerDataManager(); diff --git a/src/main/java/ac/grim/grimac/GrimExternalAPI.java b/src/main/java/ac/grim/grimac/GrimExternalAPI.java index bf8f14c5f6..5fcb8df5f1 100644 --- a/src/main/java/ac/grim/grimac/GrimExternalAPI.java +++ b/src/main/java/ac/grim/grimac/GrimExternalAPI.java @@ -3,6 +3,7 @@ import ac.grim.grimac.api.AbstractCheck; import ac.grim.grimac.api.GrimAbstractAPI; import ac.grim.grimac.api.GrimUser; +import ac.grim.grimac.api.alerts.AlertManager; import ac.grim.grimac.manager.init.Initable; import ac.grim.grimac.player.GrimPlayer; import com.github.retrooper.packetevents.netty.channel.ChannelHelper; @@ -99,6 +100,11 @@ public void reload() { GrimAPI.INSTANCE.getExternalAPI().start(); } + @Override + public AlertManager getAlertManager() { + return GrimAPI.INSTANCE.getAlertManager(); + } + @Override public void start() { variableReplacements.put("%player%", GrimUser::getName); diff --git a/src/main/java/ac/grim/grimac/events/packets/ProxyAlertMessenger.java b/src/main/java/ac/grim/grimac/events/packets/ProxyAlertMessenger.java index c6b1f7f008..caf54d88bc 100644 --- a/src/main/java/ac/grim/grimac/events/packets/ProxyAlertMessenger.java +++ b/src/main/java/ac/grim/grimac/events/packets/ProxyAlertMessenger.java @@ -2,7 +2,6 @@ import ac.grim.grimac.GrimAPI; import ac.grim.grimac.utils.anticheat.LogUtil; -import ac.grim.grimac.utils.anticheat.MessageUtil; import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.event.PacketListenerAbstract; import com.github.retrooper.packetevents.event.PacketReceiveEvent; diff --git a/src/main/java/ac/grim/grimac/manager/AlertManager.java b/src/main/java/ac/grim/grimac/manager/AlertManagerImpl.java similarity index 89% rename from src/main/java/ac/grim/grimac/manager/AlertManager.java rename to src/main/java/ac/grim/grimac/manager/AlertManagerImpl.java index 95284a82ce..d46d3300d2 100644 --- a/src/main/java/ac/grim/grimac/manager/AlertManager.java +++ b/src/main/java/ac/grim/grimac/manager/AlertManagerImpl.java @@ -1,6 +1,7 @@ package ac.grim.grimac.manager; import ac.grim.grimac.GrimAPI; +import ac.grim.grimac.api.alerts.AlertManager; import ac.grim.grimac.utils.anticheat.MessageUtil; import lombok.Getter; import org.bukkit.entity.Player; @@ -9,13 +10,18 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; -public class AlertManager { +public class AlertManagerImpl implements AlertManager { @Getter private final Set enabledAlerts = new CopyOnWriteArraySet<>(new HashSet<>()); @Getter private final Set enabledVerbose = new CopyOnWriteArraySet<>(new HashSet<>()); + @Override + public boolean hasAlertsEnabled(Player player) { + return enabledAlerts.contains(player); + } + @Override public void toggleAlerts(Player player) { if (!enabledAlerts.remove(player)) { String alertString = GrimAPI.INSTANCE.getConfigManager().getConfig().getStringElse("alerts-enabled", "%prefix% &fAlerts enabled");