mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
Remove runtime mods.toml string substitution (#10698)
This commit is contained in:
1 parent
ecd1491f96
commit
fc80e30289
6 files changed
+14
-53
No files matched your search
@@ -985,6 +985,15 @@ tasks.register('genAllData') {
|
||||
dependsOn 'forge_data', 'forge_test_data'
|
||||
}
|
||||
|
||||
tasks.named('processResources', ProcessResources) {
|
||||
final Map<String, String> replaceProperties = Map.of('forge_version', (String) version)
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('UPDATE_MAPPINGS')) {
|
||||
extractRangeMap {
|
||||
sources.from sourceSets.test.java.srcDirs
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.text.StrLookup;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StringSubstitutor {
|
||||
private static final Map<String, String> GLOBALS = Map.of(
|
||||
"mcVersion", FMLLoader.versionInfo().mcVersion(),
|
||||
"forgeVersion", FMLLoader.versionInfo().forgeVersion()
|
||||
);
|
||||
|
||||
public static String replace(final String in, final ModFile file) {
|
||||
return new StrSubstitutor(getStringLookup(file)).replace(in);
|
||||
}
|
||||
|
||||
private static StrLookup<String> getStringLookup(final ModFile file) {
|
||||
return new StrLookup<>() {
|
||||
@Override
|
||||
public String lookup(String key) {
|
||||
var parts = key.split("\\.");
|
||||
if (parts.length == 1)
|
||||
return key;
|
||||
var pfx = parts[0];
|
||||
|
||||
if ("global".equals(pfx))
|
||||
return GLOBALS.get(parts[1]);
|
||||
else if ("file".equals(pfx) && file != null)
|
||||
return String.valueOf(file.getSubstitutionMap().get().get(parts[1]));
|
||||
|
||||
return key;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fml.loading.moddiscovery;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.jarhandling.SecureJar;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
@@ -39,7 +38,6 @@ import java.util.jar.Manifest;
|
||||
public class ModFile implements IModFile {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private final String jarVersion;
|
||||
private Map<String, Object> fileProperties;
|
||||
private List<IModLanguageProvider> loaders;
|
||||
private Throwable scanError;
|
||||
private final SecureJar jar;
|
||||
@@ -69,9 +67,10 @@ public class ModFile implements IModFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Map<String,Object>> getSubstitutionMap() {
|
||||
return () -> ImmutableMap.<String,Object>builder().put("jarVersion", jarVersion).putAll(fileProperties).build();
|
||||
public Supplier<Map<String, Object>> getSubstitutionMap() {
|
||||
return Map::of;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return modFileType;
|
||||
@@ -151,7 +150,7 @@ public class ModFile implements IModFile {
|
||||
}
|
||||
|
||||
public void setFileProperties(Map<String, Object> fileProperties) {
|
||||
this.fileProperties = fileProperties;
|
||||
LOGGER.warn(LogMarkers.LOADING, "Setting file properties for the purposes of runtime mods.toml string substitution is no longer supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -101,7 +101,6 @@ public class ModFileInfo implements IModFileInfo, IConfigurable {
|
||||
this.properties = config.<Map<String, Object>>getConfigElement("properties")
|
||||
.orElse(Collections.emptyMap());
|
||||
}
|
||||
this.modFile.setFileProperties(this.properties);
|
||||
|
||||
final List<? extends IConfigurable> modConfigs = config.getConfigList("mods");
|
||||
if (modConfigs == null || modConfigs.isEmpty())
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package net.minecraftforge.fml.loading.moddiscovery;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.fml.loading.StringSubstitutor;
|
||||
import net.minecraftforge.fml.loading.StringUtils;
|
||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
@@ -74,7 +73,6 @@ public record ModInfo(
|
||||
}
|
||||
|
||||
ArtifactVersion version = config.<String>getConfigElement("version")
|
||||
.map(s -> StringSubstitutor.replace(s, owningFile.getFile()))
|
||||
.map(DefaultArtifactVersion::new)
|
||||
.orElse(DEFAULT_VERSION);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ license="LGPL v2.1"
|
||||
|
||||
[[mods]]
|
||||
modId="forge"
|
||||
version="${global.forgeVersion}"
|
||||
version="${forge_version}"
|
||||
updateJSONURL="https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json"
|
||||
displayURL="https://minecraftforge.net/"
|
||||
displayName="Forge"
|
||||
|
||||
Reference in new issue
Block a user