mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-18 08:16:58 -04:00
FIx: unable to download Forge installer
This commit is contained in:
parent
a9feb65fc8
commit
ce3b9e3b1f
@ -28,11 +28,16 @@ import org.jackhuang.hmcl.util.StringUtils;
|
|||||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||||
import org.jackhuang.hmcl.util.gson.Validation;
|
import org.jackhuang.hmcl.util.gson.Validation;
|
||||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||||
|
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||||
|
|
||||||
public final class ForgeBMCLVersionList extends VersionList<ForgeRemoteVersion> {
|
public final class ForgeBMCLVersionList extends VersionList<ForgeRemoteVersion> {
|
||||||
|
|
||||||
public static final ForgeBMCLVersionList INSTANCE = new ForgeBMCLVersionList();
|
public static final ForgeBMCLVersionList INSTANCE = new ForgeBMCLVersionList();
|
||||||
@ -79,10 +84,13 @@ public final class ForgeBMCLVersionList extends VersionList<ForgeRemoteVersion>
|
|||||||
String jar = null;
|
String jar = null;
|
||||||
for (ForgeVersion.File file : version.getFiles())
|
for (ForgeVersion.File file : version.getFiles())
|
||||||
if ("installer".equals(file.getCategory()) && "jar".equals(file.getFormat())) {
|
if ("installer".equals(file.getCategory()) && "jar".equals(file.getFormat())) {
|
||||||
String classifier = gameVersion + "-" + version.getVersion()
|
jar = NetworkUtils.withQuery("https://bmclapi2.bangbang93.com/forge/download", mapOf(
|
||||||
+ (StringUtils.isNotBlank(version.getBranch()) ? "-" + version.getBranch() : "");
|
pair("mcversion", version.getGameVersion()),
|
||||||
String fileName = "forge-" + classifier + "-" + file.getCategory() + "." + file.getFormat();
|
pair("version", version.getVersion()),
|
||||||
jar = "https://bmclapi2.bangbang93.com/maven/net/minecraftforge/forge/" + classifier + "/" + fileName;
|
pair("branch", version.getBranch()),
|
||||||
|
pair("category", file.getCategory()),
|
||||||
|
pair("format", file.getFormat())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jar == null)
|
if (jar == null)
|
||||||
@ -121,18 +129,22 @@ public final class ForgeBMCLVersionList extends VersionList<ForgeRemoteVersion>
|
|||||||
this.files = files;
|
this.files = files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getBranch() {
|
public String getBranch() {
|
||||||
return branch;
|
return branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public String getGameVersion() {
|
public String getGameVersion() {
|
||||||
return mcversion;
|
return mcversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public List<File> getFiles() {
|
public List<File> getFiles() {
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
@ -231,12 +231,13 @@ public class ForgeNewInstallTask extends Task<Version> {
|
|||||||
|
|
||||||
command.add(mainClass);
|
command.add(mainClass);
|
||||||
|
|
||||||
List<String> args = processor.getArgs().stream().map(arg -> {
|
List<String> args = new ArrayList<>(processor.getArgs().size());
|
||||||
|
for (String arg : processor.getArgs()) {
|
||||||
String parsed = parseLiteral(arg, data, ExceptionalFunction.identity());
|
String parsed = parseLiteral(arg, data, ExceptionalFunction.identity());
|
||||||
if (parsed == null)
|
if (parsed == null)
|
||||||
throw new IOException("Invalid forge installation configuration");
|
throw new IOException("Invalid forge installation configuration");
|
||||||
return parsed;
|
args.add(parsed);
|
||||||
}).collect(Collectors.toList());
|
}
|
||||||
|
|
||||||
command.addAll(args);
|
command.addAll(args);
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ public final class NetworkUtils {
|
|||||||
StringBuilder sb = new StringBuilder(baseUrl);
|
StringBuilder sb = new StringBuilder(baseUrl);
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Entry<String, String> param : params.entrySet()) {
|
for (Entry<String, String> param : params.entrySet()) {
|
||||||
|
if (param.getValue() == null)
|
||||||
|
continue;
|
||||||
if (first) {
|
if (first) {
|
||||||
sb.append('?');
|
sb.append('?');
|
||||||
first = false;
|
first = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user