gurgunda_

AuthGuardLogin — Production-Ready Minecraft Authentication Plugin

Create a complete, production-ready Minecraft authentication/login plugin named AuthGuardLogin using Java and targeting Paper 1.21.11.

The plugin's primary purpose is to protect player accounts on a private Minecraft server. A player must authenticate before they can access the normal world, move around, interact with blocks, inspect containers, or reach their previous location.

The implementation must be modular, secure, maintainable, and compile successfully without missing classes, imports, methods, or dependencies.

---

  1. Technical Requirements
  • Platform: Paper
  • Minecraft version: 1.21.11
  • Language: Java
  • Build system: Maven
  • Use the modern Paper API wherever possible.
  • Use Adventure API for messages, colors, titles, and formatting.
  • Do not use deprecated APIs when a modern alternative exists.
  • Use SQLite for persistent authentication data.
  • Use UUID, not player names, as the primary player identifier.
  • Passwords must never be stored in plaintext.
  • Use a secure password-hashing algorithm such as BCrypt.
  • Database operations must not block the Minecraft main server thread.
  • Handle database errors safely.
  • Handle missing worlds and invalid saved locations safely.
  • Do not hardcode authentication-spawn coordinates.
  • Configuration must be stored in "config.yml".

---

  1. Core Authentication States

Create an authentication manager with exactly these logical states:

REGISTER_REQUIRED LOGIN_REQUIRED AUTHENTICATED

Every relevant player event must check the player's authentication state through the central authentication manager.

Avoid scattering independent authentication logic throughout the plugin.

---

  1. First-Time Player Registration

When a player joins for the first time and their UUID does not exist in the authentication database:

  1. Set their state to:

REGISTER_REQUIRED

  1. Immediately teleport them to the configured authentication spawn.
  1. Freeze them at the authentication spawn.
  1. Prevent them from accessing the normal world.
  1. Display registration instructions.

The player must NOT be able to:

  • Move away from the authentication spawn.
  • Break blocks.
  • Place blocks.
  • Attack players.
  • Attack entities.
  • Take damage.
  • Deal damage.
  • Drop items.
  • Pick up items.
  • Open chests.
  • Open barrels.
  • Open shulker boxes.
  • Open furnaces.
  • Open any containers.
  • Interact with blocks.
  • Use items.
  • Interact with entities.
  • Ride vehicles.
  • Enter vehicles.
  • Use portals.
  • Change gamemode.
  • Use teleport commands.
  • Teleport through any plugin mechanism.
  • Use normal commands.
  • Access gameplay-related inventories.
  • Bypass authentication through death.
  • Bypass authentication through disconnect/reconnect.
  • Bypass authentication through spectator mode.

Only authentication-related commands should be allowed.

---

  1. Registration Command

Create:

/register <password> <password>

Example:

/register 12345 12345

Requirements:

  • Password must be entered twice.
  • Both passwords must match.
  • Enforce a configurable minimum password length.
  • Optionally support a configurable maximum password length.
  • Never store the plaintext password.
  • Hash the password using BCrypt.
  • Store the hash in SQLite.
  • Associate the account with the player's UUID.
  • Save the registration timestamp.

If the passwords do not match:

❌ Passwords do not match.

If the password is too short:

❌ Password must be at least <length> characters.

If registration succeeds:

Set the player state to:

AUTHENTICATED

Display a private title visible only to that player.

Default title:

✔ Registration Successful LADKE 😎🔥

Use configurable title/subtitle text and colors.

After successful registration:

  1. Restore normal gameplay.
  2. Restore normal movement.
  3. Restore normal interaction.
  4. If a valid previous saved location exists, teleport the player there.
  5. If no valid saved location exists, teleport them to the configured fallback/server spawn.

---

  1. Returning Player Login

When a registered player joins:

  1. Check their UUID in SQLite.
  2. Set their state to:

LOGIN_REQUIRED

  1. Immediately teleport them to the authentication spawn.
  2. Freeze them.
  3. Prevent all normal gameplay access.
  4. Do NOT teleport them to their previous location before successful authentication.
  5. Show login instructions.

Create:

/login <password>

Example:

/login 12345

The password must be checked against the stored BCrypt hash.

If the password is incorrect:

❌ Wrong password! Try again.

The player must remain unauthenticated and frozen.

If the password is correct:

  1. Set state to "AUTHENTICATED".
  2. Update the last-login timestamp.
  3. Restore normal gameplay.
  4. Restore movement and interaction.
  5. Restore the player's saved location if it is valid.
  6. If the saved world no longer exists, safely use the configured fallback spawn.
  7. Display a private title visible only to that player.

Default login-success title:

😂 Agya Bhangar Ki Shakal Ka 💀

Make title/subtitle and formatting configurable.

---

  1. Authentication Spawn

The authentication spawn is the location where unauthenticated players are held.

It must contain:

  • World name
  • X
  • Y
  • Z
  • Yaw
  • Pitch

Create:

/auth setspawn

When an administrator executes this command:

  • Save the administrator's current location as the authentication spawn.
  • Persist it in "config.yml".
  • Confirm the change to the administrator.

Do not hardcode any coordinates.

If the authentication spawn is missing or its world does not exist:

  • Log a clear warning.
  • Use the configured fallback/server spawn where safe.
  • Never send an unauthenticated player to their previous location.

---

  1. Player Freeze System

Unauthenticated players must remain at the authentication spawn.

Prevent:

  • Walking
  • Sprinting
  • Jumping
  • Flying
  • Swimming
  • Gliding
  • Vehicle movement
  • Portal movement
  • Knockback
  • Plugin-generated movement where practical

Cancel unauthorized movement.

If necessary, continuously ensure the player remains at the authentication spawn.

Do not interfere with authenticated players.

---

  1. Complete Anti-Bypass Protection

Authentication must not be bypassable through:

  • Reconnecting
  • Relogging
  • Death
  • Respawn
  • Damage
  • Knockback
  • Teleport commands
  • Plugin teleports
  • Nether portals
  • End portals
  • End gateways
  • Vehicles
  • Boats
  • Minecarts
  • Spectator mode
  • Gamemode changes
  • Commands
  • Item interaction
  • Block interaction
  • Inventory interaction
  • Container interaction
  • Dropping items
  • Picking up items
  • Attacking entities
  • Being attacked
  • World changes
  • Plugin reloads
  • Server restarts
  • Client movement packets

If an unauthenticated player dies or otherwise changes location, safely return them to the authentication spawn.

Authentication restrictions must also be reapplied after reconnects and server lifecycle events.

---

  1. Command Restrictions

While the player is:

REGISTER_REQUIRED

allow only:

/register

While the player is:

LOGIN_REQUIRED

allow only:

/login

Block all other player commands.

Commands must be blocked before they can provide access to gameplay or information.

Do not block console commands.

Do not prevent administrators from using legitimate console/admin commands.

---

  1. Last Location System

Whenever an authenticated player leaves the server, save their current location.

Save:

World name X Y Z Yaw Pitch

Example:

world 250.5 72.0 -430.2 90.0 0.0

On the next successful authentication:

/login password

teleport the player back to that exact saved location.

Important:

  • Never save a new location while the player is unauthenticated.
  • Never save the authentication spawn as the player's last location.
  • Never overwrite a valid saved location with the authentication spawn.
  • Only save locations when the player is authenticated.
  • Check whether the saved world still exists.
  • If the world no longer exists, use the configured fallback spawn.
  • If the saved location is invalid or unsafe, use the fallback spawn.

Make last-location restoration configurable.

---

  1. SQLite Database

Use SQLite as persistent storage.

Create a database file such as:

plugins/AuthGuardLogin/auth.db

Use UUID as the primary key.

Recommended table:

players

Fields:

uuid password_hash registered_at last_login last_logout last_world last_x last_y last_z last_yaw last_pitch

Use prepared statements.

Do not concatenate user input directly into SQL queries.

Database connections must be handled safely.

Use asynchronous database operations where appropriate.

Do not perform expensive database operations synchronously on the main server thread.

---

  1. Password Security

Create a dedicated:

PasswordManager

Responsibilities:

  • Generate BCrypt hashes.
  • Verify passwords against BCrypt hashes.
  • Never log plaintext passwords.
  • Never store plaintext passwords.
  • Never send passwords to other players.
  • Never include passwords in error messages.
  • Avoid exposing password data through admin information commands.

Use a suitable BCrypt work factor and make it configurable only if necessary.

---

  1. Failed Login Protection

Add configurable failed-login protection.

Example:

max-login-attempts: 5 kick-after-max-attempts: true

If the player enters an incorrect password:

❌ Wrong password! Try again.

Increment their failed attempt counter.

After the configured maximum:

❌ Too many failed login attempts.

Kick the player if configured.

Failed-attempt counters should be reset after:

  • Successful authentication
  • Player disconnect
  • Appropriate authentication lifecycle reset

Do not reveal unnecessary information about whether another player's account exists.

---

  1. Authentication Timeout

Add configurable authentication timeout.

Example:

authentication-timeout-seconds: 60

If a player does not register/login within the configured time:

  • Optionally kick them.
  • Send a configurable timeout message.

Do not allow the timeout system to accidentally authenticate a player.

---

  1. Admin Command

Create:

/auth

with the following subcommands.

Reset

/auth reset <player>

Purpose:

  • Reset the player's authentication registration.
  • Remove their password hash.
  • Make them register again the next time they join.

---

Change Password

/auth changepassword <player> <newpassword>

Purpose:

  • Replace the player's password.
  • Hash the new password with BCrypt.
  • Never store plaintext.

---

Unregister

/auth unregister <player>

Purpose:

  • Completely remove the player's authentication data.

---

Info

/auth info <player>

Display:

Registered: Yes/No Last login: <timestamp> Last logout: <timestamp> Last saved location: <world, x, y, z> Authentication status: <state>

Do not display:

  • Plaintext passwords.
  • Password hashes unless there is a very strong administrative reason; preferably never display them.

---

Set Authentication Spawn

/auth setspawn

Save the administrator's current location as the authentication spawn.

---

Reload

/auth reload

Reload:

config.yml

Do not recreate the database unnecessarily.

Handle runtime configuration changes safely.

---

  1. Permissions

Create:

customlogin.admin

This permission is required for "/auth" administrative commands.

Player authentication commands should be usable by unauthenticated players only for their own authentication process.

Do not require the admin permission for:

/register /login

---

  1. Configuration

Create a clean and well-commented:

config.yml

It must support configuration of:

authentication: minimum-password-length: 5 maximum-password-length: 64 max-login-attempts: 5 kick-after-max-attempts: true authentication-timeout-seconds: 60 restore-last-location: true

spawn: world: "" x: 0.0 y: 100.0 z: 0.0 yaw: 0.0 pitch: 0.0

fallback-spawn: use-server-spawn: true

messages: prefix: "<gray>[<aqua>AuthGuardLogin</aqua>]</gray>" register: "..." login: "..." wrong-password: "..." password-mismatch: "..." password-too-short: "..." authentication-timeout: "..." too-many-attempts: "..." no-permission: "..."

titles: registration: enabled: true title: "<green>✔ Registration Successful LADKE 😎🔥</green>" subtitle: "<gray>Account successfully protected!</gray>" fade-in: 10 stay: 50 fade-out: 20

login: enabled: true title: "<gold>😂 Agya Bhangar Ki Shakal Ka 💀</gold>" subtitle: "<gray>Welcome back!</gray>" fade-in: 10 stay: 50 fade-out: 20

debug: false

Use MiniMessage/Adventure formatting appropriately.

Do not assume these exact values must be hardcoded; they are defaults.

---

  1. User Experience

Registration message should be clean and readable.

Example:

╔════════════════════╗ 🔐 ACCOUNT SETUP ╚════════════════════╝

Use: /register <password> <password>

Login message:

╔════════════════════╗ 🔐 LOGIN ╚════════════════════╝

Use: /login <password>

Messages should be configurable.

Do not spam the player repeatedly unless necessary.

---

  1. Join Lifecycle

Unregistered player

On join:

PlayerJoinEvent ↓ Check UUID in database ↓ Not registered ↓ REGISTER_REQUIRED ↓ Teleport to auth spawn ↓ Freeze ↓ Block unauthorized actions ↓ Show registration instructions

Registered player

On join:

PlayerJoinEvent ↓ Check UUID in database ↓ Registered ↓ LOGIN_REQUIRED ↓ Teleport to auth spawn ↓ Freeze ↓ Block unauthorized actions ↓ Show login instructions

Successful authentication

/login or /register ↓ Validate credentials ↓ AUTHENTICATED ↓ Reset failed attempts ↓ Restore gameplay ↓ Restore saved location ↓ Update last-login timestamp ↓ Show private success title

---

  1. Quit Lifecycle

When a player quits:

If:

state == AUTHENTICATED

then:

  1. Save their current location.
  2. Save world.
  3. Save X/Y/Z.
  4. Save yaw/pitch.
  5. Update last logout timestamp.

If:

state == REGISTER_REQUIRED

or:

state == LOGIN_REQUIRED

then:

  • Do NOT save their current location.
  • Do NOT overwrite the existing saved location.

Clean up temporary authentication state.

---

  1. Server Restart Safety

The plugin must behave correctly after:

  • Server restart
  • Server stop/start
  • Plugin reload
  • Player reconnect

Persistent registration data must remain intact.

A registered player must still be required to "/login" after reconnecting.

Do not automatically authenticate players after a restart.

Never trust in-memory authentication state after a restart.

---

  1. Death and Respawn Protection

Unauthenticated players must not bypass authentication through death.

If an unauthenticated player somehow dies:

  • Prevent unauthorized gameplay.
  • Ensure they respawn safely.
  • Return them to the authentication spawn.
  • Keep their authentication state unchanged.

They must still be required to register/login.

---

  1. Teleport Protection

Unauthenticated players must not reach their previous location through:

  • "/tp"
  • "/teleport"
  • Plugins
  • Portals
  • End gateways
  • Vehicles
  • Commands
  • Spectator
  • Other teleport mechanisms

Be careful not to break the server's legitimate administrative functionality.

The restriction should apply to the unauthenticated player rather than globally cancelling all server teleports.

---

  1. Gamemode Protection

Unauthenticated players must not gain access through:

SURVIVAL CREATIVE ADVENTURE SPECTATOR

Prevent unauthorized gamemode changes.

If their gamemode is changed by another mechanism while unauthenticated, restore the configured safe gamemode if necessary.

After authentication, restore their legitimate gameplay state.

---

  1. Inventory and World Protection

Before authentication, block:

  • Container opening
  • Inventory interaction
  • Crafting
  • Item movement
  • Item dropping
  • Item pickup
  • Block interaction
  • Entity interaction
  • Item usage
  • Attacking
  • Breaking
  • Placing

Authentication commands must remain available.

---

  1. Architecture

Use a clean modular architecture similar to:

AuthGuardLogin ├── AuthManager ├── PlayerDataManager ├── PasswordManager ├── DatabaseManager ├── ConfigManager ├── LoginCommand ├── RegisterCommand ├── AuthAdminCommand ├── PlayerListener ├── AuthProtectionListener └── model ├── AuthState └── PlayerData

You may improve this architecture if a cleaner design is appropriate.

Responsibilities must be separated.

Do not place the entire plugin inside one giant Java class.

---

  1. Required Project Structure

Provide the complete project structure first.

For example:

AuthGuardLogin/ ├── pom.xml ├── README.md └── src/ └── main/ ├── java/ │ └── <package>/ │ ├── AuthGuardLogin.java │ ├── auth/ │ │ ├── AuthManager.java │ │ ├── AuthState.java │ │ └── PasswordManager.java │ ├── database/ │ │ ├── DatabaseManager.java │ │ └── PlayerDataManager.java │ ├── command/ │ │ ├── LoginCommand.java │ │ ├── RegisterCommand.java │ │ └── AuthAdminCommand.java │ ├── listener/ │ │ ├── PlayerListener.java │ │ └── AuthProtectionListener.java │ ├── config/ │ │ └── ConfigManager.java │ └── model/ │ └── PlayerData.java └── resources/ ├── plugin.yml └── config.yml

The package name may be chosen appropriately.

---

  1. plugin.yml

Provide a complete valid "plugin.yml".

It must include:

  • Plugin name
  • Version
  • Main class
  • API version compatible with Paper 1.21.11
  • Commands
  • Permissions

Commands:

login register auth

Permission:

customlogin.admin

Make sure command registration matches the Java implementation exactly.

---

  1. Maven Configuration

Provide a complete:

pom.xml

It must:

  • Compile successfully with the required Java version.
  • Depend on the appropriate Paper API for 1.21.11.
  • Include BCrypt or another properly selected secure password hashing dependency.
  • Package all required runtime dependencies correctly.
  • Avoid unnecessary dependencies.
  • Produce a final plugin JAR suitable for installation on a Paper server.

If a dependency must be shaded/relocated, configure Maven Shade Plugin correctly.

---

  1. Complete Source Code Requirement

Do NOT provide pseudocode.

Do NOT provide incomplete snippets.

Do NOT use placeholders such as:

// implement this // TODO // omitted // rest of code

Provide the complete code for every required file.

Every class must:

  • Compile.
  • Have all required imports.
  • Have correct package declarations.
  • Match the project structure.
  • Work with the other classes.
  • Use APIs compatible with Paper 1.21.11.

Before presenting the final answer, internally verify that:

  • All referenced classes exist.
  • All methods exist.
  • All imports are correct.
  • Commands match "plugin.yml".
  • Permission nodes match.
  • Database schema matches Java queries.
  • Configuration paths match Java code.
  • No plaintext password is stored.
  • No authentication bypass is obvious.
  • The plugin can compile as provided.

---

  1. Important Security Rule

The most important requirement is:

«An unauthenticated player must NEVER be sent to their previous saved location.»

The sequence must always be:

Join ↓ Authentication spawn ↓ Frozen / protected ↓ Authentication ↓ Only after successful authentication: previous location restoration

Never reverse this order.

This is the primary security purpose of the plugin.

---

  1. Final Response Format

After implementing the complete plugin, provide the response in this exact order:

  1. Project Structure

Show the complete directory tree.

  1. pom.xml

Provide the complete file.

  1. plugin.yml

Provide the complete file.

  1. config.yml

Provide the complete file.

  1. Java Source Files

Provide e

Kodari AI
KodariSep 28 at 2:07 pm 3
AuthGuardLogin
Production-ready Minecraft authentication plugin for Paper 1.21.11 that protects player accounts through mandatory registration and login. Features BCrypt password hashing, SQLite persistence, configurable authentication spawn, comprehensive anti-bypass protection, player freezing, command restrictions, failed login attempt limits, authentication timeouts, and last location restoration. Uses Adventure API for modern messaging and MiniMessage formatting, with a modular architecture separating authentication management, database operations, command handling, and event listeners.
  1. Create the Maven/Paper project, plugin metadata, and configurable defaults.

  2. Implement SQLite persistence, BCrypt hashing, and the three-state authentication manager with async database/password work.

  3. Add login/admin commands and event protections for unauthenticated players.

1. Project Structure

Plain Text
AuthGuardLogin/
├── pom.xml
└── src/main/
    ├── java/com/authguardlogin/
    │   ├── AuthGuardLogin.java
    │   ├── auth/
    │   │   ├── AuthManager.java
    │   │   └── PasswordManager.java
    │   ├── command/
    │   │   ├── AuthAdminCommand.java
    │   │   ├── LoginCommand.java
    │   │   └── RegisterCommand.java
    │   ├── config/
    │   │   └── ConfigManager.java
    │   ├── database/
    │   │   └── DatabaseManager.java
    │   ├── listener/
    │   │   ├── AuthProtectionListener.java
    │   │   └── PlayerListener.java
    │   └── model/
    │       ├── AuthState.java
    │       └── PlayerData.java
    └── resources/
        ├── config.yml
        └── plugin.yml

2. pom.xml

Created with Paper API 1.21.11, Java 21, SQLite, BCrypt, and Maven Shade configuration.

3. plugin.yml

Created with the /login, /register, and /auth commands and the customlogin.admin permission.

4. config.yml

Created with configurable authentication settings, messages, titles, and spawn configuration.

5. Java Source Files

Created the authentication manager, async SQLite storage, BCrypt password handling, commands, and player protection listeners.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
15 1,852
src/main/java/com/authguardlogin/AuthGuardLogin.java
package com.authguardlogin;

import com.authguardlogin.auth.AuthManager;
import com.authguardlogin.auth.PasswordManager;
import com.authguardlogin.command.AuthAdminCommand;
import com.authguardlogin.command.LoginCommand;
import com.authguardlogin.command.RegisterCommand;
import com.authguardlogin.config.ConfigManager;
import com.authguardlogin.database.DatabaseManager;
import com.authguardlogin.listener.AuthProtectionListener;
import com.authguardlogin.listener.PlayerListener;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public final class AuthGuardLogin extends JavaPlugin {
    private ConfigManager configManager;
    private DatabaseManager databaseManager;
    private AuthManager authManager;
    private ExecutorService passwordExecutor;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        configManager = new ConfigManager(this);
        databaseManager = new DatabaseManager(this);
        databaseManager.initialize().exceptionally(exception -> {
            getLogger().severe("Unable to initialize the authentication database: " + rootMessage(exception));
            return null;
        });
        passwordExecutor = Executors.newFixedThreadPool(2, task -> {
            Thread thread = new Thread(task, "AuthGuardLogin-PasswordHash");
            thread.setDaemon(true);
            return thread;
        });
        authManager = new AuthManager(this, databaseManager, configManager, new PasswordManager(), passwordExecutor);

        getServer().getPluginManager().registerEvents(new PlayerListener(authManager), this);
        getServer().getPluginManager().registerEvents(new AuthProtectionListener(authManager), this);

        getCommand("login").setExecutor(new LoginCommand(authManager, configManager));
        getCommand("register").setExecutor(new RegisterCommand(authManager, configManager));
        AuthAdminCommand adminCommand = new AuthAdminCommand(this, authManager, databaseManager, configManager, passwordExecutor);
        getCommand("auth").setExecutor(adminCommand);
        getCommand("auth").setTabCompleter(adminCommand);

        for (Player player : Bukkit.getOnlinePlayers()) {
            authManager.handleJoin(player);
        }

        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                authManager.enforce(player);
            }
        }, 1L, 10L);
    }

    @Override
    public void onDisable() {
        if (authManager != null) {
            for (Player player : Bukkit.getOnlinePlayers()) {
                authManager.handleQuit(player);
            }
            authManager.shutdown();
        }
        if (passwordExecutor != null) {
            passwordExecutor.shutdown();
        }
        if (databaseManager != null) {
            databaseManager.close();
        }
    }

    public ConfigManager configManager() {
        return configManager;
    }

    private String rootMessage(Throwable throwable) {
        Throwable cause = throwable;
        while (cause.getCause() != null) {
            cause = cause.getCause();
        }
        return cause.getMessage() == null ? cause.getClass().getSimpleName() : cause.getMessage();
    }
}