### Added
- **Virtual Delivery System:** When purchasing items that exceed inventory capacity, overflow items are automatically sent to a pending delivery queue instead of being lost.
- SQLite-based delivery storage (`deliveries.db`) with transaction safety to prevent race conditions and duplication exploits.
- FIFO (First-In-First-Out) claiming with per-material tracking.
- Automatic database-first claiming approach prevents item duplication on logout/crash.
- Configurable settings: `delivery.enabled`, `delivery.auto-claim-on-login`, `delivery.max-pending-per-player`.
- **Market GUI Integration:** Access deliveries directly from the market interface.
- Ender Chest button in slot 51 displays pending item count badge.
- Full deliveries panel with material breakdown and claim buttons.
- Left-click to claim all of a material, right-click to claim one stack.
- "Claim All" button (slot 49) for bulk claiming with progress feedback.
- **Delivery Commands:** Console and command-block support for delivery system.
- `/market delivery list` - View pending deliveries with formatted output.
- `/market delivery claim <material> [amount]` - Claim specific items.
- `/market delivery claim-all` - Claim all pending deliveries.
- `/market delivery gui` - Open market GUI directly to deliveries panel.
- **Web API Endpoints:** Full delivery system integration for web dashboard.
- `GET /api/deliveries` - List pending deliveries (returns `{enabled, deliveries, total}`).
- `POST /api/deliveries/claim` - Claim deliveries (body: `{material?, amount?}` for specific or all).
- Updated `/docs` endpoint with delivery API documentation.
- **Enhanced Configuration Documentation:** Comprehensive inline comments in `config.yml` explaining delivery system settings with pros/cons and recommendations (200+ lines of documentation).
### Fixed
- **Critical:** Fixed buy loop bug where purchasing 64 items would only deliver 1 on 1.20.1 servers. Buy logic now properly calculates overflow and sends all excess items to delivery in a single operation.
### Security
- **Race Condition Protection:** Atomic transactions in `addPending()` with `conn.autoCommit=false` prevent concurrent purchases from exceeding `max-pending-per-player` limit.
- **Duplication Prevention:** Database-first approach in `claimMaterial()` removes items from database before giving to player, preventing logout duplication exploits.
- **Transaction Safety:** All delivery database operations wrapped in explicit try-catch with rollback to prevent data corruption on errors.
### Technical
- `DeliveryManager` class (426 lines) handles all delivery operations with SQLite backend.
- Per-player delivery limits with atomic transaction checks.
- Inventory capacity calculation accounts for partial stacks and empty slots.
- Delivery system fully integrated into existing buy/sell flow in `MarketCommand` and `WebServer`.
### Upgrade Notes
- **Database:** New `deliveries.db` created automatically on first launch with delivery system enabled.
- **Config:** Three new keys added with defaults (see `config.yml` for full documentation):
- `delivery.enabled: true` - Enable/disable delivery system.
- `delivery.auto-claim-on-login: false` - Automatically attempt to claim deliveries on player join.
- `delivery.max-pending-per-player: 100000` - Maximum items that can be pending per player.
- **No Breaking Changes:** Existing functionality unchanged. Delivery system activates only when inventory is full during purchase.
- **Migration:** Update from 1.3.1 is seamless. No data migration required.
### Acknowledgments
- Continued thanks to ChunkCraft server for detailed bug reporting and testing feedback throughout v1.4.0 development!