Skip to content
In DevelopmentInfrastructure
Offline

CrownTrade Economy

526 classes. 7 phases. A complete economic system.

CrownTrade Economy
526
Classes
75000+
Lines of Code
7
Development Phases
88
DB Tables
169
GUI Classes
50
Services

Starting Point
C

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.

Implementation
C

1

Architecture design with strict 4-layer separation: Commands/GUIs → Services → Repositories → Database. Each layer has clear responsibilities.

2

Implement core economy with atomic transfers: UUID-sorted locking prevents deadlocks, every transaction is logged in the ledger.

3

Build company system with GUI wizard: founding, inventory with Base64 NBT serialization, roles/permissions system, automatic salary payments.

4

Close economic cycles: tax system with state treasury, government jobs, insurance as money sinks, bot system against deflation.

5

Endgame features: stock market with IPOs and dividends, quest system, private warps — incrementally activatable via feature flags.

Functions
C

1
Player AccountsDECIMAL(15,2) precision, immutable history
Atomic TransfersDeadlock-safe through UUID-sorted locking
Vault IntegrationUniversal compatibility with all shop plugins
Transaction LedgerComplete logging of every money movement
Hourly IncomeConfigurable online income with daily cap
Login BonusesStreak tracking with daily rewards
2
Company FoundingGUI wizard: Name → Icon → Description → Confirmation
Inventory ManagementBase64 NBT serialization, paginated storefront
Roles & PermissionsOwner/Manager/Employee with per-member ACLs
Salary SystemDaily to monthly intervals, automatic payouts
Company Leveling5 tiers from Startup to Corporation, XP-based
AdvertisingBooking system with chat broadcasts and expiry dates
3
Trade GUISplit inventory with bilateral confirmation
Item OrdersPlayers order items from companies
Service OrdersBook-based descriptions, company catalog
Bot SystemVirtual buyers with daily budget against deflation
4
Tax System5% shop, 2% trade, 3% orders → state treasury
State TreasuryCollects taxes and upkeep fees
Government JobsState contracts with salary and quotas
5
5 Policy TypesKeep-inventory, company stability, trade protection, XP protection
Claims ManagementUsage tracking and automatic expiration
Death ListenerPrevents item/XP loss with active policy
6
Private Warps1 free + 4 purchasable (2k–25k€), monthly maintenance
Public WarpsOwner sets fee (10–10,000€)
Daily QuestsAuto-generated: Kill/Farm/Mine/Craft with rewards
7
IPOsCompanies go public, sell shares
Stock TradingBuy/sell at market price
DividendsAutomatic distribution based on company profits
PortfolioOverview of all holdings per player

Technical Details
C

Strict 4-layer architecture: Commands/GUIs → Services → Repositories → Database. Every architectural decision serves thread safety and scalability.

TechnologyPurpose
Paper APIPaper API
Java 21Java 21
MariaDBDatabase
HikariCPHikariCP
VaultEconomy API
PlaceholderAPIPlaceholder system
LuckPermsLuckPerms

UUID-Sorted Locking

Transfers lock accounts in deterministic order (UUID comparison). Prevents deadlocks regardless of transfer direction — the classic dining philosophers problem, solved through consistent lock ordering.

Async DB / Sync UI

All database operations run asynchronously (runTaskAsynchronously), all UI updates synchronously (runTask). Prevents server hangs on slow queries, guarantees thread-safe inventory operations.

Base64 NBT Serialization

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.

Dual Database Support

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.

GUI Manager with Debouncing

Central GuiManager (ConcurrentHashMap) routes clicks to specific GUI handlers. 200ms click cooldown prevents double purchases. Automatic cleanup on player quit against memory leaks.

Status
C

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.

7
Development phases completed
526
Java classes
88
Database tables
0
Race conditions

Learnings

1UUID-sorted locking solves the deadlock problem for financial transfers elegantly — but only if EVERY transfer takes the same path. A single unsorted lock is enough for a deadlock.
2Paper plugin classloader requires explicit Class.forName() for JDBC drivers before HikariCP — the usual ServiceLoader mechanism doesn't work in the plugin context.
3GUI clicks in Minecraft are not idempotent: without debouncing, players accidentally buy double during lag. 200ms cooldown has proven to be the sweet spot.

Roadmap
C

NowActive
Stabilization & TestingCompany Mergers & AcquisitionsGuild System with Shared Treasury
Next
Credit System with InterestServer ShopRank System with Prestige
Later
Casino & GamblingBounty System