diff --git a/gradle.properties b/gradle.properties index 81c6ae6a..409a1d8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/de/florianmichael/viafabricplus/save/impl/AccountsSave.java b/src/main/java/de/florianmichael/viafabricplus/save/impl/AccountsSave.java index 94582f69..6c522ccf 100644 --- a/src/main/java/de/florianmichael/viafabricplus/save/impl/AccountsSave.java +++ b/src/main/java/de/florianmichael/viafabricplus/save/impl/AccountsSave.java @@ -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); } diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java index 98ab7a8b..c07b0508 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java @@ -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();