|
13 | 13 | import java.time.LocalDateTime; |
14 | 14 | import java.time.LocalTime; |
15 | 15 | import java.time.ZoneId; |
| 16 | +import java.time.format.DateTimeFormatter; |
16 | 17 | import java.util.*; |
17 | 18 | import java.util.concurrent.atomic.AtomicInteger; |
18 | 19 | import java.util.stream.Collectors; |
@@ -52,7 +53,7 @@ private static void install(String[] ids) { |
52 | 53 | } |
53 | 54 | try { |
54 | 55 | JSONObject json = Utils.runRetry(() -> (JSONObject) Utils.readJsonFromUrl(Constants.CURSEFORGE_API + id)); |
55 | | - if (((long) ((JSONObject) json.get("categorySection")).get("gameCategoryId")) != 4471) |
| 56 | + if (((long) json.get("classId")) != 4471) |
56 | 57 | throw new NoSuchObjectException("The ID " + id + " does not represent a modpack."); |
57 | 58 | JSONObject files; |
58 | 59 | if (fileId == null) files = (JSONObject) Utils.getLast((JSONArray) json.get("latestFiles")); |
@@ -81,7 +82,7 @@ private static void install(String[] ids) { |
81 | 82 | FileUtils.deleteDirectory(packFolder); |
82 | 83 | } |
83 | 84 | packFolder.mkdir(); |
84 | | - String downloadUrl = ((String) files.get("downloadUrl")).replaceFirst("edge", "media"); |
| 85 | + String downloadUrl = ((String) files.get("downloadUrl")); |
85 | 86 | String loc = Utils.downloadFile(downloadUrl, packFolder.getAbsolutePath()); |
86 | 87 | if (loc == null) throw new SyncFailedException("Failed to download modpack " + name); |
87 | 88 | boolean success = Utils.unzip(loc); |
@@ -233,13 +234,13 @@ private static void genProfile(String name, String path, String icon, String loa |
233 | 234 | JSONObject json = (JSONObject) parser.parse(new FileReader(profileFile)); |
234 | 235 | JSONObject profiles = (JSONObject) json.get("profiles"); |
235 | 236 | JSONObject profile = new JSONObject(); |
236 | | - profile.put("created", LocalDateTime.now(ZoneId.of("UTC")).toString()); |
| 237 | + profile.put("created", LocalDateTime.now().format(DateTimeFormatter.ISO_INSTANT)); |
237 | 238 | profile.put("gameDir", path); |
238 | 239 | if (base64 == null) profile.put("icon", "Furnace_On"); |
239 | 240 | else profile.put("icon", base64); |
240 | 241 | int memory = (int) Math.ceil(Runtime.getRuntime().maxMemory() / 1024.0 / 1024.0 / 1024.0); |
241 | 242 | profile.put("javaArgs", String.format("-Xmx%dG -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M", memory)); |
242 | | - profile.put("lastUsed", LocalDateTime.of(LocalDate.MIN, LocalTime.MIN).atZone(ZoneId.of("UTC")).toString()); |
| 243 | + profile.put("lastUsed", "1970-01-01T00:00:00.000Z"); |
243 | 244 | profile.put("lastVersionId", loader == null ? "latest-release" : loader); |
244 | 245 | profile.put("name", name); |
245 | 246 | profile.put("type", "custom"); |
@@ -358,13 +359,13 @@ private static void update(String[] ids, boolean force) { |
358 | 359 | } |
359 | 360 | String finalKey = key; |
360 | 361 | JSONObject json = Utils.runRetry(() -> (JSONObject) Utils.readJsonFromUrl(Constants.CURSEFORGE_API + finalKey)); |
361 | | - if (((long) ((JSONObject) json.get("categorySection")).get("gameCategoryId")) != 4471) |
| 362 | + if (((long) json.get("classId")) != 4471) |
362 | 363 | throw new NoSuchObjectException("The ID " + id + " does not represent a modpack."); |
363 | 364 | String name = (String) json.get("name"); |
364 | 365 | System.out.println(Ansi.ansi().fg(Ansi.Color.YELLOW).a("Updating ").a(name).a("...").reset()); |
365 | 366 | File packFolder = new File(Config.modpackDir.getAbsolutePath() + File.separator + slug + "_" + key); |
366 | 367 | JSONObject latest = (JSONObject) Utils.getLast((JSONArray) json.get("latestFiles")); |
367 | | - String downloadUrl = ((String) latest.get("downloadUrl")).replaceFirst("edge", "media"); |
| 368 | + String downloadUrl = ((String) latest.get("downloadUrl")); |
368 | 369 | String loc = Utils.downloadFile(downloadUrl, packFolder.getAbsolutePath()); |
369 | 370 | if (loc == null) throw new SyncFailedException("Failed to download modpack " + name); |
370 | 371 | boolean success = Utils.unzip(loc); |
|
0 commit comments