mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-15 10:45:35 +01:00
Updated MinecraftAuth
This commit is contained in:
parent
581be34349
commit
0420a2c194
@ -27,7 +27,7 @@ snake_yml_version=2.0
|
||||
vialegacy_version=2.2.16
|
||||
viaaprilfools_version=2.0.7-SNAPSHOT
|
||||
viabedrock_version=0.0.1-SNAPSHOT
|
||||
minecraftauth_version=2.0.1
|
||||
minecraftauth_version=2.1.0
|
||||
|
||||
# lenni0451 libs
|
||||
mcstructs_text_version=2.2.5
|
||||
|
@ -54,12 +54,11 @@ public class BedrockAccountHandler extends FileSaver {
|
||||
@Override
|
||||
public void read(JsonObject object) {
|
||||
try {
|
||||
account = MinecraftAuth.Bedrock.Title.MC_CHAIN.fromJson(object);
|
||||
account = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.fromJson(object);
|
||||
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
||||
account = MinecraftAuth.Bedrock.Title.MC_CHAIN.refresh(httpClient, account);
|
||||
account = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.refresh(httpClient, account);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
ScreenUtil.crash("Failed to log into Bedrock account!", e);
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class BetaCraftScreen extends Screen {
|
||||
drawTextWithShadow(matrices, textRenderer, Text.translatable("words.viafabricplus.online").formatted(Formatting.GREEN), 1, 1, -1);
|
||||
}
|
||||
final String playerText = server.playerCount() + "/" + server.playerLimit();
|
||||
drawTextWithShadow(matrices, textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from line 132 */ - 1, 1, -1);
|
||||
drawTextWithShadow(matrices, textRenderer, playerText, entryWidth - textRenderer.getWidth(playerText) - 4 /* magic value from MappedSlotEntry#32 */ - 1, 1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,9 @@ import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import net.raphimc.mcauth.MinecraftAuth;
|
||||
import net.raphimc.mcauth.step.msa.StepMsaDeviceCode;
|
||||
import net.raphimc.mcauth.util.MicrosoftConstants;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@ -45,22 +48,24 @@ public class AuthenticationSettings extends SettingGroup {
|
||||
public final BooleanSetting disconnectIfJoinServerCallFails = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.fail"), true);
|
||||
public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("authentication.viafabricplus.bedrock"), () -> CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
BedrockAccountHandler.INSTANCE.setAccount(MinecraftAuth.requestBedrockLogin(msaDeviceCode -> {
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(consumer -> {
|
||||
if (consumer) {
|
||||
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
|
||||
} else {
|
||||
MinecraftClient.getInstance().setScreen(SettingsScreen.get(new MultiplayerScreen(new TitleScreen())));
|
||||
Thread.currentThread().interrupt();
|
||||
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
||||
BedrockAccountHandler.INSTANCE.setAccount(MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(consumer -> {
|
||||
if (consumer) {
|
||||
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.userCode());
|
||||
} else {
|
||||
MinecraftClient.getInstance().setScreen(SettingsScreen.get(new MultiplayerScreen(new TitleScreen())));
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
|
||||
try {
|
||||
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
|
||||
}
|
||||
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.copy"), Text.translatable("words.viafabricplus.cancel"))));
|
||||
try {
|
||||
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> Thread.currentThread().interrupt(), Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.error"), Text.translatable("words.viafabricplus.cancel"), false)));
|
||||
}
|
||||
}));
|
||||
})));
|
||||
}
|
||||
ProtocolSelectionScreen.open(new MultiplayerScreen(new TitleScreen()));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -78,7 +83,7 @@ public class AuthenticationSettings extends SettingGroup {
|
||||
public final BooleanSetting spoofUserNameIfUsingClassiCube = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.spoof"), true);
|
||||
public final BooleanSetting allowViaLegacyToLoadSkinsInLegacyVersions = new BooleanSetting(this, Text.translatable("authentication.viafabricplus.skin"), true);
|
||||
|
||||
|
||||
|
||||
public AuthenticationSettings() {
|
||||
super("Authentication");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user