sashank_playz_0915
📎 1 file 2,707 chars
📄
pasted-code-1774619391451.txt
txt 189 lines
â–¶
Create a complete Minecraft Paper plugin in Java (version 1.20+) named "SimpleAuth".

---

## CORE FEATURES

1. Authentication System:

* Players must register or login before playing
* On join:

  * If not registered → must use /register
  * If registered → must use /login
* Until logged in:

  * Block movement
  * Block chat
  * Block commands (except auth commands)

---

2. COMMANDS

---

/register  

* Register new account
* Check both passwords match
* Save password (hashed)

/login 

* Verify password
* Mark player as logged in

/changepassword  

* Require player to be logged in
* Verify old password
* Save new hashed password

/unregister 

* Verify password
* Remove account from storage
* Log player out

/logout

* Set player as not logged in

---

3. DATA STORAGE

---

* Use a YAML file: plugins/SimpleAuth/data.yml
* Store data like:

players: :
password: ""

* Use UUID (not player name)
* Load and save data using FileConfiguration

---

4. PASSWORD SECURITY

---

* NEVER store plain text passwords
* Hash passwords using SHA-256
* Compare hashed values for login

---

5. PLAYER DATA SYSTEM

---

* Use HashMap to track login status
* Methods:

  * isLoggedIn(Player)
  * setLoggedIn(Player, boolean)

---

6. EVENT LISTENERS

---

Implement:

PlayerJoinEvent:

* Check if player is registered
* Ask to login or register

PlayerMoveEvent:

* Cancel movement if not logged in

AsyncPlayerChatEvent:

* Cancel chat if not logged in

PlayerCommandPreprocessEvent:

* Block all commands except:
  /login
  /register
  /changepassword
  /unregister
  /logout

---

7. FILE MANAGEMENT

---

* Create data.yml in plugin folder if not exists
* Load config on startup
* Save file after every change

---

8. CODE STRUCTURE

---

Create these classes:

* Main (extends JavaPlugin)
* AuthManager (handles passwords + file)
* PlayerData (login status tracking)
* RegisterCommand
* LoginCommand
* ChangePasswordCommand
* UnregisterCommand
* LogoutCommand
* AuthListener

---

9. plugin.yml

---

Include:

name: SimpleAuth
version: 1.0
main: me.yourname.simpleauth.Main
api-version: 1.20

commands:
register:
login:
changepassword:
unregister:
logout:

---

10. CODE QUALITY

---

* Clean, readable code
* Proper OOP structure
* Comments explaining each method
* Beginner-friendly but production-style

---

## OUTPUT

Return:

* Full working code for ALL classes
* plugin.yml
* No explanations
* Clean and compilable
Kodari AI
KodariMar 27 at 1:52 pm 20,897 (v2)

I’ll create a complete authentication plugin for Minecraft Paper 1.20+.

SimpleAuth
A lightweight authentication system requiring players to register and login before playing. Blocks movement, chat, and commands until authenticated. Features secure password hashing with SHA-256, persistent YAML storage, and comprehensive command suite including register, login, logout, password changes, and account removal. Designed for servers requiring basic player authentication.

All files created successfully. The SimpleAuth plugin is complete with secure password hashing, YAML storage, and comprehensive authentication system.

sashank_playz_0915

name will be SecureAuth

Kodari AI
KodariMar 27 at 1:54 pm 9,689 (v2)

I’ll create a complete SecureAuth authentication plugin for you. Let me first check if any files already exist.

I’ll rename the plugin from SimpleAuth to SecureAuth by moving the package and updating configuration files.

Successfully renamed SimpleAuth to SecureAuth with complete package refactoring and updated all configuration files.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
12 568
src/main/java/me/yourname/secureauth/SecureAuth.java
package me.yourname.secureauth;

import lombok.Getter;
import me.yourname.secureauth.commands.*;
import me.yourname.secureauth.listeners.AuthListener;
import me.yourname.secureauth.managers.AuthManager;
import me.yourname.secureauth.managers.PlayerData;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class SecureAuth extends JavaPlugin {
    private AuthManager authManager;
    private PlayerData playerData;

    @Override
    public void onEnable() {
        this.playerData = new PlayerData();
        this.authManager = new AuthManager(this);
        
        this.authManager.loadData();
        
        registerCommands();
        registerListeners();
        
        getLogger().info("SecureAuth has been enabled!");
    }

    @Override
    public void onDisable() {
        this.authManager.saveData();
        getLogger().info("SecureAuth has been disabled!");
    }

    private void registerCommands() {
        getCommand("register").setExecutor(new RegisterCommand(this));
        getCommand("login").setExecutor(new LoginCommand(this));
        getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
        getCommand("unregister").setExecutor(new UnregisterCommand(this));
        getCommand("logout").setExecutor(new LogoutCommand(this));
    }

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