Fix permission lookups being case sensitive

This commit is contained in:
Luck
2016-09-26 18:52:01 +01:00
Unverified
parent e72d91503c
commit ab6b011225
6 changed files with 16 additions and 12 deletions
@@ -262,7 +262,7 @@ public class PermissionHolderLink implements PermissionHolder {
if (world != null && !world.equals("")) {
extraContext.put("world", world);
}
return master.exportNodes(new Contexts(extraContext, includeGlobal, includeGlobal, applyGroups, true, true), possibleNodes);
return master.exportNodes(new Contexts(extraContext, includeGlobal, includeGlobal, applyGroups, true, true), possibleNodes, false);
}
@Override
@@ -262,22 +262,23 @@ public abstract class PermissionHolder {
* @param possibleNodes a list of possible nodes for wildcards and regex permissions
* @return a map of permissions
*/
public Map<String, Boolean> exportNodes(Contexts context, List<String> possibleNodes) {
public Map<String, Boolean> exportNodes(Contexts context, List<String> possibleNodes, boolean lowerCase) {
Map<String, Boolean> perms = new HashMap<>();
for (Node node : getAllNodesFiltered(context)) {
if (possibleNodes != null && !possibleNodes.isEmpty()) {
if (node.getPermission().equals("*") || node.getPermission().equals("'*'")) {
if (plugin.getConfiguration().isApplyingWildcards()) {
possibleNodes.forEach(n -> perms.put(n, true));
possibleNodes.forEach(n -> perms.put(lowerCase ? n.toLowerCase() : n, true));
}
}
}
perms.put(node.getPermission(), node.getValue());
perms.put(lowerCase ? node.getPermission().toLowerCase() : node.getPermission(), node.getValue());
if (plugin.getConfiguration().isApplyingShorthand()) {
node.resolveShorthand().stream()
.map(s -> lowerCase ? s.toLowerCase() : s)
.filter(s -> !perms.containsKey(s))
.forEach(s -> perms.put(s, node.getValue()));
}
@@ -285,6 +286,7 @@ public abstract class PermissionHolder {
if (possibleNodes != null && !possibleNodes.isEmpty()) {
if (plugin.getConfiguration().isApplyingWildcards()) {
node.resolveWildcard(possibleNodes).stream()
.map(s -> lowerCase ? s.toLowerCase() : s)
.filter(s -> !perms.containsKey(s))
.forEach(s -> perms.put(s, node.getValue()));
}
@@ -576,7 +578,7 @@ public abstract class PermissionHolder {
if (world != null && !world.equals("")) {
context.put("world", world);
}
return exportNodes(new Contexts(context, plugin.getConfiguration().isIncludingGlobalPerms(), true, true, true, true), Collections.emptyList());
return exportNodes(new Contexts(context, plugin.getConfiguration().isIncludingGlobalPerms(), true, true, true, true), Collections.emptyList(), false);
}
@Deprecated
@@ -588,7 +590,7 @@ public abstract class PermissionHolder {
if (world != null && !world.equals("")) {
context.put("world", world);
}
return exportNodes(new Contexts(context, plugin.getConfiguration().isIncludingGlobalPerms(), true, true, true, true), Collections.emptyList());
return exportNodes(new Contexts(context, plugin.getConfiguration().isIncludingGlobalPerms(), true, true, true, true), Collections.emptyList(), false);
}
@SuppressWarnings("deprecation")