Migrate group weightings onto the group itself as well as to the chat meta held by it

This commit is contained in:
Luck
2017-03-11 18:24:25 +00:00
Unverified
parent bce7fa871d
commit 7305c6c54b
4 changed files with 33 additions and 12 deletions
@@ -76,6 +76,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
@@ -403,6 +404,24 @@ public abstract class PermissionHolder {
invalidateCache(true);
}
public boolean removeIf(Predicate<Node> predicate) {
boolean result;
ImmutableSet<Node> before = ImmutableSet.copyOf(getNodes());
synchronized (nodes) {
result = nodes.removeIf(predicate);
}
if (!result) {
return false;
}
invalidateCache(true);
ImmutableSet<Node> after = ImmutableSet.copyOf(getNodes());
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
return true;
}
public Set<Node> getTransientNodes() {
return transientCache.get();
}