vl.ash

Create a Fabric 1.21.11 client mod named VlashLogin. It should automatically detect server chat messages containing login or register prompts (like /login or /register) and automatically send the saved password using /login <password> or /register <password> <password>. Add a custom config screen with a text field for the password, a toggle button to enable/disable auto-auth, and a manual 'Login Now' button. Also, add a keybinding in the game controls settings to open this GUI menu easily.

Kodari AI
KodariOct 27 at 10:10 pm 3
VlashLogin
VlashLogin is a Fabric 1.21.11 client mod that automatically detects login and register prompts in server chat messages. It monitors incoming chat for patterns containing "/login" or "/register" and automatically sends the configured password using "/login &lt;password&gt;" or "/register &lt;password&gt; &lt;password&gt;". The mod includes a custom config screen with a password text field, an enable/disable toggle for auto-auth, and a manual "Login Now" button. A configurable keybinding in game controls opens the GUI menu, allowing quick access to manage authentication settings.
  1. Set up the Fabric client mod and persistent auth settings.

  2. Add prompt detection, safe auto-auth commands, and a controls keybinding.

  3. Build the owo-ui config screen with password, enable toggle, and manual login.

Created VlashLogin with automatic /login and /register responses to detected server system-chat prompts, an enable toggle, a saved-password field, a Login Now action, and a remappable O keybind for opening settings.

The password is stored locally in plaintext at config/vlashlogin.properties. YACL is bundled through manifest.kod.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
9 290
src/client/java/com/vlashlogin/client/VlashLoginClient.java
package com.vlashlogin.client;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

import java.util.Locale;

public final class VlashLoginClient implements ClientModInitializer {
    private static KeyBinding openConfigKey;
    private static long lastAutomaticAttempt;

    @Override
    public void onInitializeClient() {
        VlashLoginSettings.load();

        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("vlashlogin", "general"));
        openConfigKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.vlashlogin.open_config", GLFW.GLFW_KEY_O, category)
        );

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (openConfigKey.wasPressed()) {
                client.setScreen(VlashLoginConfig.createScreen(client.currentScreen));
            }
        });

        ClientReceiveMessageEvents.GAME.register((Text message, boolean overlay) -> {
            if (!overlay) {
                tryAutomaticAuth(message.getString());
            }
        });
    }

    static void loginNow() {
        sendAuthCommand(false);
    }

    private static void tryAutomaticAuth(String message) {
        if (!VlashLoginSettings.autoAuth || VlashLoginSettings.password.isEmpty()) {
            return;
        }

        String prompt = message.toLowerCase(Locale.ROOT);
        boolean asksForPassword = prompt.contains("password")
                || prompt.contains("passwort")
                || prompt.contains("please")
                || prompt.contains("enter")
                || prompt.contains("use /")
                || prompt.contains("authenticate")
                || prompt.contains("required")
                || prompt.contains("to continue");
        if (!asksForPassword) {
            return;
        }

        boolean registerPrompt = prompt.contains("register") || prompt.contains("/reg ");
        boolean loginPrompt = prompt.contains("login") || prompt.contains("log in");
        if (!registerPrompt && !loginPrompt) {
            return;
        }

        long now = System.currentTimeMillis();
        if (now - lastAutomaticAttempt < 3000) {
            return;
        }

        if (sendAuthCommand(registerPrompt)) {
            lastAutomaticAttempt = now;
        }
    }

    private static boolean sendAuthCommand(boolean register) {
        String password = VlashLoginSettings.password;
        if (password.isEmpty() || password.length() > 240) {
            return false;
        }
        for (int i = 0; i < password.length(); i++) {
            char character = password.charAt(i);
            if (Character.isWhitespace(character) || Character.isISOControl(character)) {
                return false;
            }
        }

        MinecraftClient client = MinecraftClient.getInstance();
        ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
        if (networkHandler == null) {
            return false;
        }

        if (register) {
            networkHandler.sendChatCommand("register " + password + " " + password);
        } else {
            networkHandler.sendChatCommand("login " + password);
        }
        return true;
    }
}