diff --git a/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java b/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java index d8ca244..e1a558a 100644 --- a/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java +++ b/src/main/java/net/gravitydevelopment/anticheat/event/PlayerListener.java @@ -45,7 +45,7 @@ public class PlayerListener extends EventListener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); - if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)) { + if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM) && !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) { CheckResult result = getBackend().checkCommandSpam(player, event.getMessage()); if (result.failed()) { event.setCancelled(!silentMode()); diff --git a/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java b/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java index 0558ee1..c7c0db7 100644 --- a/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java +++ b/src/main/java/net/gravitydevelopment/anticheat/util/Permission.java @@ -64,9 +64,15 @@ public enum Permission { SYSTEM_RELOAD; private static final String PERMISSION_ALL = "anticheat.*"; + private static final String PERMISSION_SPAM = "anticheat.check.spam"; + + public static boolean getCommandExempt(CommandSender cs, String commandLabel) { + // Check permission, base, and all will have already been checked + return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel); + } public boolean get(CommandSender cs) { - if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission("anticheat.check.spam")) return true; + if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM)) return true; return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL); }