Fixed bedrock accounts not saving

This commit is contained in:
RaphiMC 2023-06-02 00:36:11 +02:00
parent 7448c0cbff
commit 5a3ea47e8d
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 13 additions and 9 deletions

View File

@ -20,12 +20,10 @@ package net.raphimc.viaproxy.saves.impl;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.raphimc.mcauth.step.bedrock.StepMCChain;
import net.raphimc.mcauth.step.java.StepMCProfile;
import net.raphimc.mcauth.util.MicrosoftConstants;
import net.raphimc.viaproxy.saves.AbstractSave;
import net.raphimc.viaproxy.saves.impl.accounts.Account;
import net.raphimc.viaproxy.saves.impl.accounts.BedrockAccount;
import net.raphimc.viaproxy.saves.impl.accounts.MicrosoftAccount;
import net.raphimc.viaproxy.saves.impl.accounts.OfflineAccount;
import net.raphimc.viaproxy.util.logging.Logger;
@ -76,14 +74,13 @@ public class NewAccountsSave extends AbstractSave {
}
}
public Account addAccount(final StepMCChain.MCChain mcChain) {
final Account account = new BedrockAccount(mcChain);
public Account addAccount(final String username) {
final Account account = new OfflineAccount(username);
this.accounts.add(account);
return account;
}
public Account addAccount(final String username) {
final Account account = new OfflineAccount(username);
public Account addAccount(final Account account) {
this.accounts.add(account);
return account;
}

View File

@ -37,8 +37,9 @@ public class BedrockAccount extends Account {
}
}
public BedrockAccount(final StepMCChain.MCChain mcChain) {
public BedrockAccount(final StepMCChain.MCChain mcChain, final StepPlayFabToken.PlayFabToken playFabToken) {
this.mcChain = mcChain;
this.playFabToken = playFabToken;
}
@Override

View File

@ -18,11 +18,14 @@
package net.raphimc.viaproxy.ui.impl;
import net.raphimc.mcauth.MinecraftAuth;
import net.raphimc.mcauth.step.bedrock.StepMCChain;
import net.raphimc.mcauth.step.bedrock.playfab.StepPlayFabToken;
import net.raphimc.mcauth.step.msa.StepMsaDeviceCode;
import net.raphimc.mcauth.util.MicrosoftConstants;
import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.cli.options.Options;
import net.raphimc.viaproxy.saves.impl.accounts.Account;
import net.raphimc.viaproxy.saves.impl.accounts.BedrockAccount;
import net.raphimc.viaproxy.ui.AUITab;
import net.raphimc.viaproxy.ui.ViaProxyUI;
import net.raphimc.viaproxy.ui.popups.AddAccountPopup;
@ -207,9 +210,12 @@ public class AccountsTab extends AUITab {
this.addBedrockAccountButton.setEnabled(false);
this.handleLogin(msaDeviceCodeConsumer -> {
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
return MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCodeConsumer));
final StepMCChain.MCChain mcChain = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCodeConsumer));
final StepPlayFabToken.PlayFabToken playFabToken = MinecraftAuth.BEDROCK_PLAY_FAB_TOKEN.getFromInput(httpClient, mcChain.prevResult().fullXblSession());
return new BedrockAccount(mcChain, playFabToken);
}
}, chain -> ViaProxy.saveManager.accountsSave.addAccount(chain));
}, account -> ViaProxy.saveManager.accountsSave.addAccount(account));
});
addButtons.add(this.addBedrockAccountButton);
}