Fix issue with Bukkit attachment permissions never being removed (#991)

This commit is contained in:
Luck
2018-05-13 14:06:05 +01:00
Unverified
parent 5d34661a15
commit a0be1c7c48
6 changed files with 32 additions and 20 deletions
@@ -227,13 +227,13 @@ public final class NodeMap {
setContent(multimap.values());
}
boolean removeIf(Predicate<? super Node> predicate) {
boolean removeIf(Predicate<? super LocalizedNode> predicate) {
boolean ret = this.map.values().removeIf(predicate);
this.inheritanceMap.values().removeIf(predicate);
return ret;
}
boolean removeIf(ContextSet contextSet, Predicate<? super Node> predicate) {
boolean removeIf(ContextSet contextSet, Predicate<? super LocalizedNode> predicate) {
ImmutableContextSet context = contextSet.makeImmutable();
SortedSet<LocalizedNode> nodes = this.map.get(context);
boolean ret = nodes.removeIf(predicate);
@@ -241,12 +241,12 @@ public final class NodeMap {
return ret;
}
boolean auditTemporaryNodes(@Nullable Set<Node> removed) {
boolean auditTemporaryNodes(@Nullable Set<? super LocalizedNode> removed) {
boolean work = false;
Iterator<? extends Node> it = this.map.values().iterator();
Iterator<? extends LocalizedNode> it = this.map.values().iterator();
while (it.hasNext()) {
Node entry = it.next();
LocalizedNode entry = it.next();
if (entry.hasExpired()) {
if (removed != null) {
removed.add(entry);
@@ -261,11 +261,11 @@ public abstract class PermissionHolder {
return ret;
}
public boolean removeIf(Predicate<? super Node> predicate) {
public boolean removeIf(Predicate<? super LocalizedNode> predicate) {
return removeIf(predicate, null);
}
public boolean removeIf(Predicate<? super Node> predicate, Runnable taskIfSuccess) {
public boolean removeIf(Predicate<? super LocalizedNode> predicate, Runnable taskIfSuccess) {
ImmutableCollection<? extends Node> before = enduringData().immutable().values();
if (!this.enduringNodes.removeIf(predicate)) {
return false;
@@ -280,11 +280,11 @@ public abstract class PermissionHolder {
return true;
}
public boolean removeIf(ContextSet contextSet, Predicate<? super Node> predicate) {
public boolean removeIf(ContextSet contextSet, Predicate<? super LocalizedNode> predicate) {
return removeIf(contextSet, predicate, null);
}
public boolean removeIf(ContextSet contextSet, Predicate<? super Node> predicate, Runnable taskIfSuccess) {
public boolean removeIf(ContextSet contextSet, Predicate<? super LocalizedNode> predicate, Runnable taskIfSuccess) {
ImmutableCollection<? extends Node> before = enduringData().immutable().values();
if (!this.enduringNodes.removeIf(contextSet, predicate)) {
return false;
@@ -299,7 +299,7 @@ public abstract class PermissionHolder {
return true;
}
public boolean removeIfTransient(Predicate<? super Node> predicate) {
public boolean removeIfTransient(Predicate<? super LocalizedNode> predicate) {
boolean result = this.transientNodes.removeIf(predicate);
if (result) {
invalidateCache();
@@ -455,7 +455,7 @@ public abstract class PermissionHolder {
// we don't call events for transient nodes
boolean transientWork = this.transientNodes.auditTemporaryNodes(null);
ImmutableCollection<? extends Node> before = enduringData().immutable().values();
ImmutableCollection<? extends LocalizedNode> before = enduringData().immutable().values();
Set<Node> removed = new HashSet<>();
boolean enduringWork = this.enduringNodes.auditTemporaryNodes(removed);
@@ -40,11 +40,6 @@ public final class ImmutableLocalizedNode extends ForwardingNode implements Loca
Objects.requireNonNull(node, "node");
Objects.requireNonNull(location, "location");
// unwrap
while (node instanceof LocalizedNode) {
node = ((LocalizedNode) node).getNode();
}
return new ImmutableLocalizedNode(node, location);
}