Feature/pipe or permissions (#418)

* Add pipe OR handling for permissions
This commit is contained in:
Vaan1310
2025-02-22 17:28:34 +01:00
committed by GitHub
parent 1d285db1aa
commit 25e692eb50
@@ -329,12 +329,29 @@ public abstract class CommandManager<
if (permission == null || permission.isEmpty()) { if (permission == null || permission.isEmpty()) {
return true; return true;
} }
for (String perm : ACFPatterns.COMMA.split(permission)) {
if (!perm.isEmpty() && !issuer.hasPermission(perm)) { //handle commas as an AND operation
return false; if (permission.contains(",")) {
for (String perm : ACFPatterns.COMMA.split(permission)) {
if (!perm.isEmpty() && !issuer.hasPermission(perm)) {
return false;
}
} }
return true;
} }
return true;
//handle pipe as an OR operation
if (permission.contains("|")) {
for (String perm : ACFPatterns.PIPE.split(permission)) {
if (!perm.isEmpty() && issuer.hasPermission(perm)) {
return true;
}
}
return false;
}
//if none are used just test the permission itself
return issuer.hasPermission(permission);
} }
public synchronized RootCommand getRootCommand(@NotNull String cmd) { public synchronized RootCommand getRootCommand(@NotNull String cmd) {