Fix versions that are not downloaded yet

This commit is contained in:
artdeell 2022-11-12 13:16:40 +03:00 committed by ArtDev
parent 765b504c5f
commit 4a6eea08fc
2 changed files with 12 additions and 3 deletions

View File

@ -132,7 +132,7 @@ public class LauncherActivity extends BaseActivity {
return false;
}
String normalizedVersionId = AsyncMinecraftDownloader.normalizeVersionId(prof.lastVersionId);
JMinecraftVersionList.Version mcVersion = Tools.getVersionInfo(normalizedVersionId);
JMinecraftVersionList.Version mcVersion = AsyncMinecraftDownloader.getListedVersion(normalizedVersionId);
new AsyncMinecraftDownloader(this, mcVersion, normalizedVersionId, () -> runOnUiThread(() -> {
try {
Intent mainIntent = new Intent(getBaseContext(), MainActivity.class);

View File

@ -62,7 +62,7 @@ public class AsyncMinecraftDownloader {
try {
File verJsonDir = new File(Tools.DIR_HOME_VERSION + downVName + ".json");
if (verInfo.url != null) {
if (verInfo != null && verInfo.url != null) {
if(!LauncherPreferences.PREF_CHECK_LIBRARY_SHA) Log.w("Chk","Checker is off");
boolean isManifestGood = verJsonDir.exists()
@ -80,7 +80,7 @@ public class AsyncMinecraftDownloader {
}
}
verInfo = Tools.getVersionInfo(verInfo.id);
verInfo = Tools.getVersionInfo(versionName);
// THIS one function need the activity in the case of an error
if(!JRE17Util.installNewJreIfNeeded(activity, verInfo)){
@ -358,6 +358,15 @@ public class AsyncMinecraftDownloader {
return versionString;
}
public static JMinecraftVersionList.Version getListedVersion(String normalizedVersionString) {
JMinecraftVersionList versionList = (JMinecraftVersionList) ExtraCore.getValue(ExtraConstants.RELEASE_TABLE);
for(JMinecraftVersionList.Version version : versionList.versions) {
if(version.id.equals(normalizedVersionString)) return version;
}
return null;
}
/**@return A byte buffer bound to a thread, useful to recycle it across downloads */
private byte[] getByteBuffer(){
byte[] buffer = mThreadBuffers.get(Thread.currentThread());