mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2026-10-16 21:21:33 +08:00
转化 CurseMetaMod 为 Record (#6822)
This commit is contained in:
@@ -26,43 +26,28 @@ import org.jackhuang.hmcl.util.Immutable;
|
||||
* https://addons-ecs.forgesvc.net/api/v2/addon/<projectID>/file/<fileID>
|
||||
*/
|
||||
@Immutable
|
||||
public final class CurseMetaMod {
|
||||
@SerializedName(value = "Id", alternate = "id")
|
||||
private final int id;
|
||||
public record CurseMetaMod(@SerializedName(value = "Id", alternate = "id") int id,
|
||||
@SerializedName(value = "FileName", alternate = "fileName") String fileName,
|
||||
@SerializedName(value = "FileNameOnDisk") String fileNameOnDisk,
|
||||
@SerializedName(value = "DownloadURL", alternate = "downloadUrl") String downloadURL) {
|
||||
|
||||
@SerializedName(value = "FileName", alternate = "fileName")
|
||||
private final String fileName;
|
||||
|
||||
@SerializedName(value = "FileNameOnDisk")
|
||||
private final String fileNameOnDisk;
|
||||
|
||||
@SerializedName(value = "DownloadURL", alternate = "downloadUrl")
|
||||
private final String downloadURL;
|
||||
|
||||
public CurseMetaMod() {
|
||||
this(0, "", "", "");
|
||||
}
|
||||
|
||||
public CurseMetaMod(int id, String fileName, String fileNameOnDisk, String downloadURL) {
|
||||
this.id = id;
|
||||
this.fileName = fileName;
|
||||
this.fileNameOnDisk = fileNameOnDisk;
|
||||
this.downloadURL = downloadURL;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@Override
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
@Override
|
||||
public String fileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public String getFileNameOnDisk() {
|
||||
@Override
|
||||
public String fileNameOnDisk() {
|
||||
return fileNameOnDisk;
|
||||
}
|
||||
|
||||
public String getDownloadURL() {
|
||||
@Override
|
||||
public String downloadURL() {
|
||||
return downloadURL;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -223,7 +223,7 @@ public class McbbsModpackCompletionTask extends CompletableFutureTask<Void> {
|
||||
try {
|
||||
String result = NetworkUtils.doGet(String.format("https://cursemeta.dries007.net/%d/%d.json", file.getProjectID(), file.getFileID()));
|
||||
CurseMetaMod mod = JsonUtils.fromNonNullJson(result, CurseMetaMod.class);
|
||||
return file.withFileName(mod.getFileNameOnDisk()).withURL(mod.getDownloadURL());
|
||||
return file.withFileName(mod.fileNameOnDisk()).withURL(mod.downloadURL());
|
||||
} catch (FileNotFoundException fof) {
|
||||
LOG.warning("Could not query cursemeta for deleted mods: " + file.getUrl(), fof);
|
||||
notFound.set(true);
|
||||
@@ -232,7 +232,7 @@ public class McbbsModpackCompletionTask extends CompletableFutureTask<Void> {
|
||||
try {
|
||||
String result = NetworkUtils.doGet(String.format("https://addons-ecs.forgesvc.net/api/v2/addon/%d/file/%d", file.getProjectID(), file.getFileID()));
|
||||
CurseMetaMod mod = JsonUtils.fromNonNullJson(result, CurseMetaMod.class);
|
||||
return file.withFileName(mod.getFileName()).withURL(mod.getDownloadURL());
|
||||
return file.withFileName(mod.fileName()).withURL(mod.downloadURL());
|
||||
} catch (FileNotFoundException fof) {
|
||||
LOG.warning("Could not query forgesvc for deleted mods: " + file.getUrl(), fof);
|
||||
notFound.set(true);
|
||||
|
||||
Reference in New Issue
Block a user