* Fix #3223 * 使用正则表达式删除内容 * 添加日志 添加日志 * Update GameVersion.java * Update GameVersion.java * update * update * update --------- Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
@@ -35,7 +35,6 @@ import java.util.stream.StreamSupport;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
|
||||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,8 +47,11 @@ final class GameVersion {
|
|||||||
private static Optional<String> getVersionFromJson(InputStream versionJson) {
|
private static Optional<String> getVersionFromJson(InputStream versionJson) {
|
||||||
try {
|
try {
|
||||||
Map<?, ?> version = JsonUtils.fromNonNullJsonFully(versionJson, Map.class);
|
Map<?, ?> version = JsonUtils.fromNonNullJsonFully(versionJson, Map.class);
|
||||||
return tryCast(version.get("id"), String.class);
|
String id = (String) version.get("id");
|
||||||
} catch (IOException | JsonParseException e) {
|
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);
|
LOG.warning("Failed to parse version.json", e);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user