mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Permission check fix
This commit is contained in:
@ -60,7 +60,12 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
PS.log(message);
|
||||
|
@ -60,7 +60,12 @@ public class Permissions {
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(CommandCaller caller, String permission) {
|
||||
if (caller.hasPermission(permission) || caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
if (caller.hasPermission(permission)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(permission)) {
|
||||
return false;
|
||||
}
|
||||
if (caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
return true;
|
||||
}
|
||||
permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", "");
|
||||
@ -68,9 +73,12 @@ public class Permissions {
|
||||
StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i <= (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
if (!permission.equals(n + C.PERMISSION_STAR.s())) {
|
||||
if (caller.hasPermission(n + C.PERMISSION_STAR.s())) {
|
||||
String combined = n + C.PERMISSION_STAR.s();
|
||||
if (!permission.equals(combined)) {
|
||||
if (caller.hasPermission(combined)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(combined)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public interface CommandCaller {
|
||||
* @param permission the name of the permission
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
boolean isPermissionSet(String permission);
|
||||
|
||||
RequiredType getSuperCaller();
|
||||
}
|
||||
|
Reference in New Issue
Block a user