Refactor PojavProfile.java

This commit is contained in:
SerpentSpirale 2022-02-26 17:38:13 +01:00 committed by ArtDev
parent 1a708dad7e
commit cfaefef96e

View File

@ -12,10 +12,9 @@ import net.kdt.pojavlaunch.authenticator.mojang.RefreshListener;
import net.kdt.pojavlaunch.authenticator.mojang.RefreshTokenTask; import net.kdt.pojavlaunch.authenticator.mojang.RefreshTokenTask;
import net.kdt.pojavlaunch.value.MinecraftAccount; import net.kdt.pojavlaunch.value.MinecraftAccount;
public class PojavProfile public class PojavProfile {
{ private static final String PROFILE_PREF = "pojav_profile";
private static String PROFILE_PREF = "pojav_profile"; private static final String PROFILE_PREF_FILE = "file";
private static String PROFILE_PREF_FILE = "file";
public static String PROFILE_PREF_TEMP_CONTENT = "tempContent"; public static String PROFILE_PREF_TEMP_CONTENT = "tempContent";
public static SharedPreferences getPrefs(Context ctx) { public static SharedPreferences getPrefs(Context ctx) {
@ -33,26 +32,26 @@ public class PojavProfile
public static MinecraftAccount getTempProfileContent() { public static MinecraftAccount getTempProfileContent() {
try { try {
MinecraftAccount acc = MinecraftAccount.parse(Tools.read(Tools.DIR_DATA+"/cache/tempacc.json")); MinecraftAccount account = MinecraftAccount.parse(Tools.read(Tools.DIR_DATA+"/cache/tempacc.json"));
if (acc.accessToken == null) { if (account.accessToken == null) {
acc.accessToken = "0"; account.accessToken = "0";
} }
if (acc.clientToken == null) { if (account.clientToken == null) {
acc.clientToken = "0"; account.clientToken = "0";
} }
if (acc.profileId == null) { if (account.profileId == null) {
acc.profileId = "00000000-0000-0000-0000-000000000000"; account.profileId = "00000000-0000-0000-0000-000000000000";
} }
if (acc.username == null) { if (account.username == null) {
acc.username = "0"; account.username = "0";
} }
if (acc.selectedVersion == null) { if (account.selectedVersion == null) {
acc.selectedVersion = "1.7.10"; account.selectedVersion = "1.7.10";
} }
if (acc.msaRefreshToken == null) { if (account.msaRefreshToken == null) {
acc.msaRefreshToken = "0"; account.msaRefreshToken = "0";
} }
return acc; return account;
}catch (IOException e) { }catch (IOException e) {
Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the temporary profile",e); Log.e(MinecraftAccount.class.getName(), "Caught an exception while loading the temporary profile",e);
return null; return null;