Sponge: Fix migration for subjects with identifiers containing spaces
This commit is contained in:
parent
25511f898c
commit
1c97cb3cec
@ -89,9 +89,11 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
|||||||
for (Subject pmGroup : pmService.getGroupSubjects().getAllSubjects()) {
|
for (Subject pmGroup : pmService.getGroupSubjects().getAllSubjects()) {
|
||||||
groupCount++;
|
groupCount++;
|
||||||
|
|
||||||
|
String pmName = MigrationUtils.convertGroupName(pmGroup.getIdentifier().toLowerCase());
|
||||||
|
|
||||||
// Make a LuckPerms group for the one being migrated
|
// Make a LuckPerms group for the one being migrated
|
||||||
plugin.getStorage().createAndLoadGroup(pmGroup.getIdentifier().toLowerCase()).join();
|
plugin.getStorage().createAndLoadGroup(pmName).join();
|
||||||
Group group = plugin.getGroupManager().getIfLoaded(pmGroup.getIdentifier().toLowerCase());
|
Group group = plugin.getGroupManager().getIfLoaded(pmName);
|
||||||
migrateSubject(pmGroup, group);
|
migrateSubject(pmGroup, group);
|
||||||
plugin.getStorage().saveGroup(group);
|
plugin.getStorage().saveGroup(group);
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,11 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
for (Subject pexGroup : pexService.getGroupSubjects().getAllSubjects()) {
|
for (Subject pexGroup : pexService.getGroupSubjects().getAllSubjects()) {
|
||||||
groupCount++;
|
groupCount++;
|
||||||
|
|
||||||
|
String pexName = MigrationUtils.convertGroupName(pexGroup.getIdentifier().toLowerCase());
|
||||||
|
|
||||||
// Make a LuckPerms group for the one being migrated
|
// Make a LuckPerms group for the one being migrated
|
||||||
plugin.getStorage().createAndLoadGroup(pexGroup.getIdentifier().toLowerCase()).join();
|
plugin.getStorage().createAndLoadGroup(pexName).join();
|
||||||
Group group = plugin.getGroupManager().getIfLoaded(pexGroup.getIdentifier().toLowerCase());
|
Group group = plugin.getGroupManager().getIfLoaded(pexName);
|
||||||
migrateSubject(pexGroup, group);
|
migrateSubject(pexGroup, group);
|
||||||
plugin.getStorage().saveGroup(group);
|
plugin.getStorage().saveGroup(group);
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,7 @@ public class MigrationUtils {
|
|||||||
for (Map.Entry<String, Boolean> perm : e.getValue().entrySet()) {
|
for (Map.Entry<String, Boolean> perm : e.getValue().entrySet()) {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(new NodeBuilder(perm.getKey()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(perm.getValue()).build());
|
holder.setPermission(new NodeBuilder(perm.getKey()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(perm.getValue()).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,18 +78,15 @@ public class MigrationUtils {
|
|||||||
if (opt.getKey().equalsIgnoreCase("prefix")) {
|
if (opt.getKey().equalsIgnoreCase("prefix")) {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(NodeFactory.makePrefixNode(100, opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(NodeFactory.makePrefixNode(100, opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
} else if (opt.getKey().equalsIgnoreCase("suffix")) {
|
} else if (opt.getKey().equalsIgnoreCase("suffix")) {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(NodeFactory.makeSuffixNode(100, opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(NodeFactory.makeSuffixNode(100, opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(NodeFactory.makeMetaNode(opt.getKey(), opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,9 +111,8 @@ public class MigrationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
holder.setPermission(new NodeBuilder("group." + s.getIdentifier().toLowerCase()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(new NodeBuilder("group." + convertGroupName(s.getIdentifier().toLowerCase())).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,4 +137,8 @@ public class MigrationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String convertGroupName(String s) {
|
||||||
|
return s.replace(' ', '_');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user