naruto04352

Generate a complete, production-ready Minecraft Paper/Spigot plugin (Java 17+, API version 1.19–1.21) for login security that is structured as a premium plugin with a license system. The plugin must protect player accounts with authentication and include advanced security features unlockable via a valid license key.

Plugin Name: SecureLogin Package: com.yourname.securelogin

Core Features (always available)

  • Registration: First join forces /register <password> <confirmPassword> to create an account.
  • Login: Returning players must use /login <password> before they can move, chat, interact, take damage, or execute commands (except allowed commands like /login, /register).
  • Session system: After successful login, remember the player by IP and UUID for a configurable time (default 24h) so they don’t re-enter the password on rejoin from the same IP.
  • Password hashing: Use BCrypt (or Argon2) via a reputable library (e.g., jBCrypt or Spring Security Crypto).
  • Brute-force protection: Maximum failed login attempts per account/IP per configurable time window (e.g., 5 attempts in 10 minutes) resulting in a temporary ban/kick with configurable duration.
  • Command whitelist: Block all commands before authentication except a configurable list (login, register, changepassword, resetpassword maybe).
  • Chat & interaction blocking: Freeze the player (no movement), block chat, block inventory clicks, block damage, block picking up items, block dropping items until logged in.
  • Auto-save: Save player data asynchronously on quit and periodically.
  • Configuration: Fully configurable messages, timers, session length, password minimum length, allowed commands before login, database type (YAML/MySQL), etc.
  • Admin commands:

- /securelogin reset <player> — reset a player’s password (force them to register again). - /securelogin reload — reload config and messages. - /securelogin info <player> — show account status (registered, last login IP, failed attempts, session active).

  • Player commands:

- /changepassword <oldPassword> <newPassword> — change password while logged in. - /login, /register, /logout (logs out and ends session, requiring login again).

  • Permissions:

- securelogin.admin — for admin commands. - securelogin.bypass — players with this permission skip login entirely (useful for staff in some setups).

  • Message system: All strings configurable via messages.yml with placeholders (e.g., {player}, {time}), and color code support.
  • Auto-updater placeholder: Add a config option auto-update-check: true that checks for new versions on SpigotMC (just log a message if an update exists; no auto-download).

Premium Features (require valid license, toggled via config premium: true when license verified)

  • Two-Factor Authentication (2FA): Optional per-player 2FA using TOTP (Google Authenticator). Player can enable with /2fa enable, gets a QR code link in chat (generate using a library like ZXing, output a link that can be copied, or use a map-based QR? simpler: text-based setup key and a clickable link). After enabling, login flow: after password, prompt for 2FA code. Provide /2fa disable (with password confirmation) and a recovery code system (give 8 backup codes on enable).
  • IP-Lock / Geo-IP check (optional): Configurable IP change detection: if a player’s IP changes drastically (different country via offline MaxMind GeoLite2 database), require additional verification (2FA or email confirmation if email set). Fallback: just warn admin.
  • Login notifications: When a player logs in from a new IP, broadcast a message to staff (via permission securelogin.notify).
  • Captcha on login: After multiple failed attempts, require solving a simple chat-based captcha (e.g., type the random number 12345) before allowing another login attempt.
  • Premium INVENTORY GUI: A cosmetic INVENTORY GUI (accessible after login) to view account security status, manage 2FA, see login history (stored in DB: IP, timestamp, success/fail). Use Spigot's Inventory API.
  • MySQL storage only: Premium version may require MySQL (or at least support it by default) while YAML is deprecated in premium? No, YAML can still work, but MySQL with connection pool (HikariCP) should be fully implemented and recommended for premium.
  • API events: Fire custom events (PlayerRegisterEvent, PlayerLoginSuccessEvent, PlayerLoginFailEvent, PlayerLogoutEvent) so other plugins can hook in. This can be core too, but make it part of premium to attract developers.
  • PlaceholderAPI expansion: Register a PlaceholderAPI expansion (if PAPI present) to expose placeholders: %securelogin_is_logged_in%, %securelogin_last_login_time%, %securelogin_2fa_enabled%, etc. Only load if PAPI is installed (softdepend). Make this premium.

License System

  • The plugin must have a license key verification against a remote server (simulate a simple HTTP endpoint). The config.yml contains license-key: "". On startup, if license-key is not empty, send a GET request to https://api.yourdomain.com/verify?key=xxx&server_id=xxx (server_id is the server’s IP:port or a random UUID generated on first run). The API returns JSON: {"valid": true, "premium_features": true, "message": "..."}. If valid, enable premium features; if invalid or no key, run in core mode only. Include a config option premium (read-only, set automatically based on verification). Handle connection errors gracefully (disable premium temporarily, log warning).
  • Simulate the remote API inside a comment or a placeholder class so the code compiles. Provide a clear note that the server owner must implement their own license server.

Storage

  • Use an interface DataStorage with implementations YamlStorage (for core, using playerdata.yml in plugin folder) and MySQLStorage (for premium, always available if MySQL credentials are supplied). In config, set storage.type: yaml or mysql and MySQL connection details. MySQL must use HikariCP connection pool, create tables on first load (players table: uuid, username, hashed_password, reg_ip, last_ip, reg_date, last_login, session_expiry, failed_attempts, locked_until, 2fa_secret, recovery_codes, 2fa_enabled). Implement async operations using CompletableFuture.
  • Ensure thread safety.

Compilation & Dependencies

  • Gradle (or Maven) project with dependencies:

- paper-api (latest 1.21, or 1.20.6) - bcrypt library (implementation 'at.favre.lib:bcrypt:0.10.2' or 'org.mindrot:jbcrypt:0.4') - HikariCP (implementation 'com.zaxxer:HikariCP:5.1.0') - (Optional) Apache Commons Codec for TOTP, but you can implement TOTP from scratch using javax.crypto. So no extra dep for TOTP if you do it manually; reference a simple TOTP generator using javax.crypto.Mac, java.security.Key. You can include a note to add a library like 'com.google.zxing:core' for QR generation if you want a shareable link; otherwise just print the secret and a URL like otpauth://totp/SecureLogin:{player}?secret={secret}&issuer=SecureLogin. - PlaceholderAPI (compileOnly, soft depend)

  • plugin.yml: name: SecureLogin, main: com.yourname.securelogin.SecureLogin, version: ${project.version}, api-version: 1.20, softdepend: [PlaceholderAPI], commands and permissions defined.

Additional Requirements

  • Clean, well-commented code following Java conventions.
  • Use a main class, event listener class, command handler (register commands in plugin.yml and use onCommand or a command framework like ACF but keep it simple without extra dependencies; just basic Spigot command handling).
  • When player joins, check if they are registered. If not, force registration. If registered but not session-valid, force login. The player should be put in “limbo” state: set game mode to adventure or spectator, clear inventory temporarily (store in a map?), clear potion effects, set fly off, teleport to spawn or a fixed location (configurable login location, or just spawn), and show a title/message prompting to login/register. Upon success, restore player’s previous state (game mode, inventory, location) that was saved before limbo. This ensures no item loss. Use a PlayerData object mapped to UUID for limbo state.
  • Localization: Support multiple languages via messages_XX.yml loaded based on player’s client language (optional; default to English). At least provide a configurable messages file.
  • Testing notes: Include a simple instruction on how to build and run.

Please output the complete Java source files organized in packages, along with the plugin.yml, config.yml, messages.yml (default), and any necessary resource files. The code must compile and be ready for use on a Paper server. and plugin name is login security premium

Kodari AI
KodariJul 3 at 9:59 am 14
SecureLogin
A premium login security plugin for Minecraft Paper/Spigot servers. Features registration/login with BCrypt password hashing, session management, brute-force protection, and full interaction blocking until authenticated. Premium tier adds TOTP 2FA, captcha challenges, Geo-IP change detection, staff login notifications, a security status GUI, PlaceholderAPI expansion, and custom API events. Supports YAML and MySQL (HikariCP) storage with async operations.

Build & Run

Requirements:

  • Java 17+

  • Paper 1.20.4+ server

Build:

Shell
./gradlew build

The output JAR will be at build/libs/SecureLogin-1.0.jar with all dependencies bundled (BCrypt, HikariCP).

Install:

  1. Drop the JAR into your server’s plugins/ folder

  2. Start the server — config.yml and messages.yml are generated

  3. Configure storage.type (yaml or mysql) and MySQL credentials if needed

  4. For premium features, set license-key in config.yml and restart

License Server Note: The license verification hits https://api.yourdomain.com/verify?key=KEY&server_id=ID. You must implement this endpoint to return {"valid": true, "premium_features": true}. Without a valid license, the plugin runs in core mode with all free features. The server ID is auto-generated on first run and stored in server-id.yml.

naruto04352

command not working and player data not showing and too many bug fix this all

Kodari AI
KodariJul 3 at 10:44 am 30

I found 14 bugs ranging from NPE crashes to data corruption. Let me read all affected files and fix them systematically

Now I have a complete picture of all 14 bugs. Let me fix them all systematically.

Starting with the core files that have the most issues:

Now fix the remaining critical bugs

Now I need to add the pending 2FA setup state and fix the captcha answer getter. Let me read and fix the remaining issues.

Now fix the NullPointer risks in command registration and the listener captcha flow

Now fix the listener’s captcha handling to use the unified source (BruteForceProtector

Now fix the GUI to use performCommand instead of deprecated chat(), and fix the LimboPlayer to properly copy potion effects

Now fix the race condition in handleJoin (dataCache already existing check) and the SecurityGUI’s chat() deprecation:

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
36 2,931
src/main/java/com/yourname/securelogin/SecureLogin.java
package com.yourname.securelogin;

import com.yourname.securelogin.auth.AuthManager;
import com.yourname.securelogin.auth.BruteForceProtector;
import com.yourname.securelogin.auth.SessionManager;
import com.yourname.securelogin.commands.*;
import com.yourname.securelogin.config.ConfigManager;
import com.yourname.securelogin.data.DataStorage;
import com.yourname.securelogin.data.MySQLStorage;
import com.yourname.securelogin.data.YamlStorage;
import com.yourname.securelogin.inventory.gui.GUIListener;
import com.yourname.securelogin.inventory.gui.GUIManager;
import com.yourname.securelogin.license.LicenseManager;
import com.yourname.securelogin.listener.AuthListener;
import com.yourname.securelogin.messages.MessageManager;
import com.yourname.securelogin.totp.TOTPManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class SecureLogin extends JavaPlugin {
    private static SecureLogin instance;

    private ConfigManager configManager;
    private MessageManager messageManager;
    private DataStorage dataStorage;
    private AuthManager authManager;
    private SessionManager sessionManager;
    private BruteForceProtector bruteForceProtector;
    private TOTPManager totpManager;
    private LicenseManager licenseManager;
    private GUIManager guiManager;

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

        saveDefaultConfig();

        // Core managers (no deps)
        configManager = new ConfigManager(this);
        messageManager = new MessageManager(this);

        // License verification
        licenseManager = new LicenseManager(this);
        licenseManager.verify();

        // Reload config after license sets premium field
        configManager.reload();

        // Initialize subsystem managers
        sessionManager = new SessionManager(this);
        bruteForceProtector = new BruteForceProtector(this);
        totpManager = new TOTPManager();

        // Initialize storage
        setupStorage();

        // Initialize auth manager
        authManager = new AuthManager(this, dataStorage, sessionManager, bruteForceProtector);

        // Register event listeners
        getServer().getPluginManager().registerEvents(new AuthListener(this), this);

        // Register commands
        registerCommands();

        // Register GUI system
        guiManager = new GUIManager();
        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);

        // Register PlaceholderAPI expansion (premium)
        if (licenseManager.isPremium() && getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
            try {
                Class.forName("me.clip.placeholderapi.expansion.PlaceholderExpansion");
                new com.yourname.securelogin.api.PlaceholderAPIExpansion(this).register();
                getLogger().info("PlaceholderAPI expansion registered.");
            } catch (ClassNotFoundException e) {
                getLogger().info("PlaceholderAPI not found — skipping expansion.");
            }
        }

        // Auto-update check
        if (configManager.isAutoUpdateCheck()) {
            checkForUpdates();
        }

        getLogger().info("SecureLogin v" + getDescription().getVersion() + " enabled.");
        if (licenseManager.isPremium()) {
            getLogger().info("Premium features are ACTIVE.");
        } else {
            getLogger().info("Running in core mode.");
        }
    }

    @Override
    public void onDisable() {
        if (authManager != null) {
            // Save all cached data
            Bukkit.getOnlinePlayers().forEach(authManager::handleQuit);
        }
        if (dataStorage != null) {
            dataStorage.close();
        }
        getLogger().info("SecureLogin disabled.");
    }

    private void setupStorage() {
        String type = configManager.getStorageType();
        if (type.equalsIgnoreCase("mysql")) {
            MySQLStorage mysql = new MySQLStorage(this);
            boolean connected = mysql.connect(
                    configManager.getMysqlHost(),
                    configManager.getMysqlPort(),
                    configManager.getMysqlDatabase(),
                    configManager.getMysqlUsername(),
                    configManager.getMysqlPassword(),
                    configManager.isMysqlUseSSL(),
                    configManager.getMysqlPoolSize()
            );
            if (connected) {
                dataStorage = mysql;
                getLogger().info("Using MySQL storage.");
            } else {
                getLogger().warning("MySQL connection failed — falling back to YAML.");
                dataStorage = new YamlStorage(this);
            }
        } else {
            dataStorage = new YamlStorage(this);
            getLogger().info("Using YAML storage.");
        }
    }

    private void registerCommands() {
        setCommandExecutor("register", new RegisterCommand(this));
        setCommandExecutor("login", new LoginCommand(this));
        setCommandExecutor("logout", new LogoutCommand(this));
        setCommandExecutor("changepassword", new ChangePasswordCommand(this));
        setCommandExecutor("securelogin", new SecureLoginAdminCommand(this));
        setCommandExecutor("2fa", new TwoFACommand(this));
    }

    private void setCommandExecutor(String name, CommandExecutor executor) {
        org.bukkit.command.PluginCommand cmd = getCommand(name);
        if (cmd != null) {
            cmd.setExecutor(executor);
        } else {
            getLogger().severe("Command '" + name + "' not found in plugin.yml!");
        }
    }

    private void checkForUpdates() {
        getLogger().info("Checking for updates...");
        // Placeholder — log if update exists
        getServer().getScheduler().runTaskAsynchronously(this, () -> {
            try {
                java.net.URL url = new java.net.URL("https://api.spigotmc.org/legacy/update.php?resource=PLACEHOLDER_ID");
                java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
                conn.setConnectTimeout(3000);
                conn.setReadTimeout(3000);
                try (java.io.BufferedReader reader = new java.io.BufferedReader(
                        new java.io.InputStreamReader(conn.getInputStream()))) {
                    String latest = reader.readLine();
                    if (latest != null && !latest.equals(getDescription().getVersion())) {
                        getLogger().info("Update available: v" + latest + " (current: v" + getDescription().getVersion() + ")");
                    }
                }
                conn.disconnect();
            } catch (Exception e) {
                getLogger().info("Could not check for updates: " + e.getMessage());
            }
        });
    }

    public static SecureLogin getInstance() {
        return instance;
    }
}