epicxd76

create a login plugin like login security in which these feature will be there :- /register <password> /login <password> /changepassword <old password> <new password> /logout NOTE:- the passwords should be saved in text format as it is. example: - name - Steve. password - the password another key feature - there should be a text on the screen of the player which will say /register <passowrd> if the player is not yet logged in or else /login <password> will be shown. there must not be any bug and try to make it optimized so that no lag or ping problem will show.

Kodari AI
KodariAug 16 at 1:31 pm 1
SecureLoginSystem
A Minecraft plugin providing essential login security features. Players must register with /register &lt;password&gt;, then log in with /login &lt;password&gt; on each session. Supports /changepassword &lt;old&gt; &lt;new&gt; and /logout commands. Passwords are stored in plain text format in a data file, mapping player names to their passwords. The plugin displays an on-screen action bar message prompting unregistered players to use /register &lt;password&gt; and registered-but-logged-out players to use /login &lt;password&gt;. Optimized with efficient data structures, minimal event processing, and no database overhead to prevent lag or ping issues.
  1. Create the Gradle Bukkit plugin structure and metadata.

  2. Implement plaintext credential storage with safe asynchronous persistence.

  3. Add authentication commands, session handling, action-bar reminders, and pre-login restrictions.

Created the LoginSecurity Bukkit plugin with:

  • /register <password>

  • /login <password>

  • /changepassword <old password> <new password>

  • /logout

  • Plaintext credentials stored in plugins/LoginSecurity/credentials.txt

  • Action-bar reminders showing either /register <password> or /login <password>

  • Movement, chat, interactions, inventory, block actions, damage, and unauthorized commands blocked before login

  • Asynchronous credential saving to avoid main-thread lag

  • Credentials saved safely through a temporary file replacement mechanism

  • Login state reset when players leave or rejoin

epicxd76

make it of version 26.2 paper

Kodari AI
KodariAug 16 at 1:34 pm 1
  1. Switch the server API from Spigot to Paper 1.26.2.

  2. Update the Java target and plugin metadata to match the requested Paper version without changing the login behavior.

Updated the plugin for Paper 26.2:

  • Replaced Spigot API with io.papermc.paper:paper-api:26.2-R0.1-SNAPSHOT

  • Added the Paper Maven repository

  • Updated api-version to 26.2

  • Updated the Java target to Java 21

  • Login commands and plaintext storage remain unchanged

epicxd76

where is the announcement of /register <password> and /login <password> that Itold you and where is the chat msg that is only showed to the player who is registering or logging in that you are succesfully logged in and in the chat there should also be warnings of how many chances is left if password is wrong.

Kodari AI
KodariAug 16 at 1:44 pm 1
  1. Add visible action-bar prompts for unregistered and registered-but-logged-out players.

  2. Add per-player success messages and wrong-password attempt warnings, including a lockout policy to prevent unlimited guessing.

Implemented the missing login feedback:

  • Action-bar prompts are in LoginSecurityPlugin.sendReminder() and now appear immediately when a player joins, then repeat every second:

    • Unregistered: /register <password>

    • Registered but logged out: /login <password>

  • Private success messages use player.sendMessage(...), so only that player sees them:

    • Registration: account registered and logged in

    • Login: successfully logged in

  • Wrong password warnings now show remaining attempts:

    • Default limit: 3 attempts

    • Configurable in config.yml:

      YAML
      security:
        max-login-attempts: 3
      
    • The player is disconnected after all attempts are used.

  • Updated messages are in src/main/resources/config.yml.

epicxd76

add more configs

Kodari AI
KodariAug 16 at 1:45 pm 1
  1. Add configurable action-bar behavior and reminder timing.

  2. Add password policy settings and validation messages.

  3. Add configurable pre-login restrictions and failed-attempt kick behavior.

  4. Add a configurable chat prefix while preserving the existing commands and storage format.

Added more configurable settings in config.yml.

New configurations

YAML
messages:
  prefix: '&8[&bLoginSecurity&8] &r'

Controls the prefix shown before chat messages.

YAML
actionbar:
  enabled: true
  interval-seconds: 1
  • Enable or disable action-bar reminders.

  • Change how often reminders appear.

YAML
security:
  max-login-attempts: 3
  kick-on-max-attempts: true
  • Configure the number of incorrect login attempts.

  • Choose whether the player is kicked after reaching the limit.

YAML
passwords:
  min-length: 4
  max-length: 64

Controls the minimum and maximum password length for /register and /changepassword.

YAML
restrictions:
  block-chat: true
  block-commands: true
  block-movement: true
  block-damage: true
  block-interactions: true
  block-item-drop: true
  block-inventory: true
  block-block-break: true
  block-block-place: true

Each pre-login restriction can now be enabled or disabled separately.

Also added configurable messages for passwords that are too short or too long. Changes are in:

  • src/main/resources/config.yml

  • src/main/java/com/kodari/loginsecurity/LoginSecurityPlugin.java

  • src/main/java/com/kodari/loginsecurity/AuthCommand.java

Restart the server after changing the configuration.

epicxd76

players should also not take any damage during login or registering and the should also be restricted to use any other commands than the commands of this plugin.

Kodari AI
KodariAug 16 at 1:48 pm 1

Updated the plugin:

  • Unauthenticated players now always take no damage from any damage source while registering or logging in.

  • Unauthenticated players can only use:

    • /register

    • /login

    • /changepassword

    • /logout

  • All other commands are cancelled and the player receives the login reminder message.

  • Removed the configuration toggles for damage and command blocking so these protections cannot accidentally be disabled.

  • Other restrictions remain configurable in config.yml.

epicxd76

not only msg but also announcement on screen

Kodari AI
KodariAug 16 at 1:49 pm 1
  1. Add configurable title-screen announcements for registration/login prompts.

  2. Show private title announcements on join, logout, failed login, and successful authentication while keeping the action-bar reminders and chat messages.

Added title-screen announcements in addition to chat messages and action-bar reminders.

Players now see private on-screen announcements:

  • On join:

    • Registration required → /register <password>

    • Login required → /login <password>

  • After successful registration:

    • Registration successful

  • After successful login:

    • Login successful

  • After an incorrect password:

    • Login-required announcement appears again

  • After logout:

    • Login-required announcement appears again

  • After too many failed attempts:

    • Login-failed announcement appears

The title announcements are configurable in config.yml:

YAML
screen-announcement:
  enabled: true
  fade-in-ticks: 5
  stay-ticks: 40
  fade-out-ticks: 10

You can also customize every title and subtitle under screen-announcement.

epicxd76

the announcement should stay for the time of login and register.

Kodari AI
KodariAug 16 at 1:51 pm 1
  1. Keep the registration/login title visible by re-sending it for every unauthenticated reminder cycle.

  2. Run the reminder cycle when either action-bar or screen announcements are enabled, so disabling action-bar does not disable the on-screen prompt.

Updated the screen announcement behavior:

  • /register <password> or /login <password> now stays visible throughout the unauthenticated period.

  • The title is automatically refreshed every reminder interval until the player successfully registers or logs in.

  • The announcement stops immediately after authentication.

  • It also continues working when actionbar.enabled is set to false, as long as screen-announcement.enabled remains true.

  • After /logout, the login announcement appears again and remains visible until the next login.

epicxd76

screen and chat announcement is not working

Kodari AI
KodariAug 16 at 5:05 pm 1
  1. Add a real private chat prompt for registration/login; currently only action-bar and title prompts exist.

  2. Ensure join announcements are sent one tick after joining and repeat the screen prompt while authentication is pending.

  3. Send the prompt again after logout and failed login without affecting authenticated players.

Fixed the missing announcements.

  • Added private chat prompts:

    • Unregistered: /register <password>

    • Registered but logged out: /login <password>

  • Join announcements now run one server tick after joining, ensuring the player client is ready.

  • Screen announcements continue refreshing while the player is unauthenticated.

  • Chat and screen prompts appear after:

    • Joining

    • Logging out

    • Entering an incorrect password

  • Added configurable messages in config.yml:

    YAML
    messages:
      registration-required: '&eYou are not registered. Use &a/register <password>&e.'
      login-required: '&eYou are not logged in. Use &a/login <password>&e.'
    

Restart the server after updating the plugin; a normal /reload may not reload title and scheduler behavior correctly.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
7 637
src/main/java/com/kodari/loginsecurity/LoginSecurityPlugin.java
package com.kodari.loginsecurity;

import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public final class LoginSecurityPlugin extends JavaPlugin implements Listener {
    private CredentialStore credentialStore;
    private final Set<UUID> authenticatedPlayers = Collections.newSetFromMap(new ConcurrentHashMap<UUID, Boolean>());
    private final Map<UUID, Integer> failedLoginAttempts = new ConcurrentHashMap<>();
    private BukkitTask reminderTask;

    @Override
    public void onEnable() {
        if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
            getLogger().warning("Could not create the plugin data folder.");
        }

        credentialStore = new CredentialStore(new File(getDataFolder(), "credentials.txt"));
        credentialStore.load();

        getCommand("register").setExecutor(new AuthCommand(this, AuthCommand.Action.REGISTER));
        getCommand("login").setExecutor(new AuthCommand(this, AuthCommand.Action.LOGIN));
        getCommand("changepassword").setExecutor(new AuthCommand(this, AuthCommand.Action.CHANGE_PASSWORD));
        getCommand("logout").setExecutor(new AuthCommand(this, AuthCommand.Action.LOGOUT));
        getServer().getPluginManager().registerEvents(this, this);

        if (getConfig().getBoolean("actionbar.enabled", true)
                || getConfig().getBoolean("screen-announcement.enabled", true)) {
            reminderTask = getServer().getScheduler().runTaskTimer(this, () -> {
                for (Player player : getServer().getOnlinePlayers()) {
                    if (!isAuthenticated(player)) {
                        sendReminder(player);
                    }
                }
            }, 0L, getActionbarIntervalTicks());
        }
    }

    @Override
    public void onDisable() {
        if (reminderTask != null) {
            reminderTask.cancel();
        }
        if (credentialStore != null) {
            credentialStore.saveNow();
        }
    }

    public CredentialStore getCredentialStore() {
        return credentialStore;
    }

    public boolean isAuthenticated(Player player) {
        return authenticatedPlayers.contains(player.getUniqueId());
    }

    public void authenticate(Player player) {
        authenticatedPlayers.add(player.getUniqueId());
        failedLoginAttempts.remove(player.getUniqueId());
    }

    public void logout(Player player) {
        authenticatedPlayers.remove(player.getUniqueId());
        failedLoginAttempts.remove(player.getUniqueId());
    }

    public int recordFailedLogin(Player player) {
        int attempts = failedLoginAttempts.merge(player.getUniqueId(), 1, Integer::sum);
        return Math.max(0, getMaxLoginAttempts() - attempts);
    }

    public int getMaxLoginAttempts() {
        return Math.max(1, getConfig().getInt("security.max-login-attempts", 3));
    }

    public boolean shouldKickAfterMaxAttempts() {
        return getConfig().getBoolean("security.kick-on-max-attempts", true);
    }

    public String passwordError(String password) {
        int minLength = Math.max(1, getConfig().getInt("passwords.min-length", 4));
        int maxLength = Math.max(minLength, getConfig().getInt("passwords.max-length", 64));
        if (password.length() < minLength) {
            return message("password-too-short").replace("%min%", String.valueOf(minLength));
        }
        if (password.length() > maxLength) {
            return message("password-too-long").replace("%max%", String.valueOf(maxLength));
        }
        return null;
    }

    public boolean restrictionEnabled(String restriction) {
        return getConfig().getBoolean("restrictions." + restriction, true);
    }

    private long getActionbarIntervalTicks() {
        long seconds = Math.max(1, getConfig().getLong("actionbar.interval-seconds", 1));
        return Math.max(1L, seconds * 20L);
    }

    private void sendScreenAnnouncement(Player player, String key) {
        if (!getConfig().getBoolean("screen-announcement.enabled", true)) {
            return;
        }
        String path = "screen-announcement." + key;
        String title = color(getConfig().getString(path + ".title", ""));
        String subtitle = color(getConfig().getString(path + ".subtitle", ""));
        int fadeIn = Math.max(0, getConfig().getInt("screen-announcement.fade-in-ticks", 5));
        int stay = Math.max(1, getConfig().getInt("screen-announcement.stay-ticks", 40));
        int fadeOut = Math.max(0, getConfig().getInt("screen-announcement.fade-out-ticks", 10));
        player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
    }

    public void sendAuthenticationAnnouncement(Player player) {
        String key = credentialStore.isRegistered(player.getName()) ? "login-required" : "registration-required";
        sendScreenAnnouncement(player, key);
    }

    public void sendChatAuthenticationAnnouncement(Player player) {
        String key = credentialStore.isRegistered(player.getName())
                ? "login-required"
                : "registration-required";
        player.sendMessage(message(key));
    }

    public void sendScreenAnnouncementForResult(Player player, String key) {
        sendScreenAnnouncement(player, key);
    }

    public void saveCredentialsAsync() {
        getServer().getScheduler().runTaskAsynchronously(this, credentialStore::saveNow);
    }

    public String message(String key) {
        String prefix = getConfig().getString("messages.prefix", "");
        return color(prefix + getConfig().getString("messages." + key, ""));
    }

    private void sendReminder(Player player) {
        if (getConfig().getBoolean("actionbar.enabled", true)) {
            String key = credentialStore.isRegistered(player.getName()) ? "registered" : "unregistered";
            String text = color(getConfig().getString("actionbar." + key, ""));
            player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(text));
        }
        sendAuthenticationAnnouncement(player);
    }

    private String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text);
    }

    private boolean blocked(Player player) {
        return !isAuthenticated(player);
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        logout(player);
        getServer().getScheduler().runTask(this, () -> {
            if (!player.isOnline() || isAuthenticated(player)) {
                return;
            }
            sendChatAuthenticationAnnouncement(player);
            sendReminder(player);
        });
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        logout(event.getPlayer());
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)