mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Add granular command spam exemption via permissions
This commit is contained in:
1 parent
d6fbd7d5f3
commit
c6d232d493
2 files changed
+8
-2
No files matched your search
@@ -45,7 +45,7 @@ public class PlayerListener extends EventListener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
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());
|
CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
event.setCancelled(!silentMode());
|
event.setCancelled(!silentMode());
|
||||||
|
|||||||
@@ -64,9 +64,15 @@ public enum Permission {
|
|||||||
SYSTEM_RELOAD;
|
SYSTEM_RELOAD;
|
||||||
|
|
||||||
private static final String PERMISSION_ALL = "anticheat.*";
|
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) {
|
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);
|
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user