Search in sources :

Example 1 with PermissionCalculatorMetadata

use of me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata in project LuckPerms by lucko.

the class AbstractCachedData method calculatePermissions.

/**
 * Calculates a {@link PermissionCache} instance.
 *
 * @param contexts the contexts to calculate in
 * @param data an old data instance to try to reuse - ignored if null
 * @return the calculated instance
 */
private PermissionCache calculatePermissions(Contexts contexts, PermissionCache data) {
    Objects.requireNonNull(contexts, "contexts");
    if (data == null) {
        PermissionCalculatorMetadata metadata = getMetadataForContexts(contexts);
        data = new PermissionCache(contexts, metadata, getCalculatorFactory());
    }
    if (contexts == Contexts.allowAll()) {
        data.setPermissions(resolvePermissions());
    } else {
        data.setPermissions(resolvePermissions(contexts));
    }
    return data;
}
Also used : PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) PermissionCalculatorMetadata(me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata)

Aggregations

PermissionCache (me.lucko.luckperms.common.caching.type.PermissionCache)1 PermissionCalculatorMetadata (me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata)1