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

Co-Authored-By: J-RAP <[email protected]>
This commit is contained in:
Paint_NinjaandJ-RAP authored and GitHub committed 2024-05-01 21:58:24 +01:00
1 parent f5a168dc4b
commit d11733a48c
2 files changed
+4 -4

No files matched your search

@@ -353,7 +353,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);