mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 03:53:00 +08:00
add negative permission check
This commit is contained in:
parent
20e3b8ffda
commit
922359d6e6
@ -144,12 +144,20 @@ public class Account {
|
||||
}
|
||||
|
||||
public boolean hasPermission(String permission) {
|
||||
if (this.permissions.contains(permission) || this.permissions.contains("*")) {
|
||||
if (this.permissions.contains(permission)) {
|
||||
return true;
|
||||
}
|
||||
if(this.permissions.contains("*") && this.permissions.contains("-"+permission)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] permissionParts = permission.split("\\.");
|
||||
for (String p : this.permissions) {
|
||||
if (p.startsWith("-") && permissionMatchesWildcard(p.substring(1), permissionParts)) {
|
||||
return false;
|
||||
}
|
||||
if (permissionMatchesWildcard(p, permissionParts)) {
|
||||
Grasscutter.getLogger().info("Permission " + p + " matches " + permission);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user