mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 08:36:38 +00:00
fix logic and some cleaning
This commit is contained in:
parent
c7849c0462
commit
c0d79aa75b
@ -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