mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-21 10:52:01 +00:00
Optimize comparePermissionString
This commit is contained in:
parent
dec7ea1926
commit
73a7a6a1dd
|
@ -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,6 +970,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
if (userAcessLevel == null || fullPermissionName == null) {
|
||||
return false;
|
||||
}
|
||||
boolean logFinest = (GroupManager.logger.getLevel() == Level.FINEST);
|
||||
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("COMPARING " + userAcessLevel + " WITH " + fullPermissionName);
|
||||
|
||||
if (userAcessLevel.startsWith("+")) {
|
||||
|
@ -986,24 +992,30 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
while (levelATokenizer.hasMoreTokens() && levelBTokenizer.hasMoreTokens()) {
|
||||
String levelA = levelATokenizer.nextToken();
|
||||
String levelB = levelBTokenizer.nextToken();
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("ROUND " + levelA + " AGAINST " + levelB);
|
||||
if (levelA.contains("*")) {
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("WIN");
|
||||
return true;
|
||||
}
|
||||
if (levelA.equalsIgnoreCase(levelB)) {
|
||||
if (!levelATokenizer.hasMoreTokens() && !levelBTokenizer.hasMoreTokens()) {
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("WIN");
|
||||
return true;
|
||||
}
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("NEXT");
|
||||
continue;
|
||||
} else {
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("FAIL");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if (logFinest)
|
||||
GroupManager.logger.finest("FAIL");
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue