Sponge: Fix migration for subjects with identifiers containing spaces

This commit is contained in:
Luck 2016-12-07 21:14:24 +00:00
parent 25511f898c
commit 1c97cb3cec
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 18 additions and 15 deletions

View File

@ -89,9 +89,11 @@ public class MigrationPermissionManager extends SubCommand<Object> {
for (Subject pmGroup : pmService.getGroupSubjects().getAllSubjects()) {
groupCount++;
String pmName = MigrationUtils.convertGroupName(pmGroup.getIdentifier().toLowerCase());
// Make a LuckPerms group for the one being migrated
plugin.getStorage().createAndLoadGroup(pmGroup.getIdentifier().toLowerCase()).join();
Group group = plugin.getGroupManager().getIfLoaded(pmGroup.getIdentifier().toLowerCase());
plugin.getStorage().createAndLoadGroup(pmName).join();
Group group = plugin.getGroupManager().getIfLoaded(pmName);
migrateSubject(pmGroup, group);
plugin.getStorage().saveGroup(group);
}

View File

@ -83,9 +83,11 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
for (Subject pexGroup : pexService.getGroupSubjects().getAllSubjects()) {
groupCount++;
String pexName = MigrationUtils.convertGroupName(pexGroup.getIdentifier().toLowerCase());
// Make a LuckPerms group for the one being migrated
plugin.getStorage().createAndLoadGroup(pexGroup.getIdentifier().toLowerCase()).join();
Group group = plugin.getGroupManager().getIfLoaded(pexGroup.getIdentifier().toLowerCase());
plugin.getStorage().createAndLoadGroup(pexName).join();
Group group = plugin.getGroupManager().getIfLoaded(pexName);
migrateSubject(pexGroup, group);
plugin.getStorage().saveGroup(group);
}

View File

@ -59,8 +59,7 @@ public class MigrationUtils {
for (Map.Entry<String, Boolean> perm : e.getValue().entrySet()) {
try {
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")) {
try {
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")) {
try {
holder.setPermission(NodeFactory.makeSuffixNode(100, opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
} catch (ObjectAlreadyHasException ignored) {
}
} catch (ObjectAlreadyHasException ignored) {}
} else {
try {
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 {
holder.setPermission(new NodeBuilder("group." + s.getIdentifier().toLowerCase()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
} catch (ObjectAlreadyHasException ignored) {
}
holder.setPermission(new NodeBuilder("group." + convertGroupName(s.getIdentifier().toLowerCase())).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
} catch (ObjectAlreadyHasException ignored) {}
}
}
}
@ -142,4 +137,8 @@ public class MigrationUtils {
}
}
public static String convertGroupName(String s) {
return s.replace(' ', '_');
}
}