mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 15:48:10 +01:00
Offering a sacrifice to the gods of pedantry. canX() -> mayX() for permissions.
This commit is contained in:
parent
d61e32ebb5
commit
532a45f9e7
@ -34,81 +34,81 @@ public RegionPermissionModel(WorldGuardPlugin plugin, CommandSender sender) {
|
|||||||
super(plugin, sender);
|
super(plugin, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canForceLoadRegions() {
|
public boolean mayForceLoadRegions() {
|
||||||
return hasPluginPermission("region.load");
|
return hasPluginPermission("region.load");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canForceSaveRegions() {
|
public boolean mayForceSaveRegions() {
|
||||||
return hasPluginPermission("region.save");
|
return hasPluginPermission("region.save");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canMigrateRegionStore() {
|
public boolean mayMigrateRegionStore() {
|
||||||
return hasPluginPermission("region.migratedb");
|
return hasPluginPermission("region.migratedb");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDefine() {
|
public boolean mayDefine() {
|
||||||
return hasPluginPermission("region.define");
|
return hasPluginPermission("region.define");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRedefine(ProtectedRegion region) {
|
public boolean mayRedefine(ProtectedRegion region) {
|
||||||
return hasPatternPermission("redefine", region);
|
return hasPatternPermission("redefine", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canClaim() {
|
public boolean mayClaim() {
|
||||||
return hasPluginPermission("region.claim");
|
return hasPluginPermission("region.claim");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canClaimRegionsUnbounded() {
|
public boolean mayClaimRegionsUnbounded() {
|
||||||
return hasPluginPermission("region.unlimited");
|
return hasPluginPermission("region.unlimited");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDelete(ProtectedRegion region) {
|
public boolean mayDelete(ProtectedRegion region) {
|
||||||
return hasPatternPermission("remove", region);
|
return hasPatternPermission("remove", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSetPriority(ProtectedRegion region) {
|
public boolean maySetPriority(ProtectedRegion region) {
|
||||||
return hasPatternPermission("setpriority", region);
|
return hasPatternPermission("setpriority", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSetParent(ProtectedRegion child, ProtectedRegion parent) {
|
public boolean maySetParent(ProtectedRegion child, ProtectedRegion parent) {
|
||||||
return hasPatternPermission("setparent", child) &&
|
return hasPatternPermission("setparent", child) &&
|
||||||
(parent == null ||
|
(parent == null ||
|
||||||
hasPatternPermission("setparent", parent));
|
hasPatternPermission("setparent", parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSelect(ProtectedRegion region) {
|
public boolean maySelect(ProtectedRegion region) {
|
||||||
return hasPatternPermission("select", region);
|
return hasPatternPermission("select", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canLookup(ProtectedRegion region) {
|
public boolean mayLookup(ProtectedRegion region) {
|
||||||
return hasPatternPermission("info", region);
|
return hasPatternPermission("info", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTeleportTo(ProtectedRegion region) {
|
public boolean mayTeleportTo(ProtectedRegion region) {
|
||||||
return hasPatternPermission("teleport", region);
|
return hasPatternPermission("teleport", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canList() {
|
public boolean mayList() {
|
||||||
return hasPluginPermission("region.list");
|
return hasPluginPermission("region.list");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canList(String targetPlayer) {
|
public boolean mayList(String targetPlayer) {
|
||||||
if (targetPlayer == null) {
|
if (targetPlayer == null) {
|
||||||
return canList();
|
return mayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetPlayer.equalsIgnoreCase(getSender().getName())) {
|
if (targetPlayer.equalsIgnoreCase(getSender().getName())) {
|
||||||
return hasPluginPermission("region.list.own");
|
return hasPluginPermission("region.list.own");
|
||||||
} else {
|
} else {
|
||||||
return canList();
|
return mayList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSetFlag(ProtectedRegion region) {
|
public boolean maySetFlag(ProtectedRegion region) {
|
||||||
return hasPatternPermission("flag", region);
|
return hasPatternPermission("flag", region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSetFlag(ProtectedRegion region, Flag<?> flag) {
|
public boolean maySetFlag(ProtectedRegion region, Flag<?> flag) {
|
||||||
// This is a WTF permission
|
// This is a WTF permission
|
||||||
return hasPatternPermission(
|
return hasPatternPermission(
|
||||||
"flag.flags." + flag.getName().toLowerCase(), region);
|
"flag.flags." + flag.getName().toLowerCase(), region);
|
||||||
|
@ -377,7 +377,7 @@ public void define(CommandContext args, CommandSender sender)
|
|||||||
Player player = plugin.checkPlayer(sender);
|
Player player = plugin.checkPlayer(sender);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canDefine()) {
|
if (!getPermissionModel(sender).mayDefine()) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ public void redefine(CommandContext args, CommandSender sender)
|
|||||||
ProtectedRegion existing = findExistingRegion(regionManager, id, false);
|
ProtectedRegion existing = findExistingRegion(regionManager, id, false);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canRedefine(existing)) {
|
if (!getPermissionModel(sender).mayRedefine(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
|||||||
RegionPermissionModel permModel = getPermissionModel(sender);
|
RegionPermissionModel permModel = getPermissionModel(sender);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!permModel.canClaim()) {
|
if (!permModel.mayClaim()) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
|||||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(player.getWorld());
|
||||||
|
|
||||||
// Check whether the player has created too many regions
|
// Check whether the player has created too many regions
|
||||||
if (!permModel.canClaimRegionsUnbounded()) {
|
if (!permModel.mayClaimRegionsUnbounded()) {
|
||||||
int maxRegionCount = wcfg.getMaxRegionCount(player);
|
int maxRegionCount = wcfg.getMaxRegionCount(player);
|
||||||
if (maxRegionCount >= 0
|
if (maxRegionCount >= 0
|
||||||
&& mgr.getRegionCountOfPlayer(localPlayer) >= maxRegionCount) {
|
&& mgr.getRegionCountOfPlayer(localPlayer) >= maxRegionCount) {
|
||||||
@ -558,7 +558,7 @@ public void claim(CommandContext args, CommandSender sender) throws CommandExcep
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check claim volume
|
// Check claim volume
|
||||||
if (!permModel.canClaimRegionsUnbounded()) {
|
if (!permModel.mayClaimRegionsUnbounded()) {
|
||||||
if (region.volume() > wcfg.maxClaimVolume) {
|
if (region.volume() > wcfg.maxClaimVolume) {
|
||||||
player.sendMessage(ChatColor.RED + "This region is too large to claim.");
|
player.sendMessage(ChatColor.RED + "This region is too large to claim.");
|
||||||
player.sendMessage(ChatColor.RED +
|
player.sendMessage(ChatColor.RED +
|
||||||
@ -622,7 +622,7 @@ public void select(CommandContext args, CommandSender sender) throws CommandExce
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canSelect(existing)) {
|
if (!getPermissionModel(sender).maySelect(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +662,7 @@ public void info(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!permModel.canLookup(existing)) {
|
if (!permModel.mayLookup(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ public void info(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
// Let the player also select the region
|
// Let the player also select the region
|
||||||
if (args.hasFlag('s')) {
|
if (args.hasFlag('s')) {
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!permModel.canSelect(existing)) {
|
if (!permModel.maySelect(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ public void list(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canList(ownedBy)) {
|
if (!getPermissionModel(sender).mayList(ownedBy)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
args.getString(0), false);
|
args.getString(0), false);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!permModel.canSetFlag(existing)) {
|
if (!permModel.maySetFlag(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
// Need to build a list
|
// Need to build a list
|
||||||
for (Flag<?> flag : DefaultFlag.getFlags()) {
|
for (Flag<?> flag : DefaultFlag.getFlags()) {
|
||||||
// Can the user set this flag?
|
// Can the user set this flag?
|
||||||
if (!permModel.canSetFlag(existing, flag)) {
|
if (!permModel.maySetFlag(existing, flag)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +820,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
// Also make sure that we can use this flag
|
// Also make sure that we can use this flag
|
||||||
// This permission is confusing and probably should be replaced, but
|
// This permission is confusing and probably should be replaced, but
|
||||||
// but not here -- in the model
|
// but not here -- in the model
|
||||||
if (!permModel.canSetFlag(existing, foundFlag)) {
|
if (!permModel.maySetFlag(existing, foundFlag)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,7 +924,7 @@ public void setPriority(CommandContext args, CommandSender sender)
|
|||||||
args.getString(0), false);
|
args.getString(0), false);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canSetPriority(existing)) {
|
if (!getPermissionModel(sender).maySetPriority(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,7 +965,7 @@ public void setParent(CommandContext args, CommandSender sender) throws CommandE
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canSetParent(child, parent)) {
|
if (!getPermissionModel(sender).maySetParent(child, parent)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,7 +1024,7 @@ public void remove(CommandContext args, CommandSender sender) throws CommandExce
|
|||||||
args.getString(0), true);
|
args.getString(0), true);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canDelete(existing)) {
|
if (!getPermissionModel(sender).mayDelete(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,7 +1048,7 @@ public void load(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
World world = getWorld(args, sender, 'w'); // Get the world
|
World world = getWorld(args, sender, 'w'); // Get the world
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canForceLoadRegions()) {
|
if (!getPermissionModel(sender).mayForceLoadRegions()) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,7 +1071,7 @@ public void save(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
World world = getWorld(args, sender, 'w'); // Get the world
|
World world = getWorld(args, sender, 'w'); // Get the world
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canForceSaveRegions()) {
|
if (!getPermissionModel(sender).mayForceSaveRegions()) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1092,7 +1092,7 @@ public void save(CommandContext args, CommandSender sender) throws CommandExcept
|
|||||||
desc = "Migrate from one Protection Database to another.", min = 1)
|
desc = "Migrate from one Protection Database to another.", min = 1)
|
||||||
public void migrateDB(CommandContext args, CommandSender sender) throws CommandException {
|
public void migrateDB(CommandContext args, CommandSender sender) throws CommandException {
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canMigrateRegionStore()) {
|
if (!getPermissionModel(sender).mayMigrateRegionStore()) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,7 +1165,7 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx
|
|||||||
args.getString(0), false);
|
args.getString(0), false);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if (!getPermissionModel(sender).canTeleportTo(existing)) {
|
if (!getPermissionModel(sender).mayTeleportTo(existing)) {
|
||||||
throw new CommandPermissionsException();
|
throw new CommandPermissionsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user