mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-09 12:30:15 +01:00
PEX migration carries weights of prefixes/suffixes of groups and individuals (#5)
* PEX migration carries weights of prefixes/suffixes of groups and individuals. * Forgot to increase maxGroupWeight.
This commit is contained in:
parent
4b67913eee
commit
ade70bb7ba
@ -123,9 +123,17 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
|
|
||||||
// Migrate all groups.
|
// Migrate all groups.
|
||||||
log.info("PermissionsEx Migration: Starting group migration.");
|
log.info("PermissionsEx Migration: Starting group migration.");
|
||||||
|
|
||||||
|
int maxGroupWeight = 0;
|
||||||
int groupCount = 0;
|
int groupCount = 0;
|
||||||
|
|
||||||
for (PermissionGroup group : manager.getGroupList()) {
|
for (PermissionGroup group : manager.getGroupList()) {
|
||||||
groupCount ++;
|
groupCount ++;
|
||||||
|
|
||||||
|
if(group.getWeight() > maxGroupWeight) {
|
||||||
|
maxGroupWeight = group.getWeight();
|
||||||
|
}
|
||||||
|
|
||||||
final String name = group.getName().toLowerCase();
|
final String name = group.getName().toLowerCase();
|
||||||
plugin.getDatastore().createAndLoadGroup(name);
|
plugin.getDatastore().createAndLoadGroup(name);
|
||||||
Group lpGroup = plugin.getGroupManager().get(name);
|
Group lpGroup = plugin.getGroupManager().get(name);
|
||||||
@ -224,10 +232,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
if (prefix != null && !prefix.equals("")) {
|
if (prefix != null && !prefix.equals("")) {
|
||||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||||
try {
|
try {
|
||||||
lpGroup.setPermission("prefix.50." + prefix, true);
|
lpGroup.setPermission("prefix." + group.getWeight() + "." + prefix, true);
|
||||||
LogEntry.build()
|
LogEntry.build()
|
||||||
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
||||||
.acted(lpGroup).action("set prefix.50." + prefix + " true")
|
.acted(lpGroup).action("set prefix." + group.getWeight() + "." + prefix + " true")
|
||||||
.build().submit(plugin);
|
.build().submit(plugin);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!(ex instanceof ObjectAlreadyHasException)) {
|
if (!(ex instanceof ObjectAlreadyHasException)) {
|
||||||
@ -239,10 +247,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
if (suffix != null && !suffix.equals("")) {
|
if (suffix != null && !suffix.equals("")) {
|
||||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||||
try {
|
try {
|
||||||
lpGroup.setPermission("suffix.50." + suffix, true);
|
lpGroup.setPermission("suffix." + group.getWeight() + "." + suffix, true);
|
||||||
LogEntry.build()
|
LogEntry.build()
|
||||||
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
||||||
.acted(lpGroup).action("set suffix.50." + suffix + " true")
|
.acted(lpGroup).action("set suffix." + group.getWeight() + "." + suffix + " true")
|
||||||
.build().submit(plugin);
|
.build().submit(plugin);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!(ex instanceof ObjectAlreadyHasException)) {
|
if (!(ex instanceof ObjectAlreadyHasException)) {
|
||||||
@ -377,10 +385,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
if (prefix != null && !prefix.equals("")) {
|
if (prefix != null && !prefix.equals("")) {
|
||||||
prefix = ArgumentChecker.escapeCharacters(prefix);
|
prefix = ArgumentChecker.escapeCharacters(prefix);
|
||||||
try {
|
try {
|
||||||
lpUser.setPermission("prefix.100." + prefix, true);
|
lpUser.setPermission("prefix." + (maxGroupWeight + 1) + "." + prefix, true);
|
||||||
LogEntry.build()
|
LogEntry.build()
|
||||||
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
||||||
.acted(lpUser).action("set prefix.100." + prefix + " true")
|
.acted(lpUser).action("set prefix." + (maxGroupWeight + 1) + "." + prefix + " true")
|
||||||
.build().submit(plugin);
|
.build().submit(plugin);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!(ex instanceof ObjectAlreadyHasException)) {
|
if (!(ex instanceof ObjectAlreadyHasException)) {
|
||||||
@ -392,10 +400,10 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
|||||||
if (suffix != null && !suffix.equals("")) {
|
if (suffix != null && !suffix.equals("")) {
|
||||||
suffix = ArgumentChecker.escapeCharacters(suffix);
|
suffix = ArgumentChecker.escapeCharacters(suffix);
|
||||||
try {
|
try {
|
||||||
lpUser.setPermission("suffix.100." + suffix, true);
|
lpUser.setPermission("suffix." + (maxGroupWeight + 1) + "." + suffix, true);
|
||||||
LogEntry.build()
|
LogEntry.build()
|
||||||
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
.actor(Constants.getConsoleUUID()).actorName(Constants.getConsoleName())
|
||||||
.acted(lpUser).action("set suffix.100." + suffix + " true")
|
.acted(lpUser).action("set suffix." + (maxGroupWeight + 1) + "." + suffix + " true")
|
||||||
.build().submit(plugin);
|
.build().submit(plugin);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!(ex instanceof ObjectAlreadyHasException)) {
|
if (!(ex instanceof ObjectAlreadyHasException)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user