
526 classes. 7 phases. A complete economic system.
Minecraft economy plugins are limited to simple account balances. No system models real economic cycles — companies, trading, taxes, insurance, stock market. A network with a realistic economy needs more than a wallet.
The technical requirements go far beyond standard plugins: thread-safe financial transactions that cause no race conditions or deadlocks. GUI systems that don't crash under load. Database architecture that works across servers.
And everything must remain compatible: Vault as the universal interface, existing shop plugins must not break, and the system must run with both MariaDB and standalone with SQLite.
Architecture design with strict 4-layer separation: Commands/GUIs → Services → Repositories → Database. Each layer has clear responsibilities.
Implement core economy with atomic transfers: UUID-sorted locking prevents deadlocks, every transaction is logged in the ledger.
Build company system with GUI wizard: founding, inventory with Base64 NBT serialization, roles/permissions system, automatic salary payments.
Close economic cycles: tax system with state treasury, government jobs, insurance as money sinks, bot system against deflation.
Endgame features: stock market with IPOs and dividends, quest system, private warps — incrementally activatable via feature flags.
Strict 4-layer architecture: Commands/GUIs → Services → Repositories → Database. Every architectural decision serves thread safety and scalability.
Transfers lock accounts in deterministic order (UUID comparison). Prevents deadlocks regardless of transfer direction — the classic dining philosophers problem, solved through consistent lock ordering.
All database operations run asynchronously (runTaskAsynchronously), all UI updates synchronously (runTask). Prevents server hangs on slow queries, guarantees thread-safe inventory operations.
Items are stored as Base64-encoded NBT in the database instead of physical chests. Server-independent, backup-capable, multi-server compatible — one LONGTEXT field per item.
MariaDB for production (HikariCP pool, 10 connections, leak detection). SQLite as fallback for single servers — WAL mode, no external dependencies. Same repository interfaces, no code branching.
Central GuiManager (ConcurrentHashMap) routes clicks to specific GUI handlers. 200ms click cooldown prevents double purchases. Automatic cleanup on player quit against memory leaks.
CrownTrade Economy encompasses 526 Java classes across 7 development phases: from simple account balances to full stock market trading with IPOs and dividends.
The architecture has proven itself under load: zero race conditions thanks to deterministic locking, zero memory leaks thanks to central GUI management, zero data loss thanks to atomic transactions.