use of org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata in project LuckPerms by lucko.
the class MigrationZPermissions method migrateEntity.
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.builder(e.getPermission()).setValue(e.isValue()).setWorld(e.getWorld().getName()).build());
} else {
holder.setPermission(NodeFactory.builder(e.getPermission()).setValue(e.isValue()).build());
}
}
// only migrate inheritances for groups
if (entity.isGroup()) {
for (PermissionEntity inheritance : entity.getParents()) {
if (!inheritance.getDisplayName().equals(holder.getObjectName())) {
holder.setPermission(NodeFactory.buildGroupNode(MigrationUtils.standardizeName(inheritance.getDisplayName())).build());
}
}
}
for (EntityMetadata metadata : entity.getMetadata()) {
String key = metadata.getName().toLowerCase();
if (key.isEmpty() || metadata.getStringValue().isEmpty())
continue;
if (key.equals(NodeFactory.PREFIX_KEY) || key.equals(NodeFactory.SUFFIX_KEY)) {
ChatMetaType type = ChatMetaType.valueOf(key.toUpperCase());
holder.setPermission(NodeFactory.buildChatMetaNode(type, weight, metadata.getStringValue()).build());
} else {
holder.setPermission(NodeFactory.buildMetaNode(key, metadata.getStringValue()).build());
}
}
}
Aggregations