Skip to content

Commit

Permalink
Add permissions for landlords to remove regions
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
NLthijs48 committed Jul 31, 2015
1 parent 9f436a7 commit 25c56e8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public String getHelp(CommandSender target) {

@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;
}
Expand All @@ -61,15 +65,16 @@ public void execute(CommandSender sender, Command command, String[] args) {
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);
Expand All @@ -90,24 +95,24 @@ public void execute(CommandSender sender, Command command, String[] args) {
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 {
plugin.message(sender, "destroy-noPermissionRent");
}
} 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");
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onSignBreak(BlockBreakEvent event) {
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());
Expand Down
12 changes: 10 additions & 2 deletions AreaShop/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25c56e8

Please sign in to comment.