IvailoBG_

Generate me a minecraft mod for the version 1.21.11 fabric, I want the mod to be for login security. The most important thing should be that when every player joins for the first time, they should register with the command /register password password. From then on, every time they join they need to login with the command /login password. The password must be longer than 6 characters. Every players password must have a way of resetting but only operators must have the option to do so. I want every password to be saved in the server files in the folder where the mod is located. The mod must be lightweight as we are playing on a server with limited RAM.

Kodari AI
KodariOct 10 at 2:01 pm 3
LoginSecurity
A lightweight Fabric mod for Minecraft 1.21.11 that adds mandatory registration and login security. New players must register with /register password password (password must be over 6 characters). Returning players must authenticate with /login password before interacting with the world. Passwords are securely hashed and stored in a JSON file within the mod's config folder. Operators can reset any player's password using /resetpassword [player] [newpassword]. The mod blocks movement, interaction, and chat until authentication is complete, ensuring server security while minimizing resource usage.
  • Check the 1.21.11 command and connection/chat hook signatures.

  • Build the server-side registration/login flow with per-session auth and operator-only resets.

  • Store salted password hashes in server files; block chat and commands until authenticated.

Created a server-only Fabric 1.21.11 login security mod.

  • First-time players use /register <password> <password>; returning players use /login <password>. Passwords must be at least 7 characters.

  • Until login, chat and other commands are blocked, gameplay interactions are denied, and movement is returned to the player’s join position.

  • Operators can use /resetpassword <player> <new_password> to reset an online player’s password.

  • Credentials are stored in login-security/accounts.properties under the server’s working directory. The file contains salted PBKDF2 password hashes, not plaintext passwords.

  • The mod keeps only account and session state in memory and has no extra library dependencies.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 567
src/main/java/com/kodari/loginsecurity/LoginSecurityMod.java
package com.kodari.loginsecurity;

import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class LoginSecurityMod implements ModInitializer {
    public static final String MOD_ID = "loginsecurity";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    public static final AuthManager AUTH = new AuthManager();

    @Override
    public void onInitialize() {
        AUTH.initialize();
    }
}