mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 12:42:52 +08:00
fix logic and some cleaning
This commit is contained in:
parent
922359d6e6
commit
855a098aa7
@ -144,24 +144,22 @@ public class Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
if (this.permissions.contains(permission)) {
|
|
||||||
return true;
|
if (this.permissions.contains(permission)) return true;
|
||||||
}
|
if(this.permissions.contains("*") && this.permissions.size() == 1) return true;
|
||||||
if(this.permissions.contains("*") && this.permissions.contains("-"+permission)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] permissionParts = permission.split("\\.");
|
String[] permissionParts = permission.split("\\.");
|
||||||
for (String p : this.permissions) {
|
for (String p : this.permissions) {
|
||||||
|
|
||||||
if (p.startsWith("-") && permissionMatchesWildcard(p.substring(1), permissionParts)) {
|
if (p.startsWith("-") && permissionMatchesWildcard(p.substring(1), permissionParts)) {
|
||||||
|
Grasscutter.getLogger().info("Permission " + permission + " denied to " + this.username);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (permissionMatchesWildcard(p, permissionParts)) {
|
|
||||||
Grasscutter.getLogger().info("Permission " + p + " matches " + permission);
|
if (permissionMatchesWildcard(p, permissionParts)) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return this.permissions.contains("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removePermission(String permission) {
|
public boolean removePermission(String permission) {
|
||||||
|
Loading…
Reference in New Issue
Block a user