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