Search in sources :

Example 16 with DataMutateResult

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

the class HolderSubjectData method removeParent.

@Override
public CompletableFuture<Boolean> removeParent(ImmutableContextSet contexts, LPSubjectReference subject) {
    Objects.requireNonNull(contexts, "contexts");
    Objects.requireNonNull(subject, "subject");
    if (!subject.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP)) {
        return CompletableFuture.completedFuture(false);
    }
    Node node = NodeFactory.buildGroupNode(subject.getSubjectIdentifier()).withExtraContext(contexts).build();
    DataMutateResult result = this.type.supply(() -> this.holder.unsetPermission(node), () -> this.holder.unsetTransientPermission(node));
    if (!result.asBoolean()) {
        return CompletableFuture.completedFuture(false);
    }
    return objectSave(this.holder).thenApply(v -> true);
}
Also used : Node(me.lucko.luckperms.api.Node) DataMutateResult(me.lucko.luckperms.api.DataMutateResult)

Example 17 with DataMutateResult

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

the class HolderSubjectData method addParent.

@Override
public CompletableFuture<Boolean> addParent(ImmutableContextSet contexts, LPSubjectReference subject) {
    Objects.requireNonNull(contexts, "contexts");
    Objects.requireNonNull(subject, "subject");
    if (!subject.getCollectionIdentifier().equals(PermissionService.SUBJECTS_GROUP)) {
        return CompletableFuture.completedFuture(false);
    }
    Node node = NodeFactory.buildGroupNode(subject.getSubjectIdentifier()).withExtraContext(contexts).build();
    DataMutateResult result = this.type.supply(() -> this.holder.setPermission(node), () -> this.holder.setTransientPermission(node));
    if (!result.asBoolean()) {
        return CompletableFuture.completedFuture(false);
    }
    return objectSave(this.holder).thenApply(v -> true);
}
Also used : Node(me.lucko.luckperms.api.Node) DataMutateResult(me.lucko.luckperms.api.DataMutateResult)

Aggregations

DataMutateResult (me.lucko.luckperms.api.DataMutateResult)17 MutableContextSet (me.lucko.luckperms.api.context.MutableContextSet)12 Node (me.lucko.luckperms.api.Node)5 Group (me.lucko.luckperms.common.model.Group)4 TextComponent (net.kyori.text.TextComponent)4 HoverEvent (net.kyori.text.event.HoverEvent)4 Map (java.util.Map)3 TemporaryModifier (me.lucko.luckperms.common.model.TemporaryModifier)3 User (me.lucko.luckperms.common.model.User)1