Search in sources :

Example 1 with ImmutableTransientNode

use of me.lucko.luckperms.common.node.ImmutableTransientNode in project LuckPerms by lucko.

the class LPPermissionAttachment method setPermissionInternal.

private void setPermissionInternal(String name, boolean value) {
    if (!this.permissible.getPlugin().getConfiguration().get(ConfigKeys.APPLY_BUKKIT_ATTACHMENT_PERMISSIONS)) {
        return;
    }
    // construct a node for the permission being set
    // we use the servers static context to *try* to ensure that the node will apply
    Node node = NodeFactory.builder(name).setValue(value).withExtraContext(this.permissible.getPlugin().getContextManager().getStaticContext()).build();
    // convert the constructed node to a transient node instance to refer back to this attachment
    ImmutableTransientNode<LPPermissionAttachment> transientNode = ImmutableTransientNode.of(node, this);
    // set the transient node
    User user = this.permissible.getUser();
    if (user.setTransientPermission(transientNode).asBoolean()) {
        user.reloadCachedData();
    }
}
Also used : User(me.lucko.luckperms.common.model.User) ImmutableTransientNode(me.lucko.luckperms.common.node.ImmutableTransientNode) Node(me.lucko.luckperms.api.Node)

Example 2 with ImmutableTransientNode

use of me.lucko.luckperms.common.node.ImmutableTransientNode in project LuckPerms by lucko.

the class LPPermissionAttachment method setPermissionInternal.

private void setPermissionInternal(String name, boolean value) {
    if (!this.permissible.getPlugin().getConfiguration().get(ConfigKeys.APPLY_NUKKIT_ATTACHMENT_PERMISSIONS)) {
        return;
    }
    // construct a node for the permission being set
    // we use the servers static context to *try* to ensure that the node will apply
    Node node = NodeFactory.builder(name).setValue(value).withExtraContext(this.permissible.getPlugin().getContextManager().getStaticContext()).build();
    // convert the constructed node to a transient node instance to refer back to this attachment
    ImmutableTransientNode<LPPermissionAttachment> transientNode = ImmutableTransientNode.of(node, this);
    // set the transient node
    User user = this.permissible.getUser();
    if (user.setTransientPermission(transientNode).asBoolean()) {
        user.reloadCachedData();
    }
}
Also used : User(me.lucko.luckperms.common.model.User) ImmutableTransientNode(me.lucko.luckperms.common.node.ImmutableTransientNode) Node(me.lucko.luckperms.api.Node)

Aggregations

Node (me.lucko.luckperms.api.Node)2 User (me.lucko.luckperms.common.model.User)2 ImmutableTransientNode (me.lucko.luckperms.common.node.ImmutableTransientNode)2