sayon0029
📎 1 file 1,962 chars
📄
pasted-code-1772881932468.txt
txt 38 lines
▶
I want to create a separate Minecraft authentication plugin in Java for Paper servers that works from version 1.21 up to all 1.21.x versions. The plugin should function similarly to AuthMe but be lightweight and simple.
When a player joins the server, they should spawn at a login spawn location instead of the normal server spawn. Players must register or login before they can move or interact with the world.
Commands:
/register  
Registers the player with a password. The captcha must be a simple randomly generated number or text displayed to the player to prevent bots.
/login 
Logs the player into their account.
Admin commands:
/setloginspawn
Sets the login spawn location where players appear before authentication.
/setspawn
Sets the main server spawn location where players are teleported after successful login.
Behavior:
When a player joins:
If the player is not registered, they must use /register.
If the player is registered, they must use /login.
Until the player logs in:
They cannot move
They cannot break blocks
They cannot place blocks
They cannot open inventories
They cannot chat
They cannot run commands except /login and /register
After successful login:
The player is teleported to the main spawn location.
Permissions:
auth.admin
Allows admin commands such as /setloginspawn and /setspawn.
Configuration:
The plugin must include a config.yml that stores:
login spawn location
main spawn location
messages for register, login, and errors
captcha settings
options to enable or disable movement blocking before login
Security:
Passwords must be stored securely using hashing such as BCrypt or SHA-256. Player data should be stored in a data file such as players.yml or a simple database.
Generate the full plugin structure including the main class, authentication manager, command classes, event listeners, plugin.yml, config.yml, and an explanation of how the system works. The plugin must be optimized and have no external dependencies.
Kodari AI
KodariMar 7 at 11:14 am 20,021 (v2)

I’ll create a lightweight authentication plugin for Paper 1.21+.

SimpleAuth
A lightweight authentication plugin for Paper servers that requires players to register and login before accessing the server. Features include secure password hashing using SHA-256 with salt, captcha verification to prevent bots, customizable spawn locations for login and main areas, and comprehensive player action blocking until authentication. Players cannot move, interact, chat, or execute commands until they complete authentication. Includes admin commands for spawn management and a fully configurable message system.

Plan

  • Create secure authentication system with SHA-256 + salt password hashing

  • Implement captcha system to prevent bot registrations

  • Create spawn management for login and main areas

  • Block all player interactions until authenticated

  • Admin commands for spawn configuration

Complete authentication system created with secure SHA-256 password hashing, captcha verification, comprehensive player protection, and admin spawn management commands.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
19 1,025
src/main/java/com/auth/plugin/SimpleAuth.java
package com.auth.plugin;

import com.auth.plugin.command.LoginCommand;
import com.auth.plugin.command.RegisterCommand;
import com.auth.plugin.command.SetLoginSpawnCommand;
import com.auth.plugin.command.SetSpawnCommand;
import com.auth.plugin.listener.CommandPreprocessListener;
import com.auth.plugin.listener.PlayerJoinListener;
import com.auth.plugin.listener.PlayerProtectionListener;
import com.auth.plugin.listener.PlayerQuitListener;
import com.auth.plugin.manager.AuthManager;
import com.auth.plugin.manager.CaptchaManager;
import com.auth.plugin.manager.SessionManager;
import com.auth.plugin.manager.SpawnManager;
import com.auth.plugin.util.ConfigManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class SimpleAuth extends JavaPlugin {
    
    private ConfigManager configManager;
    private AuthManager authManager;
    private SessionManager sessionManager;
    private CaptchaManager captchaManager;
    private SpawnManager spawnManager;
    
    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.authManager = new AuthManager(this);
        this.sessionManager = new SessionManager(this);
        this.captchaManager = new CaptchaManager(this);
        this.spawnManager = new SpawnManager(this);
        
        registerCommands();
        registerListeners();
        
        getLogger().info("SimpleAuth has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (authManager != null) {
            authManager.saveData();
        }
        getLogger().info("SimpleAuth has been disabled!");
    }
    
    private void registerCommands() {
        getCommand("register").setExecutor(new RegisterCommand(this));
        getCommand("login").setExecutor(new LoginCommand(this));
        getCommand("setloginspawn").setExecutor(new SetLoginSpawnCommand(this));
        getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
    }
    
    private void registerListeners() {
        PluginManager pm = Bukkit.getPluginManager();
        pm.registerEvents(new PlayerJoinListener(this), this);
        pm.registerEvents(new PlayerQuitListener(this), this);
        pm.registerEvents(new PlayerProtectionListener(this), this);
        pm.registerEvents(new CommandPreprocessListener(this), this);
    }
}