use of me.lucko.luckperms.common.api.implementation.ApiPermissionHolder in project LuckPerms by lucko.
the class EventDispatcher method dispatchNodeClear.
public void dispatchNodeClear(PermissionHolder target, DataType dataType, Difference<Node> changes) {
if (!this.eventBus.shouldPost(NodeClearEvent.class)) {
return;
}
if (changes.isEmpty()) {
return;
}
ApiPermissionHolder proxy = proxy(target);
ImmutableSet<Node> state = target.getData(dataType).asImmutableSet();
// call clear event
ImmutableSet<Node> nodes = ImmutableSet.copyOf(changes.getRemoved());
postAsync(NodeClearEvent.class, proxy, dataType, state, nodes);
// call add event if needed for any nodes that were added
for (Node added : changes.getAdded()) {
postAsync(NodeAddEvent.class, proxy, dataType, state, added);
}
}
use of me.lucko.luckperms.common.api.implementation.ApiPermissionHolder in project LuckPerms by lucko.
the class EventDispatcher method dispatchNodeChanges.
public void dispatchNodeChanges(PermissionHolder target, DataType dataType, Difference<Node> changes) {
if (!this.eventBus.shouldPost(NodeAddEvent.class) && !this.eventBus.shouldPost(NodeRemoveEvent.class)) {
return;
}
if (changes.isEmpty()) {
return;
}
ApiPermissionHolder proxy = proxy(target);
ImmutableSet<Node> state = target.getData(dataType).asImmutableSet();
// call an event for each recorded change
for (Difference.Change<Node> change : changes.getChanges()) {
Class<? extends NodeMutateEvent> type = change.type() == Difference.ChangeType.ADD ? NodeAddEvent.class : NodeRemoveEvent.class;
postAsync(type, proxy, dataType, state, change.value());
}
}
Aggregations