diff --git a/src/main/java/ac/grim/grimac/checks/Check.java b/src/main/java/ac/grim/grimac/checks/Check.java index c2b3f615c8..8adc776957 100644 --- a/src/main/java/ac/grim/grimac/checks/Check.java +++ b/src/main/java/ac/grim/grimac/checks/Check.java @@ -7,6 +7,7 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; import github.scarsz.configuralize.DynamicConfig; +import io.github.retrooper.packetevents.util.folia.FoliaScheduler; import lombok.Getter; import lombok.Setter; import org.bukkit.Bukkit; @@ -60,6 +61,13 @@ public boolean shouldModifyPackets() { return isEnabled && !player.disableGrim && !player.noModifyPacketPermission && !exempted; } + public void updateExempted() { + if (player.bukkitPlayer == null || checkName == null) return; + FoliaScheduler.getEntityScheduler().run(player.bukkitPlayer, GrimAPI.INSTANCE.getPlugin(), + t -> exempted = player.bukkitPlayer.hasPermission("grim.exempt." + checkName.toLowerCase()), + () -> {}); + } + public final boolean flagAndAlert(String verbose) { if (flag()) { alert(verbose); @@ -105,7 +113,7 @@ public void reload() { if (setbackVL == -1) setbackVL = Double.MAX_VALUE; - exempted = player.bukkitPlayer != null && player.bukkitPlayer.hasPermission("grim.exempt." + checkName.toLowerCase()); + updateExempted(); } public boolean alert(String verbose) { diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index 106110eed1..71882b15ce 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -3,6 +3,7 @@ import ac.grim.grimac.GrimAPI; import ac.grim.grimac.api.AbstractCheck; import ac.grim.grimac.api.GrimUser; +import ac.grim.grimac.checks.Check; import ac.grim.grimac.checks.impl.aim.processor.AimProcessor; import ac.grim.grimac.checks.impl.misc.ClientBrand; import ac.grim.grimac.checks.impl.misc.TransactionOrder; @@ -35,7 +36,6 @@ import com.github.retrooper.packetevents.protocol.player.GameMode; import com.github.retrooper.packetevents.protocol.player.User; import com.github.retrooper.packetevents.protocol.world.BlockFace; -import com.github.retrooper.packetevents.protocol.world.Dimension; import com.github.retrooper.packetevents.protocol.world.dimension.DimensionType; import com.github.retrooper.packetevents.util.Vector3d; import com.github.retrooper.packetevents.wrapper.PacketWrapper; @@ -504,6 +504,13 @@ public void updatePermissions() { if (bukkitPlayer == null) return; 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()) { + if (check instanceof Check) { + ((Check) check).updateExempted(); + } + } + ); } private int spamThreshold = 100;