Search in sources :

Example 6 with LPSubject

use of me.lucko.luckperms.sponge.service.model.LPSubject in project LuckPerms by lucko.

the class CachedSubjectReference method fillCache.

void fillCache(LPSubject subject) {
    LPSubject sub = tryCache();
    if (sub == null) {
        // if no value is currently cached, populate with the passed value
        this.lastLookup = System.currentTimeMillis();
        this.cache = new WeakReference<>(subject);
    } else if (sub == subject) {
        // if equal, reset the cache timeout
        this.lastLookup = System.currentTimeMillis();
    }
}
Also used : LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject)

Example 7 with LPSubject

use of me.lucko.luckperms.sponge.service.model.LPSubject in project LuckPerms by lucko.

the class ParentRemove method execute.

@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, LPSubjectData subjectData, List<String> args, String label) {
    String collection = args.get(0);
    String name = args.get(1);
    ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
    LPPermissionService service = Sponge.getServiceManager().provideUnchecked(LPPermissionService.class);
    if (service.getLoadedCollections().keySet().stream().map(String::toLowerCase).noneMatch(s -> s.equalsIgnoreCase(collection))) {
        MessageUtils.sendPluginMessage(sender, "Warning: SubjectCollection '&4" + collection + "&c' doesn't exist.");
    }
    LPSubjectCollection c = service.getCollection(collection);
    if (!c.hasRegistered(name).join()) {
        MessageUtils.sendPluginMessage(sender, "Warning: Subject '&4" + name + "&c' doesn't exist.");
    }
    LPSubject subject = c.loadSubject(name).join();
    if (subjectData.removeParent(contextSet, subject.toReference()).join()) {
        MessageUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() + "&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
    } else {
        MessageUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
    }
    return CommandResult.SUCCESS;
}
Also used : LPPermissionService(me.lucko.luckperms.sponge.service.model.LPPermissionService) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) ImmutableContextSet(me.lucko.luckperms.api.context.ImmutableContextSet) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection)

Example 8 with LPSubject

use of me.lucko.luckperms.sponge.service.model.LPSubject in project LuckPerms by lucko.

the class CachedSubjectReference method resolveDirectly.

private synchronized LPSubject resolveDirectly() {
    /* As this method is synchronized, it's possible that since this was invoked
           the subject has been cached.
           Therefore, we check the cache again, and return if there's a value present.
           This effectively means all calls to this method block, but all return the same value
           at the same time once the data is loaded :) */
    LPSubject s = tryCache();
    if (s != null) {
        return s;
    }
    // subject isn't cached, so make a call to load it
    s = this.service.getCollection(this.collectionIdentifier).loadSubject(this.subjectIdentifier).join();
    // cache the result
    this.lastLookup = System.currentTimeMillis();
    this.cache = new WeakReference<>(s);
    return s;
}
Also used : LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject)

Example 9 with LPSubject

use of me.lucko.luckperms.sponge.service.model.LPSubject in project LuckPerms by lucko.

the class SpongeUserManager method loadSubjects.

@Override
public CompletableFuture<ImmutableCollection<LPSubject>> loadSubjects(Set<String> identifiers) {
    return CompletableFuture.supplyAsync(() -> {
        ImmutableSet.Builder<LPSubject> ret = ImmutableSet.builder();
        for (String id : identifiers) {
            UUID uuid = Uuids.parseNullable(id);
            if (uuid == null) {
                continue;
            }
            ret.add(loadSubject(uuid.toString()).join());
        }
        return ret.build();
    }, this.plugin.getBootstrap().getScheduler().async());
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) UUID(java.util.UUID)

Aggregations

LPSubject (me.lucko.luckperms.sponge.service.model.LPSubject)9 LPSubjectCollection (me.lucko.luckperms.sponge.service.model.LPSubjectCollection)5 Map (java.util.Map)3 Nonnull (javax.annotation.Nonnull)3 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2 Tristate (me.lucko.luckperms.api.Tristate)2 ImmutableContextSet (me.lucko.luckperms.api.context.ImmutableContextSet)2 LPPermissionDescription (me.lucko.luckperms.sponge.service.model.LPPermissionDescription)2 LPPermissionService (me.lucko.luckperms.sponge.service.model.LPPermissionService)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 CommandManager (me.lucko.luckperms.common.command.CommandManager)1 CommandResult (me.lucko.luckperms.common.command.CommandResult)1