mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
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()) {
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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(' ', '_');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user