Add permissions for landlords to remove regions

Closes #33
This commit is contained in:
Thijs Wiefferink 2015-07-31 22:56:12 +02:00
parent 9f436a7eb4
commit 25c56e8ecb
3 changed files with 22 additions and 9 deletions

View File

@ -36,7 +36,11 @@ public class DelCommand extends CommandAreaShop {
@Override
public void execute(CommandSender sender, Command command, String[] args) {
if(!sender.hasPermission("areashop.destroybuy") && !sender.hasPermission("areashop.destroyrent")) {
if( !sender.hasPermission("areashop.destroybuy")
&& !sender.hasPermission("areashop.destroybuy.landlord")
&& !sender.hasPermission("areashop.destroyrent")
&& !sender.hasPermission("areashop.destroyrent.landlord")) {
plugin.message(sender, "del-noPermission");
return;
}
@ -61,15 +65,16 @@ public class DelCommand extends CommandAreaShop {
ArrayList<String> namesSuccess = new ArrayList<String>();
ArrayList<String> namesFailed = new ArrayList<String>();
for(GeneralRegion region : regions) {
boolean isLandlord = sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId());
if(region.isRentRegion()) {
if(!sender.hasPermission("areashop.destroyrent")) {
if(!sender.hasPermission("areashop.destroyrent") && !(isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
namesFailed.add(region.getName());
} else {
plugin.getFileManager().removeRent((RentRegion)region, true);
namesSuccess.add(region.getName());
}
} else if(region.isBuyRegion()) {
if(!sender.hasPermission("areashop.destroybuy")) {
if(!sender.hasPermission("areashop.destroybuy") && !(isLandlord && sender.hasPermission("areashop.destroybuy.landlord"))) {
namesFailed.add(region.getName());
} else {
plugin.getFileManager().removeBuy((BuyRegion)region, true);
@ -90,9 +95,10 @@ public class DelCommand extends CommandAreaShop {
plugin.message(sender, "del-noRegion", args[1]);
return;
}
boolean isLandlord = sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId());
if(region.isRentRegion()) {
/* Remove the rent if the player has permission */
if(sender.hasPermission("areashop.destroyrent")) {
if(sender.hasPermission("areashop.destroyrent") || (isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
plugin.getFileManager().removeRent((RentRegion)region, true);
plugin.message(sender, "destroy-successRent", region.getName());
} else {
@ -100,14 +106,13 @@ public class DelCommand extends CommandAreaShop {
}
} else if(region.isBuyRegion()) {
/* Remove the buy if the player has permission */
if(sender.hasPermission("areashop.destroybuy")) {
if(sender.hasPermission("areashop.destroybuy") || (isLandlord && sender.hasPermission("areashop.destroybuy.landlord"))) {
plugin.getFileManager().removeBuy((BuyRegion)region, true);
plugin.message(sender, "destroy-successBuy", region.getName());
} else {
plugin.message(sender, "destroy-noPermissionBuy");
}
}
}
}

View File

@ -45,7 +45,7 @@ public final class SignBreakListener implements Listener {
if(region == null) {
return;
}
/* Remove the rent if the player has permission */
/* Remove the sign of the rental region if the player has permission */
if(event.getPlayer().hasPermission("areashop.delsign")) {
region.removeSign(block.getLocation());
plugin.message(event.getPlayer(), "delsign-success", region.getName());

View File

@ -60,6 +60,8 @@ permissions:
areashop.createbuy.owner: true
areashop.setprice.landlord: true
areashop.setduration.landlord: true
areashop.destroyrent.landlord: true
areashop.destroybuy.landlord: true
areashop.help:
description: Allows you to see the help pages
default: true
@ -100,11 +102,17 @@ permissions:
description: Allows you to add buy regions to AreaShop for which you are registered as owner
default: false
areashop.destroyrent:
description: Allows you to break signs used for renting regions
description: Allows you remove rental regions from AreaShop
default: op
areashop.destroyrent.landlord:
description: Allows you to remove rental regions from AreaShop when you are the landlord
default: false
areashop.destroybuy:
description: Allows you to break signs used for renting regions
description: Allows you to remove buy regions from AreaShop
default: op
areashop.destroybuy.landlord:
description: Allows you to remove buy regions from AreaShop when you are the landlord
default: false
areashop.info:
description: Allows you check the status of regions and players
default: true