Fix NPE when acceptableValues in defineInList() does not allow nulls, backport of #9903 (#9907)

Co-authored-by: J-RAP <SrRapero720@hotmail.com>
This commit is contained in:
Paint_NinjaandJ-RAP authored and GitHub committed 2024-04-18 21:22:11 +01:00
1 parent 921771bd11
commit 1b0360928f
1 file changed
+1 -1
@@ -346,7 +346,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
return defineInList(path, () -> defaultValue, acceptableValues);
}
public <T> ConfigValue<T> defineInList(List<String> path, Supplier<T> defaultSupplier, Collection<? extends T> acceptableValues) {
return define(path, defaultSupplier, acceptableValues::contains);
return define(path, defaultSupplier, o -> o != null && acceptableValues.contains(o));
}
public <T> ConfigValue<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Predicate<Object> elementValidator) {
return defineList(split(path), defaultValue, elementValidator);