Fix modproperties property in mods.toml causing exception (#7192)

This commit is contained in:
sciwhiz12 authored and GitHub committed 2020-08-21 11:25:40 -07:00
1 parent 5a20705f05
commit 07ffc890e5
2 files changed
+8 -3

No files matched your search

@@ -70,8 +70,7 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
this.license = config.<String>getConfigElement("license")
.orElseThrow(()->new InvalidModFileException("Missing License, please supply a license.", 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