default to calamus(gen2) when mojmap isn't available
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s
This commit is contained in:
parent
f7c90d15e6
commit
ac3e0d86df
|
@ -7,7 +7,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.frogmc"
|
group = "dev.frogmc"
|
||||||
version = "0.0.1-alpha.26"
|
version = "0.0.1-alpha.27"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import dev.frogmc.frogloader.api.FrogLoader;
|
import dev.frogmc.frogloader.api.FrogLoader;
|
||||||
import dev.frogmc.frogloader.api.mod.ModDependencies;
|
import dev.frogmc.frogloader.api.mod.ModDependencies;
|
||||||
|
@ -22,6 +23,7 @@ import dev.frogmc.frogloader.api.plugin.GamePlugin;
|
||||||
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
import dev.frogmc.frogloader.impl.FrogLoaderImpl;
|
||||||
import dev.frogmc.frogloader.impl.mod.ModPropertiesImpl;
|
import dev.frogmc.frogloader.impl.mod.ModPropertiesImpl;
|
||||||
import dev.frogmc.frogloader.impl.util.SystemProperties;
|
import dev.frogmc.frogloader.impl.util.SystemProperties;
|
||||||
|
import dev.frogmc.thyroxine.HttpHelper;
|
||||||
import dev.frogmc.thyroxine.Thyroxine;
|
import dev.frogmc.thyroxine.Thyroxine;
|
||||||
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
||||||
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser;
|
import dev.frogmc.thyroxine.parser.tiny.TinyV2Parser;
|
||||||
|
@ -32,6 +34,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class MinecraftGamePlugin implements GamePlugin {
|
public class MinecraftGamePlugin implements GamePlugin {
|
||||||
|
|
||||||
|
protected static final String CALAMUS_META_URL = "https://meta.ornithemc.net/v3/versions/gen2/intermediary/%s";
|
||||||
|
protected static final String CALAMUS_MAVEN_URL = "https://maven.ornithemc.net/releases/%s";
|
||||||
protected final String[] MINECRAFT_CLASSES = new String[]{
|
protected final String[] MINECRAFT_CLASSES = new String[]{
|
||||||
"net/minecraft/client/main/Main.class",
|
"net/minecraft/client/main/Main.class",
|
||||||
"net/minecraft/client/MinecraftApplet.class",
|
"net/minecraft/client/MinecraftApplet.class",
|
||||||
|
@ -136,8 +140,22 @@ public class MinecraftGamePlugin implements GamePlugin {
|
||||||
if (mappingPath != null) {
|
if (mappingPath != null) {
|
||||||
mappings = readIntemediaryMappings(mappingPath);
|
mappings = readIntemediaryMappings(mappingPath);
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt"))
|
mappings = MojmapProvider.get(version, remappedGamePath.resolveSibling("client-" + version + ".txt"))
|
||||||
.reverse();
|
.reverse();
|
||||||
|
} catch (NullPointerException e) { // NPE is only thrown if the mappings for this version can't be found
|
||||||
|
LOGGER.info("Mojmap is not available for version {}, using ornithe's calamus as a fallback!", version);
|
||||||
|
Path file = remappedGamePath.resolveSibling("calamus-"+version+".tiny");
|
||||||
|
if (!Files.exists(file)) {
|
||||||
|
String location = FrogLoaderImpl.getInstance().getGson().fromJson(HttpHelper.getString(String.format(CALAMUS_META_URL, version)), JsonArray.class)
|
||||||
|
.get(0).getAsJsonObject().get("maven").getAsString();
|
||||||
|
String[] groups = location.split(":");
|
||||||
|
HttpHelper.download(String.format(CALAMUS_MAVEN_URL,
|
||||||
|
location.replaceAll("[.:]", "/")+"/"+groups[1]+"-"+groups[2]+".jar"),
|
||||||
|
file);
|
||||||
|
}
|
||||||
|
mappings = TinyV2Parser.parse(Files.readString(file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mappings == null) {
|
if (mappings == null) {
|
||||||
mappings = readIntemediaryMappings("/mappings/mappings.tiny");
|
mappings = readIntemediaryMappings("/mappings/mappings.tiny");
|
||||||
|
|
Loading…
Reference in a new issue