From a2abfffcda39573db738d41c39d65390df72c701 Mon Sep 17 00:00:00 2001 From: Majick Tek Date: Fri, 27 May 2022 01:38:42 -0400 Subject: [PATCH] finally fix versions not displaying --- .../minilauncher/windows/ChannelSelector.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/MiniCraftLauncher/src/com/mt/minilauncher/windows/ChannelSelector.java b/MiniCraftLauncher/src/com/mt/minilauncher/windows/ChannelSelector.java index 2f5a608..39030f8 100644 --- a/MiniCraftLauncher/src/com/mt/minilauncher/windows/ChannelSelector.java +++ b/MiniCraftLauncher/src/com/mt/minilauncher/windows/ChannelSelector.java @@ -34,6 +34,7 @@ import com.mt.minilauncher.util.Util; import com.mt.minilauncher.util.XMLConverter; +import io.quicktype.Asset; import io.quicktype.GithubAPI; import javax.swing.JScrollPane; @@ -116,15 +117,47 @@ public void actionPerformed(ActionEvent e) { DefaultTreeModel dtm = new DefaultTreeModel(root); DefaultMutableTreeNode releaseNode = new DefaultMutableTreeNode("Releases"); DefaultMutableTreeNode preReleaseNode = new DefaultMutableTreeNode("Pre-Releases"); -// DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(); -// tmpNode.setUserObject(versionObject); -// preReleaseNode.add(tmpNode); + GithubAPI[] releaseTree = GithubReleaseParser.parseReleases(this.getList().getSelectedValue().liveUsername, this.getList().getSelectedValue().liveRepoName); ArrayList releases = new ArrayList<>(Arrays.asList(releaseTree)); releases.stream().filter(r -> (r.getPrerelease() == false)).forEach(release -> { + VersionObject vo = new VersionObject(); + vo.canEdit = false; + vo.description = release.getBody(); + vo.version = release.getTagName(); + + ArrayList assets = new ArrayList<>(Arrays.asList(release.getAssets())); + assets.stream().filter(a -> (a.getName().contains(".jar"))).forEach(asset -> { + vo.url = asset.getBrowserDownloadURL(); + }); + assets.stream().filter(a -> (a.getName().toLowerCase().contains("changelog"))).forEach(asset -> { + vo.changelogURL = asset.getBrowserDownloadURL(); + }); + + DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(); + tmpNode.setUserObject(vo); + releaseNode.add(tmpNode); + }); + + releases.stream().filter(r -> (r.getPrerelease() == true)).forEach(release -> { + VersionObject vo = new VersionObject(); + vo.canEdit = false; + vo.description = release.getBody(); + vo.version = release.getTagName(); + + ArrayList assets = new ArrayList<>(Arrays.asList(release.getAssets())); + assets.stream().filter(a -> (a.getName().contains(".jar"))).forEach(asset -> { + vo.url = asset.getBrowserDownloadURL(); + }); + assets.stream().filter(a -> (a.getName().toLowerCase().contains("changelog"))).forEach(asset -> { + vo.changelogURL = asset.getBrowserDownloadURL(); + }); + DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(); + tmpNode.setUserObject(vo); + preReleaseNode.add(tmpNode); }); root.add(releaseNode); root.add(preReleaseNode);