mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
Add pipe OR handling for permissions
This commit is contained in:
@@ -329,12 +329,30 @@ public abstract class CommandManager<
|
||||
if (permission == null || permission.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (String perm : ACFPatterns.COMMA.split(permission)) {
|
||||
if (!perm.isEmpty() && !issuer.hasPermission(perm)) {
|
||||
return false;
|
||||
|
||||
//handle commas as an AND operation
|
||||
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)) {
|
||||
perm = perm.trim();
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user