mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-17 17:09:55 +08:00
* Fix #3223 * 使用正则表达式删除内容 * 添加日志 添加日志 * Update GameVersion.java * Update GameVersion.java * update * update * update --------- Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
parent
47cc9ebe2b
commit
95a1496389
@ -35,7 +35,6 @@ import java.util.stream.StreamSupport;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -48,8 +47,11 @@ final class 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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user