mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-21 11:46:49 +01:00
Updated MinecraftAuth
This commit is contained in:
parent
d644e2f8a4
commit
e8015a864c
@ -21,7 +21,7 @@ viaaprilfools_version=2.0.11-SNAPSHOT
|
||||
vialoader_version=2.2.13-SNAPSHOT
|
||||
|
||||
# RaphiMC Libraries
|
||||
minecraftauth_version=3.1.0
|
||||
minecraftauth_version=4.0.0-SNAPSHOT
|
||||
|
||||
viabedrock_version=0.0.4-SNAPSHOT
|
||||
raknet_transport_version=1.0.0.CR1-SNAPSHOT
|
||||
|
@ -25,8 +25,6 @@ import de.florianmichael.viafabricplus.ViaFabricPlus;
|
||||
import de.florianmichael.viafabricplus.save.AbstractSave;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.step.bedrock.session.StepFullBedrockSession;
|
||||
import net.raphimc.minecraftauth.util.MicrosoftConstants;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
public class AccountsSave extends AbstractSave {
|
||||
|
||||
@ -68,8 +66,8 @@ public class AccountsSave extends AbstractSave {
|
||||
public StepFullBedrockSession.FullBedrockSession refreshAndGetBedrockAccount() {
|
||||
if (bedrockAccount == null) return null;
|
||||
|
||||
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
||||
bedrockAccount = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.refresh(httpClient, bedrockAccount);
|
||||
try {
|
||||
bedrockAccount = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.refresh(MinecraftAuth.createHttpClient(), bedrockAccount);
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to refresh Bedrock chain data. Please re-login to Bedrock!", t);
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCode;
|
||||
import net.raphimc.minecraftauth.util.MicrosoftConstants;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@ -64,21 +62,19 @@ public class BedrockSettings extends SettingGroup {
|
||||
private void openBedrockAccountLogin() {
|
||||
final var prevScreen = MinecraftClient.getInstance().currentScreen;
|
||||
try {
|
||||
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
||||
final var bedrockSession = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> {
|
||||
MinecraftClient.getInstance().setScreen(prevScreen);
|
||||
Thread.currentThread().interrupt();
|
||||
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrock.viafabricplus.login"), Text.translatable("base.viafabricplus.cancel"), true)));
|
||||
try {
|
||||
Util.getOperatingSystem().open(new URI(msaDeviceCode.getDirectVerificationUri()));
|
||||
} catch (URISyntaxException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
VFPScreen.showErrorScreen("Microsoft Bedrock Login", e, prevScreen);
|
||||
}
|
||||
}));
|
||||
ViaFabricPlus.global().getSaveManager().getAccountsSave().setBedrockAccount(bedrockSession);
|
||||
}
|
||||
ViaFabricPlus.global().getSaveManager().getAccountsSave().setBedrockAccount(MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> {
|
||||
MinecraftClient.getInstance().setScreen(prevScreen);
|
||||
Thread.currentThread().interrupt();
|
||||
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrock.viafabricplus.login"), Text.translatable("base.viafabricplus.cancel"), true)));
|
||||
try {
|
||||
Util.getOperatingSystem().open(new URI(msaDeviceCode.getDirectVerificationUri()));
|
||||
} catch (URISyntaxException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
VFPScreen.showErrorScreen("Microsoft Bedrock Login", e, prevScreen);
|
||||
}
|
||||
})));
|
||||
|
||||
RenderSystem.recordRenderCall(() -> MinecraftClient.getInstance().setScreen(prevScreen));
|
||||
} catch (Throwable e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
Loading…
Reference in New Issue
Block a user