mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Always store node metadata keys in a HashMap, not IdentityHashMap, and ensure immutability when built
This commit is contained in:
parent
85451a9a20
commit
bb3afa21a4
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.common.node;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.common.node.utils.ShorthandParser;
|
||||
|
||||
@ -74,7 +75,7 @@ public abstract class AbstractNode<N extends ScopedNode<N, B>, B extends NodeBui
|
||||
this.value = value;
|
||||
this.expireAt = expireAt;
|
||||
this.contexts = contexts;
|
||||
this.metadata = metadata;
|
||||
this.metadata = ImmutableMap.copyOf(metadata);
|
||||
|
||||
this.resolvedShorthand = this instanceof PermissionNode ? ImmutableList.copyOf(ShorthandParser.expandShorthand(this.key)) : ImmutableList.of();
|
||||
|
||||
|
@ -42,8 +42,8 @@ import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.time.temporal.TemporalAmount;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -54,13 +54,6 @@ public abstract class AbstractNodeBuilder<N extends ScopedNode<N, B>, B extends
|
||||
protected ImmutableContextSet.Builder context;
|
||||
protected final Map<NodeMetadataKey<?>, Object> metadata;
|
||||
|
||||
protected AbstractNodeBuilder() {
|
||||
this.value = true;
|
||||
this.expireAt = 0L;
|
||||
this.context = new ImmutableContextSetImpl.BuilderImpl();
|
||||
this.metadata = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
protected AbstractNodeBuilder(boolean value, long expireAt, ImmutableContextSet context, Map<NodeMetadataKey<?>, Object> metadata) {
|
||||
this.value = value;
|
||||
this.expireAt = expireAt;
|
||||
@ -68,6 +61,10 @@ public abstract class AbstractNodeBuilder<N extends ScopedNode<N, B>, B extends
|
||||
this.metadata = new HashMap<>(metadata);
|
||||
}
|
||||
|
||||
protected AbstractNodeBuilder() {
|
||||
this(true, 0L, ImmutableContextSet.empty(), Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull B value(boolean value) {
|
||||
this.value = value;
|
||||
|
Loading…
Reference in New Issue
Block a user