mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-18 09:07:48 -04:00
fix[MinecraftAccount.load()]: Fix crash when accounts.json is malformed
This commit is contained in:
parent
66db228605
commit
7670c5cf89
@ -13,6 +13,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ public class MinecraftAccount {
|
|||||||
public static MinecraftAccount parse(String content) throws JsonSyntaxException {
|
public static MinecraftAccount parse(String content) throws JsonSyntaxException {
|
||||||
return Tools.GLOBAL_GSON.fromJson(content, MinecraftAccount.class);
|
return Tools.GLOBAL_GSON.fromJson(content, MinecraftAccount.class);
|
||||||
}
|
}
|
||||||
|
@Nullable
|
||||||
public static MinecraftAccount load(String name) {
|
public static MinecraftAccount load(String name) {
|
||||||
if(!accountExists(name)) return null;
|
if(!accountExists(name)) return null;
|
||||||
try {
|
try {
|
||||||
@ -92,7 +93,7 @@ public class MinecraftAccount {
|
|||||||
acc.msaRefreshToken = "0";
|
acc.msaRefreshToken = "0";
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
} catch(IOException | JsonSyntaxException e) {
|
} catch(NullPointerException | 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