diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index a1e305e7..78ba3288 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -58,7 +58,6 @@ import java.io.File; * - Blit-jump is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225) * * TODO | Migration v3 - * - Fix classic login input field (MixinSharedConstants) * - Make recipe fixes dynamic instead of a data dump in java classes * - Make mixin injection methods private * - Make mixins abstract @@ -67,6 +66,7 @@ import java.io.File; * - Is de.florianmichael.viafabricplus.injection.mixin.jsonwebtoken.* still needed? * - Apply MixinAutoRefillHandler_ItemSlotMonitor only when mod is actually installed * - Make block shapes static + * - Remove information package / system */ public class ViaFabricPlus { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/ITextFieldWidget.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/ITextFieldWidget.java new file mode 100644 index 00000000..bf086a0b --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/ITextFieldWidget.java @@ -0,0 +1,23 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package de.florianmichael.viafabricplus.injection.access; + +public interface ITextFieldWidget { + + void viaFabricPlus$unlockForbiddenCharacters(); +} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinTextFieldWidget.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinTextFieldWidget.java new file mode 100644 index 00000000..f90090fc --- /dev/null +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/MixinTextFieldWidget.java @@ -0,0 +1,54 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus + * Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package de.florianmichael.viafabricplus.injection.mixin.base; + +import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget; +import net.minecraft.SharedConstants; +import net.minecraft.client.gui.widget.TextFieldWidget; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(TextFieldWidget.class) +public class MixinTextFieldWidget implements ITextFieldWidget { + + @Unique + private boolean viaFabricPlus$forbiddenCharactersUnlocked = false; + + @Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;isValidChar(C)Z")) + public boolean allowForbiddenCharacters(char c) { + if (this.viaFabricPlus$forbiddenCharactersUnlocked) { + return true; + } + return SharedConstants.isValidChar(c); + } + + @Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;")) + public String allowForbiddenCharacters(String string) { + if (this.viaFabricPlus$forbiddenCharactersUnlocked) { + return string; + } + return SharedConstants.stripInvalidChars(string); + } + + @Override + public void viaFabricPlus$unlockForbiddenCharacters() { + this.viaFabricPlus$forbiddenCharactersUnlocked = true; + } +} diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/classicube/ClassiCubeLoginScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/classicube/ClassiCubeLoginScreen.java index e0f8fe41..b4f6ad88 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/classicube/ClassiCubeLoginScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/classicube/ClassiCubeLoginScreen.java @@ -21,6 +21,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import de.florianmichael.classic4j.ClassiCubeHandler; import de.florianmichael.classic4j.api.LoginProcessHandler; import de.florianmichael.classic4j.model.classicube.account.CCAccount; +import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget; import de.florianmichael.viafabricplus.screen.VFPScreen; import de.florianmichael.viafabricplus.definition.account.ClassiCubeAccountHandler; import de.florianmichael.viafabricplus.screen.common.ProtocolSelectionScreen; @@ -66,6 +67,9 @@ public class ClassiCubeLoginScreen extends VFPScreen { nameField.setMaxLength(Integer.MAX_VALUE); passwordField.setMaxLength(Integer.MAX_VALUE); + ((ITextFieldWidget) nameField).viaFabricPlus$unlockForbiddenCharacters(); + ((ITextFieldWidget) passwordField).viaFabricPlus$unlockForbiddenCharacters(); + nameField.setText(ClassiCubeAccountHandler.INSTANCE.getUsername()); passwordField.setText(ClassiCubeAccountHandler.INSTANCE.getPassword()); diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 0ade9436..f645f46c 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -20,6 +20,7 @@ "base.MixinMultiplayerServerListWidget_ServerEntry", "base.MixinOptionsScreen", "base.MixinServerInfo", + "base.MixinTextFieldWidget", "classic4j.MixinCCAuthenticationResponse", "compat.ipnext.MixinAutoRefillHandler_ItemSlotMonitor", "fixes.authlib.MixinKeyPairResponse",