use of me.lucko.luckperms.common.caching.type.MetaCache in project LuckPerms by lucko.
the class VaultChatHook method getGroupMeta.
@Override
public String getGroupMeta(String world, String name, String key) {
Objects.requireNonNull(name, "name");
Objects.requireNonNull(key, "key");
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.getMeta().get(key);
if (log()) {
logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
}
return ret;
}
use of me.lucko.luckperms.common.caching.type.MetaCache in project LuckPerms by lucko.
the class VaultChatHook method getGroupChatPrefix.
@Override
public String getGroupChatPrefix(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.getPrefix();
if (log()) {
logMsg("#getGroupPrefix: %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), ret);
}
return Strings.nullToEmpty(ret);
}
use of me.lucko.luckperms.common.caching.type.MetaCache in project LuckPerms by lucko.
the class AbstractCachedData method calculateMeta.
/**
* Calculates a {@link MetaCache} 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 MetaCache calculateMeta(MetaContexts contexts, MetaCache data) {
Objects.requireNonNull(contexts, "contexts");
if (data == null) {
data = new MetaCache(contexts);
}
MetaAccumulator accumulator = newAccumulator(contexts);
if (contexts.getContexts() == Contexts.allowAll()) {
resolveMeta(accumulator);
} else {
resolveMeta(accumulator, contexts);
}
data.loadMeta(accumulator);
return data;
}
use of me.lucko.luckperms.common.caching.type.MetaCache 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)));
}
use of me.lucko.luckperms.common.caching.type.MetaCache 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;
}
Aggregations