Search in sources :

Example 11 with Contexts

use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.

the class VaultChatHook method getUserMeta.

@Override
public String getUserMeta(String world, UUID uuid, String key) {
    if (uuid == null) {
        return null;
    }
    Objects.requireNonNull(key, "key");
    User user = getUser(uuid);
    if (user == null) {
        return null;
    }
    Contexts contexts = this.permissionHook.contextForLookup(user, world);
    MetaCache metaData = user.getCachedData().getMetaData(contexts);
    String ret = metaData.getMeta().get(key);
    if (log()) {
        logMsg("#getUserMeta: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), key, ret);
    }
    return ret;
}
Also used : User(me.lucko.luckperms.common.model.User) Contexts(me.lucko.luckperms.api.Contexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache)

Example 12 with Contexts

use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.

the class VaultChatHook method getGroupChatSuffix.

@Override
public String getGroupChatSuffix(String world, String name) {
    Objects.requireNonNull(name, "name");
    Group group = getGroup(name);
    if (group == null) {
        return null;
    }
    Contexts contexts = this.permissionHook.contextForLookup(null, world);
    MetaCache metaData = group.getCachedData().getMetaData(contexts);
    String ret = metaData.getSuffix();
    if (log()) {
        logMsg("#getGroupSuffix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
    }
    return Strings.nullToEmpty(ret);
}
Also used : Group(me.lucko.luckperms.common.model.Group) Contexts(me.lucko.luckperms.api.Contexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache)

Example 13 with Contexts

use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.

the class VaultChatHook method getUserChatPrefix.

@Override
public String getUserChatPrefix(String world, UUID uuid) {
    if (uuid == null) {
        return null;
    }
    User user = getUser(uuid);
    if (user == null) {
        return null;
    }
    Contexts contexts = this.permissionHook.contextForLookup(user, world);
    MetaCache metaData = user.getCachedData().getMetaData(contexts);
    String ret = metaData.getPrefix();
    if (log()) {
        logMsg("#getUserChatPrefix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret);
    }
    return Strings.nullToEmpty(ret);
}
Also used : User(me.lucko.luckperms.common.model.User) Contexts(me.lucko.luckperms.api.Contexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache)

Example 14 with Contexts

use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.

the class VaultChatHook method getUserChatSuffix.

@Override
public String getUserChatSuffix(String world, UUID uuid) {
    if (uuid == null) {
        return null;
    }
    User user = getUser(uuid);
    if (user == null) {
        return null;
    }
    Contexts contexts = this.permissionHook.contextForLookup(user, world);
    MetaCache metaData = user.getCachedData().getMetaData(contexts);
    String ret = metaData.getSuffix();
    if (log()) {
        logMsg("#getUserChatSuffix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret);
    }
    return Strings.nullToEmpty(ret);
}
Also used : User(me.lucko.luckperms.common.model.User) Contexts(me.lucko.luckperms.api.Contexts) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache)

Example 15 with Contexts

use of me.lucko.luckperms.api.Contexts in project LuckPerms by lucko.

the class VaultPermissionHook method userHasPermission.

@Override
public boolean userHasPermission(String world, UUID uuid, String permission) {
    if (uuid == null) {
        return false;
    }
    Objects.requireNonNull(permission, "permission");
    User user = getUser(uuid);
    if (user == null) {
        return false;
    }
    Contexts contexts = contextForLookup(user, world);
    PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
    Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
    if (log()) {
        logMsg("#userHasPermission: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), permission, result);
    }
    return result.asBoolean();
}
Also used : User(me.lucko.luckperms.common.model.User) Tristate(me.lucko.luckperms.api.Tristate) PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) Contexts(me.lucko.luckperms.api.Contexts)

Aggregations

Contexts (me.lucko.luckperms.api.Contexts)18 MetaCache (me.lucko.luckperms.common.caching.type.MetaCache)8 User (me.lucko.luckperms.common.model.User)8 Group (me.lucko.luckperms.common.model.Group)7 Tristate (me.lucko.luckperms.api.Tristate)5 PermissionCache (me.lucko.luckperms.common.caching.type.PermissionCache)5 Objects (java.util.Objects)3 Node (me.lucko.luckperms.api.Node)3 MetaContexts (me.lucko.luckperms.api.caching.MetaContexts)3 CacheLoader (com.github.benmanes.caffeine.cache.CacheLoader)2 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)2 LoadingCache (com.github.benmanes.caffeine.cache.LoadingCache)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 UUID (java.util.UUID)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 TimeUnit (java.util.concurrent.TimeUnit)2 Nonnull (javax.annotation.Nonnull)2 ChatMetaType (me.lucko.luckperms.api.ChatMetaType)2