bromc876.
πŸ“Ž 1 file 6,146 chars
πŸ“„
pasted-code-1783762071336.txt
txt 537 lines
β–Ά
NDLOGIN Premium

Version: 1.0.0
Author: NDGAMING
Minecraft: Paper/Spigot 1.13 – Latest (Java 8+ compatible)

Project Goal

Develop a high-performance authentication plugin similar to nLogin, but designed specifically for hybrid (Offline/Cracked + Premium + Floodgate Bedrock) Minecraft servers.

The plugin must automatically distinguish between three account types:

- Bedrock (Floodgate)
- Java Premium (Official Mojang/Microsoft Account)
- Java Cracked

The plugin must prioritize security, asynchronous execution, compatibility, and performance.

---

Core Features

1. Floodgate Bedrock Support

Use the official Floodgate API.

When a player joins:

- Detect if the player is a Floodgate player.
- If true:
  - Skip Register.
  - Skip Login.
  - Authenticate automatically.
  - Save account type as BEDROCK.
  - Future joins should automatically authenticate without any password.

No registration should ever be required for Floodgate players.

---

2. Java First Join

When a Java player joins for the first time, freeze movement until authentication is complete.

Display a beautiful clickable Adventure message:

━━━━━━━━━━━━━━━━━━━━━━

Welcome!

Are you using an Official Minecraft Premium Account?

[ βœ” YES ]
[ ✘ NO ]

━━━━━━━━━━━━━━━━━━━━━━

Requirements:

- Clickable buttons
- Hover text
- Colored MiniMessage format
- Play UI click sounds
- Show Title
- Show Subtitle
- ActionBar reminder
- Optional BossBar countdown

Buttons must be clickable using Adventure API.

---

3. If Player Clicks NO

Account Type:

CRACK

Player must register:

/register  

After registration:

Automatically login.

Future joins:

/login 

Support configurable password policy:

- Minimum length
- Maximum length
- Require numbers
- Require letters
- Optional special characters

Passwords must NEVER be stored in plain text.

Use:

Argon2id (preferred)

or

BCrypt

Never use SHA1, SHA256, or MD5.

---

4. If Player Clicks YES

The plugin must NEVER trust the player's choice.

Instead:

Verify Premium ownership.

Security Requirements:

Use Mojang Session Server authentication.

Never authenticate only by checking whether the username exists.

The plugin must verify ownership of the premium session.

If verification succeeds:

Account Type:

PREMIUM

Save:

- Premium UUID
- Username
- Account type

Future joins:

Automatically authenticate.

No /login required.

If verification fails:

Return player to authentication screen.

Allow selecting Crack account instead.

Never allow fake premium usernames to bypass authentication.

---

5. Premium Security

Implement enterprise-grade security.

Requirements:

βœ” Session Server Verification

βœ” UUID validation

βœ” Username consistency checks

βœ” Prevent UUID spoofing

βœ” Prevent session spoofing

βœ” Async HTTP requests

βœ” Timeout protection

βœ” Retry mechanism

βœ” Cached verification

βœ” Rate limiting

βœ” Thread-safe implementation

Never block the Minecraft main thread.

All web requests must be asynchronous.

---

6. Login Session

Optional feature:

Remember authenticated devices.

Configurable:

session:
enabled: true
expire: 30m

If the player reconnects within the configured time:

Skip login.

Otherwise:

Require authentication again.

---

7. Security Protection

Freeze player before authentication.

Disable:

Movement

Jumping

Breaking blocks

Placing blocks

Commands (except auth commands)

Inventory

Crafting

Dropping items

Picking items

Attacking

Interacting

Chat

Sleeping

Using portals

Taking damage (optional)

Player becomes fully active only after successful authentication.

---

8. Authentication Timeout

Configurable:

60 seconds

Countdown shown in ActionBar.

BossBar optional.

If timeout expires:

Kick player.

Reason configurable.

---

9. Anti Bot Protection

Basic protection:

Login delay

Connection cooldown

Authentication timeout

Packet spam detection

Repeated login protection

Optional CAPTCHA support

---

10. Sound Effects

Play configurable sounds.

Examples:

Join INVENTORY GUI

Button Click

Successful Login

Successful Register

Premium Verified

Authentication Failed

Kick

Everything configurable.

---

11. Visual Effects

Support:

Adventure API

MiniMessage

Titles

Subtitles

ActionBar

BossBar

Clickable Components

Hover Components

Hex Colors (when supported)

Legacy color fallback

---

12. Database

Support:

SQLite

MySQL

MariaDB

Automatic table creation.

---

Database fields:

UUID

Username

Premium UUID

Account Type

Password Hash

First Join

Last Login

Last IP

Session Token

Created At

Updated At

---

13. Configuration

Fully configurable.

config.yml

messages.yml

sounds.yml

database.yml

settings.yml

language support.

No hardcoded messages.

---

14. Performance

Plugin must be optimized.

Requirements:

No memory leaks

Async database

Async Mojang API

Minimal allocations

No blocking tasks

Thread-safe cache

Low CPU usage

Low RAM usage

Support servers with 500+ concurrent players

---

15. Compatibility

Paper

Spigot

Purpur

Folia (if possible)

Minecraft versions:

1.13 β†’ Latest

Support:

Floodgate

Geyser

PlaceholderAPI

LuckPerms

BungeeCord

Velocity

---

16. Admin Commands

/ndlogin reload

/ndlogin version

/ndlogin info

/ndlogin premium 

/ndlogin unregister 

/ndlogin forceauth 

/ndlogin migrate

Permissions for every command.

---

17. Logging

Log:

Premium verification

Failed verification

Register

Login

Auto login

Floodgate login

Database errors

HTTP errors

Warnings

Debug mode

---

18. Code Quality

Use modern Java.

Follow SOLID principles.

Separate modules:

API

Authentication

Premium Verification

Floodgate

Database

Commands

Listeners

Cache

Configuration

Utilities

Provide a clean public API for other plugins.

---

Goal

The final product should feel like a modern enterprise authentication plugin with security comparable to nLogin while adding seamless Floodgate Bedrock auto-login, secure Premium authentication, and traditional Cracked authentication in one lightweight plugin.

The code must be clean, maintainable, secure, highly optimized, and production-ready.
Kodari AI
KodariJul 11 at 9:38 am 18
NDLoginPremium
NDLogin Premium provides secure authentication for hybrid Minecraft servers supporting Java cracked accounts, official premium accounts, and Floodgate Bedrock players. It verifies premium ownership through Mojang session services, automatically authenticates trusted Bedrock and premium users, protects cracked accounts with BCrypt password hashing and configurable policies, freezes unauthenticated players, supports login sessions, timeout enforcement, anti-bot rate limits, SQLite/MySQL/MariaDB storage, Adventure messages, titles, action bars, boss bars, sounds, admin commands, and a public API.
bromc876.

NDLOGIN Premium – Premium Verification Flow Update

Update the existing NDLOGIN Premium plugin to implement a secure Premium verification flow similar to nLogin.

Important

The server is an Offline/Cracked server that allows both Premium Java players and Cracked Java players.

Do NOT trust the player's click on [YES] alone.

Do NOT verify Premium status only by checking username or UUID existence from Mojang API.

Do NOT auto-login Premium players immediately after they click [YES].

Required Premium Verification Flow

First Join

When a Java player joins for the first time, show clickable Adventure buttons:

  • [βœ” YES] = I use an Official Minecraft Premium account
  • [✘ NO] = I use a Cracked account

If Player Clicks [NO]

  • Save account type as CRACK.
  • Require /register <password> <confirm>.
  • Future joins require /login <password>.

If Player Clicks [YES]

  1. Save the player state as PENDING_PREMIUM_VERIFICATION.
  2. Save temporary verification data: UUID, username, timestamp, and pending verification token.
  3. Send a message:

"Your Premium account will now be verified. Please reconnect using the Official Minecraft Launcher."

  1. Play a confirmation sound.
  2. Kick the player with a reconnect message.

On Reconnect

When the player reconnects and state = PENDING_PREMIUM_VERIFICATION:

  • Attempt Premium session verification using Mojang/Microsoft Session Server authentication.
  • Verify that the player is actually authenticated with an official Premium session.
  • If verification succeeds:

- Save account type as PREMIUM_VERIFIED. - Save premium UUID and username. - Auto-login the player. - Future joins auto-login without /login.

  • If verification fails:

- Remove pending verification state. - Send a failure message. - Return player to the YES/NO selection flow or Crack registration.

Security Requirements

  • Do NOT use username existence alone for Premium verification.
  • Do NOT use UUID lookup alone for Premium verification.
  • Use Mojang/Microsoft Session Server verification only.
  • All HTTP requests must be asynchronous.
  • Add timeout and retry handling.
  • Prevent fake Premium usernames from bypassing authentication.
  • Pending verification should expire after 5 minutes.
  • Store pending verification in memory and optionally database if needed.

Player States

  • UNKNOWN
  • PENDING_PREMIUM_VERIFICATION
  • PREMIUM_VERIFIED
  • CRACK_REGISTERED
  • BEDROCK

Bedrock Flow

  • Floodgate players auto-login immediately.
  • No register/login required.
  • Save account type as BEDROCK.

Crack Security

  • Passwords must use BCrypt or Argon2id.
  • Never store plain text passwords.
  • Freeze player movement and actions before authentication.
  • Show ActionBar countdown for login timeout.

UI Requirements

  • Use Adventure API clickable buttons.
  • Use MiniMessage formatting.
  • Use Title, Subtitle, ActionBar, and optional BossBar.
  • Play configurable sounds for YES, NO, success, failure, register, login, and kick.

Deliverable

Update the existing plugin code so the Premium verification flow is secure, similar to nLogin, and production-ready for a hybrid Offline/Cracked + Premium + Floodgate server.

Kodari AI
KodariJul 12 at 10:06 am 49
  1. Trace the existing authentication, account-state, database, premium-verification, Floodgate, and join/UI flow.

  2. Replace the YES path with pending reconnect verification using asynchronous Session Server checks, expiry, retries, and secure state transitions.

  3. Preserve/update cracked, Bedrock, timeout, and Adventure UI behavior, then patch all affected files consistently.

The current YES path verifies immediately and authenticates; it also stores no reconnect-pending state. I’m checking the startup/database wiring and message helpers before replacing that path so the new state survives disconnects without leaving dangling schema or API calls.

The pending record will use the existing account row: PENDING_PREMIUM_VERIFICATION, the player UUID/username, sessionToken as the temporary token, and updatedAt as its five-minute timestamp. That makes the state survive reconnects without adding a second persistence table.

The core state transition is patched. I’m correcting the resource keys and reviewing the two admin/user entry points separately, because both previously called the same save helper and must not accidentally diverge.

The implementation now has the required reconnect gate and persistent expiry/token fields. I’m doing a final compile-oriented check for malformed edits and tightening the display path so the player sees only the clickable choice rather than a duplicate prompt.

One security gap remains in the old automatic branch: a stored premium account was trusted on later joins without rechecking the official session. I’m closing that bypass by revalidating the stored premium UUID and username asynchronously on every premium join; failed validation clears the untrusted record and returns to account selection.

Implemented the Premium verification flow update.

  • Added account states:

    • UNKNOWN

    • PENDING_PREMIUM_VERIFICATION

    • PREMIUM_VERIFIED

    • CRACK_REGISTERED

    • BEDROCK

  • YES now:

    • Stores a pending account record and temporary token.

    • Saves the timestamp for five-minute expiry.

    • Sends the reconnect instruction.

    • Plays the pending-verification sound.

    • Kicks the player.

  • Reconnect now:

    • Checks pending-state expiry.

    • Validates the reconnecting username.

    • Performs asynchronous Session Server verification with timeout/retries.

    • Validates the returned username and UUID.

    • Converts the account to PREMIUM_VERIFIED.

    • Authenticates the player only after successful verification.

  • Failed or expired verification removes the pending record and returns the player to the account-selection UI.

  • Stored Premium accounts are revalidated against Session Server before automatic authentication.

  • Cracked registrations now use CRACK_REGISTERED.

  • Added premium.pending-expire-minutes: 5.

  • Added configurable reconnect messages and pending-verification sound.

  • Expanded database account-state column support.

  • Improved UUID parsing and HTTP connection cleanup.

Important deployment limitation: Mojang’s hasJoined Session Server endpoint only proves a client joined with a valid server-session hash. An offline-mode server cannot independently obtain or prove a live Microsoft authentication session from only a reconnecting player. For genuinely production-grade Premium verification, the server must use an online-mode authentication gateway, a properly configured proxy/session-forwarding layer, or another trusted premium-authentication bridge. A static premium.server-id alone should not be treated as enterprise-grade authentication.

The Gradle wrapper is not present in the project, so a local Gradle build could not be executed.

bromc876.

Fix!

[NDLoginPremium] Enabling NDLoginPremium v1.0.0* >....[11:09:47 ERROR]: Error occurred while enabling NDLoginPremium v1.0.0 (Is it up to date?) java.lang.NoClassDefFoundError: com/ndgaming/ndlogin/libs/net/kyori/adventure/text/minimessage/MiniMessage at NDLoginPremium-1.0.0 (1).jar//com.ndgaming.ndlogin.service.MessageService.<init>(MessageService.java:19) ~[?:?] at NDLoginPremium-1.0.0 (1).jar//com.ndgaming.ndlogin.NDLoginPlugin.onEnable(NDLoginPlugin.java:33) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:279) ~[paper-api-1.21.11-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:207) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:520) ~[paper-api-1.21.11-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:639) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:596) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at net.minecraft.server.MinecraftServer.initPostWorld(MinecraftServer.java:636) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:365) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1253) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388) ~[paper-1.21.11.jar:1.21.11-132-c5eb079] at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?] Caused by: java.lang.ClassNotFoundException: com.ndgaming.ndlogin.libs.net.kyori.adventure.text.minimessage.MiniMessage at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:208) ~[paper-api-1.21.11-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:175) ~[paper-api-1.21.11-R0.1-SNAPSHOT.jar:?] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?] ... 13 more >....[11:09:47 INFO]: [NDLoginPremium] Disabling NDLoginPremium v1.0.0

Kodari AI
KodariJul 12 at 11:21 am 10
  1. Inspect the MiniMessage dependency declaration and MessageService imports.

  2. Correct the dependency packaging/classpath mismatch using the project’s supported build setup.

  3. Check the affected references for a clean Paper startup path.

The crash is caused by the packaged dependency layout: MessageService is being rewritten to a relocated MiniMessage class, but that class is not present in the plugin JAR. Since this runs on Paper 1.21.11, I’m removing the unnecessary Adventure runtime bundle and compiling against Paper’s built-in Adventure/MiniMessage API instead; BukkitAudiences will also be replaced with Paper-native audience calls.

Fixed the MiniMessage startup crash.

Changes:

  • Switched build.gradle from Spigot API to Paper API 1.21.11.

  • Removed adventure-platform-bukkit, which was causing the invalid relocated class reference.

  • Made MiniMessage compile-only because Paper provides the Adventure runtime.

  • Removed BukkitAudiences usage from MessageService.

  • Replaced audience calls with Paper-native:

    • player.sendMessage(...)

    • player.showTitle(...)

    • player.sendActionBar(...)

  • Removed Adventure dependencies from manifest.kod so they are no longer incorrectly relocated or packaged.

The missing class:

Plain Text
com.ndgaming.ndlogin.libs.net.kyori.adventure.text.minimessage.MiniMessage

was caused by the generated plugin referencing a relocated dependency that was not included in the final JAR.

Rebuild and reinstall the plugin JAR:

Shell
gradle clean build

The environment does not contain a Gradle executable, so compilation could not be run here. Ensure the server is running Paper 1.21.11 or another Paper version that includes Adventure MiniMessage.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
settings.gradle
Code
27 2,108
src/main/java/com/ndgaming/ndlogin/NDLoginPlugin.java
package com.ndgaming.ndlogin;

import com.ndgaming.ndlogin.api.NDLoginAPI;
import com.ndgaming.ndlogin.auth.AuthenticationManager;
import com.ndgaming.ndlogin.command.AuthCommand;
import com.ndgaming.ndlogin.command.NDLoginCommand;
import com.ndgaming.ndlogin.config.PluginConfig;
import com.ndgaming.ndlogin.database.DatabaseManager;
import com.ndgaming.ndlogin.listener.AuthListener;
import com.ndgaming.ndlogin.service.FloodgateService;
import com.ndgaming.ndlogin.service.MessageService;
import com.ndgaming.ndlogin.service.SoundService;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class NDLoginPlugin extends JavaPlugin {
    private PluginConfig pluginConfig;
    private MessageService messageService;
    private SoundService soundService;
    private DatabaseManager databaseManager;
    private AuthenticationManager authenticationManager;
    private NDLoginAPI api;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("settings.yml", false);
        saveResource("messages.yml", false);
        saveResource("sounds.yml", false);
        saveResource("database.yml", false);

        this.pluginConfig = new PluginConfig(this);
        this.messageService = new MessageService(this);
        this.soundService = new SoundService(this);
        this.databaseManager = new DatabaseManager(this, pluginConfig);
        this.authenticationManager = new AuthenticationManager(
                this,
                pluginConfig,
                messageService,
                soundService,
                databaseManager,
                new FloodgateService()
        );
        this.api = new NDLoginAPI(authenticationManager);

        Bukkit.getPluginManager().registerEvents(new AuthListener(authenticationManager, pluginConfig), this);
        getCommand("register").setExecutor(new AuthCommand(authenticationManager, false));
        getCommand("login").setExecutor(new AuthCommand(authenticationManager, true));
        getCommand("ndlogin").setExecutor(new NDLoginCommand(this, authenticationManager));

        databaseManager.initialize().whenComplete((ignored, throwable) -> {
            if (throwable != null) {
                getLogger().severe("Database initialization failed: " + throwable.getMessage());
            } else {
                getLogger().info("Database initialized.");
            }
        });

        Bukkit.getScheduler().runTaskTimer(this, authenticationManager::tick, 20L, 20L);
        getLogger().info("NDLogin Premium enabled.");
    }

    @Override
    public void onDisable() {
        if (authenticationManager != null) {
            authenticationManager.shutdown();
        }
        if (databaseManager != null) {
            databaseManager.close();
        }
        if (messageService != null) {
            messageService.close();
        }
    }

    public void reloadPlugin() {
        reloadConfig();
        pluginConfig.reload();
        messageService.reload();
        soundService.reload();
    }

    public PluginConfig getPluginConfig() {
        return pluginConfig;
    }

    public MessageService getMessageService() {
        return messageService;
    }

    public AuthenticationManager getAuthenticationManager() {
        return authenticationManager;
    }

    public NDLoginAPI getApi() {
        return api;
    }
}