Permalink
Browse files

fix permission clashing

If a person has for example worldguard permission, the
checkForSelectionRights doesn't check for example if you have lwc
permission rights. Fix this by saving the results of each check and at
the end return them all.
  • Loading branch information...
1 parent d2c52d3 commit a170be176c24415f9fb9b1cf6cce3a938cb8e437 @azatoth committed Apr 19, 2012
Showing with 19 additions and 10 deletions.
  1. +19 −10 src/main/java/me/DDoS/Quicksign/handler/SelectionHandler.java
View
29 src/main/java/me/DDoS/Quicksign/handler/SelectionHandler.java
@@ -273,6 +273,7 @@ private boolean checkForLWCPerms(Player player, Location loc, boolean forceProte
public boolean checkForSelectionRights(Player player, Location location) {
World world = location.getWorld();
+ boolean wgperm = false, residenceperm = false, regiosperm = false, lwcperm = false;
if (wg == null && !residence && regiosAPI == null && lwc == null) {
@@ -291,77 +292,85 @@ public boolean checkForSelectionRights(Player player, Location location) {
if (plugin.hasPermissions(player, Permission.WG_MEMBER)
&& checkForWGMembership(player, location, world)) {
- return true;
+ wgperm = true;
}
if (plugin.hasPermissions(player, Permission.WG_OWNER)
&& checkForWGOwnership(player, location, world)) {
- return true;
+ wgperm = true;
}
if (plugin.hasPermissions(player, Permission.WG_CAN_BUILD)
&& checkForWGBuildPermissions(player, location, world)) {
- return true;
+ wgperm = true;
}
+ } else {
+ wgperm = true;
}
if (residence) {
if (plugin.hasPermissions(player, Permission.RS_CAN_BUILD_FP)
&& checkForResidencePerms(world, location, player, true)) {
- return true;
+ residenceperm = true;
}
if (plugin.hasPermissions(player, Permission.RS_CAN_BUILD)
&& checkForResidencePerms(world, location, player, false)) {
- return true;
+ residenceperm = true;
}
+ } else {
+ residenceperm = true;
}
if (regiosAPI != null) {
if (plugin.hasPermissions(player, Permission.RE_CAN_BUILD_FP)
&& checkForRegiosPerms(player, true)) {
- return true;
+ regiosperm = true;
}
if (plugin.hasPermissions(player, Permission.RE_CAN_BUILD)
&& checkForRegiosPerms(player, false)) {
- return true;
+ regiosperm = true;
}
+ } else {
+ regiosperm = true;
}
if (lwc != null) {
if (plugin.hasPermissions(player, Permission.LWC_CAN_ACCESS_FP)
&& checkForLWCPerms(player, location, true)) {
- return true;
+ lwcperm = true;
}
if (plugin.hasPermissions(player, Permission.LWC_CAN_ACCESS)
&& checkForLWCPerms(player, location, false)) {
- return true;
+ lwcperm = true;
}
+ } else {
+ lwcperm = true;
}
- return false;
+ return wgperm && residenceperm && regiosperm && lwcperm;
}

0 comments on commit a170be1

Please sign in to comment.