Put bedrock login process messages into translations, various cleanups

This commit is contained in:
FlorianMichael 2024-07-16 20:40:44 +02:00
parent e8ef14d0aa
commit d7e59af1e3
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
8 changed files with 77 additions and 50 deletions

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.injection.mixin.compat.jsonwebtoken;
package de.florianmichael.viafabricplus.injection.mixin.compat.minecraftauth;
import io.jsonwebtoken.lang.Classes;
import org.spongepowered.asm.mixin.Mixin;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.injection.mixin.compat.jsonwebtoken;
package de.florianmichael.viafabricplus.injection.mixin.compat.minecraftauth;
import io.jsonwebtoken.gson.io.GsonDeserializer;
import io.jsonwebtoken.impl.DefaultJwtParserBuilder;

View File

@ -38,7 +38,7 @@ public class ViaFabricPlusOldAuthProvider extends OldAuthProvider {
final var mc = MinecraftClient.getInstance();
mc.getSessionService().joinServer(mc.getSession().getUuidOrNull(), mc.getSession().getAccessToken(), serverId);
} catch (Exception e) {
user.getChannel().attr(ProtocolTranslator.CLIENT_CONNECTION_ATTRIBUTE_KEY).get().disconnect(ChatUtil.prefixText(Text.translatable("authentication.viafabricplus.failed_to_verify_session")));
user.getChannel().attr(ProtocolTranslator.CLIENT_CONNECTION_ATTRIBUTE_KEY).get().disconnect(ChatUtil.prefixText(Text.translatable("betacraft.viafabricplus.failed_to_verify_session")));
ViaFabricPlus.global().getLogger().error("Error occurred while calling join server to verify session", e);
}
}

View File

@ -44,29 +44,30 @@ public class ReportIssuesScreen extends VFPScreen {
public ReportIssuesScreen() {
super("Report issues", true);
if (actions.isEmpty()) {
actions.put("report.viafabricplus.bug_report", () -> {
Util.getOperatingSystem().open(URI.create("https://github.com/ViaVersion/ViaFabricPlus/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml"));
this.setupSubtitle(Text.of("Opened GitHub issue page!"));
});
actions.put("report.viafabricplus.feature_request", () -> {
Util.getOperatingSystem().open(URI.create("https://github.com/ViaVersion/ViaFabricPlus/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.yml"));
this.setupSubtitle(Text.of("Opened GitHub issue page!"));
});
actions.put("report.viafabricplus.create_via_dump", () -> DumpUtil.postDump(client.getSession().getUuidOrNull()).whenComplete((s, throwable) -> {
if (throwable != null) {
this.setupSubtitle(Text.of("Failed to create a dump! See logs for more information."));
ViaFabricPlus.global().getLogger().error("Failed to create a dump", throwable);
return;
}
this.setupSubtitle(Text.of("Dump created and copied to clipboard!"));
client.keyboard.setClipboard(s);
}));
actions.put("report.viafabricplus.open_logs", () -> {
Util.getOperatingSystem().open(new File(client.runDirectory, "logs") /* there is no constant for this in the game */);
this.setupSubtitle(Text.of("Logs folder opened!"));
});
if (!actions.isEmpty()) {
return;
}
actions.put("report.viafabricplus.bug_report", () -> {
Util.getOperatingSystem().open(URI.create("https://github.com/ViaVersion/ViaFabricPlus/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml"));
this.setupSubtitle(Text.of("Opened GitHub issue page!"));
});
actions.put("report.viafabricplus.feature_request", () -> {
Util.getOperatingSystem().open(URI.create("https://github.com/ViaVersion/ViaFabricPlus/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.yml"));
this.setupSubtitle(Text.of("Opened GitHub issue page!"));
});
actions.put("report.viafabricplus.create_via_dump", () -> DumpUtil.postDump(client.getSession().getUuidOrNull()).whenComplete((s, throwable) -> {
if (throwable != null) {
this.setupSubtitle(Text.of("Failed to create a dump! See logs for more information."));
ViaFabricPlus.global().getLogger().error("Failed to create a dump", throwable);
return;
}
this.setupSubtitle(Text.of("Dump created and copied to clipboard!"));
client.keyboard.setClipboard(s);
}));
actions.put("report.viafabricplus.open_logs", () -> {
Util.getOperatingSystem().open(new File(client.runDirectory, "logs") /* there is no constant for this in the game */);
this.setupSubtitle(Text.of("Logs folder opened!"));
});
}
@Override

View File

@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.settings.impl;
import com.mojang.blaze3d.systems.RenderSystem;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.injection.access.IConfirmScreen;
import de.florianmichael.viafabricplus.save.impl.AccountsSave;
import de.florianmichael.viafabricplus.screen.VFPScreen;
import de.florianmichael.viafabricplus.settings.base.BooleanSetting;
import de.florianmichael.viafabricplus.settings.base.ButtonSetting;
@ -33,12 +34,17 @@ import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.raphimc.minecraftauth.MinecraftAuth;
import net.raphimc.minecraftauth.step.AbstractStep;
import net.raphimc.minecraftauth.step.bedrock.StepMCChain;
import net.raphimc.minecraftauth.step.bedrock.StepPlayFabToken;
import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCode;
import net.raphimc.minecraftauth.step.msa.StepMsaDeviceCodeMsaCode;
import net.raphimc.minecraftauth.step.xbl.StepXblDeviceToken;
import net.raphimc.minecraftauth.step.xbl.StepXblSisuAuthentication;
import net.raphimc.minecraftauth.step.xbl.StepXblXstsToken;
import net.raphimc.minecraftauth.util.logging.ConsoleLogger;
import net.raphimc.minecraftauth.util.logging.ILogger;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.CompletableFuture;
public class BedrockSettings extends SettingGroup {
@ -47,7 +53,7 @@ public class BedrockSettings extends SettingGroup {
private static final BedrockSettings INSTANCE = new BedrockSettings();
private final ButtonSetting _IGNORED = new ButtonSetting(this, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account"), () -> CompletableFuture.runAsync(this::openBedrockAccountLogin)) {
private final ButtonSetting clickToSetBedrockAccount = new ButtonSetting(this, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account"), () -> CompletableFuture.runAsync(this::openBedrockAccountLogin)) {
@Override
public MutableText displayValue() {
@ -63,14 +69,14 @@ public class BedrockSettings extends SettingGroup {
private final ILogger GUI_LOGGER = new ConsoleLogger() {
@Override
public void info(String message) {
super.info(message);
if (message.equals("Waiting for MSA login via device code...")) {
public void info(AbstractStep<?, ?> step, String message) {
super.info(step, message);
if (step instanceof StepMsaDeviceCodeMsaCode) {
return;
}
MinecraftClient.getInstance().execute(() -> {
if (MinecraftClient.getInstance().currentScreen instanceof ConfirmScreen confirmScreen) {
((IConfirmScreen) confirmScreen).viaFabricPlus$setMessage(Text.literal(message));
((IConfirmScreen) confirmScreen).viaFabricPlus$setMessage(Text.translatable(translationKey(step)));
}
});
}
@ -81,10 +87,12 @@ public class BedrockSettings extends SettingGroup {
}
private void openBedrockAccountLogin() {
final AccountsSave accountsSave = ViaFabricPlus.global().getSaveManager().getAccountsSave();
final MinecraftClient client = MinecraftClient.getInstance();
final Screen prevScreen = client.currentScreen;
try {
ViaFabricPlus.global().getSaveManager().getAccountsSave().setBedrockAccount(MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(GUI_LOGGER, MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
accountsSave.setBedrockAccount(MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(GUI_LOGGER, MinecraftAuth.createHttpClient(), new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
client.execute(() -> client.setScreen(new ConfirmScreen(copyUrl -> {
if (copyUrl) {
client.keyboard.setClipboard(msaDeviceCode.getDirectVerificationUri());
@ -92,13 +100,8 @@ public class BedrockSettings extends SettingGroup {
client.setScreen(prevScreen);
Thread.currentThread().interrupt();
}
}, TITLE, Text.translatable("bedrock.viafabricplus.login"), Text.translatable("base.viafabricplus.copy_link"), Text.translatable("base.viafabricplus.cancel"))));
try {
Util.getOperatingSystem().open(new URI(msaDeviceCode.getDirectVerificationUri()));
} catch (URISyntaxException e) {
Thread.currentThread().interrupt();
VFPScreen.showErrorScreen("Microsoft Bedrock Login", e, prevScreen);
}
}, TITLE, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account.notice"), Text.translatable("base.viafabricplus.copy_link"), Text.translatable("base.viafabricplus.cancel"))));
Util.getOperatingSystem().open(msaDeviceCode.getDirectVerificationUri());
})));
RenderSystem.recordRenderCall(() -> client.setScreen(prevScreen));
@ -108,6 +111,17 @@ public class BedrockSettings extends SettingGroup {
}
}
private String translationKey(final AbstractStep<?, ?> step) {
return "minecraftauth_library.viafabricplus." + switch (step) {
case StepXblDeviceToken stepXblDeviceToken -> "authenticate_xbox_live";
case StepXblSisuAuthentication stepXblSisuAuthentication -> "authenticate_sisu";
case StepMCChain stepMCChain -> "authenticate_minecraft";
case StepXblXstsToken stepXblXstsToken -> "requesting_xsts_token";
case StepPlayFabToken stepPlayFabToken -> "authenticate_playfab";
case null, default -> throw new IllegalArgumentException("Unknown step: " + step);
};
}
public static BedrockSettings global() {
return INSTANCE;
}

View File

@ -46,6 +46,7 @@
"general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Inventaraktionen in Alpha-Versionen emulieren",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Klicke, um den Account für die Bedrock-Edition einzustellen",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account.notice": "Dein Browser sollte sich geöffnet haben.\nDas Schließen dieses Bildschirms unterbricht den Vorgang!",
"bedrock_settings.viafabricplus.replace_default_port": "Standardport in der Serverliste ersetzen",
"debug_settings.viafabricplus.queue_config_packets": "Konfigurationspakete in Warteschlange einreihen",
@ -90,9 +91,6 @@
"visual_settings.viafabricplus.hide_crafting_recipe_book": "Bastelrezeptbuch verstecken",
"visual_settings.viafabricplus.hide_modern_jigsaw_screen_features": "Moderne Puzzle-Funktionen ausblenden",
"bedrock.viafabricplus.login": "Dein Browser sollte sich geöffnet haben.\nDas Schließen dieses Bildschirms unterbricht den Vorgang!",
"authentication.viafabricplus.failed_to_verify_session": "ViaFabricPlus konnte deine Sitzung nicht verifizieren! Bitte logge dich in einen Account ein oder deaktiviere die BetaCraft-Authentifizierung in den ViaFabricPlus-Einstellungen.",
"report.viafabricplus.button": "Probleme melden",
"report.viafabricplus.bug_report": "Fehler auf GitHub melden",
"report.viafabricplus.feature_request": "Funktion auf GitHub vorschlagen",
@ -102,11 +100,19 @@
"classicube.viafabricplus.account": "Du kannst hier einen Account erstellen: https://www.classicube.net/",
"classicube.viafabricplus.loading": "Lade Profilinformationen und Serverliste...",
"classicube.viafabricplus.warning": "Diese Funktion sendet API-Anfragen an die ClassiCube-API.",
"betacraft.viafabricplus.failed_to_verify_session": "ViaFabricPlus konnte deine Sitzung nicht verifizieren! Bitte logge dich in einen Account ein oder deaktiviere die BetaCraft-Authentifizierung in den ViaFabricPlus-Einstellungen.",
"betacraft.viafabricplus.warning": "Durch Drücken dieser Schaltfläche werden API-Anfragen an \"betacraft.uk/serverlist\" gesendet.",
"classic4j_library.viafabricplus.error.token": "Inkorrektes Token. Ist ViaFabricPlus veraltet?",
"classic4j_library.viafabricplus.error.username": "Ungültiger Benutzername.",
"classic4j_library.viafabricplus.error.password": "Ungültiges Passwort.",
"classic4j_library.viafabricplus.error.verification": "Benutzer hat seine E-Mail-Adresse noch nicht verifiziert.",
"classic4j_library.viafabricplus.error.logincode": "Mehrstufige Authentifizierung angefordert. Bitte überprüfe deine E-Mails."
"classic4j_library.viafabricplus.error.logincode": "Mehrstufige Authentifizierung angefordert. Bitte überprüfe deine E-Mails.",
"minecraftauth_library.viafabricplus.authenticate_xbox_live": "Gerät mit Xbox Live authentifizieren...",
"minecraftauth_library.viafabricplus.authenticate_sisu": "Authentifizierung mit Xbox Live über SISU...",
"minecraftauth_library.viafabricplus.authenticate_minecraft": "Authentifizierung mit den Minecraft-Diensten...",
"minecraftauth_library.viafabricplus.requesting_xsts_token": "Anfordern des XSTS-Tokens...",
"minecraftauth_library.viafabricplus.authenticate_playfab": "Authentifizierung mit PlayFab..."
}

View File

@ -46,6 +46,7 @@
"general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emulate inventory actions in alpha versions",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock Edition",
"bedrock_settings.viafabricplus.click_to_set_bedrock_account.notice": "Your browser should have opened.\nClosing this screen will cancel the process!",
"bedrock_settings.viafabricplus.replace_default_port": "Replace default port in server list",
"debug_settings.viafabricplus.queue_config_packets": "Queue config packets",
@ -91,9 +92,6 @@
"visual_settings.viafabricplus.hide_crafting_recipe_book": "Hide crafting recipe book",
"visual_settings.viafabricplus.hide_modern_jigsaw_screen_features": "Hide modern Jigsaw screen features",
"bedrock.viafabricplus.login": "Your browser should have opened.\nClosing this screen will cancel the process!",
"authentication.viafabricplus.failed_to_verify_session": "ViaFabricPlus couldn't verify your session! Please log in to an account or disable the BetaCraft authentication in the ViaFabricPlus Settings",
"report.viafabricplus.button": "Report issues",
"report.viafabricplus.bug_report": "Report a bug on GitHub",
"report.viafabricplus.feature_request": "Request a feature on GitHub",
@ -103,11 +101,19 @@
"classicube.viafabricplus.account": "You can create an account here: https://www.classicube.net/",
"classicube.viafabricplus.loading": "Loading profile information and server list...",
"classicube.viafabricplus.warning": "This feature will send API requests to the ClassiCube API.",
"betacraft.viafabricplus.failed_to_verify_session": "ViaFabricPlus couldn't verify your session! Please log in to an account or disable the BetaCraft authentication in the ViaFabricPlus Settings",
"betacraft.viafabricplus.warning": "Pressing this button will send API requests to \"betacraft.uk/serverlist\".",
"classic4j_library.viafabricplus.error.token": "Incorrect token. Is your ViaFabricPlus out of date?",
"classic4j_library.viafabricplus.error.username": "Invalid username.",
"classic4j_library.viafabricplus.error.password": "Invalid password.",
"classic4j_library.viafabricplus.error.verification": "User hasn't verified their email address yet.",
"classic4j_library.viafabricplus.error.logincode": "Multi-factor authentication requested. Please check your email."
"classic4j_library.viafabricplus.error.logincode": "Multi-factor authentication requested. Please check your email.",
"minecraftauth_library.viafabricplus.authenticate_xbox_live": "Authenticating device with Xbox Live...",
"minecraftauth_library.viafabricplus.authenticate_sisu": "Authenticating with Xbox Live using SISU...",
"minecraftauth_library.viafabricplus.authenticate_minecraft": "Authenticating with Minecraft Services...",
"minecraftauth_library.viafabricplus.requesting_xsts_token": "Requesting XSTS Token...",
"minecraftauth_library.viafabricplus.authenticate_playfab": "Authenticating with PlayFab..."
}

View File

@ -32,9 +32,9 @@
"compat.classic4j.MixinTextFieldWidget",
"compat.fabricapi.MixinRegistrySyncManager",
"compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor",
"compat.jsonwebtoken.MixinClasses",
"compat.jsonwebtoken.MixinDefaultJwtParserBuilder",
"compat.lithium.MixinEntity",
"compat.minecraftauth.MixinClasses",
"compat.minecraftauth.MixinDefaultJwtParserBuilder",
"fixes.authlib.MixinKeyPairResponse",
"fixes.authlib.MixinYggdrasilUserApiService",
"fixes.minecraft.MixinActionResult",