Search in sources :

Example 1 with MetaContexts

use of me.lucko.luckperms.api.caching.MetaContexts in project LuckPerms by lucko.

the class AbstractCachedData method reloadMeta.

@Nonnull
@Override
public CompletableFuture<MetaCache> reloadMeta(@Nonnull MetaContexts contexts) {
    Objects.requireNonNull(contexts, "contexts");
    // get the previous value - to use when recalculating
    MetaCache previous = this.meta.getIfPresent(contexts);
    // invalidate the entry
    this.meta.invalidate(contexts);
    // repopulate the cache
    return CompletableFuture.supplyAsync(() -> this.meta.get(contexts, c -> calculateMeta(c, previous)));
}
Also used : PermissionCalculatorMetadata(me.lucko.luckperms.common.calculators.PermissionCalculatorMetadata) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) FullySatisfiedContexts(me.lucko.luckperms.api.FullySatisfiedContexts) CacheLoader(com.github.benmanes.caffeine.cache.CacheLoader) LoadingCache(com.github.benmanes.caffeine.cache.LoadingCache) Contexts(me.lucko.luckperms.api.Contexts) PermissionCalculator(me.lucko.luckperms.common.calculators.PermissionCalculator) PermissionCache(me.lucko.luckperms.common.caching.type.PermissionCache) Set(java.util.Set) CachedData(me.lucko.luckperms.api.caching.CachedData) CompletableFuture(java.util.concurrent.CompletableFuture) MetaContexts(me.lucko.luckperms.api.caching.MetaContexts) CalculatorFactory(me.lucko.luckperms.common.calculators.CalculatorFactory) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache) HashSet(java.util.HashSet) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) SimpleMetaStack(me.lucko.luckperms.common.metastacking.SimpleMetaStack) Map(java.util.Map) ChatMetaType(me.lucko.luckperms.api.ChatMetaType) LuckPermsPlugin(me.lucko.luckperms.common.plugin.LuckPermsPlugin) Nonnull(javax.annotation.Nonnull) MetaAccumulator(me.lucko.luckperms.common.caching.type.MetaAccumulator) MetaCache(me.lucko.luckperms.common.caching.type.MetaCache) Nonnull(javax.annotation.Nonnull)

Example 2 with MetaContexts

use of me.lucko.luckperms.api.caching.MetaContexts in project LuckPerms by lucko.

the class DebugCommand method getPlayersData.

private static JObject getPlayersData(LuckPermsPlugin plugin) {
    JObject ret = new JObject();
    Set<UUID> onlinePlayers = plugin.getBootstrap().getOnlinePlayers().collect(Collectors.toSet());
    ret.add("count", onlinePlayers.size());
    JArray playerArray = new JArray();
    for (UUID uuid : onlinePlayers) {
        User user = plugin.getUserManager().getIfLoaded(uuid);
        if (user == null) {
            playerArray.add(new JObject().add("uniqueId", uuid.toString()).add("loaded", false));
            continue;
        }
        playerArray.add(new JObject().add("uniqueId", uuid.toString()).add("loaded", true).add("username", user.getName().orElse("null")).add("primaryGroup", new JObject().add("type", user.getPrimaryGroup().getClass().getName()).add("value", user.getPrimaryGroup().getValue()).add("storedValue", user.getPrimaryGroup().getStoredValue().orElse("null"))).add("activeContext", () -> {
            JObject obj = new JObject();
            Contexts contexts = plugin.getContextForUser(user).orElse(null);
            if (contexts != null) {
                MetaContexts metaContexts = plugin.getContextManager().formMetaContexts(contexts);
                obj.add("data", new JObject().add("permissions", serializePermissionsData(user.getCachedData().getPermissionData(contexts))).add("meta", serializeMetaData(user.getCachedData().getMetaData(metaContexts)))).add("contextSet", ContextSetJsonSerializer.serializeContextSet(contexts.getContexts())).add("settings", serializeContextsSettings(contexts)).add("metaSettings", serializeMetaContextsSettings(metaContexts));
            }
            return obj;
        }));
    }
    ret.add("players", playerArray);
    return ret;
}
Also used : MetaContexts(me.lucko.luckperms.api.caching.MetaContexts) User(me.lucko.luckperms.common.model.User) JObject(me.lucko.luckperms.common.utils.gson.JObject) UUID(java.util.UUID) Contexts(me.lucko.luckperms.api.Contexts) MetaContexts(me.lucko.luckperms.api.caching.MetaContexts) JArray(me.lucko.luckperms.common.utils.gson.JArray)

Aggregations

Contexts (me.lucko.luckperms.api.Contexts)2 MetaContexts (me.lucko.luckperms.api.caching.MetaContexts)2 CacheLoader (com.github.benmanes.caffeine.cache.CacheLoader)1 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)1 LoadingCache (com.github.benmanes.caffeine.cache.LoadingCache)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 Nonnull (javax.annotation.Nonnull)1 ChatMetaType (me.lucko.luckperms.api.ChatMetaType)1 FullySatisfiedContexts (me.lucko.luckperms.api.FullySatisfiedContexts)1 CachedData (me.lucko.luckperms.api.caching.CachedData)1 MetaAccumulator (me.lucko.luckperms.common.caching.type.MetaAccumulator)1 MetaCache (me.lucko.luckperms.common.caching.type.MetaCache)1 PermissionCache (me.lucko.luckperms.common.caching.type.PermissionCache)1 CalculatorFactory (me.lucko.luckperms.common.calculators.CalculatorFactory)1