fix cache dir creation for mojmap
All checks were successful
Publish to snapshot maven / build (push) Successful in 41s
All checks were successful
Publish to snapshot maven / build (push) Successful in 41s
This commit is contained in:
parent
f90baaef1b
commit
811b4e3611
|
@ -8,7 +8,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1-alpha.10"
|
||||
version = "0.0.1-alpha.11"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
@ -20,35 +20,36 @@ public class MojmapProvider {
|
|||
return getMappings(gameVersion, cacheFile).map(ProguardParser::read).map(MappingBundle::new);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Optional<String> getMappings(String gameVersion, Path cacheFile) {
|
||||
if (Files.exists(cacheFile)){
|
||||
if (Files.exists(cacheFile)){
|
||||
try {
|
||||
return Optional.of(Files.readString(cacheFile, StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
// TODO
|
||||
// TODO
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return HttpHelper.getJson(Constants.VERSION_MANIFEST).flatMap(manifest -> {
|
||||
String versionName;
|
||||
if (gameVersion.startsWith("latest-")) {
|
||||
versionName = (String) ((Map<?, ?>) manifest.get("latest")).get(gameVersion.split("-")[1]);
|
||||
} else {
|
||||
versionName = gameVersion;
|
||||
}
|
||||
return HttpHelper.getJson(Constants.VERSION_MANIFEST).flatMap(manifest -> {
|
||||
String versionName;
|
||||
if (gameVersion.startsWith("latest-")) {
|
||||
versionName = (String) ((Map<?, ?>) manifest.get("latest")).get(gameVersion.split("-")[1]);
|
||||
} else {
|
||||
versionName = gameVersion;
|
||||
}
|
||||
|
||||
System.out.println("Loading version: " + versionName);
|
||||
System.out.println("Loading version: " + versionName);
|
||||
|
||||
for (UnmodifiableConfig version : (List<UnmodifiableConfig>) manifest.get("versions")) {
|
||||
if (version.get("id").equals(versionName)) {
|
||||
for (UnmodifiableConfig version : (List<UnmodifiableConfig>) manifest.get("versions")) {
|
||||
if (version.get("id").equals(versionName)) {
|
||||
|
||||
UnmodifiableConfig versionManifest = HttpHelper.getJson(version.get("url")).orElseThrow();
|
||||
String mappingsUrl = ((UnmodifiableConfig) ((UnmodifiableConfig) versionManifest
|
||||
.get("downloads")).get("client_mappings")).get("url");
|
||||
UnmodifiableConfig versionManifest = HttpHelper.getJson(version.get("url")).orElseThrow();
|
||||
String mappingsUrl = ((UnmodifiableConfig) ((UnmodifiableConfig) versionManifest
|
||||
.get("downloads")).get("client_mappings")).get("url");
|
||||
|
||||
return HttpHelper.getString(mappingsUrl).map(s -> {
|
||||
return HttpHelper.getString(mappingsUrl).map(s -> {
|
||||
try {
|
||||
Files.createDirectories(cacheFile.getParent());
|
||||
Files.writeString(cacheFile, s);
|
||||
} catch (IOException e) {
|
||||
// TODO
|
||||
|
@ -56,10 +57,10 @@ public class MojmapProvider {
|
|||
}
|
||||
return s;
|
||||
});
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue