Search in sources :

Example 1 with EntityMetadata

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());
        }
    }
}
Also used : Entry(org.tyrannyofheaven.bukkit.zPermissions.model.Entry) EntityMetadata(org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata) ChatMetaType(me.lucko.luckperms.api.ChatMetaType) PermissionEntity(org.tyrannyofheaven.bukkit.zPermissions.model.PermissionEntity)

Aggregations

ChatMetaType (me.lucko.luckperms.api.ChatMetaType)1 EntityMetadata (org.tyrannyofheaven.bukkit.zPermissions.model.EntityMetadata)1 Entry (org.tyrannyofheaven.bukkit.zPermissions.model.Entry)1 PermissionEntity (org.tyrannyofheaven.bukkit.zPermissions.model.PermissionEntity)1