|
21 | 21 | import com.google.gson.JsonObject; |
22 | 22 | import com.google.gson.JsonParseException; |
23 | 23 | import org.jackhuang.hmcl.task.FileDownloadTask.IntegrityCheck; |
24 | | -import org.jackhuang.hmcl.util.Pack200Utils; |
25 | 24 | import org.jackhuang.hmcl.util.gson.JsonUtils; |
26 | 25 | import org.jackhuang.hmcl.util.io.NetworkUtils; |
27 | 26 |
|
28 | 27 | import java.io.IOException; |
29 | 28 | import java.util.Optional; |
30 | 29 |
|
31 | | -public class RemoteVersion { |
| 30 | +public final class RemoteVersion { |
32 | 31 |
|
33 | 32 | public static RemoteVersion fetch(UpdateChannel channel, String url) throws IOException { |
34 | 33 | try { |
35 | 34 | JsonObject response = JsonUtils.fromNonNullJson(NetworkUtils.doGet(NetworkUtils.toURL(url)), JsonObject.class); |
36 | 35 | String version = Optional.ofNullable(response.get("version")).map(JsonElement::getAsString).orElseThrow(() -> new IOException("version is missing")); |
37 | 36 | String jarUrl = Optional.ofNullable(response.get("jar")).map(JsonElement::getAsString).orElse(null); |
38 | 37 | String jarHash = Optional.ofNullable(response.get("jarsha1")).map(JsonElement::getAsString).orElse(null); |
39 | | - String packXZUrl = Optional.ofNullable(response.get("packxz")).map(JsonElement::getAsString).orElse(null); |
40 | | - String packXZHash = Optional.ofNullable(response.get("packxzsha1")).map(JsonElement::getAsString).orElse(null); |
41 | 38 | boolean force = Optional.ofNullable(response.get("force")).map(JsonElement::getAsBoolean).orElse(false); |
42 | | - if (Pack200Utils.isSupported() && packXZUrl != null && packXZHash != null) { |
43 | | - return new RemoteVersion(channel, version, packXZUrl, Type.PACK_XZ, new IntegrityCheck("SHA-1", packXZHash), force); |
44 | | - } else if (jarUrl != null && jarHash != null) { |
| 39 | + if (jarUrl != null && jarHash != null) { |
45 | 40 | return new RemoteVersion(channel, version, jarUrl, Type.JAR, new IntegrityCheck("SHA-1", jarHash), force); |
46 | 41 | } else { |
47 | 42 | throw new IOException("No download url is available"); |
@@ -97,7 +92,6 @@ public String toString() { |
97 | 92 | } |
98 | 93 |
|
99 | 94 | public enum Type { |
100 | | - PACK_XZ, |
101 | 95 | JAR |
102 | 96 | } |
103 | 97 | } |
0 commit comments