summaryrefslogtreecommitdiffstats
path: root/EssentialsGroupManager/src/org
diff options
context:
space:
mode:
authorElgarL <ElgarL@palmergames.com>2011-11-24 15:28:32 +0000
committerElgarL <ElgarL@palmergames.com>2011-11-24 15:28:32 +0000
commit73a7a6a1ddbddb294254b0d271a2928509db574f (patch)
treedc91bb3c8aca76c1a91f871a716f989e49e75ec3 /EssentialsGroupManager/src/org
parentdec7ea19268d0e4624c3bbb7da0f3a1b52e69c72 (diff)
downloadEssentials-73a7a6a1ddbddb294254b0d271a2928509db574f.tar
Essentials-73a7a6a1ddbddb294254b0d271a2928509db574f.tar.gz
Essentials-73a7a6a1ddbddb294254b0d271a2928509db574f.tar.lz
Essentials-73a7a6a1ddbddb294254b0d271a2928509db574f.tar.xz
Essentials-73a7a6a1ddbddb294254b0d271a2928509db574f.zip
Optimize comparePermissionString
Diffstat (limited to 'EssentialsGroupManager/src/org')
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index feec3f17f..94052bb25 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -9,6 +9,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.logging.Level;
+
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.dataholder.WorldDataHolder;
@@ -698,7 +700,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
}
// Check Bukkit perms to support plugins which add perms via code (Heroes).
- if ((Bukkit.getPlayer(user.getName()) != null) && (Bukkit.getPlayer(user.getName()).hasPermission(targetPermission))) {
+ final Player player = Bukkit.getPlayer(user.getName());
+ if ((player != null) && (player.hasPermission(targetPermission))) {
result.resultType = PermissionCheckResult.Type.FOUND;
result.owner = user;
return result;
@@ -967,7 +970,10 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if (userAcessLevel == null || fullPermissionName == null) {
return false;
}
- GroupManager.logger.finest("COMPARING " + userAcessLevel + " WITH " + fullPermissionName);
+ boolean logFinest = (GroupManager.logger.getLevel() == Level.FINEST);
+
+ if (logFinest)
+ GroupManager.logger.finest("COMPARING " + userAcessLevel + " WITH " + fullPermissionName);
if (userAcessLevel.startsWith("+")) {
userAcessLevel = userAcessLevel.substring(1);
@@ -986,25 +992,31 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
while (levelATokenizer.hasMoreTokens() && levelBTokenizer.hasMoreTokens()) {
String levelA = levelATokenizer.nextToken();
String levelB = levelBTokenizer.nextToken();
- GroupManager.logger.finest("ROUND " + levelA + " AGAINST " + levelB);
+ if (logFinest)
+ GroupManager.logger.finest("ROUND " + levelA + " AGAINST " + levelB);
if (levelA.contains("*")) {
- GroupManager.logger.finest("WIN");
+ if (logFinest)
+ GroupManager.logger.finest("WIN");
return true;
}
if (levelA.equalsIgnoreCase(levelB)) {
if (!levelATokenizer.hasMoreTokens() && !levelBTokenizer.hasMoreTokens()) {
- GroupManager.logger.finest("WIN");
+ if (logFinest)
+ GroupManager.logger.finest("WIN");
return true;
}
- GroupManager.logger.finest("NEXT");
+ if (logFinest)
+ GroupManager.logger.finest("NEXT");
continue;
} else {
- GroupManager.logger.finest("FAIL");
+ if (logFinest)
+ GroupManager.logger.finest("FAIL");
return false;
}
}
- GroupManager.logger.finest("FAIL");
+ if (logFinest)
+ GroupManager.logger.finest("FAIL");
return false;
}