mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-20 13:30:15 -07:00
Auto-download inherited version if it does not exist
This commit is contained in:
parent
91815f486e
commit
d7acd362e2
3 changed files with 17 additions and 6 deletions
|
|
@ -127,7 +127,7 @@ public class BaseMainActivity extends LoggableActivity {
|
||||||
logStream = new PrintStream(logFile.getAbsolutePath());
|
logStream = new PrintStream(logFile.getAbsolutePath());
|
||||||
|
|
||||||
mProfile = PojavProfile.getCurrentProfileContent(this);
|
mProfile = PojavProfile.getCurrentProfileContent(this);
|
||||||
mVersionInfo = Tools.getVersionInfo(mProfile.selectedVersion);
|
mVersionInfo = Tools.getVersionInfo(null,mProfile.selectedVersion);
|
||||||
|
|
||||||
setTitle("Minecraft " + mProfile.selectedVersion);
|
setTitle("Minecraft " + mProfile.selectedVersion);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -534,7 +534,7 @@ public final class Tools
|
||||||
return libDir.toArray(new String[0]);
|
return libDir.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JMinecraftVersionList.Version getVersionInfo(String versionName) {
|
public static JMinecraftVersionList.Version getVersionInfo(BaseLauncherActivity bla, String versionName) {
|
||||||
try {
|
try {
|
||||||
JMinecraftVersionList.Version customVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + versionName + "/" + versionName + ".json"), JMinecraftVersionList.Version.class);
|
JMinecraftVersionList.Version customVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + versionName + "/" + versionName + ".json"), JMinecraftVersionList.Version.class);
|
||||||
for (DependentLibrary lib : customVer.libraries) {
|
for (DependentLibrary lib : customVer.libraries) {
|
||||||
|
|
@ -545,9 +545,20 @@ public final class Tools
|
||||||
if (customVer.inheritsFrom == null || customVer.inheritsFrom.equals(customVer.id)) {
|
if (customVer.inheritsFrom == null || customVer.inheritsFrom.equals(customVer.id)) {
|
||||||
return customVer;
|
return customVer;
|
||||||
} else {
|
} else {
|
||||||
JMinecraftVersionList.Version inheritsVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
|
JMinecraftVersionList.Version inheritsVer = null;
|
||||||
|
if(bla != null) if (bla.mVersionList != null) {
|
||||||
|
for (JMinecraftVersionList.Version valueVer : bla.mVersionList.versions) {
|
||||||
|
if (valueVer.id.equals(customVer.inheritsFrom) && (!new File(DIR_HOME_VERSION + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json").exists()) && (valueVer.url != null)) {
|
||||||
|
Tools.downloadFile(valueVer.url,DIR_HOME_VERSION + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//If it won't download, just search for it
|
||||||
|
try{
|
||||||
|
inheritsVer = Tools.GLOBAL_GSON.fromJson(read(DIR_HOME_VERSION + "/" + customVer.inheritsFrom + "/" + customVer.inheritsFrom + ".json"), JMinecraftVersionList.Version.class);
|
||||||
|
}catch(IOException e) {
|
||||||
|
throw new RuntimeException("Can't find the source version for "+ versionName +" (req version="+customVer.inheritsFrom+")");
|
||||||
|
}
|
||||||
inheritsVer.inheritsFrom = inheritsVer.id;
|
inheritsVer.inheritsFrom = inheritsVer.id;
|
||||||
|
|
||||||
insertSafety(inheritsVer, customVer,
|
insertSafety(inheritsVer, customVer,
|
||||||
"assetIndex", "assets", "id",
|
"assetIndex", "assets", "id",
|
||||||
"mainClass", "minecraftArguments",
|
"mainClass", "minecraftArguments",
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
verInfo = Tools.getVersionInfo(p1[0]);
|
verInfo = Tools.getVersionInfo(mActivity,p1[0]);
|
||||||
try {
|
try {
|
||||||
assets = downloadIndex(verInfo.assets, new File(Tools.ASSETS_PATH, "indexes/" + verInfo.assets + ".json"));
|
assets = downloadIndex(verInfo.assets, new File(Tools.ASSETS_PATH, "indexes/" + verInfo.assets + ".json"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -341,6 +341,6 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom version, inherits from base.
|
// Custom version, inherits from base.
|
||||||
return Tools.getVersionInfo(version);
|
return Tools.getVersionInfo(mActivity,version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue