mateuszglowacki2013-lang

create a login plugin commands /register password password and /login password when not logged in cant use any command only /login cant open inventory cant move

Kodari AI
KodariJan 19 at 5:14 pm 5,319 (v2)

I’ll create a login/register plugin with authentication and movement restrictions.

LoginPlugin
A secure authentication plugin requiring players to register and login before playing. Features password-protected accounts with BCrypt hashing, command blocking, movement restrictions, and inventory protection for unauthenticated players. Players must use /register to create an account and /login to authenticate each session. All actions are blocked until successful authentication.

Plugin created! Features:

  • /register <password> <password> - Create account with password confirmation

  • /login <password> - Authenticate with BCrypt-hashed password

  • Blocks all movement, inventory access, item interactions, and commands (except /login and /register) until authenticated

  • Automatic logout on disconnect, re-authentication required on rejoin

  • Secure password storage using BCrypt hashing

mateuszglowacki2013-lang

players can add they own passwords on a screen viev message register when they not registred or log in when they are

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
8 371
src/main/java/com/loginplugin/LoginPlugin.java
package com.loginplugin;

import com.loginplugin.commands.LoginCommand;
import com.loginplugin.commands.RegisterCommand;
import com.loginplugin.data.PlayerDataManager;
import com.loginplugin.listeners.PlayerProtectionListener;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class LoginPlugin extends JavaPlugin {
    
    @Getter
    private PlayerDataManager dataManager;
    
    private final Set<UUID> loggedInPlayers = new HashSet<>();
    
    @Override
    public void onEnable() {
        dataManager = new PlayerDataManager(this);
        dataManager.load();
        
        getCommand("register").setExecutor(new RegisterCommand(this));
        getCommand("login").setExecutor(new LoginCommand(this));
        
        getServer().getPluginManager().registerEvents(new PlayerProtectionListener(this), this);
        
        getLogger().info("LoginPlugin has been enabled!");
    }
    
    @Override
    public void onDisable() {
        loggedInPlayers.clear();
        getLogger().info("LoginPlugin has been disabled!");
    }
    
    public boolean isLoggedIn(Player player) {
        return loggedInPlayers.contains(player.getUniqueId());
    }
    
    public void setLoggedIn(Player player, boolean loggedIn) {
        if (loggedIn) {
            loggedInPlayers.add(player.getUniqueId());
        } else {
            loggedInPlayers.remove(player.getUniqueId());
        }
    }
}