From 2518a7c8e5bb1266be4c5b08bb4f7303db3614a0 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 11 Mar 2020 11:38:38 +0000 Subject: [PATCH] Fix NPE in QueryOptionsImpl (#2051, #2052) --- .../me/lucko/luckperms/common/query/QueryOptionsImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java index 7f8353426..f0041d5e0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java @@ -36,6 +36,7 @@ import net.luckperms.api.query.QueryMode; import net.luckperms.api.query.QueryOptions; import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Map; import java.util.Objects; @@ -51,11 +52,11 @@ public class QueryOptionsImpl implements QueryOptions { private Set flagsSet = null; - QueryOptionsImpl(QueryMode mode, ImmutableContextSet context, byte flags, Map, Object> options) { + QueryOptionsImpl(QueryMode mode, @Nullable ImmutableContextSet context, byte flags, @Nullable Map, Object> options) { this.mode = mode; this.context = context; this.flags = flags; - this.options = ImmutableMap.copyOf(options); + this.options = options == null ? null : ImmutableMap.copyOf(options); this.hashCode = calculateHashCode(); } @@ -104,6 +105,9 @@ public class QueryOptionsImpl implements QueryOptions { @Override public @NonNull Map, Object> options() { + if (this.options == null) { + return ImmutableMap.of(); + } return this.options; }