mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 07:39:00 -04:00
Workaround: auto Delete corrupted accounts
This commit is contained in:
parent
7c0a69fb6c
commit
c8cf5df4e2
@ -159,6 +159,7 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
|
|||||||
}
|
}
|
||||||
|
|
||||||
pickAccount(position);
|
pickAccount(position);
|
||||||
|
if(mSelectecAccount != null)
|
||||||
performLogin(mSelectecAccount);
|
performLogin(mSelectecAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +279,16 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
|
|||||||
if(position != -1){
|
if(position != -1){
|
||||||
PojavProfile.setCurrentProfile(getContext(), mAccountList.get(position));
|
PojavProfile.setCurrentProfile(getContext(), mAccountList.get(position));
|
||||||
selectedAccount = PojavProfile.getCurrentProfileContent(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);
|
setSelection(position);
|
||||||
}else {
|
}else {
|
||||||
// Get the current profile, or the first available profile if the wanted one is unavailable
|
// 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);
|
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);
|
return MinecraftAccount.load(profileName == null ? getCurrentProfileName(ctx) : profileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class MinecraftAccount {
|
|||||||
return Tools.GLOBAL_GSON.fromJson(content, MinecraftAccount.class);
|
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;
|
if(!accountExists(name)) return null;
|
||||||
try {
|
try {
|
||||||
MinecraftAccount acc = parse(Tools.read(Tools.DIR_ACCOUNT_NEW + "/" + name + ".json"));
|
MinecraftAccount acc = parse(Tools.read(Tools.DIR_ACCOUNT_NEW + "/" + name + ".json"));
|
||||||
@ -88,7 +88,7 @@ public class MinecraftAccount {
|
|||||||
// acc.updateSkinFace("MHF_Steve");
|
// acc.updateSkinFace("MHF_Steve");
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
} catch(IOException e) {
|
} catch(IOException | JsonSyntaxException e) {
|
||||||
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the profile",e);
|
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the profile",e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user