[1.15] Fix modproperties property in mods.toml causing exception (#7524)

Cherry-pick of 07ffc890e5 (GH-7192)
for 1.15.x.
Co-authored-by: sciwhiz12 <[email protected]>
This commit is contained in:
Jamie Mansfield authored and GitHub committed 2020-11-29 10:57:19 -08:00
1 parent 90c50085c0
commit 60eb1c25e9
2 files changed
+8 -3

No files matched your search

@@ -62,8 +62,7 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
map(MavenVersionAdapter::createFromVersionSpec).
orElseThrow(()->new InvalidModFileException("Missing ModLoader version in file", this));
this.showAsResourcePack = config.<Boolean>getConfigElement("showAsResourcePack").orElse(false);
this.properties = config.<UnmodifiableConfig>getConfigElement("properties").
map(UnmodifiableConfig::valueMap).orElse(Collections.emptyMap());
this.properties = config.<Map<String, Object>>getConfigElement("properties").orElse(Collections.emptyMap());
this.modFile.setFileProperties(this.properties);
this.issueURL = config.<String>getConfigElement("issueTrackerURL").map(StringUtils::toURL).orElse(null);
final List<? extends IConfigurable> modConfigs = config.getConfigList("mods");
@@ -45,8 +45,14 @@ public class NightConfigWrapper implements IConfigurable {
}
@Override
@SuppressWarnings("unchecked")
public <T> Optional<T> getConfigElement(final String... key) {
return this.config.getOptional(asList(key));
return this.config.getOptional(asList(key)).map(value -> {
if (value instanceof UnmodifiableConfig) {
return (T) ((UnmodifiableConfig) value).valueMap();
}
return (T) value;
});
}
@Override