Search in sources :

Example 1 with LPPermissionDescription

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

the class DescriptionBuilder method register.

@Nonnull
@Override
public PermissionDescription register() throws IllegalStateException {
    if (this.id == null) {
        throw new IllegalStateException("id cannot be null");
    }
    LPPermissionDescription description = this.service.registerPermissionDescription(this.id, this.description, this.container);
    // Set role-templates
    LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
    for (Map.Entry<String, Tristate> assignment : this.roles.entrySet()) {
        LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join();
        roleSubject.getTransientSubjectData().setPermission(ContextSet.empty(), this.id, assignment.getValue());
    }
    this.service.getPlugin().getPermissionVault().offer(this.id);
    // null stuff so this instance can be reused
    this.roles.clear();
    this.id = null;
    this.description = null;
    return description.sponge();
}
Also used : Tristate(me.lucko.luckperms.api.Tristate) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection) HashMap(java.util.HashMap) Map(java.util.Map) LPPermissionDescription(me.lucko.luckperms.sponge.service.model.LPPermissionDescription) Nonnull(javax.annotation.Nonnull)

Example 2 with LPPermissionDescription

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

the class DescriptionBuilder method register.

@Nonnull
@Override
public PermissionDescription register() throws IllegalStateException {
    if (this.id == null) {
        throw new IllegalStateException("id cannot be null");
    }
    LPPermissionDescription description = this.service.registerPermissionDescription(this.id, this.description, this.container);
    // Set role-templates
    LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE);
    for (Map.Entry<String, Tristate> assignment : this.roles.entrySet()) {
        LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join();
        roleSubject.getTransientSubjectData().setPermission(ContextSet.empty(), this.id, assignment.getValue());
    }
    this.service.getPlugin().getPermissionVault().offer(this.id);
    // null stuff so this instance can be reused
    this.roles.clear();
    this.id = null;
    this.description = null;
    return description.sponge();
}
Also used : Tristate(me.lucko.luckperms.api.Tristate) LPSubject(me.lucko.luckperms.sponge.service.model.LPSubject) LPSubjectCollection(me.lucko.luckperms.sponge.service.model.LPSubjectCollection) HashMap(java.util.HashMap) Map(java.util.Map) LPPermissionDescription(me.lucko.luckperms.sponge.service.model.LPPermissionDescription) Nonnull(javax.annotation.Nonnull)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 Nonnull (javax.annotation.Nonnull)2 Tristate (me.lucko.luckperms.api.Tristate)2 LPPermissionDescription (me.lucko.luckperms.sponge.service.model.LPPermissionDescription)2 LPSubject (me.lucko.luckperms.sponge.service.model.LPSubject)2 LPSubjectCollection (me.lucko.luckperms.sponge.service.model.LPSubjectCollection)2