From 07ffc890e59b4c1345eae5c2ddaecdbfd38db95b Mon Sep 17 00:00:00 2001 From: sciwhiz12 Date: Sat, 22 Aug 2020 02:25:40 +0800 Subject: [PATCH] Fix modproperties property in mods.toml causing exception (#7192) --- .../fml/loading/moddiscovery/ModFileInfo.java | 3 +-- .../fml/loading/moddiscovery/NightConfigWrapper.java | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java index ee92783e08..80251180d7 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -70,8 +70,7 @@ public class ModFileInfo implements IModFileInfo, IConfigurable this.license = config.getConfigElement("license") .orElseThrow(()->new InvalidModFileException("Missing License, please supply a license.", this)); this.showAsResourcePack = config.getConfigElement("showAsResourcePack").orElse(false); - this.properties = config.getConfigElement("properties"). - map(UnmodifiableConfig::valueMap).orElse(Collections.emptyMap()); + this.properties = config.>getConfigElement("properties").orElse(Collections.emptyMap()); this.modFile.setFileProperties(this.properties); this.issueURL = config.getConfigElement("issueTrackerURL").map(StringUtils::toURL).orElse(null); final List modConfigs = config.getConfigList("mods"); diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java index 01e1251aa1..c869f18304 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/moddiscovery/NightConfigWrapper.java @@ -45,8 +45,14 @@ public class NightConfigWrapper implements IConfigurable { } @Override + @SuppressWarnings("unchecked") public Optional 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