mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-19 16:59:36 +01:00
Fix block list flag permissions
This commit is contained in:
parent
7edfc313d6
commit
7e56e47046
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flag.*;
|
import com.github.intellectualsites.plotsquared.plot.flag.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
|
|
||||||
@ -30,13 +31,37 @@ import java.util.*;
|
|||||||
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
|
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
|
||||||
numeric :
|
numeric :
|
||||||
Settings.Limit.MAX_PLOTS;
|
Settings.Limit.MAX_PLOTS;
|
||||||
return player.hasPermissionRange(perm, checkRange) >= numeric;
|
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE
|
||||||
|
.f(key.toLowerCase(), value.toLowerCase()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
}
|
}
|
||||||
|
} else if (flag instanceof PlotBlockListFlag) {
|
||||||
|
final PlotBlockListFlag blockListFlag = (PlotBlockListFlag) flag;
|
||||||
|
final HashSet<PlotBlock> parsedBlocks = blockListFlag.parseValue(value);
|
||||||
|
for (final PlotBlock block : parsedBlocks) {
|
||||||
|
final String permission = C.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(),
|
||||||
|
block.getRawId().toString().toLowerCase());
|
||||||
|
final boolean result = Permissions.hasPermission(player, permission);
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE
|
||||||
|
.f(key.toLowerCase(), value.toLowerCase()));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return Permissions.hasPermission(player, perm);
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final boolean result = Permissions.hasPermission(player, perm);
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE
|
||||||
|
.f(key.toLowerCase(), value.toLowerCase()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||||
@ -116,8 +141,6 @@ import java.util.*;
|
|||||||
}
|
}
|
||||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
if (!checkPermValue(player, flag, args[1], value)) {
|
if (!checkPermValue(player, flag, args[1], value)) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE
|
|
||||||
.f(args[1].toLowerCase(), value.toLowerCase()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Object parsed = flag.parseValue(value);
|
Object parsed = flag.parseValue(value);
|
||||||
@ -152,8 +175,6 @@ import java.util.*;
|
|||||||
}
|
}
|
||||||
for (String entry : args[2].split(",")) {
|
for (String entry : args[2].split(",")) {
|
||||||
if (!checkPermValue(player, flag, args[1], entry)) {
|
if (!checkPermValue(player, flag, args[1], entry)) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
|
||||||
C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,8 +221,6 @@ import java.util.*;
|
|||||||
}
|
}
|
||||||
for (String entry : args[2].split(",")) {
|
for (String entry : args[2].split(",")) {
|
||||||
if (!checkPermValue(player, flag, args[1], entry)) {
|
if (!checkPermValue(player, flag, args[1], entry)) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
|
||||||
C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,7 +265,7 @@ import java.util.*;
|
|||||||
for (Flag<?> flag1 : Flags.getFlags()) {
|
for (Flag<?> flag1 : Flags.getFlags()) {
|
||||||
String type = flag1.getClass().getSimpleName();
|
String type = flag1.getClass().getSimpleName();
|
||||||
if (!flags.containsKey(type)) {
|
if (!flags.containsKey(type)) {
|
||||||
flags.put(type, new ArrayList<String>());
|
flags.put(type, new ArrayList<>());
|
||||||
}
|
}
|
||||||
flags.get(type).add(flag1.getName());
|
flags.get(type).add(flag1.getName());
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
|
|||||||
return StringMan.join((HashSet<PlotBlock>) value, ",");
|
return StringMan.join((HashSet<PlotBlock>) value, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HashSet<PlotBlock> parseValue(String value) {
|
@Override public HashSet<PlotBlock> parseValue(final String value) {
|
||||||
HashSet<PlotBlock> list = new HashSet<>();
|
final HashSet<PlotBlock> list = new HashSet<>();
|
||||||
for (String item : value.split(",")) {
|
for (final String item : value.split(",")) {
|
||||||
PlotBlock block = PlotSquared.get().IMP.getLegacyMappings().fromAny(item);
|
final PlotBlock block = PlotSquared.get().IMP.getLegacyMappings().fromAny(item);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
list.add(block);
|
list.add(block);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user