Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/official/main' into prs-base
Browse files Browse the repository at this point in the history
  • Loading branch information
burningtnt committed Aug 23, 2024
2 parents e120091 + 95a1496 commit e871805
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import static org.jackhuang.hmcl.util.Lang.tryCast;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

/**
Expand All @@ -48,8 +47,11 @@ private GameVersion() {
private static Optional<String> getVersionFromJson(InputStream versionJson) {
try {
Map<?, ?> version = JsonUtils.fromNonNullJsonFully(versionJson, Map.class);
return tryCast(version.get("id"), String.class);
} catch (IOException | JsonParseException e) {
String id = (String) version.get("id");
if (id != null && id.contains(" / "))
id = id.substring(0, id.indexOf(" / "));
return Optional.ofNullable(id);
} catch (IOException | JsonParseException | ClassCastException e) {
LOG.warning("Failed to parse version.json", e);
return Optional.empty();
}
Expand Down

0 comments on commit e871805

Please sign in to comment.