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

This commit is contained in:
sciwhiz12 2020-08-22 02:25:40 +08:00 committed by GitHub
parent 5a20705f05
commit 07ffc890e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -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");

View file

@ -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