Reimplement autoop on Bukkit & other misc fixes

This commit is contained in:
Luck
2016-10-15 21:04:04 +01:00
Unverified
parent 699c4d107b
commit 02a75fc32a
10 changed files with 77 additions and 29 deletions
@@ -247,7 +247,7 @@ public class PermissionHolderLink implements PermissionHolder {
if (world != null && !world.equals("")) {
context.put("world", world);
}
return master.exportNodes(new Contexts(context, true, true, true, true, true), Collections.emptyList(), false);
return master.exportNodes(new Contexts(context, true, true, true, true, true), false);
}
@Override
@@ -259,7 +259,7 @@ public class PermissionHolderLink implements PermissionHolder {
if (world != null && !world.equals("")) {
context.put("world", world);
}
return master.exportNodes(new Contexts(context, true, true, true, true, true), Collections.emptyList(), false);
return master.exportNodes(new Contexts(context, true, true, true, true, true), false);
}
@Override
@@ -283,7 +283,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, false);
return master.exportNodes(new Contexts(extraContext, includeGlobal, includeGlobal, applyGroups, true, true), false);
}
@Override
@@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.common.calculators.CalculatorFactory;
import me.lucko.luckperms.common.users.User;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -50,7 +49,7 @@ public class UserData {
public PermissionData calculatePermissions(Contexts contexts) {
PermissionData data = new PermissionData(contexts, user, calculatorFactory);
data.setPermissions(user.exportNodes(contexts, Collections.emptyList(), true));
data.setPermissions(user.exportNodes(contexts, true));
return data;
}
@@ -60,7 +59,7 @@ public class UserData {
data = new PermissionData(c, user, calculatorFactory);
}
data.comparePermissions(user.exportNodes(c, Collections.emptyList(), true));
data.comparePermissions(user.exportNodes(c, true));
return data;
});
}
@@ -455,23 +455,15 @@ public abstract class PermissionHolder {
}
/**
* Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands wildcards/regex/shorthand perms
* Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands shorthand perms
* @param context the context for this request
* @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, boolean lowerCase) {
public Map<String, Boolean> exportNodes(Contexts context, boolean lowerCase) {
Map<String, Boolean> perms = new HashMap<>();
for (LocalizedNode ln : getAllNodesFiltered(context)) {
Node node = ln.getNode();
if (possibleNodes != null && !possibleNodes.isEmpty()) {
if (node.getPermission().equals("*") || node.getPermission().equals("'*'")) {
if (plugin.getConfiguration().isApplyingWildcards()) {
possibleNodes.forEach(n -> perms.put(lowerCase ? n.toLowerCase() : n, true));
}
}
}
perms.put(lowerCase ? node.getPermission().toLowerCase() : node.getPermission(), node.getValue());
@@ -481,15 +473,6 @@ public abstract class PermissionHolder {
.filter(s -> !perms.containsKey(s))
.forEach(s -> perms.put(s, node.getValue()));
}
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()));
}
}
}
return ImmutableMap.copyOf(perms);