From 1fd02b8a4ad82427f96e1870252a31375d58c2f5 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Mon, 31 Oct 2011 20:20:57 +0000 Subject: Expanded 'canUserBuild()' to include inheritance and subgroups. --- EssentialsGroupManager/src/Changelog.txt | 3 +- .../org/anjocaido/groupmanager/GroupManager.java | 1 + .../permissions/AnjoPermissionsHandler.java | 51 ++++++++++++---------- 3 files changed, 30 insertions(+), 25 deletions(-) (limited to 'EssentialsGroupManager/src') diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index b2a85568f..aef900781 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -61,4 +61,5 @@ v 1.5: Create groups in the yml with a g: prefix, then inherit in the worlds groups files. - Added Info node support to Global Groups. - Fixed an error on 'manucheckv'. If the users doesn't have the variable it fell through causing an exception. - - Added checking of subgroups for Info nodes. \ No newline at end of file + - Added checking of subgroups for Info nodes. + - Expanded 'canUserBuild()' to include inheritance and subgroups. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index ebb63653a..e3999d212 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -1183,6 +1183,7 @@ public class GroupManager extends JavaPlugin { if (!auxUser.isSubGroupsEmpty() && auxGroup2 == null) for (Group subGroup : auxUser.subGroupListCopy()) { auxGroup2 = permissionHandler.nextGroupWithVariable(subGroup, args[1]); + if (auxGroup2 != null) continue; } if (auxGroup2 == null) { sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!"); diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java index e7939c411..e7ece0575 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java @@ -225,7 +225,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { } /** - * Check if user can build. + * Check if user can build. Checks inheritance and subgroups. * * @param world * Player's world @@ -233,14 +233,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { * Player's name * @return Whether the user can build */ - public boolean canUserBuild(String user) { - boolean test = ph.getUser(user).getVariables().getVarBoolean("build"); + public boolean canUserBuild(String userName) { - if (test) { - return test; - } - - return canGroupBuild(getGroup(user)); + return getPermissionBoolean(userName, "build"); } @@ -438,8 +433,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { /** * Returns the variable value of the user, in INFO node. If not found, it - * will search for his Group variables. It will harvest the inheritance - * and subgroups. + * will search for his Group variables. It will harvest the inheritance and + * subgroups. * * @param user * @param variable @@ -465,9 +460,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { for (Group subGroup : auser.subGroupListCopy()) { result = nextGroupWithVariable(subGroup, variable); // Found value? - if (result != null) continue; + if (result != null) + continue; } - if (result == null) return ""; + if (result == null) + return ""; } return result.getVariables().getVarString(variable); // return getUserPermissionString(user, variable); @@ -475,8 +472,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { /** * Returns the variable value of the user, in INFO node. If not found, it - * will search for his Group variables. It will harvest the inheritance - * and subgroups. + * will search for his Group variables. It will harvest the inheritance and + * subgroups. * * @param user * @param variable @@ -502,9 +499,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { for (Group subGroup : auser.subGroupListCopy()) { result = nextGroupWithVariable(subGroup, variable); // Found value? - if (result != null) continue; + if (result != null) + continue; } - if (result == null) return -1; + if (result == null) + return -1; } return result.getVariables().getVarInteger(variable); // return getUserPermissionInteger(string, string1); @@ -512,8 +511,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { /** * Returns the variable value of the user, in INFO node. If not found, it - * will search for his Group variables. It will harvest the inheritance - * and subgroups. + * will search for his Group variables. It will harvest the inheritance and + * subgroups. * * @param user * @param variable @@ -539,9 +538,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { for (Group subGroup : auser.subGroupListCopy()) { result = nextGroupWithVariable(subGroup, variable); // Found value? - if (result != null) continue; + if (result != null) + continue; } - if (result == null) return false; + if (result == null) + return false; } return result.getVariables().getVarBoolean(variable); // return getUserPermissionBoolean(user, string1); @@ -549,8 +550,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { /** * Returns the variable value of the user, in INFO node. If not found, it - * will search for his Group variables. It will harvest the inheritance - * and subgroups. + * will search for his Group variables. It will harvest the inheritance and + * subgroups. * * @param user * @param variable @@ -576,9 +577,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface { for (Group subGroup : auser.subGroupListCopy()) { result = nextGroupWithVariable(subGroup, variable); // Found value? - if (result != null) continue; + if (result != null) + continue; } - if (result == null) return -1.0D; + if (result == null) + return -1.0D; } return result.getVariables().getVarDouble(variable); // return getUserPermissionDouble(string, string1); -- cgit v1.2.3