From 2e1b6e4630b148e98938c76994779ddf8e0b95ad Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sun, 19 Aug 2018 11:56:39 +0800 Subject: [PATCH] Fix not correctly loading remote game version list --- .../jackhuang/hmcl/ui/download/VersionsPage.java | 2 -- .../jackhuang/hmcl/download/RemoteVersion.java | 5 +++-- .../hmcl/download/game/GameRemoteVersion.java | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java index f7c425e35..24cd7a769 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/VersionsPage.java @@ -100,8 +100,6 @@ public final class VersionsPage extends StackPane implements WizardPage, Refresh private List loadVersions() { return versionList.getVersions(gameVersion).stream() .filter(it -> { - if (it.getVersionType() == null) - return true; switch (it.getVersionType()) { case RELEASE: return chkRelease.isSelected(); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/RemoteVersion.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/RemoteVersion.java index 1cc7a5bd6..bee1b8dd7 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/RemoteVersion.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/RemoteVersion.java @@ -42,7 +42,7 @@ public class RemoteVersion implements Comparable { * @param url the installer or universal jar URL. */ public RemoteVersion(String gameVersion, String selfVersion, String url) { - this(gameVersion, selfVersion, url, null); + this(gameVersion, selfVersion, url, Type.UNCATEGORIZED); } /** @@ -56,7 +56,7 @@ public class RemoteVersion implements Comparable { this.gameVersion = Objects.requireNonNull(gameVersion); this.selfVersion = Objects.requireNonNull(selfVersion); this.url = Objects.requireNonNull(url); - this.type = type; + this.type = Objects.requireNonNull(type); } public String getGameVersion() { @@ -100,6 +100,7 @@ public class RemoteVersion implements Comparable { } public enum Type { + UNCATEGORIZED, RELEASE, SNAPSHOT, OLD diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersion.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersion.java index ac86f3f0e..e63737bd3 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersion.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersion.java @@ -34,7 +34,7 @@ public final class GameRemoteVersion extends RemoteVersion { private final Date time; public GameRemoteVersion(String gameVersion, String selfVersion, String url, ReleaseType type, Date time) { - super(gameVersion, selfVersion, url); + super(gameVersion, selfVersion, url, getReleaseType(type)); this.type = type; this.time = time; } @@ -54,4 +54,18 @@ public final class GameRemoteVersion extends RemoteVersion { return ((GameRemoteVersion) o).getTime().compareTo(getTime()); } + + private static Type getReleaseType(ReleaseType type) { + if (type == null) return Type.UNCATEGORIZED; + switch (type) { + case RELEASE: + return Type.RELEASE; + case SNAPSHOT: + return Type.SNAPSHOT; + case UNKNOWN: + return Type.UNCATEGORIZED; + default: + return Type.OLD; + } + } }