mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-05 09:20:52 +01:00
Fix: permission check for integer flags (#4217)
* Changing numeric check to support '0' * Adding notes * More detailed description of 'max-plots' setting
This commit is contained in:
parent
be6838f29e
commit
ba7880241b
@ -158,6 +158,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
final String[] nodes = stub.split("\\.");
|
||||
final StringBuilder n = new StringBuilder();
|
||||
// Wildcard check from less specific permission to more specific permission
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i]).append(".");
|
||||
if (!stub.equals(n + Permission.PERMISSION_STAR.toString())) {
|
||||
@ -166,9 +167,11 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Wildcard check for the full permission
|
||||
if (hasPermission(stub + ".*")) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
// Permission value cache for iterative check
|
||||
int max = 0;
|
||||
if (CHECK_EFFECTIVE) {
|
||||
boolean hasAny = false;
|
||||
|
@ -103,9 +103,10 @@ public final class FlagCommand extends Command {
|
||||
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
|
||||
try {
|
||||
int numeric = Integer.parseInt(value);
|
||||
// Getting full permission without ".<amount>" at the end
|
||||
perm = perm.substring(0, perm.length() - value.length() - 1);
|
||||
boolean result = false;
|
||||
if (numeric > 0) {
|
||||
if (numeric >= 0) {
|
||||
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
|
||||
numeric :
|
||||
Settings.Limit.MAX_PLOTS;
|
||||
|
@ -522,7 +522,7 @@ public class Settings extends Config {
|
||||
@Comment("Should the limit be global (over multiple worlds)")
|
||||
public static boolean GLOBAL =
|
||||
false;
|
||||
@Comment({"The max range of permissions to check for, e.g. plots.plot.127",
|
||||
@Comment({"The max range of integer permissions to check for, e.g. 'plots.plot.127' or 'plots.set.flag.mob-cap.127'",
|
||||
"The value covers the permission range to check, you need to assign the permission to players/groups still",
|
||||
"Modifying the value does NOT change the amount of plots players can claim"})
|
||||
public static int MAX_PLOTS = 127;
|
||||
|
@ -100,6 +100,7 @@ public interface PermissionHolder {
|
||||
}
|
||||
String[] nodes = stub.split("\\.");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// Wildcard check from less specific permission to more specific permission
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
builder.append(nodes[i]).append(".");
|
||||
if (!stub.equals(builder + Permission.PERMISSION_STAR.toString())) {
|
||||
@ -108,6 +109,7 @@ public interface PermissionHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Wildcard check for the full permission
|
||||
if (hasPermission(stub + ".*")) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user