Fix not correctly loading remote game version list

This commit is contained in:
huangyuhui
2018-08-19 11:56:39 +08:00
parent 6911cfa387
commit 2e1b6e4630
3 changed files with 18 additions and 5 deletions

View File

@@ -42,7 +42,7 @@ public class RemoteVersion implements Comparable<RemoteVersion> {
* @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<RemoteVersion> {
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<RemoteVersion> {
}
public enum Type {
UNCATEGORIZED,
RELEASE,
SNAPSHOT,
OLD

View File

@@ -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;
}
}
}