mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
Feature/pipe or permissions (#418)
* Add pipe OR handling for permissions
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user