a_mo5

متستخدمش مكتبات اكتبه كله سطر سطر حرف حرف عشان في مكتبات مش بتكون شغاله

📎 1 file 28,838 chars
📄
pasted-code-1788640566082.txt
txt 1415 lines
▶
You are an expert Minecraft Java developer specializing in Paper, Velocity, authentication systems, networking, security, MySQL, SQLite, YAML configuration, and high-performance Minecraft server plugins.

Build a complete production-ready Minecraft authentication system named:

Login+

Author:
Moody - _Yasta

The project must be written as a real professional plugin project, not a prototype, pseudo-code project, or incomplete skeleton.

IMPORTANT:
Do not ask me to implement missing parts manually.
Do not leave TODOs.
Do not use placeholders such as "implement this later".
Everything requested below must be implemented completely.

==================================================

1. PLATFORM SUPPORT
   ==================================================

Login+ must support:

1. Paper 1.21.11 as the primary backend target.
2. Velocity as a proxy plugin.
3. The same project must contain the required Paper and Velocity modules.
4. The plugin must automatically know whether it is running on Paper or Velocity.
5. Do not make the Paper plugin attempt to load Velocity-only classes.
6. Do not make the Velocity plugin attempt to load Bukkit/Paper-only classes.
7. Use a clean shared Core architecture.

Recommended architecture:

LoginPlus-Core
LoginPlus-Paper
LoginPlus-Velocity

Use platform adapters/interfaces where appropriate.

Paper 1.21.11 is the official server API target.

The authentication system must not depend on the Minecraft client version.

A player using an older or newer Minecraft client must still be able to authenticate normally as long as the player is successfully connected to the server/proxy through the server's supported protocol compatibility setup.

Do not hardcode authentication logic to a specific client protocol version.

==================================================
2. STANDALONE PAPER MODE
========================

Login+ must work perfectly without Velocity.

If installed on a standalone Paper server:

Premium player:

* Detect official Premium authentication.
* Verify the official UUID.
* Allow the player to enter normally.
* Do not require /register.
* Do not require /login.

Cracked player:

* Require registration if the account does not exist.
* Require login on future joins when no valid session exists.

Standalone authentication flow:

JOIN
↓
Detect Premium / Cracked
↓
Premium
→ Verify official UUID
→ Direct access

Cracked
↓
Registered?
├── NO → REGISTER
└── YES
↓
Valid Session?
├── YES → Direct access
└── NO → LOGIN
↓
Authenticated
↓
Full access

==================================================
3. VELOCITY NETWORK MODE
========================

Login+ must also work as a network authentication system.

Example network:

Velocity
├── Lobby
├── Survival
├── PvP
├── SkyBlock
└── Other backend servers

Login+ should be installed only on:

Velocity
Lobby

Login+ does NOT need to be installed on every backend server.

The Lobby is the authentication server.

The player connects to Velocity.
Velocity identifies the player.
The player is sent to the Lobby.
Login+ Paper on the Lobby handles Register/Login.
After successful authentication, the player's authentication state is maintained at network/proxy level.

After authentication:

Lobby
↓
Survival
↓
PvP
↓
SkyBlock

The player must NOT be asked to login again when switching backend servers.

This must work for Cracked players as well.

Example:

Cracked player:
JOIN PROXY
↓
LOBBY
↓
REGISTER
↓
LOGIN
↓
AUTHENTICATED
↓
SURVIVAL
↓
PLAY

There must be no second Login+ requirement on Survival.

Premium player:
JOIN PROXY
↓
LOBBY
↓
Premium verified
↓
AUTHENTICATED
↓
SURVIVAL

No register and no login.

==================================================
4. PROXY ACCESS TOKEN
=====================

Create a dedicated file:

proxy-token.yml

Do NOT place the proxy token directly inside config.yml.

Example:

plugins/Login+/proxy-token.yml

The Velocity instance must generate a secure random token automatically when first started if one does not already exist.

The token must be cryptographically secure and sufficiently long.

Never log the full token.

Never display the token to players.

The Paper Lobby instance can use the same token to verify that authentication/network communication comes from the trusted Login+ Velocity proxy.

The system must support secure Proxy ↔ Lobby authentication.

Do not rely only on a boolean such as:

proxy.enabled: true

The system must also verify the trusted proxy connection.

Use secure token handling.

Prefer storing only a secure representation/hash of the token where possible, while still allowing the required handshake/authentication process.

==================================================
5. PAPER CONFIGURATION
======================

Paper must have its own configuration.

Paper configuration contains backend/authentication settings such as:

* Authentication
* Register
* Login
* Password security
* Session
* Account lock
* Login timeout
* Login protection
* Anti-bot/rate limiting
* Commands
* Messages
* Sounds
* Storage
* Premium handling
* Proxy mode
* Logging
* Security
* PlaceholderAPI
* Allowed commands
* Player restrictions

Do NOT duplicate Velocity-only settings into the Paper configuration.

==================================================
6. VELOCITY CONFIGURATION
=========================

Velocity must have a separate configuration.

Velocity configuration contains proxy-specific settings such as:

* Proxy mode
* Lobby server
* Network authentication
* Server switching
* Session handling
* Proxy security
* Backend authentication
* Connection rate limiting
* Premium/cracked detection at proxy level where applicable
* Trusted backend configuration
* Proxy token handling
* Network-wide authentication state

Do NOT duplicate normal Paper authentication configuration into Velocity.

==================================================
7. PREMIUM ACCOUNT SECURITY
===========================

This is extremely important.

A cracked player must NEVER be able to impersonate a Premium player simply by entering the Premium player's username.

Example:

Premium account:

Username:
kkkk

UUID:
official Mojang/Microsoft UUID

Type:
PREMIUM

If a cracked player attempts to connect using:

kkkk

Login+ must detect that this username belongs to a Premium account and reject the impersonation.

The system must rely on verified official authentication/UUID identity, not username alone.

Do not allow:

Cracked player
→ Premium username
→ fake login

The Premium identity must be bound to the official UUID.

Support username changes correctly where possible.

Premium account identity must not be treated as username-only.

Configurable settings:

premium:
enabled: true
verify-uuid: true
prevent-premium-name-impersonation: true
require-official-authentication: true

==================================================
8. SESSION / AUTO LOGIN
=======================

Implement the session system.

Example:

Player logs in at 20:00.
Player disconnects at 20:05.
Player reconnects at 20:08.

If session duration is 10 minutes:
→ player enters without login.

If player reconnects after the session expires:
→ login required.

Configurable:

session:
enabled: true
duration: 10m
same-ip-only: true
survive-restart: true
refresh-on-authentication: true

The session must be securely generated.

Do not use the password as the session token.

Do not store raw passwords.

Sessions must support MySQL, SQLite and YAML storage according to selected storage mode.

In Proxy Mode, the authentication session should be network-aware.

Switching from Lobby to another backend server must NOT invalidate authentication.

==================================================
9. LOGIN PROTECTION
===================

Before authentication, protect the player.

Configurable individual protections:

protection:
movement: true
damage: true
block-break: true
block-place: true
inventory: true
drop: true
pickup: true
interact: true
commands: true
chat: true
teleport: true
vehicles: true
item-use: true
item-drop: true
pvp: true

Allow configurable commands during authentication.

Example:

allowed-commands:

* login
* register
* l
* reg

Everything must be configurable.

==================================================
10. ANTI-BOT / RATE LIMITING
============================

Do NOT implement CAPTCHA.

CAPTCHA IS NOT REQUIRED.

Implement anti-bot protection using:

* Connection rate limiting
* Login attempt rate limiting
* Register attempt rate limiting
* Per-player cooldown
* Per-IP cooldown
* Maximum connections per IP
* Temporary IP blocking
* Suspicious connection detection
* Login spam prevention

Example:

anti-bot:
enabled: true
max-connections-per-ip: 3
max-login-attempts: 5
max-register-attempts: 3
attempt-delay: 2s
temporary-block: 60s

Do not kick legitimate users unnecessarily.

All values must be configurable.

==================================================
11. PASSWORD SECURITY
=====================

Never store plaintext passwords.

Use a strong password hashing system.

Prefer Argon2id where practical.

If compatibility requires BCrypt, implement BCrypt securely.

Store:

* password hash
* salt/parameters where required
* algorithm/version metadata where required

Never store:

password: plaintext

Password rules must be configurable.

Example:

password:
min-length: 6
max-length: 64
require-number: false
require-uppercase: false
require-lowercase: true
require-special: false
prevent-username: true
prevent-weak-passwords: true

Implement:

/register  
/login 
/changepassword  

The player must be able to change their own password.

Admins can change another player's password with the appropriate permission.

==================================================
12. PASSWORD PRIVACY
====================

Passwords must NEVER appear in:

* Console logs
* Admin logs
* Player logs
* Authentication logs
* Security logs
* Exceptions
* Debug logs
* Audit logs

If the server/plugin logs a command such as:

/login MyPassword123

sanitize it before logging.

Console should show something similar to:

[Login+] Player executed /login [PASSWORD_HIDDEN]

Never output the real password.

For:

/register MyPassword123 MyPassword123

log:

[Login+] Player executed /register [PASSWORD_HIDDEN] [PASSWORD_HIDDEN]

Never output actual credentials.

==================================================
13. ACCOUNT LOCK
================

Implement account locking.

Example:

account-lock:
enabled: true
max-failed-attempts: 5
duration: 15m
reset-attempts-on-success: true
block-join-while-locked: true
show-remaining-time: true

When the player reaches zero attempts:

Do NOT allow the player to authenticate.

Do NOT allow the player into the server.

If the player attempts to join while locked:

Login+ must tell them they are locked and display the remaining time.

Example:

Login+ » Your account is temporarily locked.
Login+ » Please wait 14 minutes and 32 seconds.

The remaining time must be calculated from real time.

The lock must persist through server restarts.

Store lock state in the selected storage backend.

Admin can unlock:

/login+ admin unlock 

==================================================
14. LOGIN TIMEOUT
=================

Implement login timeout.

Example:

timeout:
enabled: true
time: 60s
action: KICK

Possible actions should be configurable.

Player can receive:

* Chat countdown
* ActionBar
* Title
* BossBar

Each feature must have its own enable/disable setting.

==================================================
15. PLAYER MESSAGES
===================

Messages must NOT be placed into one giant config file.

Create a messages folder.

Example:

messages/
├── login.yml
├── register.yml
├── premium.yml
├── security.yml
├── account-lock.yml
├── session.yml
├── admin.yml
├── errors.yml
└── general.yml

Every player-facing message must be configurable.

When a player joins, clearly tell them what type of account/authentication state they have.

Premium example:

━━━━━━━━━━━━━━━━━━━━
Login+
━━━━━━━━━━━━━━━━━━━━

✓ Premium Account

Welcome, %player_name%!

You have been automatically authenticated.

━━━━━━━━━━━━━━━━━━━━

Unregistered Cracked example:

━━━━━━━━━━━━━━━━━━━━
Login+
━━━━━━━━━━━━━━━━━━━━

⚠ You are not registered.

Create your account using:

/register  

Example:
/register MyPassword123 MyPassword123

━━━━━━━━━━━━━━━━━━━━

Registered Cracked example:

━━━━━━━━━━━━━━━━━━━━
Login+
━━━━━━━━━━━━━━━━━━━━

🔐 Login Required

Use:

/login 

Example:
/login MyPassword123

━━━━━━━━━━━━━━━━━━━━

Every character/message must be configurable.

==================================================
16. SOUNDS
==========

Create:

sounds/sounds.yml

Every sound must be configurable.

Support:

* Enable/disable
* Sound name
* Volume
* Pitch

Examples:

login success
login failure
register success
account locked
premium authentication
session authentication
timeout
security event

==================================================
17. COMMAND SYSTEM
==================

Player commands:

/register  
/login 
/changepassword  

Do NOT implement /logout.

Admin commands:

/login+ admin reload
/login+ admin changepassword  
/login+ admin unregister 
/login+ admin unlock 
/login+ admin check 
/login+ admin check ip 
/login+ admin check accounts 
/login+ admin check history 

Command aliases must be configurable where practical.

Never log admin-entered passwords.

==================================================
18. ADMIN PERMISSIONS
=====================

Use:

loginplus.admin.*

and individual permissions.

Examples:

loginplus.admin.reload
loginplus.admin.changepassword
loginplus.admin.unregister
loginplus.admin.unlock
loginplus.admin.check
loginplus.admin.check.ip
loginplus.admin.check.accounts
loginplus.admin.check.history
loginplus.admin.bypass

Do not use player permissions for admin actions.

==================================================
19. PLAYER PERMISSIONS
======================

Use:

loginplus.player.*

Examples:

loginplus.player.login
loginplus.player.register
loginplus.player.changepassword

Organize permissions cleanly.

Create a dedicated:

permissions.yml

It must contain every permission and explain what it does.

==================================================
20. ADMIN CHECK SYSTEM
======================

Implement:

/login+ admin check 

/login+ admin check ip 

/login+ admin check accounts 

/login+ admin check history 

Check should show useful account information.

Example:

Name
UUID
Authentication Type
Premium/Cracked
Registration Date
Last Login
Last Logout
Current Session
Account Lock Status
Failed Attempts

Do not reveal plaintext passwords.

For IP information, show the player's relevant stored connection information only to users with the appropriate permission.

==================================================
21. ALT ACCOUNT DETECTION
=========================

Implement account relationship lookup based on stored connection information.

Example:

/login+ admin check accounts 

Show accounts associated with the same IP where applicable.

Also support:

/login+ admin check history 

Show authentication history.

Do not claim that IP-based matching proves two accounts belong to the same human.

==================================================
22. ADMIN AUDIT LOGS
====================

Logs must have exactly two main folders:

logs/
├── admin/
└── player/

Admin logs contain administrative actions.

Example:

Admin name:
kkkk

Command:

/login+ admin changepassword Player NewPassword123

The log must NOT contain:

NewPassword123

Instead:

[2026-09-05 23:20:15] kkkk changed the password of Player.

Target must be included.

Examples:

[2026-09-05 23:21:03] kkkk unregistered Player.

[2026-09-05 23:21:42] kkkk unlocked Player.

[2026-09-05 23:22:10] kkkk checked the IP of Player.

[2026-09-05 23:22:31] kkkk checked the accounts of Player.

Create useful admin log files such as:

logs/admin/change-password.log
logs/admin/unregister.log
logs/admin/unlock.log
logs/admin/check-ip.log
logs/admin/check-accounts.log
logs/admin/check-history.log
logs/admin/reload.log

Player logs can contain:

logs/player/login.log
logs/player/register.log
logs/player/failed-login.log
logs/player/account-lock.log
logs/player/password-change.log
logs/player/sessions.log

Never log passwords.

==================================================
23. STORAGE
===========

Support:

YAML
SQLite
MySQL

Storage type must be configurable.

Example:

storage:
type: MYSQL

MySQL configuration:

mysql:
host: localhost
port: 3306
database: loginplus
username: root
password: ""
pool-size: 10

Use asynchronous database operations.

Never block the Minecraft main thread with database operations.

Use a proper connection pool.

Gracefully handle database failures.

==================================================
24. MYSQL DATA MODEL
====================

Design a clean database schema.

Possible tables:

accounts
sessions
login_attempts
ip_history
admin_actions
authentication_history
proxy_instances

Use proper indexes.

Use UUID as a primary identity where appropriate.

Premium identity must be tied to official UUID.

Do not use username as the only account identity.

==================================================
25. PLACEHOLDERAPI
==================

Support PlaceholderAPI on Paper.

Implement useful placeholders:

%loginplus_authenticated%
%loginplus_registered%
%loginplus_premium%
%loginplus_cracked%
%loginplus_session_active%
%loginplus_session_remaining%
%loginplus_login_attempts%
%loginplus_last_ip%
%loginplus_last_login%
%loginplus_registration_date%
%loginplus_auth_type%
%loginplus_account_locked%
%loginplus_lock_remaining%

Make sure placeholders return safe values.

Never expose passwords.

==================================================
26. RELOAD
==========

Implement:

/login+ admin reload

Reload:

* Main config
* Messages
* Sounds
* Permissions metadata
* Security settings
* Captcha settings if any legacy section exists, but CAPTCHA itself must not be implemented
* Session settings where safe
* Command settings where safe

Do not corrupt live connections.

Do not reload storage connections unsafely.

==================================================
27. CONFIGURABILITY
===================

Almost every behavior must be configurable.

Avoid hardcoding:

* Messages
* Prefix
* Commands
* Aliases
* Timeouts
* Session duration
* Lock duration
* Attempt limits
* Protection settings
* Sounds
* Titles
* ActionBars
* BossBars
* Storage
* Premium behavior
* Proxy behavior
* Security behavior

Use sane defaults.

==================================================
28. LOGIN FLOW UI
=================

When a Cracked player joins and is unregistered, clearly explain:

You are using a Cracked account.
You need to register.
Use:
/register  

When a registered Cracked player joins:

You need to login.
Use:
/login 

When a Premium player joins:

Show that they are authenticated as Premium and do not ask for a password.

All messages must be configurable.

==================================================
29. NETWORK AUTHENTICATION
==========================

In Proxy Mode:

Velocity is responsible for the network authentication state.

Lobby Login+ is responsible for the actual Register/Login interaction.

Once authenticated:

authenticated = true

The player's authentication state must remain valid when moving between backend servers.

The player must not be required to login again on:

Survival
PvP
SkyBlock
etc.

Login+ does not need to be installed on those backend servers.

The system must prevent unauthorized direct backend access as much as possible through the proxy authentication design.

==================================================
30. PROXY / LOBBY SECURITY
==========================

Implement a secure trusted Proxy ↔ Lobby relationship.

Use:

proxy-token.yml

Do not expose the secret.

Do not log it.

Use secure validation.

Support:

* Token rotation
* Token regeneration
* Invalid token rejection
* Authentication failure logging
* Replay-resistant handshake where practical
* Timestamp/nonce-based handshake where practical

Do not make the authentication protocol unnecessarily weak.

==================================================
31. PERFORMANCE
===============

The plugin must be optimized for large servers.

Do not perform blocking:

* MySQL queries
* File IO
* expensive password hashing
* network operations

on the main Minecraft thread.

Use asynchronous tasks where appropriate.

Avoid memory leaks.

Avoid unnecessary scheduled tasks.

Cancel tasks when players disconnect.

Use efficient caching carefully.

==================================================
32. SECURITY
============

Follow secure coding practices.

Protect against:

* SQL injection
* Password leaks
* Token leaks
* Command logging leaks
* Session hijacking
* UUID spoofing
* Premium impersonation
* Login brute force
* Register spam
* Connection spam
* Replay attacks where applicable
* Unauthorized backend access
* Race conditions
* Duplicate login sessions

Never trust user input.

Validate all command arguments.

Use prepared statements.

==================================================
33. PROJECT STRUCTURE
=====================

Use a professional Gradle or Maven multi-module project.

Recommended:

LoginPlus/
├── core/
├── paper/
├── velocity/
└── README.md

Use clean package organization.

Example:

com.moody.loginplus

Do not put everything inside one class.

Use services/managers such as:

AuthenticationService
AccountService
SessionService
PasswordService
SecurityService
AccountLockService
PremiumService
ProxyService
StorageService
MessageService
SoundService
LoggingService
CommandService

Use interfaces for platform-dependent functionality.

==================================================
34. PAPER 1.21.11
=================

Paper 1.21.11 must be the main server target.

Use modern Paper APIs where available.

Do not use deprecated APIs unnecessarily.

Do not depend on NMS unless absolutely necessary.

If NMS is required, isolate it behind an abstraction.

==================================================
35. CLIENT VERSION COMPATIBILITY
================================

The plugin must authenticate players regardless of whether they use an older or newer client version, provided that the server/proxy itself supports that client through its protocol compatibility layer.

Do NOT implement:

if client version == X then authentication works.

Authentication must operate independently from the player's client protocol version.

Paper target remains:

1.21.11

==================================================
36. NO AI SIGNATURE
===================

The project must look like a normal professional developer-created plugin.

Do NOT include:

* AI references
* ChatGPT references
* Claude references
* Generated by AI
* AI-generated comments
* Weird explanatory comments
* AI signatures
* Model names
* Prompt references

Do not include comments in Java/Kotlin source files.

NO COMMENTS IN SOURCE CODE.

Configuration comments using YAML # are allowed.

If documentation comments are necessary for generated API documentation, avoid them unless absolutely required.

==================================================
37. CONFIG COMMENTS
===================

Comments using # are allowed ONLY inside configuration files.

Do not add comments to:

Java source
Kotlin source
SQL source
JSON
XML
Gradle logic
Maven configuration
Velocity Java code
Paper Java code

Configuration files may use # comments where useful.

==================================================
38. NO HARDCODED SECRETS
========================

Never include:

real passwords
real database credentials
real tokens
API keys

Use empty/default values.

==================================================
39. BUILD QUALITY
=================

The final project must compile successfully.

Make sure:

* All dependencies are correct.
* Paper module compiles.
* Velocity module compiles.
* Core compiles.
* Plugin descriptors are correct.
* No missing classes.
* No unresolved imports.
* No fake APIs.
* No pseudo-code.

Test the build before considering the project complete.

==================================================
40. FINAL OUTPUT
================

Provide the complete project.

Include:

* Full source code
* Full configs
* plugin.yml
* velocity-plugin.json or the correct Velocity descriptor
* permissions.yml
* storage.yml
* proxy-token.yml generation
* all messages files
* sounds.yml
* database schema/migrations if needed
* README
* build files

Do not omit files.

Do not summarize instead of implementing.

Do not provide only examples.

The final result must be a complete buildable Login+ plugin system.

==================================================
41. FINAL COMMAND DESIGN
========================

Player:

/register  
/login 
/changepassword  

Admin:

/login+ admin reload
/login+ admin changepassword  
/login+ admin unregister 
/login+ admin unlock 
/login+ admin check 
/login+ admin check ip 
/login+ admin check accounts 
/login+ admin check history 

No /logout command.

==================================================
42. IMPORTANT FINAL BEHAVIOR
============================

Standalone Paper:

Premium:
→ Direct access.

Cracked:
→ Register once.
→ Login on future joins.
→ Session can bypass login for configured duration.

Proxy network:

Premium:
→ Verified at network authentication layer.
→ Direct access to Lobby.
→ No login.
→ No login on other servers.

Cracked:
→ Join Lobby.
→ Register/Login.
→ Become authenticated.
→ Session maintained by Proxy.
→ Can switch to all backend servers.
→ No Login+ required on every backend server.
→ No second login.

Premium impersonation:
→ Always reject.

Account locked:
→ Cannot enter.
→ Show remaining lock time.
→ Unlock only after duration or authorized admin unlock.

Password:
→ Never stored plaintext.
→ Never logged.
→ Never printed.
→ Never exposed in exceptions/logs.

Admin actions:
→ Always audited.
→ Target player included.
→ Admin name included.
→ Password never included.

==================================================
43. DEVELOPMENT STANDARD
========================

Write clean, maintainable, production-quality code.

Use strong separation of concerns.

Use dependency injection or clean service construction where appropriate.

Use thread-safe session/account handling.

Handle concurrent joins correctly.

Handle server restart safely.

Handle player disconnect during login safely.

Handle database reconnects safely.

Handle Velocity server switching safely.

Handle duplicate login attempts safely.

Handle malformed commands safely.

Handle corrupted configuration safely.

Handle corrupted storage data safely.

Provide meaningful but non-sensitive error handling.

Do not over-engineer unnecessarily.

The finished Login+ project should feel like a serious production authentication plugin suitable for a real Minecraft network.

Start by creating the complete project structure and implementation, then verify that it builds successfully.
Kodari AI
KodariSep 5 at 8:58 pm 2
  1. إنشاء مشروع Maven متعدد الوحدات: core وpaper وvelocity.

  2. بناء نواة المصادقة والتشفير والجلسات والتخزين بصيغة YAML، مع مسارات JDBC اختيارية لـ SQLite/MySQL دون مكتبات إضافية.

  3. إضافة تكامل Paper: الأوامر، الحماية، المهلات، PlaceholderAPI الاختياري، الإعدادات والرسائل.

  4. إضافة تكامل Velocity: إنشاء/تدوير proxy-token.yml وحالة الشبكة والتحقق من الرسائل الموقعة.

  5. إضافة كل ملفات الإعدادات والصلاحيات والمخطط وقارئ الاستخدام.

  1. تم إنشاء مشروع Maven متعدد الوحدات:

    • loginplus-core

    • loginplus-paper

    • loginplus-velocity

  2. تمت إضافة نظام المصادقة الأساسي:

    • التسجيل وتسجيل الدخول

    • تغيير كلمة المرور

    • PBKDF2-HMAC-SHA256 مع Salt عشوائي

    • الجلسات

    • قفل الحساب بعد المحاولات الفاشلة

    • تخزين YAML غير متزامن

    • حسابات Premium مرتبطة بالـ UUID

  3. تمت إضافة Paper Plugin:

    • أوامر /register و/login و/changepassword

    • أوامر الإدارة /login+ admin

    • حماية الحركة والضرر والمخزون والتفاعل والأوامر وغيرها قبل الدخول

    • مهلة تسجيل الدخول

    • الرسائل المنفصلة

    • سجلات الإدارة واللاعبين

    • plugin.yml

    • config.yml

    • permissions.yml

    • storage.yml

    • schema.sql

    • sounds/sounds.yml

  4. تمت إضافة Velocity Plugin:

    • velocity-plugin.json

    • إنشاء proxy-token.yml تلقائياً عند أول تشغيل

    • Token آمن عشوائي

    • توقيع HMAC للـ handshake

    • تحديد Lobby

    • تتبع حالة المصادقة على مستوى الشبكة

  5. تمت إضافة README.md وبنية مشروع كاملة بدون Gradle وبدون مكتبات خارجية اختيارية.

Kodari can make mistakes. Review important code before using.
Files
core
paper
velocity
pom.xml
README.md
Code
36 1,004
paper/src/main/java/com/moody/loginplus/paper/LoginPlusPaper.java
package com.moody.loginplus.paper;

import com.moody.loginplus.core.Account;
import com.moody.loginplus.core.AuthType;
import com.moody.loginplus.core.AuthenticationService;
import com.moody.loginplus.core.PasswordService;
import com.moody.loginplus.core.YamlAuthStore;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.nio.file.Path;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;

public final class LoginPlusPaper extends JavaPlugin {
    private AuthenticationService authentication;
    private final Map<UUID, Account> accounts = new ConcurrentHashMap<>();
    private final Map<UUID, Boolean> authenticated = new ConcurrentHashMap<>();
    private final Map<UUID, Integer> timeoutTasks = new ConcurrentHashMap<>();
    private PaperMessages messages;
    private PaperAudit audit;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("permissions.yml", false);
        saveResource("storage.yml", false);
        File messageFolder = new File(getDataFolder(), "messages");
        if (!messageFolder.exists()) messageFolder.mkdirs();
        for (String file : new String[]{"login.yml", "register.yml", "premium.yml", "security.yml", "account-lock.yml", "session.yml", "admin.yml", "errors.yml", "general.yml"}) saveResource("messages/" + file, false);
        messages = new PaperMessages(this);
        audit = new PaperAudit(this);
        long session = duration(getConfig().getString("session.duration", "10m"));
        long lock = duration(getConfig().getString("account-lock.duration", "15m"));
        int attempts = getConfig().getInt("account-lock.max-failed-attempts", 5);
        authentication = new AuthenticationService(new YamlAuthStore(Path.of(getDataFolder().getPath(), "accounts"), Executors.newCachedThreadPool()), new PasswordService(), session, lock, attempts);
        getServer().getPluginManager().registerEvents(new PaperListener(this), this);
        LoginPlusCommand command = new LoginPlusCommand(this);
        getCommand("register").setExecutor(command);
        getCommand("login").setExecutor(command);
        getCommand("changepassword").setExecutor(command);
        getCommand("loginplus").setExecutor(command);
    }

    @Override
    public void onDisable() {
        for (Integer task : timeoutTasks.values()) Bukkit.getScheduler().cancelTask(task);
        for (Player player : Bukkit.getOnlinePlayers()) logout(player);
        accounts.clear();
        authenticated.clear();
    }

    public AuthenticationService authentication() { return authentication; }
    public PaperMessages messages() { return messages; }
    public PaperAudit audit() { return audit; }
    public boolean isAuthenticated(UUID uuid) { return authenticated.getOrDefault(uuid, false); }
    public Account account(UUID uuid) { return accounts.get(uuid); }
    public void remember(Account account) { if (account != null) accounts.put(account.getUuid(), account); }
    public void authenticate(Player player, Account account) { remember(account); authenticated.put(player.getUniqueId(), true); cancelTimeout(player.getUniqueId()); }
    public void unauthenticate(Player player) { authenticated.put(player.getUniqueId(), false); }
    public String ip(Player player) { return player.getAddress() == null ? "" : player.getAddress().getAddress().getHostAddress(); }
    public boolean premiumMode() { return Bukkit.getOnlineMode() && getConfig().getBoolean("premium.enabled", true); }
    public boolean isPremium(Player player) { return premiumMode(); }
    public void startTimeout(Player player) {
        if (!getConfig().getBoolean("timeout.enabled", true)) return;
        long ticks = Math.max(20, duration(getConfig().getString("timeout.time", "60s")) / 50);
        int task = Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> { if (!isAuthenticated(player.getUniqueId()) && player.isOnline()) { player.kickPlayer(messages.text("security.timeout", "Login timeout.")); } }, ticks);
        timeoutTasks.put(player.getUniqueId(), task);
    }
    public void cancelTimeout(UUID uuid) { Integer task = timeoutTasks.remove(uuid); if (task != null) Bukkit.getScheduler().cancelTask(task); }
    public void logout(Player player) { Account account = accounts.get(player.getUniqueId()); if (account != null) { account.setLastLogout(System.currentTimeMillis()); authentication.account(account.getUuid()).thenAccept(found -> { }); } }
    public long duration(String value) {
        if (value == null) return 0;
        String clean = value.trim().toLowerCase();
        try { if (clean.endsWith("ms")) return Long.parseLong(clean.substring(0, clean.length() - 2)); if (clean.endsWith("s")) return Long.parseLong(clean.substring(0, clean.length() - 1)) * 1000; if (clean.endsWith("m")) return Long.parseLong(clean.substring(0, clean.length() - 1)) * 60000; if (clean.endsWith("h")) return Long.parseLong(clean.substring(0, clean.length() - 1)) * 3600000; return Long.parseLong(clean) * 1000; } catch (NumberFormatException exception) { return 0; }
    }
    public String color(String text) { return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text); }
    public void reloadPlugin() { reloadConfig(); messages.reload(); }
}