diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java index 49b73410..53da05bd 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java @@ -270,7 +270,7 @@ public class MigrationGroupManager extends SubCommand { } String primaryGroup = primaryGroups.get(e.getKey()); - if (primaryGroup != null) { + if (primaryGroup != null && !primaryGroup.isEmpty()) { user.setPermission(NodeFactory.make("group." + primaryGroup)); user.getPrimaryGroup().setStoredValue(primaryGroup); user.unsetPermission(NodeFactory.make("group.default")); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java index 3413452d..eee988e8 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java @@ -159,7 +159,7 @@ public class MigrationPermissionsEx extends SubCommand { } } - if (primary != null && !primary.equalsIgnoreCase("default")) { + if (primary != null && !primary.isEmpty() && !primary.equalsIgnoreCase("default")) { lpUser.setPermission(NodeFactory.make("group." + primary.toLowerCase())); lpUser.getPrimaryGroup().setStoredValue(primary); lpUser.unsetPermission(NodeFactory.make("group.default")); @@ -216,11 +216,11 @@ public class MigrationPermissionsEx extends SubCommand { String prefix = entity.getOwnPrefix(); String suffix = entity.getOwnSuffix(); - if (prefix != null && !prefix.equals("")) { + if (prefix != null && !prefix.isEmpty()) { holder.setPermission(NodeFactory.makePrefixNode(weight, prefix).build()); } - if (suffix != null && !suffix.equals("")) { + if (suffix != null && !suffix.isEmpty()) { holder.setPermission(NodeFactory.makeSuffixNode(weight, suffix).build()); } @@ -228,7 +228,7 @@ public class MigrationPermissionsEx extends SubCommand { Map> options = entity.getAllOptions(); for (Map.Entry> worldData : options.entrySet()) { String world = worldData.getKey(); - if (world != null && (world.equals("") || world.equals("*"))) { + if (world != null && (world.isEmpty() || world.equals("*"))) { world = null; } if (world != null) { diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java index ef50fef5..56617121 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java @@ -181,6 +181,10 @@ public class MigrationPowerfulPerms extends SubCommand { // server --> prefix afaik for (Map.Entry prefix : g.getPrefixes().entrySet()) { + if (prefix.getValue().isEmpty()) { + continue; + } + String server = prefix.getKey().toLowerCase(); if (prefix.getKey().equals("*") || prefix.getKey().equals("all")) { server = null; @@ -194,6 +198,10 @@ public class MigrationPowerfulPerms extends SubCommand { } for (Map.Entry suffix : g.getSuffixes().entrySet()) { + if (suffix.getValue().isEmpty()) { + continue; + } + String server = suffix.getKey().toLowerCase(); if (suffix.getKey().equals("*") || suffix.getKey().equals("all")) { server = null; @@ -247,11 +255,11 @@ public class MigrationPowerfulPerms extends SubCommand { String prefix = joinFuture(pm.getPlayerOwnPrefix(uuid)); String suffix = joinFuture(pm.getPlayerOwnSuffix(uuid)); - if (prefix != null && !prefix.equals("")) { + if (prefix != null && !prefix.isEmpty()) { user.setPermission(NodeFactory.makePrefixNode(maxWeight, prefix).build()); } - if (suffix != null && !suffix.equals("")) { + if (suffix != null && !suffix.isEmpty()) { user.setPermission(NodeFactory.makeSuffixNode(maxWeight, suffix).build()); } @@ -279,6 +287,10 @@ public class MigrationPowerfulPerms extends SubCommand { value = false; } + if (node.isEmpty()) { + return; + } + String server = p.getServer(); if (server != null && (server.equalsIgnoreCase("all") || server.equalsIgnoreCase("*"))) { server = null; @@ -299,18 +311,9 @@ public class MigrationPowerfulPerms extends SubCommand { } Node.Builder nb = NodeFactory.newBuilder(node).setValue(value); - - if (expireAt != 0) { - nb.setExpiry(expireAt); - } - - if (server != null) { - nb.setServer(server); - } - - if (world != null) { - nb.setWorld(world); - } + if (expireAt != 0) nb.setExpiry(expireAt); + if (server != null) nb.setServer(server); + if (world != null) nb.setWorld(world); holder.setPermission(nb.build()); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java index b24fc003..605eb304 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java @@ -196,6 +196,10 @@ public class MigrationZPermissions extends SubCommand { private void migrateEntity(PermissionHolder holder, PermissionEntity entity, int weight) { for (Entry e : entity.getPermissions()) { + if (e.getPermission().isEmpty()) { + continue; + } + if (e.getWorld() != null && !e.getWorld().getName().equals("")) { holder.setPermission(NodeFactory.newBuilder(e.getPermission()).setValue(e.isValue()).setWorld(e.getWorld().getName()).build()); } else { @@ -215,6 +219,10 @@ public class MigrationZPermissions extends SubCommand { for (EntityMetadata metadata : entity.getMetadata()) { String key = metadata.getName().toLowerCase(); + if (key.isEmpty() || metadata.getStringValue().isEmpty()) { + continue; + } + if (key.equals("prefix") || key.equals("suffix")) { ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase()); holder.setPermission(NodeFactory.makeChatMetaNode(type, weight, metadata.getStringValue()).build()); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java index 53577191..653a4889 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java @@ -174,10 +174,10 @@ public class MigrationBungeePerms extends SubCommand { String prefix = entity.getPrefix(); String suffix = entity.getSuffix(); - if (prefix != null && !prefix.equals("")) { + if (prefix != null && !prefix.isEmpty()) { holder.setPermission(NodeFactory.makePrefixNode(weight, prefix).build()); } - if (suffix != null && !suffix.equals("")) { + if (suffix != null && !suffix.isEmpty()) { holder.setPermission(NodeFactory.makeSuffixNode(weight, suffix).build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java index 483e33d8..7a2d2540 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/migration/MigrationUtils.java @@ -36,9 +36,17 @@ public class MigrationUtils { public static Node.Builder parseNode(String permission, boolean value) { if (permission.startsWith("-") || permission.startsWith("!")) { + if (permission.length() == 1) { + return NodeFactory.newBuilder(permission).setValue(value); + } + permission = permission.substring(1); value = false; } else if (permission.startsWith("+")) { + if (permission.length() == 1) { + return NodeFactory.newBuilder(permission).setValue(value); + } + permission = permission.substring(1); value = true; } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java index 72ac526c..eadc6d70 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionManager.java @@ -56,6 +56,7 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubject; +import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubjectData; public class MigrationPermissionManager extends SubCommand { public MigrationPermissionManager(LocaleManager locale) { @@ -93,12 +94,12 @@ public class MigrationPermissionManager extends SubCommand { // Migrate defaults log.log("Migrating default subjects."); for (SubjectCollection collection : pmService.getKnownSubjects().values()) { - SpongeMigrationUtils.migrateSubjectData( + migrateSubjectData( collection.getDefaults().getSubjectData(), lpService.getCollection("defaults").loadSubject(collection.getIdentifier()).join().sponge().getSubjectData() ); } - SpongeMigrationUtils.migrateSubjectData(pmService.getDefaults().getSubjectData(), lpService.getDefaults().sponge().getSubjectData()); + migrateSubjectData(pmService.getDefaults().getSubjectData(), lpService.getDefaults().sponge().getSubjectData()); // Migrate groups log.log("Starting group migration."); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java index c864b83f..f0eb41e9 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java @@ -62,6 +62,7 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubject; +import static me.lucko.luckperms.sponge.migration.SpongeMigrationUtils.migrateSubjectData; public class MigrationPermissionsEx extends SubCommand { public MigrationPermissionsEx(LocaleManager locale) { @@ -90,12 +91,12 @@ public class MigrationPermissionsEx extends SubCommand { // Migrate defaults log.log("Migrating default subjects."); for (SubjectCollection collection : pexService.getKnownSubjects().values()) { - SpongeMigrationUtils.migrateSubjectData( + migrateSubjectData( collection.getDefaults().getSubjectData(), lpService.getCollection("defaults").loadSubject(collection.getIdentifier()).join().sponge().getSubjectData() ); } - SpongeMigrationUtils.migrateSubjectData(pexService.getDefaults().getSubjectData(), lpService.getDefaults().sponge().getSubjectData()); + migrateSubjectData(pexService.getDefaults().getSubjectData(), lpService.getDefaults().sponge().getSubjectData()); log.log("Calculating group weightings."); int maxWeight = 0;