mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
Don't attempt to migrate empty permissions
This commit is contained in:
parent
132d0cf578
commit
9de44d2605
@ -189,10 +189,17 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
private static void migrateHolder(World world, Calculable c, PermissionHolder holder) {
|
||||
// Migrate the groups permissions in this world
|
||||
for (Permission p : c.getPermissions()) {
|
||||
if (p.name().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
holder.setPermission(NodeFactory.make(p.name(), p.isTrue(), "global", world.getName()));
|
||||
|
||||
// Include any child permissions
|
||||
for (Map.Entry<String, Boolean> child : p.getChildren().entrySet()) {
|
||||
if (child.getKey().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
holder.setPermission(NodeFactory.make(child.getKey(), child.getValue(), "global", world.getName()));
|
||||
}
|
||||
}
|
||||
@ -209,6 +216,10 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
|
||||
// Migrate existing meta
|
||||
for (Map.Entry<String, String> meta : c.getMeta().entrySet()) {
|
||||
if (meta.getKey().isEmpty() || meta.getValue().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (meta.getKey().equalsIgnoreCase("prefix") || meta.getKey().equalsIgnoreCase("suffix")) {
|
||||
holder.setPermission(NodeFactory.makeChatMetaNode(meta.getKey().equalsIgnoreCase("prefix"), c.getPriority(), meta.getValue()).setWorld(world.getName()).build());
|
||||
continue;
|
||||
|
@ -97,10 +97,18 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
me.lucko.luckperms.common.core.model.Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
|
||||
for (String node : g.getPermissionList()) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(MigrationUtils.parseNode(node, true).build());
|
||||
}
|
||||
|
||||
for (String s : g.getInherits()) {
|
||||
if (s.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(s)));
|
||||
}
|
||||
|
||||
@ -131,10 +139,18 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
groups.putIfAbsent(groupName, new HashSet<>());
|
||||
|
||||
for (String node : group.getPermissionList()) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
groups.get(groupName).add(MigrationUtils.parseNode(node, true).setWorld(worldMappingFunc.apply(world)).build());
|
||||
}
|
||||
|
||||
for (String s : group.getInherits()) {
|
||||
if (s.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
groups.get(groupName).add(NodeFactory.make("group." + MigrationUtils.standardizeName(s), true, null, worldMappingFunc.apply(world)));
|
||||
}
|
||||
|
||||
@ -144,6 +160,10 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
String value = group.getVariables().getVarString(key);
|
||||
key = key.toLowerCase();
|
||||
|
||||
if (key.isEmpty() || value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.equals("build")) {
|
||||
continue;
|
||||
}
|
||||
@ -172,12 +192,17 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
users.putIfAbsent(uuid, new HashSet<>());
|
||||
|
||||
for (String node : user.getPermissionList()) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
users.get(uuid).add(MigrationUtils.parseNode(node, true).setWorld(worldMappingFunc.apply(world)).build());
|
||||
}
|
||||
|
||||
// Collect sub groups
|
||||
String finalWorld = worldMappingFunc.apply(world);
|
||||
users.get(uuid).addAll(user.subGroupListStringCopy().stream()
|
||||
.filter(n -> !n.isEmpty())
|
||||
.map(n -> "group." + MigrationUtils.standardizeName(n))
|
||||
.map(n -> NodeFactory.make(n, true, null, finalWorld))
|
||||
.collect(Collectors.toSet())
|
||||
@ -191,6 +216,10 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
String value = user.getVariables().getVarString(key);
|
||||
key = key.toLowerCase();
|
||||
|
||||
if (key.isEmpty() || value.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.equals("build")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -106,6 +106,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
|
||||
try {
|
||||
for (String node : group.getOwnPermissions(null)) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpGroup.setPermission(MigrationUtils.parseNode(node, true).build());
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
@ -113,7 +117,15 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
for (String world : worlds) {
|
||||
if (world.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (String node : group.getOwnPermissions(world)) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpGroup.setPermission(MigrationUtils.parseNode(node, true).setWorld(world.toLowerCase()).build());
|
||||
}
|
||||
}
|
||||
@ -123,6 +135,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
for (String world : worlds) {
|
||||
if (world.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (PermissionGroup g : group.getParents(world)) {
|
||||
lpGroup.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(g.getName()), true, "global", world.toLowerCase()));
|
||||
}
|
||||
@ -176,6 +192,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
|
||||
try {
|
||||
for (String node : user.getOwnPermissions(null)) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpUser.setPermission(MigrationUtils.parseNode(node, true).build());
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
@ -183,17 +203,37 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
for (String world : worlds) {
|
||||
if (world.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (String node : user.getOwnPermissions(world)) {
|
||||
if (node.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpUser.setPermission(MigrationUtils.parseNode(node, true).setWorld(world.toLowerCase()).build());
|
||||
}
|
||||
}
|
||||
|
||||
for (String g : user.getGroupNames()) {
|
||||
if (g.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpUser.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(g)));
|
||||
}
|
||||
|
||||
for (String world : worlds) {
|
||||
if (world.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (String g : user.getGroupNames(world)) {
|
||||
if (g.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lpUser.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(g), true, "global", world.toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
@ -88,18 +88,30 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
|
||||
// Migrate global perms
|
||||
for (String perm : g.getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(MigrationUtils.parseNode(perm, true).build());
|
||||
}
|
||||
|
||||
// Migrate per-server perms
|
||||
for (Map.Entry<String, Server> e : g.getServers().entrySet()) {
|
||||
for (String perm : e.getValue().getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(MigrationUtils.parseNode(perm, true).setWorld(e.getKey()).build());
|
||||
}
|
||||
|
||||
// Migrate per-world perms
|
||||
for (Map.Entry<String, World> we : e.getValue().getWorlds().entrySet()) {
|
||||
for (String perm : we.getValue().getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(MigrationUtils.parseNode(perm, true).setServer(e.getKey()).setWorld(we.getKey()).build());
|
||||
}
|
||||
}
|
||||
@ -107,6 +119,10 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
|
||||
// Migrate any parent groups
|
||||
for (String inherit : g.getInheritances()) {
|
||||
if (inherit.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(inherit)));
|
||||
}
|
||||
|
||||
@ -145,18 +161,30 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
|
||||
// Migrate global perms
|
||||
for (String perm : u.getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.setPermission(MigrationUtils.parseNode(perm, true).build());
|
||||
}
|
||||
|
||||
// Migrate per-server perms
|
||||
for (Map.Entry<String, Server> e : u.getServers().entrySet()) {
|
||||
for (String perm : e.getValue().getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.setPermission(MigrationUtils.parseNode(perm, true).setWorld(e.getKey()).build());
|
||||
}
|
||||
|
||||
// Migrate per-world perms
|
||||
for (Map.Entry<String, World> we : e.getValue().getWorlds().entrySet()) {
|
||||
for (String perm : we.getValue().getPerms()) {
|
||||
if (perm.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.setPermission(MigrationUtils.parseNode(perm, true).setServer(e.getKey()).setWorld(we.getKey()).build());
|
||||
}
|
||||
}
|
||||
@ -164,6 +192,10 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
|
||||
// Migrate groups
|
||||
for (String group : u.getGroupsString()) {
|
||||
if (group.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
user.setPermission(NodeFactory.make("group." + MigrationUtils.standardizeName(group)));
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,10 @@ public class SpongeMigrationUtils {
|
||||
ContextSet context = Util.convertContexts(e.getKey());
|
||||
|
||||
for (Map.Entry<String, Boolean> perm : e.getValue().entrySet()) {
|
||||
if (perm.getKey().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
holder.setPermission(NodeFactory.newBuilder(perm.getKey()).withExtraContext(context).setValue(perm.getValue()).build());
|
||||
}
|
||||
}
|
||||
@ -65,6 +69,10 @@ public class SpongeMigrationUtils {
|
||||
ContextSet context = Util.convertContexts(e.getKey());
|
||||
|
||||
for (Map.Entry<String, String> opt : e.getValue().entrySet()) {
|
||||
if (opt.getKey().isEmpty() || opt.getValue().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opt.getKey().equalsIgnoreCase("prefix")) {
|
||||
holder.setPermission(NodeFactory.makePrefixNode(priority, opt.getValue()).withExtraContext(context).setValue(true).build());
|
||||
} else if (opt.getKey().equalsIgnoreCase("suffix")) {
|
||||
|
Loading…
Reference in New Issue
Block a user