This commit is contained in:
khanhduytran0 committed 2020-12-18 16:43:50 +07:00
1 parent 9e3fdedaff
commit d5eb4b4388
11 files changed
+35 -63

No files matched your search

@@ -99,7 +99,6 @@ public class BaseMainActivity extends LoggableActivity {
private LinearLayout contentCanvas;
private AWTSurfaceView contentCanvasView;
*/
private boolean resuming;
private boolean lastEnabled = false;
private boolean lastGrab = false;
private boolean isExited = false;
@@ -298,17 +298,16 @@ public class PojavLoginActivity extends BaseActivity
}
private void initMain() throws Throwable {
mkdirs(Tools.DIR_ACCOUNT_NEW);
PojavMigrator.migrateAccountData(this);
mkdirs(Tools.DIR_HOME_VERSION);
mkdirs(Tools.DIR_HOME_LIBRARY);
if (!PojavMigrator.migrateGameDir()) {
mkdirs(Tools.DIR_GAME_NEW);
mkdirs(Tools.DIR_GAME_NEW + "/config");
mkdirs(Tools.DIR_GAME_NEW + "/lwjgl3");
mkdirs(Tools.DIR_GAME_NEW + "/mods");
mkdirs(Tools.DIR_HOME_VERSION);
mkdirs(Tools.DIR_HOME_LIBRARY);
}
mkdirs(Tools.DIR_GAME_NEW);
mkdirs(Tools.DIR_GAME_NEW + "/config");
mkdirs(Tools.DIR_GAME_NEW + "/lwjgl3");
mkdirs(Tools.DIR_GAME_NEW + "/mods");
PojavMigrator.migrateAccountData(this);
PojavMigrator.migrateGameDir();
File forgeSplashFile = new File(Tools.DIR_GAME_NEW, "config/splash.properties");
String forgeSplashContent = "enabled=true";
@@ -331,7 +330,7 @@ public class PojavLoginActivity extends BaseActivity
Tools.copyAssetFile(this, "components/ForgeInstallerHeadless/forge-installer-headless-1.0.1.jar", Tools.DIR_GAME_NEW + "/config", "forge-installer-headless.jar", true);
Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false);
Tools.copyAssetFile(this, "java_sandbox.policy", Tools.DIR_GAME_HOME, true);
Tools.copyAssetFile(this, "java_sandbox.policy", Tools.DIR_GAME_NEW, true);
// TODO: Remove after implement.
Tools.copyAssetFile(this, "launcher_profiles.json", Tools.DIR_GAME_NEW, false);
@@ -7,6 +7,7 @@ public class PojavMigrator
{
public static void migrateAccountData(Context ctx) {
File oldAccDir = new File(Tools.DIR_ACCOUNT_OLD);
if (oldAccDir.exists() && oldAccDir.isDirectory()) {
for (String account : oldAccDir.list()) {
File oldAccFile = new File(oldAccDir, account);
@@ -31,42 +32,16 @@ public class PojavMigrator
}
}
public static boolean migrateGameDir() throws IOException, InterruptedException {
public static void migrateGameDir() throws IOException, InterruptedException {
File oldGameDir = new File(Tools.DIR_GAME_OLD);
boolean moved = oldGameDir.exists() && oldGameDir.isDirectory();
if (!migrateBugFix20201217() && moved) {
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
}
return moved;
}
public static boolean migrateBugFix20201217() throws IOException, InterruptedException {
File bugGameDir = new File(Tools.DIR_GAME_NEW + "/.minecraft");
File oldGameDir = new File(Tools.DIR_GAME_OLD);
boolean moved = bugGameDir.exists() && bugGameDir.isDirectory();
if (oldGameDir.exists() && oldGameDir.isDirectory() && moved) {
command("rm -rf " + oldGameDir.getAbsolutePath());
}
if (moved) {
command("mv " + bugGameDir.getAbsolutePath() + " " + Tools.DIR_GAME_OLD);
command("rm -rf " + Tools.DIR_GAME_HOME);
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
}
return moved;
}
private static void command(String cmd) throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec(
new String[]{cmd});
int exitCode = p.waitFor();
if (exitCode != 0) {
throw new IOException("Exit code " + exitCode +
", message:\n" + Tools.read(p.getErrorStream()));
if (oldGameDir.exists() && oldGameDir.isDirectory()) {
Process p = Runtime.getRuntime().exec(
new String[]{"mv", Tools.DIR_GAME_OLD, Tools.DIR_GAME_NEW});
int exitCode = p.waitFor();
if (exitCode != 0) {
throw new IOException("Could not move game dir! Exit code " + exitCode +
", message:\n" + Tools.read(p.getErrorStream()));
}
}
}
}
@@ -35,10 +35,9 @@ public final class Tools
public static String CURRENT_ARCHITECTURE;
// New since 3.3.1
public static String DIR_ACCOUNT_NEW;
public static String DIR_ACCOUNT_OLD;
public static final String DIR_GAME_HOME = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher";
public static final String DIR_GAME_NEW = DIR_GAME_NEW + "/.minecraft";
public static String DIR_ACCOUNT_NEW;
public static final String DIR_GAME_NEW = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher/.minecraft";
public static final String DIR_GAME_OLD = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/.minecraft";
// New since 3.0.0
@@ -85,6 +84,8 @@ public final class Tools
overrideableArgList.add("-Duser.language=" + System.getProperty("user.language"));
// overrideableArgList.add("-Duser.timezone=GMT");
// Should be compatible?
// overrideableArgList.add("-Dos.name=Android");
overrideableArgList.add("-Dos.name=Linux");
overrideableArgList.add("-Dos.version=Android-" + Build.VERSION.RELEASE);
@@ -196,11 +196,7 @@ public abstract class HandleView extends View implements ViewPositionListener, V
if (mActionPopupShower == null) {
mActionPopupShower = new Runnable() {
public void run() {
try {
mActionPopupWindow.show();
} catch (Throwable th) {
th.printStackTrace();
}
mActionPopupWindow.show();
}
};
} else {