Skip to content

Commit ba78802

Browse files
Fix: permission check for integer flags (#4217)
* Changing numeric check to support '0' * Adding notes * More detailed description of 'max-plots' setting
1 parent be6838f commit ba78802

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public int hasPermissionRange(
158158
}
159159
final String[] nodes = stub.split("\\.");
160160
final StringBuilder n = new StringBuilder();
161+
// Wildcard check from less specific permission to more specific permission
161162
for (int i = 0; i < (nodes.length - 1); i++) {
162163
n.append(nodes[i]).append(".");
163164
if (!stub.equals(n + Permission.PERMISSION_STAR.toString())) {
@@ -166,9 +167,11 @@ public int hasPermissionRange(
166167
}
167168
}
168169
}
170+
// Wildcard check for the full permission
169171
if (hasPermission(stub + ".*")) {
170172
return Integer.MAX_VALUE;
171173
}
174+
// Permission value cache for iterative check
172175
int max = 0;
173176
if (CHECK_EFFECTIVE) {
174177
boolean hasAny = false;

Core/src/main/java/com/plotsquared/core/command/FlagCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ private static boolean checkPermValue(
103103
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
104104
try {
105105
int numeric = Integer.parseInt(value);
106+
// Getting full permission without ".<amount>" at the end
106107
perm = perm.substring(0, perm.length() - value.length() - 1);
107108
boolean result = false;
108-
if (numeric > 0) {
109+
if (numeric >= 0) {
109110
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
110111
numeric :
111112
Settings.Limit.MAX_PLOTS;

Core/src/main/java/com/plotsquared/core/configuration/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public static final class Limit {
522522
@Comment("Should the limit be global (over multiple worlds)")
523523
public static boolean GLOBAL =
524524
false;
525-
@Comment({"The max range of permissions to check for, e.g. plots.plot.127",
525+
@Comment({"The max range of integer permissions to check for, e.g. 'plots.plot.127' or 'plots.set.flag.mob-cap.127'",
526526
"The value covers the permission range to check, you need to assign the permission to players/groups still",
527527
"Modifying the value does NOT change the amount of plots players can claim"})
528528
public static int MAX_PLOTS = 127;

Core/src/main/java/com/plotsquared/core/permissions/PermissionHolder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ default int hasPermissionRange(
100100
}
101101
String[] nodes = stub.split("\\.");
102102
StringBuilder builder = new StringBuilder();
103+
// Wildcard check from less specific permission to more specific permission
103104
for (int i = 0; i < (nodes.length - 1); i++) {
104105
builder.append(nodes[i]).append(".");
105106
if (!stub.equals(builder + Permission.PERMISSION_STAR.toString())) {
@@ -108,6 +109,7 @@ default int hasPermissionRange(
108109
}
109110
}
110111
}
112+
// Wildcard check for the full permission
111113
if (hasPermission(stub + ".*")) {
112114
return Integer.MAX_VALUE;
113115
}

0 commit comments

Comments
 (0)