StorageManager and ExtendedDataStore
listings.yml (sync) and market-data.yml (async, atomic write) — listings, outbox, history.
Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.
Two stores, two files. Listings live in StorageManager. History, mailbox, favorites, alerts, and ratings — in ExtendedDataStore.
StorageManager — listings.yml
File: plugins/GrzybcioRynek/listings.yml. Write is synchronous (dataConfig.save).
YAML keys:
| Key | Contents |
|---|---|
listings | list of MarketListing |
next-id | next ID (max of file and listings) |
expiry-outbox.<id> | expired return journal (seller, item, price, reason) |
pending-returns.<uuid> | item queue when mailbox disabled / legacy |
pending-sales.<uuid> | sale notifications for offline players |
API
| Method | Action |
|---|---|
createListing(...) | nextId++, add, save() |
removeListing(int) | remove, save() |
restoreListing(listing) | restore after failed buy (same ID) |
getListing / getAllListings / getListingsBySeller | in-memory read |
returnListingToSeller(listing, reason) | inventory or mailbox |
backupListings() | copy listings.yml.bak (REPLACE_EXISTING) |
removeExpiredListings() | under globalLock, skips reserved |
processExpiryOutbox() | delivers journal |
addPendingSaleNotification / deliverPendingSaleNotifications | notifications by UUID |
deliverPendingReturns | pending-returns per-item (save before give) |
addPendingReturnPublic is used when mailbox.enabled: false and the seller is offline (MailboxService.deposit).
Expiry outbox
So a crash does not lose the item: first write expiry-outbox.<id>, then remove the listing in the same save(), then processExpiryOutbox. Outbox clears the entry before delivery; if online + inventory space — expiry.returned, otherwise mailbox.
Timer: startup + every 30 minutes.
Write errors
Nie można utworzyć pliku listings.yml!
Nie można zapisać pliku listings.yml!
Nie udało się utworzyć backupu listings.yml: <msg>
Pominięto oferte #<id> - brak przedmiotu.
Nie udalo sie wczytac oferty ze starszego formatu: <msg>ExtendedDataStore — market-data.yml
File: plugins/GrzybcioRynek/market-data.yml. Mutations call saveAsync() → runTaskAsynchronously → synchronized save().
Atomic write: market-data.yml.tmp → Files.move(..., ATOMIC_MOVE), fallback plain move, finally direct data.save.
YAML sections: favorites.<uuid>, mailbox.<uuid>, alerts.<uuid>, ratings, transactions.
API (selected)
| Method | Action |
|---|---|
toggleFavorite / removeFavoriteEverywhere | favorites by listing ID |
addMailbox / takeMailboxEntry / restoreMailboxEntry | mailbox atomically |
addAlert / removeAlert / getAllAlerts | alerts (limit price-alerts.max-per-player) |
addRating / hasRated / getAverageRating | ratings 1–5 |
addTransaction / updateTransaction / getTransaction | TX by string-ID |
getCompletedTransactions | only TransactionState.COMPLETED |
getBuyerHistory / getSellerHistory | sorted descending by time |
getPriceHistory(material, nexoId, oraxenId) | identity: Nexo first, then Oraxen, then material |
pruneHistory() | removes COMPLETED older than history.retention-days (default 30) |
flushAndSave() | synchronous save (reload) |
backup() | market-data.yml.bak |
MarketAPI.getCompletedTransactions() / getTransaction(String) read this store.
Write errors
Nie można utworzyć market-data.yml
Nie można zapisać market-data.yml: <msg>
Nie udało się utworzyć backupu market-data.yml: <msg>
Pominięto transakcję: <msg>listings.yml is compatible with the older Map format. market-data.yml appeared in 1.0.3.