O
๐Ÿ“Ž 1 file 8,802 chars
๐Ÿ“„
pasted-code-1780907948607.txt
txt 454 lines
โ–ถ
Create a complete production-ready Minecraft Paper/Spigot authentication plugin named "OrionAuth".

Author: RipperSensei
Co-Author: AnshuG

Target:
- Java 21
- Paper 1.21.1 โ€“ 1.21.11
- Maven project
- Production ready
- No placeholder code
- No TODOs
- Fully functional implementation

=================================================
PLUGIN CONCEPT
=================================================

OrionAuth is a hybrid authentication system supporting both Premium and Cracked players.

Premium Players:
- Automatically detected.
- No registration required.
- No login required.
- Instantly join and play.

Cracked Players:
- First join -> Register.
- Future joins -> Login.
- Cannot play until authenticated.

=================================================
PREMIUM ACCOUNT SYSTEM
=================================================

When a player joins:

1. Detect whether the account is Premium.
2. Cache Premium status.
3. Store Premium status in database.
4. Premium players bypass all authentication.
5. Premium players instantly enter gameplay.

Security:
- Prevent cracked players from using Premium usernames.
- If username belongs to a Premium account and authentication fails:
  Kick message:

"&cThis username belongs to a Premium account."

=================================================
FIRST JOIN EXPERIENCE
=================================================

When a cracked player joins for the first time:

Apply:
- Darkness effect
- Slowness 255
- Freeze player completely

Show animated title:

Title:
"&6ORIONAUTH"

Subtitle:
"&eSecure Authentication System"

Duration:
3 seconds

After title:

Title:
"&aWELCOME"

Subtitle:
"&fPlease register to continue"

Player must execute:

/register  

=================================================
RETURNING PLAYER LOGIN
=================================================

Returning cracked players must execute:

/login 

Show title:

"&6ORIONAUTH"
"&ePlease login to continue"

=================================================
AUTHENTICATION RESTRICTIONS
=================================================

Until authenticated, block:

- Movement
- Jumping
- Sprinting
- Flying
- Chat
- Commands except auth commands
- Inventory access
- Block breaking
- Block placing
- Entity interaction
- Item pickup
- Item dropping
- Crafting
- Using containers
- Taking damage
- Dealing damage

Player remains frozen until authentication succeeds.

=================================================
BOSSBAR AUTH SYSTEM
=================================================

Show BossBar while unauthenticated.

Title:

"&6Authenticate To Continue"

Countdown:

60 seconds

BossBar updates every second.

Example:

"&eTime Remaining: 58s"

=================================================
TIMEOUT SYSTEM
=================================================

If player does not authenticate within 60 seconds:

Kick player:

"&cAuthentication Timeout
&7Please reconnect and try again."

Configurable timeout.

=================================================
PASSWORD SYSTEM
=================================================

Requirements:

- Minimum length: 8
- Maximum length: 32
- Reject weak passwords
- BCrypt hashing
- Never store plain text passwords

Store only hashes.

=================================================
AUTO LOGIN SYSTEM
=================================================

Config:

auto-login:
  enabled: true
  trusted-days: 14

After successful login:

Store trusted IP.

If same IP joins within trusted period:

Automatically login player.

=================================================
SESSION LOGIN SYSTEM
=================================================

Config:

session-login:
  enabled: true
  duration: 30m

If player reconnects during active session:

Skip login.

=================================================
CAPTCHA SYSTEM
=================================================

Config:

captcha:
  enabled: true

Before registration:

Generate random math question.

Examples:

5 + 3 = ?
9 - 4 = ?
7 + 8 = ?

Player must answer before registration.

=================================================
BRUTE FORCE PROTECTION
=================================================

Track failed login attempts.

Config:

max-attempts: 5

After 5 failed attempts:

- Lock account temporarily
- Kick player

Configurable lock duration.

=================================================
PASSWORD MANAGEMENT
=================================================

Commands:

/changepassword  

Permission:

orionauth.changepassword

=================================================
ADMIN COMMANDS
=================================================

/orionauth reload
/orionauth info 
/orionauth resetpassword 
/orionauth forcelogin 
/orionauth forceregister 

/auth reset 

=================================================
ACCOUNT INFO COMMAND
=================================================

Show:

- UUID
- Username
- Premium status
- Registration date
- Last login
- Last IP
- Login count
- Failed attempts

=================================================
DATABASE SYSTEM
=================================================

Support:

- SQLite
- MySQL
- MariaDB

Use:

- HikariCP
- Async database operations
- Prepared statements

Store:

- UUID
- Username
- Password hash
- Premium status
- Registration date
- Last login
- Last IP
- Login count
- Failed attempts
- Trusted IP data
- Session data

=================================================
DISCORD WEBHOOK SUPPORT
=================================================

Send webhook notifications for:

- New registration
- Password reset
- Account lock
- Premium detection
- Failed login spam
- Suspicious activity

=================================================
PLACEHOLDERAPI SUPPORT
=================================================

Create placeholders:

%orionauth_status%
%orionauth_premium%
%orionauth_lastlogin%
%orionauth_logincount%
%orionauth_authenticated%

=================================================
ADMIN NOTIFICATIONS
=================================================

Permission:

orionauth.notify

Notify staff when:

- Premium spoof attempts
- Multiple failed logins
- Locked accounts
- Suspicious IP changes

=================================================
INVENTORY GUI SYSTEM
=================================================

Command:

/orionauth

Open admin INVENTORY GUI containing:

- Registered Accounts
- Premium Accounts
- Locked Accounts
- Online Players
- Plugin Statistics

=================================================
JOIN EFFECTS
=================================================

When authentication is required:

Show title:

"&6ORIONAUTH"

Subtitle:

"&eSecure Authentication System"

Apply:

- Darkness
- Slowness
- Freeze

Play sounds.

Use smooth title animations.

=================================================
FILES TO GENERATE
=================================================

Generate complete project including:

- Full source code
- Maven pom.xml
- plugin.yml
- config.yml
- messages.yml
- DatabaseManager
- AuthManager
- PremiumDetectionManager
- SessionManager
- BossBarManager
- CaptchaManager
- DiscordWebhookManager
- GUIManager
- Command classes
- Event listeners
- SQL schema
- PlaceholderAPI expansion
- Utility classes

=================================================
PERMISSIONS
=================================================

orionauth.admin
orionauth.reload
orionauth.info
orionauth.reset
orionauth.forcelogin
orionauth.forceregister
orionauth.notify
orionauth.changepassword

=================================================
PERFORMANCE REQUIREMENTS
=================================================

- Async operations wherever possible
- No main-thread blocking
- Optimized for 1000+ concurrent players
- Memory efficient
- Java 21 best practices
- Paper API best practices
- Proper exception handling
- Production-ready code
- Clean architecture
- Fully compilable without errors

=================================================
STARTUP BANNER
=================================================

=================================
ORIONAUTH
Advanced Authentication System

Author: RipperSensei
Co-Author: AnshuG
=================================

Generate the entire plugin with complete implementation and production-ready code.
Kodari AI
KodariJun 8 at 8:56 am 103
OrionAuth
A production-ready hybrid authentication plugin for Paper 1.21 supporting both Premium and Cracked players. Premium accounts are auto-detected via Mojang API and bypass all authentication. Cracked players must register and login with BCrypt-hashed passwords. Features include SQLite/MySQL/MariaDB support via HikariCP, session auto-login, trusted-IP auto-login, math captcha, brute-force protection, BossBar countdown, admin GUI, Discord webhooks, PlaceholderAPI, and full async database operations.

Hereโ€™s a summary of everything that was generated:


OrionAuth โ€” Complete File Overview

Build

  • pom.xml โ€” Maven with shade plugin; includes HikariCP, jBCrypt, SQLite JDBC, MySQL Connector/J, MariaDB JDBC, PlaceholderAPI, and Lombok. HikariCP and jBCrypt are relocated to avoid classpath conflicts.

Resources

  • plugin.yml โ€” All commands, aliases, and permission tree

  • config.yml โ€” Database, timeout, password policy, auto-login, session, captcha, brute-force, Discord, effects

  • messages.yml โ€” Every player-facing string, prefixed and fully replaceable via {key} tokens

Core Classes

Class
Responsibility
OrionAuth
Plugin lifecycle, wires all managers, prints banner
PlayerData
Lombok
@Data
model with all 15 DB fields
ConfigManager
Typed accessors for every config key
MessageManager
Loads
messages.yml
, provides
Component
/String with
{placeholder}
substitution

Managers

Manager
What it does
DatabaseManager
HikariCP pool for SQLite/MySQL/MariaDB โ€” full async CRUD via
CompletableFuture
PremiumDetectionManager
Calls Mojang API async-safely (in
AsyncPreLogin
), caches results with TTL
AuthManager
Central auth state, login/register/change-password/forcelogin, apply/remove effects
SessionManager
Validates and writes session & trusted-IP windows
BossBarManager
Per-player Adventure
BossBar
countdown with kick on timeout
CaptchaManager
Generates random addition/subtraction questions, verifies answers
DiscordWebhookManager
HTTP POST to Discord webhook for 6 event types

Listeners

  • PreLoginListener โ€” AsyncPlayerPreLoginEvent: calls Mojang API, sets premium UUID via event.setUniqueId()

  • JoinQuitListener โ€” Loads DB record async; triggers premium bypass, session/trusted-IP auto-login, or restriction flow

  • AuthListener โ€” Cancels movement, AsyncChatEvent, commands (whitelist: /login, /register, /auth), inventory, pickup, drop, break, place, interact, damage, sprint, flight

Commands

Command
Description
/login <password>
Password login for cracked players
/register <pass> <confirm>
Registration; doubles as captcha answer when pending
/changepassword <old> <new>
In-session password change
/orionauth
(no args)
Opens async-loaded admin inventory GUI
/orionauth reload|info|resetpassword|forcelogin|forceregister
Full admin suite
/auth reset <player>
Wipes account data and kicks if online

GUI System

  • InventoryHandler / InventoryButton / InventoryGUI โ€” Reusable framework (lazy init, button-map pattern)

  • InventoryGUIManager + GUIListener โ€” Central registry, auto-unregisters on close

  • AdminGUI โ€” 54-slot panel: Registered Accounts, Premium Accounts, Locked Accounts, Online Players, Plugin Statistics โ€” all clickable with async drill-down

Utilities & Integration

  • ColorUtil โ€” &-code to Component and String conversion

  • PasswordUtil โ€” BCrypt hash/verify + strength validation (letters + digits required)

  • TimeUtil โ€” Date formatting, duration formatting, expiry checks

  • OrionAuthExpansion โ€” PAPI: %orionauth_status%, %orionauth_premium%, %orionauth_lastlogin%, %orionauth_logincount%, %orionauth_authenticated%

O

make

O

The compilation failed with this error:

code
Compilation failed with 7 error(s):

ERROR in src/main/java/com/rippersensei/orionauth/command/ChangePasswordCommand.java at line 22: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java at line 32: no suitable method found for createBossBar(TextComponent,BarColor,BarStyle)
        BossBar bar = Bukkit.createBossBar(
                            ^

ERROR in src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java at line 56: incompatible types: TextComponent cannot be converted to String
                    .color(NamedTextColor.YELLOW));
                          ^

ERROR in src/main/java/com/rippersensei/orionauth/command/RegisterCommand.java at line 25: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/command/OrionAuthCommand.java at line 163: bad operand types for binary operator '+'
                sender.sendMessage(plugin.getMessageManager().getComponent("prefix") +
                                                                                     ^

ERROR in src/main/java/com/rippersensei/orionauth/command/LoginCommand.java at line 22: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/listener/PreLoginListener.java at line 29: cannot find symbol
            event.setUniqueId(premiumUuid);
                 ^
  symbol: method setUniqueId(UUID)
  location: variable event of type AsyncPlayerPreLoginEvent


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - setUniqueId(UUID)
ACTION: Check method names and signatures

TYPE MISMATCHES:
  - incompatible types: ConsoleCommandSender cannot be converted to Player
  - incompatible types: TextComponent cannot be converted to String
  - incompatible types: ConsoleCommandSender cannot be converted to Player
  - incompatible types: ConsoleCommandSender cannot be converted to Player
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/rippersensei/orionauth/command/ChangePasswordCommand.java
  - src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java
  - src/main/java/com/rippersensei/orionauth/command/RegisterCommand.java
  - src/main/java/com/rippersensei/orionauth/command/OrionAuthCommand.java
  - src/main/java/com/rippersensei/orionauth/command/LoginCommand.java
  - src/main/java/com/rippersensei/orionauth/listener/PreLoginListener.java

Please fix this error by creating a new artifact with the corrected code.

O

The compilation failed with this error:

code
Compilation failed with 7 error(s):

ERROR in src/main/java/com/rippersensei/orionauth/command/ChangePasswordCommand.java at line 22: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java at line 32: no suitable method found for createBossBar(TextComponent,BarColor,BarStyle)
        BossBar bar = Bukkit.createBossBar(
                            ^

ERROR in src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java at line 56: incompatible types: TextComponent cannot be converted to String
                    .color(NamedTextColor.YELLOW));
                          ^

ERROR in src/main/java/com/rippersensei/orionauth/command/RegisterCommand.java at line 25: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/command/OrionAuthCommand.java at line 163: bad operand types for binary operator '+'
                sender.sendMessage(plugin.getMessageManager().getComponent("prefix") +
                                                                                     ^

ERROR in src/main/java/com/rippersensei/orionauth/command/LoginCommand.java at line 22: incompatible types: ConsoleCommandSender cannot be converted to Player
            plugin.getMessageManager().send((org.bukkit.command.ConsoleCommandSender) sender,
                                            ^

ERROR in src/main/java/com/rippersensei/orionauth/listener/PreLoginListener.java at line 29: cannot find symbol
            event.setUniqueId(premiumUuid);
                 ^
  symbol: method setUniqueId(UUID)
  location: variable event of type AsyncPlayerPreLoginEvent


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - setUniqueId(UUID)
ACTION: Check method names and signatures

TYPE MISMATCHES:
  - incompatible types: ConsoleCommandSender cannot be converted to Player
  - incompatible types: TextComponent cannot be converted to String
  - incompatible types: ConsoleCommandSender cannot be converted to Player
  - incompatible types: ConsoleCommandSender cannot be converted to Player
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/rippersensei/orionauth/command/ChangePasswordCommand.java
  - src/main/java/com/rippersensei/orionauth/manager/BossBarManager.java
  - src/main/java/com/rippersensei/orionauth/command/RegisterCommand.java
  - src/main/java/com/rippersensei/orionauth/command/OrionAuthCommand.java
  - src/main/java/com/rippersensei/orionauth/command/LoginCommand.java
  - src/main/java/com/rippersensei/orionauth/listener/PreLoginListener.java

Please fix this error by creating a new artifact with the corrected code.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
33 2,908
src/main/java/com/rippersensei/orionauth/OrionAuth.java
package com.rippersensei.orionauth;

import com.rippersensei.orionauth.command.*;
import com.rippersensei.orionauth.inventory.gui.GUIListener;
import com.rippersensei.orionauth.inventory.gui.InventoryGUIManager;
import com.rippersensei.orionauth.listener.AuthListener;
import com.rippersensei.orionauth.listener.JoinQuitListener;
import com.rippersensei.orionauth.listener.PreLoginListener;
import com.rippersensei.orionauth.manager.*;
import com.rippersensei.orionauth.placeholder.OrionAuthExpansion;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class OrionAuth extends JavaPlugin {

    @Getter private static OrionAuth instance;

    @Getter private ConfigManager configManager;
    @Getter private MessageManager messageManager;
    @Getter private DatabaseManager databaseManager;
    @Getter private PremiumDetectionManager premiumDetectionManager;
    @Getter private AuthManager authManager;
    @Getter private SessionManager sessionManager;
    @Getter private BossBarManager bossBarManager;
    @Getter private CaptchaManager captchaManager;
    @Getter private DiscordWebhookManager discordWebhookManager;
    @Getter private InventoryGUIManager inventoryGUIManager;

    @Override
    public void onEnable() {
        instance = this;
        printBanner();

        saveDefaultConfig();

        configManager = new ConfigManager(this);
        messageManager = new MessageManager(this);

        try {
            databaseManager = new DatabaseManager(this);
            databaseManager.initialize();
        } catch (Exception e) {
            getLogger().severe("Failed to initialize database: " + e.getMessage());
            getLogger().severe("Disabling OrionAuth.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        premiumDetectionManager = new PremiumDetectionManager(this);
        sessionManager = new SessionManager(this);
        bossBarManager = new BossBarManager(this);
        captchaManager = new CaptchaManager(this);
        discordWebhookManager = new DiscordWebhookManager(this);
        authManager = new AuthManager(this);
        inventoryGUIManager = new InventoryGUIManager();

        registerListeners();
        registerCommands();

        if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new OrionAuthExpansion(this).register();
            getLogger().info("PlaceholderAPI hook enabled.");
        }

        getLogger().info("OrionAuth v" + getPluginMeta().getVersion() + " enabled successfully.");
    }

    @Override
    public void onDisable() {
        if (authManager != null) {
            authManager.saveAllAndClear();
        }
        if (bossBarManager != null) {
            bossBarManager.removeAll();
        }
        if (databaseManager != null) {
            databaseManager.close();
        }
        getLogger().info("OrionAuth disabled.");
    }

    private void registerListeners() {
        getServer().getPluginManager().registerEvents(new PreLoginListener(this), this);
        getServer().getPluginManager().registerEvents(new JoinQuitListener(this), this);
        getServer().getPluginManager().registerEvents(new AuthListener(this), this);
        getServer().getPluginManager().registerEvents(new GUIListener(inventoryGUIManager), this);
    }

    private void registerCommands() {
        getCommand("login").setExecutor(new LoginCommand(this));
        getCommand("register").setExecutor(new RegisterCommand(this));
        getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
        getCommand("orionauth").setExecutor(new OrionAuthCommand(this));
        getCommand("auth").setExecutor(new AuthCommand(this));
    }

    public void reload() {
        reloadConfig();
        configManager.reload();
        messageManager.reload();
    }

    private void printBanner() {
        getLogger().info("=================================");
        getLogger().info("ORIONAUTH");
        getLogger().info("Advanced Authentication System");
        getLogger().info("");
        getLogger().info("Author: RipperSensei");
        getLogger().info("Co-Author: AnshuG");
        getLogger().info("=================================");
    }
}