Merge remote-tracking branch 'origin/groupmanager' into 2.9

This commit is contained in:
snowleo 2013-01-18 01:01:23 +01:00
commit 6fdeddd96b
2 changed files with 33 additions and 16 deletions

View File

@ -242,15 +242,10 @@ groups:
g:towny_default:
permissions:
- towny.chat.general
- towny.chat.local
g:towny_builder:
permissions:
- towny.town.*
- towny.nation.*
- towny.chat.town
- towny.chat.nation
- towny.wild.build.6
- towny.wild.destroy.6
- towny.wild.destroy.14

View File

@ -768,6 +768,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
}
/**
* Wrapper for offline server checks.
* Looks for the 'groupmanager.noofflineperms' permissions and reports no permissions on servers set to offline.
*
* Check user and groups with inheritance and Bukkit if bukkit = true return
* a PermissionCheckResult.
*
@ -778,22 +781,41 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
*/
public PermissionCheckResult checkFullGMPermission(User user, String targetPermission, Boolean checkBukkit) {
PermissionCheckResult result = new PermissionCheckResult();
result.accessLevel = targetPermission;
result.resultType = PermissionCheckResult.Type.NOTFOUND;
if (user == null || targetPermission == null || targetPermission.isEmpty()) {
return result;
}
/*
* Do not push any perms to bukkit if...
* Report no permissions under the following conditions.
*
* We are in offline mode
* and the player has the 'groupmanager.noofflineperms' permission.
*/
if (!Bukkit.getServer().getOnlineMode()
&& (checkFullGMPermission(user, "groupmanager.noofflineperms", true).resultType == PermissionCheckResult.Type.FOUND))
if (user == null || targetPermission == null || targetPermission.isEmpty() ||
(!Bukkit.getServer().getOnlineMode()
&& (checkPermission(user, "groupmanager.noofflineperms", true).resultType == PermissionCheckResult.Type.FOUND))) {
PermissionCheckResult result = new PermissionCheckResult();
result.accessLevel = targetPermission;
result.resultType = PermissionCheckResult.Type.NOTFOUND;
return result;
}
return checkPermission(user, targetPermission, checkBukkit);
}
/**
*
* Check user and groups with inheritance and Bukkit if bukkit = true return
* a PermissionCheckResult.
*
* @param user
* @param targetPermission
* @param checkBukkit
* @return PermissionCheckResult
*/
private PermissionCheckResult checkPermission(User user, String targetPermission, Boolean checkBukkit) {
PermissionCheckResult result = new PermissionCheckResult();
result.accessLevel = targetPermission;
result.resultType = PermissionCheckResult.Type.NOTFOUND;
if (checkBukkit) {
// Check Bukkit perms to support plugins which add perms via code