Fix possible issue with context conversion

This commit is contained in:
Luck 2017-03-05 22:56:00 +00:00
parent ecf1d3790c
commit 07f38aa283
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -28,6 +28,7 @@ import lombok.experimental.UtilityClass;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ContextSet;
import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet;
@ -44,7 +45,7 @@ public class Util {
.build(new CacheLoader<Set<Context>, ImmutableContextSet>() { .build(new CacheLoader<Set<Context>, ImmutableContextSet>() {
@Override @Override
public ImmutableContextSet load(Set<Context> contexts) { public ImmutableContextSet load(Set<Context> contexts) {
return ContextSet.fromEntries(contexts); return ImmutableContextSet.fromEntries(contexts);
} }
}); });
@ -57,7 +58,7 @@ public class Util {
}); });
public static ContextSet convertContexts(@NonNull Set<Context> contexts) { public static ContextSet convertContexts(@NonNull Set<Context> contexts) {
return SPONGE_TO_LP_CACHE.getUnchecked(contexts); return SPONGE_TO_LP_CACHE.getUnchecked(ImmutableSet.copyOf(contexts));
} }
public static Set<Context> convertContexts(@NonNull ContextSet contexts) { public static Set<Context> convertContexts(@NonNull ContextSet contexts) {