diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java index ec84a86f4..1bc1b7cba 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java @@ -24,7 +24,7 @@ import javafx.scene.Node; import javafx.scene.layout.BorderPane; import org.jackhuang.hmcl.download.*; import org.jackhuang.hmcl.download.game.GameRemoteVersion; -import org.jackhuang.hmcl.mod.RemoteModRepository; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.mod.curse.CurseForgeRemoteModRepository; import org.jackhuang.hmcl.setting.DownloadProviders; import org.jackhuang.hmcl.setting.Profile; @@ -154,7 +154,7 @@ public class DownloadPage extends BorderPane implements DecoratorPage { setCenter(transitionPane); } - private void download(Profile profile, @Nullable String version, RemoteModRepository.Version file, String subdirectoryName) { + private void download(Profile profile, @Nullable String version, RemoteMod.Version file, String subdirectoryName) { if (version == null) version = profile.getSelectedVersion(); Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java index f0c45d787..cba2b7371 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java @@ -40,6 +40,7 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.*; import org.jackhuang.hmcl.game.GameVersion; import org.jackhuang.hmcl.game.Version; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.mod.RemoteModRepository; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.task.Schedulers; @@ -74,7 +75,7 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP private final BooleanProperty failed = new SimpleBooleanProperty(false); private final boolean versionSelection; private final ObjectProperty version = new SimpleObjectProperty<>(); - private final ListProperty items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); + private final ListProperty items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); private final ObservableList versions = FXCollections.observableArrayList(); private final StringProperty selectedVersion = new SimpleStringProperty(); private final DownloadPage.DownloadCallback callback; @@ -351,16 +352,16 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP } }, getSkinnable().failedProperty())); - JFXListView listView = new JFXListView<>(); + JFXListView listView = new JFXListView<>(); spinnerPane.setContent(listView); Bindings.bindContent(listView.getItems(), getSkinnable().items); listView.setOnMouseClicked(e -> { if (listView.getSelectionModel().getSelectedIndex() < 0) return; - RemoteModRepository.Mod selectedItem = listView.getSelectionModel().getSelectedItem(); + RemoteMod selectedItem = listView.getSelectionModel().getSelectedItem(); Controllers.navigate(new DownloadPage(getSkinnable(), selectedItem, getSkinnable().getProfileVersion(), getSkinnable().callback)); }); - listView.setCellFactory(x -> new FloatListCell(listView) { + listView.setCellFactory(x -> new FloatListCell(listView) { TwoLineListItem content = new TwoLineListItem(); ImageView imageView = new ImageView(); @@ -373,7 +374,7 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP } @Override - protected void updateControl(RemoteModRepository.Mod dataItem, boolean empty) { + protected void updateControl(RemoteMod dataItem, boolean empty) { if (empty) return; ModTranslations.Mod mod = ModTranslations.getModByCurseForgeId(dataItem.getSlug()); content.setTitle(mod != null ? mod.getDisplayName() : dataItem.getTitle()); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java index 72e8e3e2e..242ed9562 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java @@ -37,7 +37,7 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.*; import javafx.stage.FileChooser; import org.jackhuang.hmcl.mod.ModManager; -import org.jackhuang.hmcl.mod.RemoteModRepository; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.task.FileDownloadTask; @@ -69,16 +69,16 @@ public class DownloadPage extends Control implements DecoratorPage { private final BooleanProperty loaded = new SimpleBooleanProperty(false); private final BooleanProperty loading = new SimpleBooleanProperty(false); private final BooleanProperty failed = new SimpleBooleanProperty(false); - private final RemoteModRepository.Mod addon; + private final RemoteMod addon; private final ModTranslations.Mod mod; private final Profile.ProfileVersion version; private final DownloadCallback callback; private final DownloadListPage page; - private List dependencies; - private SimpleMultimap versions; + private List dependencies; + private SimpleMultimap versions; - public DownloadPage(DownloadListPage page, RemoteModRepository.Mod addon, Profile.ProfileVersion version, @Nullable DownloadCallback callback) { + public DownloadPage(DownloadListPage page, RemoteMod addon, Profile.ProfileVersion version, @Nullable DownloadCallback callback) { this.page = page; this.addon = addon; this.mod = ModTranslations.getModByCurseForgeId(addon.getSlug()); @@ -95,7 +95,7 @@ public class DownloadPage extends Control implements DecoratorPage { Task.allOf( Task.supplyAsync(() -> addon.getData().loadDependencies()), Task.supplyAsync(() -> { - Stream versions = addon.getData().loadVersions(); + Stream versions = addon.getData().loadVersions(); // if (StringUtils.isNotBlank(version.getVersion())) { // Optional gameVersion = GameVersion.minecraftVersion(versionJar); // if (gameVersion.isPresent()) { @@ -108,9 +108,9 @@ public class DownloadPage extends Control implements DecoratorPage { .whenComplete(Schedulers.javafx(), (result, exception) -> { if (exception == null) { @SuppressWarnings("unchecked") - List dependencies = (List) result.get(0); + List dependencies = (List) result.get(0); @SuppressWarnings("unchecked") - SimpleMultimap versions = (SimpleMultimap) result.get(1); + SimpleMultimap versions = (SimpleMultimap) result.get(1); this.dependencies = dependencies; this.versions = versions; @@ -126,9 +126,9 @@ public class DownloadPage extends Control implements DecoratorPage { this.state.set(State.fromTitle(addon.getTitle())); } - private SimpleMultimap sortVersions(Stream versions) { - SimpleMultimap classifiedVersions - = new SimpleMultimap(HashMap::new, ArrayList::new); + private SimpleMultimap sortVersions(Stream versions) { + SimpleMultimap classifiedVersions + = new SimpleMultimap(HashMap::new, ArrayList::new); versions.forEach(version -> { for (String gameVersion : version.getGameVersions()) { classifiedVersions.put(gameVersion, version); @@ -136,13 +136,13 @@ public class DownloadPage extends Control implements DecoratorPage { }); for (String gameVersion : classifiedVersions.keys()) { - List versionList = (List) classifiedVersions.get(gameVersion); - versionList.sort(Comparator.comparing(RemoteModRepository.Version::getDatePublished).reversed()); + List versionList = (List) classifiedVersions.get(gameVersion); + versionList.sort(Comparator.comparing(RemoteMod.Version::getDatePublished).reversed()); } return classifiedVersions; } - public RemoteModRepository.Mod getAddon() { + public RemoteMod getAddon() { return addon; } @@ -174,7 +174,7 @@ public class DownloadPage extends Control implements DecoratorPage { this.failed.set(failed); } - public void download(RemoteModRepository.Version file) { + public void download(RemoteMod.Version file) { if (this.callback == null) { saveAs(file); } else { @@ -182,7 +182,7 @@ public class DownloadPage extends Control implements DecoratorPage { } } - public void saveAs(RemoteModRepository.Version file) { + public void saveAs(RemoteMod.Version file) { String extension = StringUtils.substringAfterLast(file.getFile().getFilename(), '.'); FileChooser fileChooser = new FileChooser(); @@ -328,7 +328,7 @@ public class DownloadPage extends Control implements DecoratorPage { private static final class DependencyModItem extends StackPane { - DependencyModItem(DownloadListPage page, RemoteModRepository.Mod addon, Profile.ProfileVersion version, DownloadCallback callback) { + DependencyModItem(DownloadListPage page, RemoteMod addon, Profile.ProfileVersion version, DownloadCallback callback) { HBox pane = new HBox(8); pane.setPadding(new Insets(8)); pane.setAlignment(Pos.CENTER_LEFT); @@ -355,7 +355,7 @@ public class DownloadPage extends Control implements DecoratorPage { } private static final class ModItem extends StackPane { - ModItem(RemoteModRepository.Version dataItem, DownloadPage selfPage) { + ModItem(RemoteMod.Version dataItem, DownloadPage selfPage) { HBox pane = new HBox(8); pane.setPadding(new Insets(8)); pane.setAlignment(Pos.CENTER_LEFT); @@ -399,6 +399,6 @@ public class DownloadPage extends Control implements DecoratorPage { private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault()); public interface DownloadCallback { - void download(Profile profile, @Nullable String version, RemoteModRepository.Version file); + void download(Profile profile, @Nullable String version, RemoteMod.Version file); } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java index 01794aeff..e612755a0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java @@ -17,6 +17,7 @@ */ package org.jackhuang.hmcl.ui.versions; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.mod.RemoteModRepository; import org.jackhuang.hmcl.mod.curse.CurseForgeRemoteModRepository; import org.jackhuang.hmcl.mod.modrinth.ModrinthRemoteModRepository; @@ -46,7 +47,7 @@ public class ModDownloadListPage extends DownloadListPage { private class Repository implements RemoteModRepository { @Override - public Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { + public Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { String newSearchFilter; if (StringUtils.CHINESE_PATTERN.matcher(searchFilter).find()) { List mods = ModTranslations.searchMod(searchFilter); @@ -76,7 +77,7 @@ public class ModDownloadListPage extends DownloadListPage { } @Override - public Optional getRemoteVersionByLocalFile(Path file) { + public Optional getRemoteVersionByLocalFile(Path file) { throw new UnsupportedOperationException(); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java index d0325ffc6..285a7ddec 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java @@ -24,7 +24,7 @@ import javafx.collections.ObservableList; import javafx.scene.control.Skin; import javafx.stage.FileChooser; import org.jackhuang.hmcl.download.LibraryAnalyzer; -import org.jackhuang.hmcl.mod.ModInfo; +import org.jackhuang.hmcl.mod.LocalMod; import org.jackhuang.hmcl.mod.ModManager; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.task.Schedulers; @@ -151,7 +151,7 @@ public final class ModListPage extends ListPageBase { static class ModInfoObject extends RecursiveTreeObject implements Comparable { private final BooleanProperty active; - private final ModInfo modInfo; + private final LocalMod localMod; private final String message; private final ModTranslations.Mod mod; - ModInfoObject(ModInfo modInfo) { - this.modInfo = modInfo; - this.active = modInfo.activeProperty(); - StringBuilder message = new StringBuilder(modInfo.getName()); - if (isNotBlank(modInfo.getVersion())) - message.append(", ").append(i18n("archive.version")).append(": ").append(modInfo.getVersion()); - if (isNotBlank(modInfo.getGameVersion())) - message.append(", ").append(i18n("archive.game_version")).append(": ").append(modInfo.getGameVersion()); - if (isNotBlank(modInfo.getAuthors())) - message.append(", ").append(i18n("archive.author")).append(": ").append(modInfo.getAuthors()); + ModInfoObject(LocalMod localMod) { + this.localMod = localMod; + this.active = localMod.activeProperty(); + StringBuilder message = new StringBuilder(localMod.getName()); + if (isNotBlank(localMod.getVersion())) + message.append(", ").append(i18n("archive.version")).append(": ").append(localMod.getVersion()); + if (isNotBlank(localMod.getGameVersion())) + message.append(", ").append(i18n("archive.game_version")).append(": ").append(localMod.getGameVersion()); + if (isNotBlank(localMod.getAuthors())) + message.append(", ").append(i18n("archive.author")).append(": ").append(localMod.getAuthors()); this.message = message.toString(); - this.mod = ModTranslations.getModById(modInfo.getId()); + this.mod = ModTranslations.getModById(localMod.getId()); } String getTitle() { - return modInfo.getFileName(); + return localMod.getFileName(); } String getSubtitle() { return message; } - ModInfo getModInfo() { - return modInfo; + LocalMod getModInfo() { + return localMod; } public ModTranslations.Mod getMod() { @@ -160,7 +160,7 @@ class ModListPageSkin extends SkinBase { @Override public int compareTo(@NotNull ModListPageSkin.ModInfoObject o) { - return modInfo.getFileName().toLowerCase().compareTo(o.modInfo.getFileName().toLowerCase()); + return localMod.getFileName().toLowerCase().compareTo(o.localMod.getFileName().toLowerCase()); } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java index 5a6a2d5c8..673f531b8 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/Versions.java @@ -25,7 +25,7 @@ import org.jackhuang.hmcl.download.game.GameAssetDownloadTask; import org.jackhuang.hmcl.game.GameDirectoryType; import org.jackhuang.hmcl.game.GameRepository; import org.jackhuang.hmcl.game.LauncherHelper; -import org.jackhuang.hmcl.mod.RemoteModRepository; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Profile; import org.jackhuang.hmcl.setting.Profiles; @@ -77,7 +77,7 @@ public final class Versions { } } - public static void downloadModpackImpl(Profile profile, String version, RemoteModRepository.Version file) { + public static void downloadModpackImpl(Profile profile, String version, RemoteMod.Version file) { Path modpack; URL downloadURL; try { diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/Datapack.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/Datapack.java index 29c8d5c09..ba9480a69 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/Datapack.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/Datapack.java @@ -202,10 +202,10 @@ public class Datapack { private Path file; private final BooleanProperty active; private final String id; - private final ModInfo.Description description; + private final LocalMod.Description description; private final Datapack datapack; - public Pack(Path file, String id, ModInfo.Description description, Datapack datapack) { + public Pack(Path file, String id, LocalMod.Description description, Datapack datapack) { this.file = file; this.id = id; this.description = description; @@ -235,7 +235,7 @@ public class Datapack { return id; } - public ModInfo.Description getDescription() { + public LocalMod.Description getDescription() { return description; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/FabricModMetadata.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/FabricModMetadata.java index 2ad52b3a6..9bd39aac1 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/FabricModMetadata.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/FabricModMetadata.java @@ -64,14 +64,14 @@ public final class FabricModMetadata { this.contact = contact; } - public static ModInfo fromFile(File modFile) throws IOException, JsonParseException { + public static LocalMod fromFile(File modFile) throws IOException, JsonParseException { try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modFile.toPath())) { Path mcmod = fs.getPath("fabric.mod.json"); if (Files.notExists(mcmod)) throw new IOException("File " + modFile + " is not a Fabric mod."); FabricModMetadata metadata = JsonUtils.fromNonNullJson(FileUtils.readText(mcmod), FabricModMetadata.class); String authors = metadata.authors == null ? "" : metadata.authors.stream().map(author -> author.name).collect(Collectors.joining(", ")); - return new ModInfo(modFile, metadata.id, metadata.name, new ModInfo.Description(metadata.description), + return new LocalMod(modFile, ModLoaderType.FABRIC, metadata.id, metadata.name, new LocalMod.Description(metadata.description), authors, metadata.version, "", metadata.contact != null ? metadata.contact.getOrDefault("homepage", "") : "", metadata.icon); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeNewModMetadata.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeNewModMetadata.java index c11f1fce6..15be9ba56 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeNewModMetadata.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeNewModMetadata.java @@ -116,7 +116,7 @@ public final class ForgeNewModMetadata { } } - public static ModInfo fromFile(File modFile) throws IOException, JsonParseException { + public static LocalMod fromFile(File modFile) throws IOException, JsonParseException { try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modFile.toPath())) { Path modstoml = fs.getPath("META-INF/mods.toml"); if (Files.notExists(modstoml)) @@ -135,7 +135,7 @@ public final class ForgeNewModMetadata { LOG.log(Level.WARNING, "Failed to parse MANIFEST.MF in file " + modFile.getPath()); } } - return new ModInfo(modFile, mod.getModId(), mod.getDisplayName(), new ModInfo.Description(mod.getDescription()), + return new LocalMod(modFile, ModLoaderType.FORGE, mod.getModId(), mod.getDisplayName(), new LocalMod.Description(mod.getDescription()), mod.getAuthors(), mod.getVersion().replace("${file.jarVersion}", jarVersion), "", mod.getDisplayURL(), metadata.getLogoFile()); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeOldModMetadata.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeOldModMetadata.java index 25d1930cd..06e60318f 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeOldModMetadata.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ForgeOldModMetadata.java @@ -120,7 +120,7 @@ public final class ForgeOldModMetadata { return authors; } - public static ModInfo fromFile(File modFile) throws IOException, JsonParseException { + public static LocalMod fromFile(File modFile) throws IOException, JsonParseException { try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modFile.toPath())) { Path mcmod = fs.getPath("mcmod.info"); if (Files.notExists(mcmod)) @@ -138,7 +138,7 @@ public final class ForgeOldModMetadata { authors = String.join(", ", metadata.getAuthorList()); if (StringUtils.isBlank(authors)) authors = metadata.getCredits(); - return new ModInfo(modFile, metadata.getModId(), metadata.getName(), new ModInfo.Description(metadata.getDescription()), + return new LocalMod(modFile, ModLoaderType.FORGE, metadata.getModId(), metadata.getName(), new LocalMod.Description(metadata.getDescription()), authors, metadata.getVersion(), metadata.getGameVersion(), StringUtils.isBlank(metadata.getUrl()) ? metadata.getUpdateUrl() : metadata.url, metadata.getLogoFile()); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LiteModMetadata.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LiteModMetadata.java index 27a062050..982f318b2 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LiteModMetadata.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LiteModMetadata.java @@ -108,7 +108,7 @@ public final class LiteModMetadata { return updateURI; } - public static ModInfo fromFile(File modFile) throws IOException, JsonParseException { + public static LocalMod fromFile(File modFile) throws IOException, JsonParseException { try (ZipFile zipFile = new ZipFile(modFile)) { ZipEntry entry = zipFile.getEntry("litemod.json"); if (entry == null) @@ -116,7 +116,7 @@ public final class LiteModMetadata { LiteModMetadata metadata = JsonUtils.GSON.fromJson(IOUtils.readFullyAsString(zipFile.getInputStream(entry)), LiteModMetadata.class); if (metadata == null) throw new IOException("Mod " + modFile + " `litemod.json` is malformed."); - return new ModInfo(modFile, null, metadata.getName(), new ModInfo.Description(metadata.getDescription()), metadata.getAuthor(), + return new LocalMod(modFile, ModLoaderType.FORGE, null, metadata.getName(), new LocalMod.Description(metadata.getDescription()), metadata.getAuthor(), metadata.getVersion(), metadata.getGameVersion(), metadata.getUpdateURI(), ""); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModInfo.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalMod.java similarity index 83% rename from HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModInfo.java rename to HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalMod.java index e07264a70..5bb1ee7b7 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModInfo.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalMod.java @@ -35,9 +35,10 @@ import java.util.logging.Level; * * @author huangyuhui */ -public final class ModInfo implements Comparable { +public final class LocalMod implements Comparable { private Path file; + private final ModLoaderType modLoaderType; private final String id; private final String name; private final Description description; @@ -49,12 +50,13 @@ public final class ModInfo implements Comparable { private final String logoPath; private final BooleanProperty activeProperty; - public ModInfo(File file, String id, String name, Description description) { - this(file, id, name, description, "", "", "", "", ""); + public LocalMod(File file, ModLoaderType modLoaderType, String id, String name, Description description) { + this(file, modLoaderType, id, name, description, "", "", "", "", ""); } - public ModInfo(File file, String id, String name, Description description, String authors, String version, String gameVersion, String url, String logoPath) { + public LocalMod(File file, ModLoaderType modLoaderType, String id, String name, Description description, String authors, String version, String gameVersion, String url, String logoPath) { this.file = file.toPath(); + this.modLoaderType = modLoaderType; this.id = id; this.name = name; this.description = description; @@ -67,13 +69,13 @@ public final class ModInfo implements Comparable { activeProperty = new SimpleBooleanProperty(this, "active", !ModManager.isDisabled(file)) { @Override protected void invalidated() { - Path path = ModInfo.this.file.toAbsolutePath(); + Path path = LocalMod.this.file.toAbsolutePath(); try { if (get()) - ModInfo.this.file = ModManager.enableMod(path); + LocalMod.this.file = ModManager.enableMod(path); else - ModInfo.this.file = ModManager.disableMod(path); + LocalMod.this.file = ModManager.disableMod(path); } catch (IOException e) { Logging.LOG.log(Level.SEVERE, "Unable to invert state of mod file " + path, e); } @@ -87,6 +89,10 @@ public final class ModInfo implements Comparable { return file; } + public ModLoaderType getModLoaderType() { + return modLoaderType; + } + public String getId() { return id; } @@ -136,13 +142,13 @@ public final class ModInfo implements Comparable { } @Override - public int compareTo(ModInfo o) { + public int compareTo(LocalMod o) { return getFileName().compareTo(o.getFileName()); } @Override public boolean equals(Object obj) { - return obj instanceof ModInfo && Objects.equals(getFileName(), ((ModInfo) obj).getFileName()); + return obj instanceof LocalMod && Objects.equals(getFileName(), ((LocalMod) obj).getFileName()); } @Override diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModLoaderType.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModLoaderType.java new file mode 100644 index 000000000..e6f433024 --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModLoaderType.java @@ -0,0 +1,26 @@ +/* + * Hello Minecraft! Launcher + * Copyright (C) 2020 huangyuhui and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.jackhuang.hmcl.mod; + +public enum ModLoaderType { + UNKNOWN, + FORGE, + FABRIC, + LITE_LOADER, + PACK +} diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModManager.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModManager.java index e431b701f..8af7112e6 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModManager.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/ModManager.java @@ -32,7 +32,7 @@ import java.util.TreeSet; public final class ModManager { private final GameRepository repository; private final String id; - private final TreeSet modInfos = new TreeSet<>(); + private final TreeSet localMods = new TreeSet<>(); private boolean loaded = false; @@ -55,12 +55,12 @@ public final class ModManager { private void addModInfo(File file) { try { - modInfos.add(getModInfo(file)); + localMods.add(getModInfo(file)); } catch (IllegalArgumentException ignore) { } } - public static ModInfo getModInfo(File modFile) { + public static LocalMod getModInfo(File modFile) { File file = isDisabled(modFile) ? new File(modFile.getAbsoluteFile().getParentFile(), FileUtils.getNameWithoutExtension(modFile)) : modFile; String description, extension = FileUtils.getExtension(file); switch (extension) { @@ -98,11 +98,11 @@ public final class ModManager { default: throw new IllegalArgumentException("File " + modFile + " is not a mod file."); } - return new ModInfo(modFile, null, FileUtils.getNameWithoutExtension(modFile), new ModInfo.Description(description)); + return new LocalMod(modFile, ModLoaderType.UNKNOWN, null, FileUtils.getNameWithoutExtension(modFile), new LocalMod.Description(description)); } public void refreshMods() throws IOException { - modInfos.clear(); + localMods.clear(); if (Files.isDirectory(getModsDirectory())) { try (DirectoryStream modsDirectoryStream = Files.newDirectoryStream(getModsDirectory())) { for (Path subitem : modsDirectoryStream) { @@ -122,10 +122,10 @@ public final class ModManager { loaded = true; } - public Collection getMods() throws IOException { + public Collection getMods() throws IOException { if (!loaded) refreshMods(); - return modInfos; + return localMods; } public void addMod(File file) throws IOException { @@ -145,9 +145,9 @@ public final class ModManager { addModInfo(newFile); } - public void removeMods(ModInfo... modInfos) throws IOException { - for (ModInfo modInfo : modInfos) { - Files.deleteIfExists(modInfo.getFile()); + public void removeMods(LocalMod... localMods) throws IOException { + for (LocalMod localMod : localMods) { + Files.deleteIfExists(localMod.getFile()); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/PackMcMeta.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/PackMcMeta.java index 44138751f..123e8ddf8 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/PackMcMeta.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/PackMcMeta.java @@ -66,13 +66,13 @@ public class PackMcMeta implements Validation { private final int packFormat; @SerializedName("description") - private final ModInfo.Description description; + private final LocalMod.Description description; public PackInfo() { - this(0, new ModInfo.Description(Collections.emptyList())); + this(0, new LocalMod.Description(Collections.emptyList())); } - public PackInfo(int packFormat, ModInfo.Description description) { + public PackInfo(int packFormat, LocalMod.Description description) { this.packFormat = packFormat; this.description = description; } @@ -81,7 +81,7 @@ public class PackMcMeta implements Validation { return packFormat; } - public ModInfo.Description getDescription() { + public LocalMod.Description getDescription() { return description; } } @@ -112,13 +112,13 @@ public class PackMcMeta implements Validation { } } - public ModInfo.Description.Part deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException { + public LocalMod.Description.Part deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonPrimitive()) { - return new ModInfo.Description.Part(parseText(json)); + return new LocalMod.Description.Part(parseText(json)); } else if (json.isJsonObject()) { JsonObject obj = json.getAsJsonObject(); String text = parseText(obj.get("text")); - return new ModInfo.Description.Part(text); + return new LocalMod.Description.Part(text); } else { throw new JsonParseException("pack.mcmeta Raw JSON text should be string or an object"); } @@ -126,31 +126,31 @@ public class PackMcMeta implements Validation { @Override public PackInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - List parts = new ArrayList<>(); + List parts = new ArrayList<>(); JsonObject packInfo = json.getAsJsonObject(); int packFormat = packInfo.get("pack_format").getAsInt(); JsonElement description = packInfo.get("description"); if (description.isJsonPrimitive()) { - parts.add(new ModInfo.Description.Part(parseText(description))); + parts.add(new LocalMod.Description.Part(parseText(description))); } else if (description.isJsonArray()) { for (JsonElement element : description.getAsJsonArray()) { JsonObject descriptionPart = element.getAsJsonObject(); - parts.add(new ModInfo.Description.Part(descriptionPart.get("text").getAsString(), descriptionPart.get("color").getAsString())); + parts.add(new LocalMod.Description.Part(descriptionPart.get("text").getAsString(), descriptionPart.get("color").getAsString())); } } else { throw new JsonParseException("pack.mcmeta::pack::description should be String or array of text objects with text and color fields"); } - return new PackInfo(packFormat, new ModInfo.Description(parts)); + return new PackInfo(packFormat, new LocalMod.Description(parts)); } } - public static ModInfo fromFile(File modFile) throws IOException, JsonParseException { + public static LocalMod fromFile(File modFile) throws IOException, JsonParseException { try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modFile.toPath())) { Path mcmod = fs.getPath("pack.mcmeta"); if (Files.notExists(mcmod)) throw new IOException("File " + modFile + " is not a resource pack."); PackMcMeta metadata = JsonUtils.fromNonNullJson(FileUtils.readText(mcmod), PackMcMeta.class); - return new ModInfo(modFile, null, FileUtils.getNameWithoutExtension(modFile), metadata.pack.description, "", "", "", "", ""); + return new LocalMod(modFile, ModLoaderType.PACK, null, FileUtils.getNameWithoutExtension(modFile), metadata.pack.description, "", "", "", "", ""); } } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteMod.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteMod.java new file mode 100644 index 000000000..63dadd478 --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteMod.java @@ -0,0 +1,180 @@ +/* + * Hello Minecraft! Launcher + * Copyright (C) 2021 huangyuhui and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.jackhuang.hmcl.mod; + +import java.io.IOException; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +public class RemoteMod { + private final String slug; + private final String author; + private final String title; + private final String description; + private final List categories; + private final String pageUrl; + private final String iconUrl; + private final IMod data; + + public RemoteMod(String slug, String author, String title, String description, List categories, String pageUrl, String iconUrl, IMod data) { + this.slug = slug; + this.author = author; + this.title = title; + this.description = description; + this.categories = categories; + this.pageUrl = pageUrl; + this.iconUrl = iconUrl; + this.data = data; + } + + public String getSlug() { + return slug; + } + + public String getAuthor() { + return author; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public List getCategories() { + return categories; + } + + public String getPageUrl() { + return pageUrl; + } + + public String getIconUrl() { + return iconUrl; + } + + public IMod getData() { + return data; + } + + public enum VersionType { + Release, + Beta, + Alpha + } + + public interface IMod { + List loadDependencies() throws IOException; + + Stream loadVersions() throws IOException; + } + + public static class Version { + private final Object self; + private final String name; + private final String version; + private final String changelog; + private final Instant datePublished; + private final VersionType versionType; + private final File file; + private final List dependencies; + private final List gameVersions; + private final List loaders; + + public Version(Object self, String name, String version, String changelog, Instant datePublished, VersionType versionType, File file, List dependencies, List gameVersions, List loaders) { + this.self = self; + this.name = name; + this.version = version; + this.changelog = changelog; + this.datePublished = datePublished; + this.versionType = versionType; + this.file = file; + this.dependencies = dependencies; + this.gameVersions = gameVersions; + this.loaders = loaders; + } + + public Object getSelf() { + return self; + } + + public String getName() { + return name; + } + + public String getVersion() { + return version; + } + + public String getChangelog() { + return changelog; + } + + public Instant getDatePublished() { + return datePublished; + } + + public VersionType getVersionType() { + return versionType; + } + + public File getFile() { + return file; + } + + public List getDependencies() { + return dependencies; + } + + public List getGameVersions() { + return gameVersions; + } + + public List getLoaders() { + return loaders; + } + } + + public static class File { + private final Map hashes; + private final String url; + private final String filename; + + public File(Map hashes, String url, String filename) { + this.hashes = hashes; + this.url = url; + this.filename = filename; + } + + public Map getHashes() { + return hashes; + } + + public String getUrl() { + return url; + } + + public String getFilename() { + return filename; + } + } +} diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteModRepository.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteModRepository.java index c897a5455..fe30e3b1a 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteModRepository.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/RemoteModRepository.java @@ -19,27 +19,19 @@ package org.jackhuang.hmcl.mod; import java.io.IOException; import java.nio.file.Path; -import java.time.Instant; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.stream.Stream; public interface RemoteModRepository { - Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) + Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException; - Optional getRemoteVersionByLocalFile(Path file) throws IOException; + Optional getRemoteVersionByLocalFile(Path file) throws IOException; Stream getCategories() throws IOException; - interface IMod { - List loadDependencies() throws IOException; - - Stream loadVersions() throws IOException; - } - class Category { private final Object self; private final String id; @@ -64,156 +56,6 @@ public interface RemoteModRepository { } } - class Mod { - private final String slug; - private final String author; - private final String title; - private final String description; - private final List categories; - private final String pageUrl; - private final String iconUrl; - private final IMod data; - - public Mod(String slug, String author, String title, String description, List categories, String pageUrl, String iconUrl, IMod data) { - this.slug = slug; - this.author = author; - this.title = title; - this.description = description; - this.categories = categories; - this.pageUrl = pageUrl; - this.iconUrl = iconUrl; - this.data = data; - } - - public String getSlug() { - return slug; - } - - public String getAuthor() { - return author; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public List getCategories() { - return categories; - } - - public String getPageUrl() { - return pageUrl; - } - - public String getIconUrl() { - return iconUrl; - } - - public IMod getData() { - return data; - } - } - - enum VersionType { - Release, - Beta, - Alpha - } - - class Version { - private final Object self; - private final String name; - private final String version; - private final String changelog; - private final Instant datePublished; - private final VersionType versionType; - private final File file; - private final List dependencies; - private final List gameVersions; - private final List loaders; - - public Version(Object self, String name, String version, String changelog, Instant datePublished, VersionType versionType, File file, List dependencies, List gameVersions, List loaders) { - this.self = self; - this.name = name; - this.version = version; - this.changelog = changelog; - this.datePublished = datePublished; - this.versionType = versionType; - this.file = file; - this.dependencies = dependencies; - this.gameVersions = gameVersions; - this.loaders = loaders; - } - - public Object getSelf() { - return self; - } - - public String getName() { - return name; - } - - public String getVersion() { - return version; - } - - public String getChangelog() { - return changelog; - } - - public Instant getDatePublished() { - return datePublished; - } - - public VersionType getVersionType() { - return versionType; - } - - public File getFile() { - return file; - } - - public List getDependencies() { - return dependencies; - } - - public List getGameVersions() { - return gameVersions; - } - - public List getLoaders() { - return loaders; - } - } - - class File { - private final Map hashes; - private final String url; - private final String filename; - - public File(Map hashes, String url, String filename) { - this.hashes = hashes; - this.url = url; - this.filename = filename; - } - - public Map getHashes() { - return hashes; - } - - public String getUrl() { - return url; - } - - public String getFilename() { - return filename; - } - } - String[] DEFAULT_GAME_VERSIONS = new String[]{ "1.17.1", "1.17", "1.16.5", "1.16.4", "1.16.3", "1.16.2", "1.16.1", "1.16", diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java index b3c5cbeaa..4597b9f96 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java @@ -17,7 +17,7 @@ */ package org.jackhuang.hmcl.mod.curse; -import org.jackhuang.hmcl.mod.RemoteModRepository; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.util.Immutable; import java.io.IOException; @@ -30,7 +30,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; @Immutable -public class CurseAddon implements RemoteModRepository.IMod { +public class CurseAddon implements RemoteMod.IMod { private final int id; private final String name; private final List authors; @@ -168,13 +168,13 @@ public class CurseAddon implements RemoteModRepository.IMod { } @Override - public List loadDependencies() throws IOException { + public List loadDependencies() throws IOException { Set dependencies = latestFiles.stream() .flatMap(latestFile -> latestFile.getDependencies().stream()) .filter(dep -> dep.getType() == 3) .map(Dependency::getAddonId) .collect(Collectors.toSet()); - List mods = new ArrayList<>(); + List mods = new ArrayList<>(); for (int dependencyId : dependencies) { mods.add(CurseForgeRemoteModRepository.MODS.getAddon(dependencyId).toMod()); } @@ -182,12 +182,12 @@ public class CurseAddon implements RemoteModRepository.IMod { } @Override - public Stream loadVersions() throws IOException { + public Stream loadVersions() throws IOException { return CurseForgeRemoteModRepository.MODS.getFiles(this).stream() .map(CurseAddon.LatestFile::toVersion); } - public RemoteModRepository.Mod toMod() { + public RemoteMod toMod() { String iconUrl = null; for (CurseAddon.Attachment attachment : attachments) { if (attachment.isDefault()) { @@ -195,7 +195,7 @@ public class CurseAddon implements RemoteModRepository.IMod { } } - return new RemoteModRepository.Mod( + return new RemoteMod( slug, "", name, @@ -481,31 +481,31 @@ public class CurseAddon implements RemoteModRepository.IMod { return fileDataInstant; } - public RemoteModRepository.Version toVersion() { - RemoteModRepository.VersionType versionType; + public RemoteMod.Version toVersion() { + RemoteMod.VersionType versionType; switch (getReleaseType()) { case 1: - versionType = RemoteModRepository.VersionType.Release; + versionType = RemoteMod.VersionType.Release; break; case 2: - versionType = RemoteModRepository.VersionType.Beta; + versionType = RemoteMod.VersionType.Beta; break; case 3: - versionType = RemoteModRepository.VersionType.Alpha; + versionType = RemoteMod.VersionType.Alpha; break; default: - versionType = RemoteModRepository.VersionType.Release; + versionType = RemoteMod.VersionType.Release; break; } - return new RemoteModRepository.Version( + return new RemoteMod.Version( this, getDisplayName(), null, null, getParsedFileDate(), versionType, - new RemoteModRepository.File(Collections.emptyMap(), getDownloadUrl(), getFileName()), + new RemoteMod.File(Collections.emptyMap(), getDownloadUrl(), getFileName()), Collections.emptyList(), gameVersion.stream().filter(ver -> ver.startsWith("1.") || ver.contains("w")).collect(Collectors.toList()), Collections.emptyList() diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java index 8c84fa8d9..277339792 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java @@ -18,6 +18,7 @@ package org.jackhuang.hmcl.mod.curse; import com.google.gson.reflect.TypeToken; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.mod.RemoteModRepository; import org.jackhuang.hmcl.util.MurmurHash; import org.jackhuang.hmcl.util.gson.JsonUtils; @@ -64,7 +65,7 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository } @Override - public Stream search(String gameVersion, RemoteModRepository.Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { + public Stream search(String gameVersion, RemoteModRepository.Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { int categoryId = 0; if (category != null) categoryId = ((Category) category.getSelf()).getId(); return searchPaginated(gameVersion, categoryId, pageOffset, pageSize, searchFilter, sort).stream() @@ -72,7 +73,7 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository } @Override - public Optional getRemoteVersionByLocalFile(Path file) throws IOException { + public Optional getRemoteVersionByLocalFile(Path file) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(file)))) { int b; diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modrinth/ModrinthRemoteModRepository.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modrinth/ModrinthRemoteModRepository.java index 6310bad75..67a7ff2cd 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modrinth/ModrinthRemoteModRepository.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modrinth/ModrinthRemoteModRepository.java @@ -19,6 +19,7 @@ package org.jackhuang.hmcl.mod.modrinth; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; +import org.jackhuang.hmcl.mod.RemoteMod; import org.jackhuang.hmcl.mod.RemoteModRepository; import org.jackhuang.hmcl.util.DigestUtils; import org.jackhuang.hmcl.util.Hex; @@ -64,13 +65,13 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository { } @Override - public Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { + public Stream search(String gameVersion, Category category, int pageOffset, int pageSize, String searchFilter, int sort) throws IOException { return searchPaginated(gameVersion, pageOffset, pageSize, searchFilter).stream() .map(ModResult::toMod); } @Override - public Optional getRemoteVersionByLocalFile(Path file) throws IOException { + public Optional getRemoteVersionByLocalFile(Path file) throws IOException { String sha1 = Hex.encodeHex(DigestUtils.digest("SHA-1", file)); try { @@ -288,23 +289,23 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository { return loaders; } - public Optional toVersion() { - RemoteModRepository.VersionType type; + public Optional toVersion() { + RemoteMod.VersionType type; if ("release".equals(versionType)) { - type = RemoteModRepository.VersionType.Release; + type = RemoteMod.VersionType.Release; } else if ("beta".equals(versionType)) { - type = RemoteModRepository.VersionType.Beta; + type = RemoteMod.VersionType.Beta; } else if ("alpha".equals(versionType)) { - type = RemoteModRepository.VersionType.Alpha; + type = RemoteMod.VersionType.Alpha; } else { - type = RemoteModRepository.VersionType.Release; + type = RemoteMod.VersionType.Release; } if (files.size() == 0) { return Optional.empty(); } - return Optional.of(new RemoteModRepository.Version( + return Optional.of(new RemoteMod.Version( this, name, versionNumber, @@ -342,12 +343,12 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository { return filename; } - public RemoteModRepository.File toFile() { - return new RemoteModRepository.File(hashes, url, filename); + public RemoteMod.File toFile() { + return new RemoteMod.File(hashes, url, filename); } } - public static class ModResult implements RemoteModRepository.IMod { + public static class ModResult implements RemoteMod.IMod { @SerializedName("mod_id") private final String modId; @@ -457,19 +458,19 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository { } @Override - public List loadDependencies() throws IOException { + public List loadDependencies() throws IOException { return Collections.emptyList(); } @Override - public Stream loadVersions() throws IOException { + public Stream loadVersions() throws IOException { return ModrinthRemoteModRepository.INSTANCE.getFiles(this).stream() .map(ModVersion::toVersion) .flatMap(Lang::toStream); } - public RemoteModRepository.Mod toMod() { - return new RemoteModRepository.Mod( + public RemoteMod toMod() { + return new RemoteMod( slug, author, title,