Skip to content

Commit

Permalink
Fixed permission check when the permission in question isn't added to…
Browse files Browse the repository at this point in the history
… the rank
  • Loading branch information
svenar-nl committed Jan 16, 2022
1 parent 116c81d commit 4ad4f6c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ public boolean hasPermission(String permission) {
boolean containsWildcard = false;
boolean checkedWildcard = false;
boolean disallowed = false;
boolean disallowedValid = false;

for (PRPermission prPermission : permissions) {
if (prPermission.getName().equals(permission)) {
disallowed = !prPermission.getValue();
disallowedValid = true;
break;
}
}
Expand All @@ -63,6 +65,7 @@ public boolean hasPermission(String permission) {
if (wildcardPermissions.contains(perm.getName())) {
containsWildcard = true;
disallowed = !perm.getValue();
disallowedValid = true;
break;
}
}
Expand All @@ -75,7 +78,8 @@ public boolean hasPermission(String permission) {
PowerRanksVerbose.log("hasPermission", "Permission: " + permission);
PowerRanksVerbose.log("hasPermission",
"Permissions: '" + String.join(", ", getAllPermissionsFormatted(permissions)) + "'");
PowerRanksVerbose.log("hasPermission", "Is Disallowed: " + disallowed);
PowerRanksVerbose.log("hasPermission",
"Is Disallowed: " + disallowed + " (Valid: " + disallowedValid + ")");
PowerRanksVerbose.log("hasPermission", "Has *: " + getAllPermissions(permissions).contains("*"));
PowerRanksVerbose.log("hasPermission", "Is Operator: " + player.isOp());
// PowerRanksVerbose.log("hasPermission", "Return #3: " +
Expand All @@ -92,13 +96,13 @@ public boolean hasPermission(String permission) {
return false;
}

if (getAllPermissions(permissions).contains("*") || player.isOp()) {
if (getAllowedPermissions(permissions).contains("*") || player.isOp()) {
return true;
}

try {
return super.hasPermission(permission) || getAllowedPermissions(permissions).contains(permission)
|| !disallowed;
|| (disallowedValid && !disallowed);
} catch (Exception e) {
return getAllowedPermissions(permissions).contains(permission);
}
Expand Down

0 comments on commit 4ad4f6c

Please sign in to comment.