[New account data] Add null check for accessToken and profileId

This commit is contained in:
khanhduytran0 2020-12-18 19:41:28 +07:00
parent b74b0389c3
commit 181fd87244
2 changed files with 15 additions and 9 deletions

View File

@ -146,9 +146,9 @@ public final class Tools
gameDir.mkdirs();
Map<String, String> varArgMap = new ArrayMap<String, String>();
varArgMap.put("auth_access_token", profile.accessToken == null ? "0" : profile.accessToken);
varArgMap.put("auth_access_token", profile.accessToken);
varArgMap.put("auth_player_name", username);
varArgMap.put("auth_uuid", profile.profileId == null ? "0" : profile.profileId);
varArgMap.put("auth_uuid", profile.profileId);
varArgMap.put("assets_root", Tools.ASSETS_PATH);
varArgMap.put("assets_index_name", versionInfo.assets);
varArgMap.put("game_assets", Tools.ASSETS_PATH);

View File

@ -5,13 +5,13 @@ import com.google.gson.*;
public class MinecraftAccount
{
public String accessToken; // access token
public String clientToken; // clientID: refresh and invalidate
public String profileId; // authenticate UUID
public String username;
public String accessToken = "0"; // access token
public String clientToken = "0"; // clientID: refresh and invalidate
public String profileId = "0"; // authenticate UUID
public String username = "Steve";
public String selectedVersion = "1.7.10";
public boolean isMicrosoft;
public String msaRefreshToken;
public boolean isMicrosoft = false;
public String msaRefreshToken = "0";
public String save(String outPath) throws IOException {
Tools.write(outPath, Tools.GLOBAL_GSON.toJson(this));
@ -27,7 +27,13 @@ public class MinecraftAccount
}
public static MinecraftAccount load(String path) throws IOException, JsonSyntaxException {
return parse(Tools.read(path));
MinecraftAccount acc = parse(Tools.read(path));
if (acc.accessToken == null) {
acc.accessToken = "0";
} if (acc.profileId == null) {
acc.profileId = "0";
}
return acc;
}
public static void clearTempAccount() {