MultiMC modpack patch json file may have "+libraries" or "libraries"

This commit is contained in:
huanghongxun 2019-01-22 15:51:52 +08:00
parent bcff1695d3
commit 76d35af5b9

View File

@ -20,6 +20,7 @@ package org.jackhuang.hmcl.mod;
import com.google.gson.annotations.SerializedName;
import org.jackhuang.hmcl.game.Library;
import org.jackhuang.hmcl.util.Immutable;
import org.jackhuang.hmcl.util.Lang;
import java.util.ArrayList;
import java.util.Collections;
@ -44,19 +45,23 @@ public final class MultiMCInstancePatch {
private final List<String> tweakers;
@SerializedName("+libraries")
private final List<Library> _libraries;
@SerializedName("libraries")
private final List<Library> libraries;
public MultiMCInstancePatch() {
this("", "", "", "", "", Collections.emptyList(), Collections.emptyList());
this("", "", "", "", "", Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
public MultiMCInstancePatch(String name, String version, String gameVersion, String mainClass, String fileId, List<String> tweakers, List<Library> libraries) {
public MultiMCInstancePatch(String name, String version, String gameVersion, String mainClass, String fileId, List<String> tweakers, List<Library> _libraries, List<Library> libraries) {
this.name = name;
this.version = version;
this.gameVersion = gameVersion;
this.mainClass = mainClass;
this.fileId = fileId;
this.tweakers = new ArrayList<>(tweakers);
this._libraries = new ArrayList<>(_libraries);
this.libraries = new ArrayList<>(libraries);
}
@ -85,7 +90,7 @@ public final class MultiMCInstancePatch {
}
public List<Library> getLibraries() {
return Collections.unmodifiableList(libraries);
return Lang.merge(_libraries, libraries);
}
}