Fixed null pointer when resetting gameplay settings in config menu

- Added a null check to make sure a config value has a comment before trying to split the comment
- Fixes #2412
This commit is contained in:
Cael Warner 2021-12-11 20:58:23 -08:00
parent 51763382d3
commit 01866db72e
No known key found for this signature in database
GPG key ID: F70FD7559CCDFC48

View file

@ -150,7 +150,12 @@ public class SubMenuConfigScreen extends ConfigScreen {
} else if (obj instanceof ForgeConfigSpec.ConfigValue<?>) {
ForgeConfigSpec.ConfigValue configValue = (ForgeConfigSpec.ConfigValue<?>) obj;
ForgeConfigSpec.ValueSpec valueSpec = spec.getRaw((List<String>) configValue.getPath());
List<String> comments = new ArrayList<>(Arrays.asList(valueSpec.getComment().split("\n")));
List<String> comments = new ArrayList<>();
if (valueSpec.getComment() != null)
comments.addAll(Arrays.asList(valueSpec.getComment().split("\n")));
Pair<String, Map<String, String>> metadata = ConfigHelper.readMetadataFromComment(comments);
ConfigHelper.setValue(String.join(".", configValue.getPath()), configValue, valueSpec.getDefault(), metadata.getSecond());