add server mojmap to MojmapProvider
All checks were successful
Publish to snapshot maven / build (push) Successful in 54s
All checks were successful
Publish to snapshot maven / build (push) Successful in 54s
This commit is contained in:
parent
5ce38092c6
commit
e08ed69730
|
@ -8,7 +8,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.frogmc"
|
group = "dev.frogmc"
|
||||||
version = "0.0.1-alpha.16"
|
version = "0.0.1-alpha.17"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
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 {
|
public static void run(String minecraftVersion, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
||||||
Path out = outputJar.toAbsolutePath();
|
Path out = outputJar.toAbsolutePath();
|
||||||
MappingBundle data = MojmapProvider.get(minecraftVersion,
|
MappingBundle data = MojmapProvider.get(minecraftVersion, "client",
|
||||||
out.resolveSibling("client-" + minecraftVersion + ".txt")).reverse();
|
out.resolveSibling("client-" + minecraftVersion + ".txt")).reverse();
|
||||||
|
|
||||||
MappingBundle parchment = null;
|
MappingBundle parchment = null;
|
||||||
|
|
|
@ -11,16 +11,27 @@ import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||||
import dev.frogmc.thyroxine.Constants;
|
import dev.frogmc.thyroxine.Constants;
|
||||||
import dev.frogmc.thyroxine.HttpHelper;
|
import dev.frogmc.thyroxine.HttpHelper;
|
||||||
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
||||||
|
import dev.frogmc.thyroxine.api.data.MappingData;
|
||||||
import dev.frogmc.thyroxine.parser.ProguardParser;
|
import dev.frogmc.thyroxine.parser.ProguardParser;
|
||||||
|
|
||||||
public class MojmapProvider {
|
public class MojmapProvider {
|
||||||
|
|
||||||
public static MappingBundle get(String gameVersion, Path cacheFile) throws IOException {
|
public static MappingBundle get(String gameVersion, Path clientCacheFile, Path serverCacheFile) throws IOException {
|
||||||
return new MappingBundle(ProguardParser.read(getMappings(gameVersion, cacheFile)));
|
MappingData client = ProguardParser.read(getMappings(gameVersion, "client", clientCacheFile));
|
||||||
|
MappingData server = ProguardParser.read(getMappings(gameVersion, "server", serverCacheFile));
|
||||||
|
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")
|
@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)) {
|
if (Files.exists(cacheFile)) {
|
||||||
return Files.readString(cacheFile, StandardCharsets.UTF_8);
|
return Files.readString(cacheFile, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +50,7 @@ public class MojmapProvider {
|
||||||
|
|
||||||
UnmodifiableConfig versionManifest = HttpHelper.getJson(version.get("url"));
|
UnmodifiableConfig versionManifest = HttpHelper.getJson(version.get("url"));
|
||||||
String mappingsUrl = ((UnmodifiableConfig) ((UnmodifiableConfig) versionManifest
|
String mappingsUrl = ((UnmodifiableConfig) ((UnmodifiableConfig) versionManifest
|
||||||
.get("downloads")).get("client_mappings")).get("url");
|
.get("downloads")).get(env+"_mappings")).get("url");
|
||||||
|
|
||||||
String s = HttpHelper.getString(mappingsUrl);
|
String s = HttpHelper.getString(mappingsUrl);
|
||||||
Files.createDirectories(cacheFile.getParent());
|
Files.createDirectories(cacheFile.getParent());
|
||||||
|
@ -47,7 +58,7 @@ public class MojmapProvider {
|
||||||
return s;
|
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