mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-09-28 22:57:29 +02:00
Add permissions for individual flag values.
Closes WORLDGUARD-3103.
This commit is contained in:
parent
d8dd86dfe8
commit
0900289437
@ -519,7 +519,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
||||
// Also make sure that we can use this flag
|
||||
// This permission is confusing and probably should be replaced, but
|
||||
// but not here -- in the model
|
||||
if (!permModel.maySetFlag(existing, foundFlag)) {
|
||||
if (!permModel.maySetFlag(existing, foundFlag, value)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
|
@ -117,13 +117,25 @@ public boolean mayList(String targetPlayer) {
|
||||
public boolean maySetFlag(ProtectedRegion region) {
|
||||
return hasPatternPermission("flag.regions", region);
|
||||
}
|
||||
|
||||
|
||||
public boolean maySetFlag(ProtectedRegion region, Flag<?> flag) {
|
||||
// This is a WTF permission
|
||||
return hasPatternPermission(
|
||||
"flag.flags." + flag.getName().toLowerCase(), region);
|
||||
}
|
||||
|
||||
public boolean maySetFlag(ProtectedRegion region, Flag<?> flag, String value) {
|
||||
String sanitizedValue = value.trim().toLowerCase().replaceAll("[^a-z0-9]", "");
|
||||
|
||||
if (sanitizedValue.length() > 20) {
|
||||
sanitizedValue = sanitizedValue.substring(0, 20);
|
||||
}
|
||||
|
||||
// This is a WTF permission
|
||||
return hasPatternPermission(
|
||||
"flag.flags." + flag.getName().toLowerCase() + "." + sanitizedValue, region);
|
||||
}
|
||||
|
||||
public boolean mayAddMembers(ProtectedRegion region) {
|
||||
return hasPatternPermission("addmember", region);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user