Ensure immutability of QueryOptions options map

This commit is contained in:
Luck 2020-03-04 12:45:13 +00:00
parent bb3afa21a4
commit bca766c20d
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -25,6 +25,7 @@
package me.lucko.luckperms.common.query;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import net.luckperms.api.context.ContextSet;
@ -45,7 +46,7 @@ public class QueryOptionsImpl implements QueryOptions {
private final QueryMode mode;
private final ImmutableContextSet context;
private final byte flags;
private final Map<OptionKey<?>, Object> options;
private final ImmutableMap<OptionKey<?>, Object> options;
private final int hashCode;
private Set<Flag> flagsSet = null;
@ -54,7 +55,7 @@ public class QueryOptionsImpl implements QueryOptions {
this.mode = mode;
this.context = context;
this.flags = flags;
this.options = options;
this.options = ImmutableMap.copyOf(options);
this.hashCode = calculateHashCode();
}