mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 15:57:18 -04:00
fix: hide GameVersionList$1 task
This commit is contained in:
parent
e138815c7b
commit
588fe5cb5f
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Hello Minecraft! Launcher
|
* Hello Minecraft! Launcher
|
||||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,12 +21,13 @@ import org.jackhuang.hmcl.download.DownloadProvider;
|
|||||||
import org.jackhuang.hmcl.download.VersionList;
|
import org.jackhuang.hmcl.download.VersionList;
|
||||||
import org.jackhuang.hmcl.task.GetTask;
|
import org.jackhuang.hmcl.task.GetTask;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
|
||||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.util.gson.JsonUtils.GSON;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
@ -50,33 +51,24 @@ public final class GameVersionList extends VersionList<GameRemoteVersion> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task<?> refreshAsync() {
|
public Task<?> refreshAsync() {
|
||||||
GetTask task = new GetTask(NetworkUtils.toURL(downloadProvider.getVersionListURL()));
|
return new GetTask(NetworkUtils.toURL(downloadProvider.getVersionListURL()))
|
||||||
return new Task<Void>() {
|
.thenAcceptAsync(json -> {
|
||||||
@Override
|
GameRemoteVersions root = GSON.fromJson(json, GameRemoteVersions.class);
|
||||||
public Collection<Task<?>> getDependents() {
|
|
||||||
return Collections.singleton(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
lock.writeLock().lock();
|
lock.writeLock().lock();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
versions.clear();
|
versions.clear();
|
||||||
|
|
||||||
GameRemoteVersions root = JsonUtils.GSON.fromJson(task.getResult(), GameRemoteVersions.class);
|
|
||||||
for (GameRemoteVersionInfo remoteVersion : root.getVersions()) {
|
for (GameRemoteVersionInfo remoteVersion : root.getVersions()) {
|
||||||
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
|
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
|
||||||
remoteVersion.getGameVersion(),
|
remoteVersion.getGameVersion(),
|
||||||
remoteVersion.getGameVersion(),
|
remoteVersion.getGameVersion(),
|
||||||
Collections.singletonList(remoteVersion.getUrl()),
|
Collections.singletonList(remoteVersion.getUrl()),
|
||||||
remoteVersion.getType(), remoteVersion.getReleaseTime())
|
remoteVersion.getType(), remoteVersion.getReleaseTime()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.writeLock().unlock();
|
lock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user