mirror of
https://github.com/essentials/Essentials.git
synced 2025-03-15 09:29:50 +01:00
Expanded 'canUserBuild()' to include inheritance and subgroups.
This commit is contained in:
parent
1606260680
commit
976cdb7868
@ -62,3 +62,4 @@ v 1.5:
|
|||||||
- Added Info node support to Global Groups.
|
- 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.
|
- 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.
|
- Added checking of subgroups for Info nodes.
|
||||||
|
- Expanded 'canUserBuild()' to include inheritance and subgroups.
|
@ -1183,6 +1183,7 @@ public class GroupManager extends JavaPlugin {
|
|||||||
if (!auxUser.isSubGroupsEmpty() && auxGroup2 == null)
|
if (!auxUser.isSubGroupsEmpty() && auxGroup2 == null)
|
||||||
for (Group subGroup : auxUser.subGroupListCopy()) {
|
for (Group subGroup : auxUser.subGroupListCopy()) {
|
||||||
auxGroup2 = permissionHandler.nextGroupWithVariable(subGroup, args[1]);
|
auxGroup2 = permissionHandler.nextGroupWithVariable(subGroup, args[1]);
|
||||||
|
if (auxGroup2 != null) continue;
|
||||||
}
|
}
|
||||||
if (auxGroup2 == null) {
|
if (auxGroup2 == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!");
|
sender.sendMessage(ChatColor.RED + "The user doesn't have access to that variable!");
|
||||||
|
@ -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
|
* @param world
|
||||||
* Player's world
|
* Player's world
|
||||||
@ -233,14 +233,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
* Player's name
|
* Player's name
|
||||||
* @return Whether the user can build
|
* @return Whether the user can build
|
||||||
*/
|
*/
|
||||||
public boolean canUserBuild(String user) {
|
public boolean canUserBuild(String userName) {
|
||||||
boolean test = ph.getUser(user).getVariables().getVarBoolean("build");
|
|
||||||
|
|
||||||
if (test) {
|
return getPermissionBoolean(userName, "build");
|
||||||
return test;
|
|
||||||
}
|
|
||||||
|
|
||||||
return canGroupBuild(getGroup(user));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,8 +433,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the variable value of the user, in INFO node. If not found, it
|
* 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
|
* will search for his Group variables. It will harvest the inheritance and
|
||||||
* and subgroups.
|
* subgroups.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param variable
|
* @param variable
|
||||||
@ -465,9 +460,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
for (Group subGroup : auser.subGroupListCopy()) {
|
for (Group subGroup : auser.subGroupListCopy()) {
|
||||||
result = nextGroupWithVariable(subGroup, variable);
|
result = nextGroupWithVariable(subGroup, variable);
|
||||||
// Found value?
|
// Found value?
|
||||||
if (result != null) continue;
|
if (result != null)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (result == null) return "";
|
if (result == null)
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
return result.getVariables().getVarString(variable);
|
return result.getVariables().getVarString(variable);
|
||||||
// return getUserPermissionString(user, 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
|
* 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
|
* will search for his Group variables. It will harvest the inheritance and
|
||||||
* and subgroups.
|
* subgroups.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param variable
|
* @param variable
|
||||||
@ -502,9 +499,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
for (Group subGroup : auser.subGroupListCopy()) {
|
for (Group subGroup : auser.subGroupListCopy()) {
|
||||||
result = nextGroupWithVariable(subGroup, variable);
|
result = nextGroupWithVariable(subGroup, variable);
|
||||||
// Found value?
|
// 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 result.getVariables().getVarInteger(variable);
|
||||||
// return getUserPermissionInteger(string, string1);
|
// 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
|
* 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
|
* will search for his Group variables. It will harvest the inheritance and
|
||||||
* and subgroups.
|
* subgroups.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param variable
|
* @param variable
|
||||||
@ -539,9 +538,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
for (Group subGroup : auser.subGroupListCopy()) {
|
for (Group subGroup : auser.subGroupListCopy()) {
|
||||||
result = nextGroupWithVariable(subGroup, variable);
|
result = nextGroupWithVariable(subGroup, variable);
|
||||||
// Found value?
|
// 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 result.getVariables().getVarBoolean(variable);
|
||||||
// return getUserPermissionBoolean(user, string1);
|
// 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
|
* 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
|
* will search for his Group variables. It will harvest the inheritance and
|
||||||
* and subgroups.
|
* subgroups.
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param variable
|
* @param variable
|
||||||
@ -576,9 +577,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||||||
for (Group subGroup : auser.subGroupListCopy()) {
|
for (Group subGroup : auser.subGroupListCopy()) {
|
||||||
result = nextGroupWithVariable(subGroup, variable);
|
result = nextGroupWithVariable(subGroup, variable);
|
||||||
// Found value?
|
// 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 result.getVariables().getVarDouble(variable);
|
||||||
// return getUserPermissionDouble(string, string1);
|
// return getUserPermissionDouble(string, string1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user