1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2025-01-05 19:09:03 +01:00

Fix library handling bug in cases of bad JSON key ordering

This commit is contained in:
Henry Le Grys 2021-01-29 16:21:59 +00:00
parent 9aced19edc
commit 40fcfdf992

View File

@ -190,7 +190,9 @@ public class Library {
Artifact virtualArtifact = new Artifact();
virtualArtifact.setUrl(url);
virtualArtifact.setPath(mavenNameToPath(name));
if (getName() != null) {
virtualArtifact.setPath(mavenNameToPath(getName()));
}
Downloads downloads = new Downloads();
downloads.setArtifact(virtualArtifact);
@ -198,13 +200,28 @@ public class Library {
setDownloads(downloads);
}
public void setName(String name) {
this.name = name;
// [DEEP SIGH]
// Sometimes 'name' comes after 'url', and I can't figure out how to get Jackson to enforce order
// So we have to do this silly check to make sure we have a path.
if (getDownloads() != null) {
if (getDownloads().getArtifact() == null) return;
if (getDownloads().getArtifact().getPath() == null) {
getDownloads().getArtifact().setPath(mavenNameToPath(name));
}
}
}
/**
* BACKWARDS COMPATIBILITY:
* Some old Forge distributions use a parameter called "serverreq" to indicate that the dependency should
* be fetched from the Minecraft library source; this setter handles that.
*/
public void setServerreq(boolean value) {
if (value) {
if (value && getDownloads() == null) {
setUrl("https://libraries.minecraft.net/"); // TODO get this from properties?
}
}