Cleanup handling of empty permissions when migrating data (closes #387)
This commit is contained in:
@@ -270,7 +270,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
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"));
|
||||
|
||||
+4
-4
@@ -159,7 +159,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
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<Object> {
|
||||
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<Object> {
|
||||
Map<String, Map<String, String>> options = entity.getAllOptions();
|
||||
for (Map.Entry<String, Map<String, String>> 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) {
|
||||
|
||||
+17
-14
@@ -181,6 +181,10 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
|
||||
// server --> prefix afaik
|
||||
for (Map.Entry<String, String> 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<Object> {
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> 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<Object> {
|
||||
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<Object> {
|
||||
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<Object> {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -196,6 +196,10 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
|
||||
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<Object> {
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user