|
28 | 28 | import net.lenni0451.miniconnect.utils.GeyserAPI; |
29 | 29 | import net.lenni0451.miniconnect.utils.InetUtils; |
30 | 30 | import net.raphimc.minecraftauth.MinecraftAuth; |
31 | | -import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCode; |
| 31 | +import net.raphimc.minecraftauth.java.JavaAuthManager; |
| 32 | +import net.raphimc.minecraftauth.msa.model.MsaDeviceCode; |
| 33 | +import net.raphimc.minecraftauth.msa.service.impl.DeviceCodeMsaAuthService; |
32 | 34 | import net.raphimc.netminecraft.packet.impl.play.S2CPlayDisconnectPacket; |
33 | 35 | import net.raphimc.viaproxy.saves.impl.accounts.MicrosoftAccount; |
34 | 36 | import net.raphimc.viaproxy.util.logging.Logger; |
35 | 37 |
|
36 | 38 | import java.net.InetAddress; |
37 | 39 | import java.util.concurrent.TimeoutException; |
| 40 | +import java.util.function.Consumer; |
38 | 41 |
|
39 | 42 | import static net.lenni0451.miniconnect.server.states.play.screen.ItemBuilder.item; |
40 | 43 |
|
@@ -114,13 +117,13 @@ public void init(ScreenHandler screenHandler, ItemList itemList) { |
114 | 117 | screenHandler.getStateHandler().send(new S2CSystemChatPacket(new StringComponent("§aLoading, please wait..."), false)); |
115 | 118 | PlatformTask<?> task = Via.getPlatform().runAsync(() -> { |
116 | 119 | try { |
117 | | - playerConfig.account = new MicrosoftAccount(MicrosoftAccount.DEVICE_CODE_LOGIN.getFromInput(MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(code -> { |
| 120 | + playerConfig.account = new MicrosoftAccount(JavaAuthManager.create(MinecraftAuth.createHttpClient()).login(DeviceCodeMsaAuthService::new, (Consumer<MsaDeviceCode>) code -> { |
118 | 121 | TextComponent component = new StringComponent("Please open your browser and visit ").styled(style -> style.setFormatting(TextFormatting.YELLOW)); |
119 | 122 | component.append(new StringComponent(code.getDirectVerificationUri()).styled(style -> style.setFormatting(TextFormatting.BLUE).setClickEvent(new OpenUrlClickEvent(code.getDirectVerificationUri())))); |
120 | 123 | component.append(new StringComponent(" and login with your Microsoft account")); |
121 | 124 | screenHandler.getStateHandler().send(new S2CSystemChatPacket(component, false)); |
122 | 125 | screenHandler.getStateHandler().send(new S2CSystemChatPacket(new StringComponent("§bIf the code is not inserted automatically, please enter the code: §a" + code.getUserCode()), false)); |
123 | | - }))); |
| 126 | + })); |
124 | 127 | screenHandler.getStateHandler().send(new S2CSystemChatPacket(new StringComponent("§aSuccessfully logged in"), false)); |
125 | 128 | } catch (InterruptedException e) { |
126 | 129 | return; |
|
0 commit comments