add server mojmap to MojmapProvider
Some checks are pending
Publish to snapshot maven / build (push) Waiting to run
Some checks are pending
Publish to snapshot maven / build (push) Waiting to run
This commit is contained in:
parent
5ce38092c6
commit
2a83eb607e
|
@ -8,7 +8,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.16"
|
||||
version = "0.0.1-alpha.17"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -32,7 +32,7 @@ public class Thyroxine {
|
|||
|
||||
public static void run(String minecraftVersion, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
||||
Path out = outputJar.toAbsolutePath();
|
||||
MappingBundle data = MojmapProvider.get(minecraftVersion,
|
||||
MappingBundle data = MojmapProvider.get(minecraftVersion, "client",
|
||||
out.resolveSibling("client-" + minecraftVersion + ".txt")).reverse();
|
||||
|
||||
MappingBundle parchment = null;
|
||||
|
|
|
@ -11,16 +11,27 @@ import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
|||
import dev.frogmc.thyroxine.Constants;
|
||||
import dev.frogmc.thyroxine.HttpHelper;
|
||||
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
||||
import dev.frogmc.thyroxine.api.data.MappingData;
|
||||
import dev.frogmc.thyroxine.parser.ProguardParser;
|
||||
|
||||
public class MojmapProvider {
|
||||
|
||||
public static MappingBundle get(String gameVersion, Path cacheFile) throws IOException {
|
||||
return new MappingBundle(ProguardParser.read(getMappings(gameVersion, cacheFile)));
|
||||
MappingData client = ProguardParser.read(getMappings(gameVersion, "client", cacheFile));
|
||||
MappingData server = ProguardParser.read(getMappings(gameVersion, "server", cacheFile));
|
||||
client.classes().putAll(server.classes());
|
||||
client.fields().putAll(server.fields());
|
||||
client.methods().putAll(server.methods());
|
||||
client.parameters().putAll(server.parameters());
|
||||
return new MappingBundle(client);
|
||||
}
|
||||
|
||||
public static MappingBundle get(String gameVersion, String env, Path cacheFile) throws IOException {
|
||||
return new MappingBundle(ProguardParser.read(getMappings(gameVersion, env, cacheFile)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static String getMappings(String gameVersion, Path cacheFile) throws IOException {
|
||||
private static String getMappings(String gameVersion, String env, Path cacheFile) throws IOException {
|
||||
if (Files.exists(cacheFile)) {
|
||||
return Files.readString(cacheFile, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
@ -39,7 +50,7 @@ public class MojmapProvider {
|
|||
|
||||
UnmodifiableConfig versionManifest = HttpHelper.getJson(version.get("url"));
|
||||
String mappingsUrl = ((UnmodifiableConfig) ((UnmodifiableConfig) versionManifest
|
||||
.get("downloads")).get("client_mappings")).get("url");
|
||||
.get("downloads")).get(env+"_mappings")).get("url");
|
||||
|
||||
String s = HttpHelper.getString(mappingsUrl);
|
||||
Files.createDirectories(cacheFile.getParent());
|
||||
|
@ -47,7 +58,7 @@ public class MojmapProvider {
|
|||
return s;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not find mojmap for the specified version: " + gameVersion + "!");
|
||||
throw new IllegalArgumentException("Could not find mojmap for the specified version: " + gameVersion + "/"+env+"!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue