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

Co-authored-by: J-RAP <[email protected]>
This commit is contained in:
Paint_NinjaandJ-RAP authored and GitHub committed 2024-04-18 21:32:03 +01:00
1 parent 2b67a9f36d
commit 388976f288
1 file changed
+1 -1
@@ -350,7 +350,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);