mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 15:17:02 -04:00
Workaround: auto Delete corrupted accounts
This commit is contained in:
parent
7c0a69fb6c
commit
c8cf5df4e2
@ -159,7 +159,8 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
|
||||
}
|
||||
|
||||
pickAccount(position);
|
||||
performLogin(mSelectecAccount);
|
||||
if(mSelectecAccount != null)
|
||||
performLogin(mSelectecAccount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -278,6 +279,16 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
|
||||
if(position != -1){
|
||||
PojavProfile.setCurrentProfile(getContext(), mAccountList.get(position));
|
||||
selectedAccount = PojavProfile.getCurrentProfileContent(getContext(), mAccountList.get(position));
|
||||
|
||||
|
||||
// WORKAROUND
|
||||
// Account file corrupted due to previous versions having improper encoding
|
||||
if (selectedAccount == null){
|
||||
removeCurrentAccount();
|
||||
pickAccount(-1);
|
||||
setSelection(0);
|
||||
return;
|
||||
}
|
||||
setSelection(position);
|
||||
}else {
|
||||
// Get the current profile, or the first available profile if the wanted one is unavailable
|
||||
|
@ -25,7 +25,7 @@ public class PojavProfile {
|
||||
return ctx.getSharedPreferences(PROFILE_PREF, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static MinecraftAccount getCurrentProfileContent(@NonNull Context ctx, @Nullable String profileName) throws JsonSyntaxException {
|
||||
public static MinecraftAccount getCurrentProfileContent(@NonNull Context ctx, @Nullable String profileName) {
|
||||
return MinecraftAccount.load(profileName == null ? getCurrentProfileName(ctx) : profileName);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class MinecraftAccount {
|
||||
return Tools.GLOBAL_GSON.fromJson(content, MinecraftAccount.class);
|
||||
}
|
||||
|
||||
public static MinecraftAccount load(String name) throws JsonSyntaxException {
|
||||
public static MinecraftAccount load(String name) {
|
||||
if(!accountExists(name)) return null;
|
||||
try {
|
||||
MinecraftAccount acc = parse(Tools.read(Tools.DIR_ACCOUNT_NEW + "/" + name + ".json"));
|
||||
@ -88,7 +88,7 @@ public class MinecraftAccount {
|
||||
// acc.updateSkinFace("MHF_Steve");
|
||||
}
|
||||
return acc;
|
||||
} catch(IOException e) {
|
||||
} catch(IOException | JsonSyntaxException e) {
|
||||
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the profile",e);
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user