diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MCLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MCLauncherActivity.java index d62dc83bb..37bf4bbe3 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MCLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/MCLauncherActivity.java @@ -39,7 +39,6 @@ public class MCLauncherActivity extends BaseLauncherActivity private TabLayout tabLayout; private TextView tvUsernameView; - private String profilePath = null; private ViewPagerAdapter viewPageAdapter; private Button switchUsrBtn, logoutBtn; // MineButtons @@ -74,7 +73,6 @@ public class MCLauncherActivity extends BaseLauncherActivity mTextVersion = (TextView) findViewById(R.id.launcherMainVersionView); try { - profilePath = PojavProfile.getCurrentProfilePath(this); mProfile = PojavProfile.getCurrentProfileContent(this); tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username)); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java index bcea8ced8..aea6bb355 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java @@ -38,7 +38,6 @@ public class PojavLauncherActivity extends BaseLauncherActivity private TextView tvUsernameView; private Spinner accountSelector; - private String profilePath = null; private ViewPagerAdapter viewPageAdapter; private Button switchUsrBtn, logoutBtn; // MineButtons @@ -136,7 +135,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity PojavProfile.setCurrentProfile(PojavLauncherActivity.this, tempProfile); } else { PojavProfile.setCurrentProfile(PojavLauncherActivity.this, - Tools.DIR_ACCOUNT_NEW + "/" + accountList.get(position + (tempProfile != null ? 1 : 0)) + ".json"); + accountList.get(position + (tempProfile != null ? 1 : 0))); } pickAccount(); } @@ -212,12 +211,10 @@ public class PojavLauncherActivity extends BaseLauncherActivity private void pickAccount() { try { - profilePath = PojavProfile.getCurrentProfilePath(this); mProfile = PojavProfile.getCurrentProfileContent(this); tvUsernameView.setText(getString(R.string.main_welcome, mProfile.username)); } catch(Exception e) { - profilePath = ""; mProfile = new MinecraftAccount(); Tools.showError(this, e, true); } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java index 73470acf5..55baefb5e 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLoginActivity.java @@ -283,8 +283,6 @@ public class PojavLoginActivity extends BaseActivity // Clear current profile PojavProfile.setCurrentProfile(this, null); - - } private boolean isJavaRuntimeInstalled(AssetManager am) { @@ -825,10 +823,9 @@ public class PojavLoginActivity extends BaseActivity try { String profileName = null; if (sRemember.isChecked() || notOnLogin) { - profileName = new File(mProfile.save()).getName(); + profileName = mProfile.save(); } - profileName = profileName.substring(0, profileName.length() - 5); - + MCProfile.launch(PojavLoginActivity.this, profileName == null ? mProfile : profileName); } catch (IOException e) { Tools.showError(this, e); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavProfile.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavProfile.java index 6807a6720..e46822857 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavProfile.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavProfile.java @@ -15,7 +15,7 @@ public class PojavProfile } public static MinecraftAccount getCurrentProfileContent(Context ctx) throws IOException, JsonSyntaxException { - MinecraftAccount build = MinecraftAccount.load(getPrefs(ctx).getString(PROFILE_PREF_FILE, "")); + MinecraftAccount build = MinecraftAccount.load(getCurrentProfileName(ctx)); if (build == null) { getTempProfileContent(ctx); } @@ -26,7 +26,7 @@ public class PojavProfile return MinecraftAccount.parse(getPrefs(ctx).getString(PROFILE_PREF_TEMP_CONTENT, "")); } - public static String getCurrentProfilePath(Context ctx) { + public static String getCurrentProfileName(Context ctx) { return getPrefs(ctx).getString(PROFILE_PREF_FILE, ""); } @@ -42,10 +42,7 @@ public class PojavProfile } } else if (obj instanceof String) { String acc = (String) obj; - pref.putString(PROFILE_PREF_FILE, - acc.startsWith("/") ? - acc : - Tools.DIR_ACCOUNT_NEW + "/" + acc + ".json"); + pref.putString(PROFILE_PREF_FILE, acc); MinecraftAccount.clearTempAccount(); } else if (obj == null) { pref.putString(PROFILE_PREF_FILE, ""); @@ -58,6 +55,6 @@ public class PojavProfile } public static boolean isFileType(Context ctx) { - return new File(PojavProfile.getCurrentProfilePath(ctx)).exists(); + return new File(Tools.DIR_ACCOUNT_NEW + "/" + PojavProfile.getCurrentProfileName(ctx) + ".json").exists(); } }