GrzybcioRynek

Transactions

Full MarketManager.buyItem cycle — states, rollback, and error strings.

Compatible with: GrzybcioRynek 1.0.3Minecraft 26.2Web 0.1.0

Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.

Purchase is GUI only: Detail (slot 11) → Confirm. There is no /market buy. Payment: Vault by UUID. Class: MarketManager.buyItem. Transaction: MarketTransaction (UUID string).

transactions.logging: true logs steps to the server console.

States (TransactionState)

CREATED → LISTING_RESERVED → MONEY_WITHDRAWN → SELLER_PAID → ITEM_DELIVERED → COMPLETED ↘ ROLLED_BACK ↘ FAILED
StateMeaning
CREATEDTX object created, listing still in storage
LISTING_RESERVEDListing removed from market (removeListing)
MONEY_WITHDRAWNPrice withdrawn from buyer
SELLER_PAIDSeller paid price - fee
ITEM_DELIVEREDItem added to inventory / overflow to mailbox
COMPLETEDSaved in market-data.yml; history, ratings, refund
ROLLED_BACKRollback or admin refund
FAILEDError with error field

Purchase cycle

  1. Reserve IDreservedListings.add(listingId). Second buyer: buy.listing-locked.
  2. Validation (under globalLock):
    • listing exists — else buy.not-available
    • not own — buy.own-listing
    • AntiAbuseManager.canPurchase
    • price finite and > 0
    • VaultHook.has(buyer, price)buy.not-enough-money
    • recreateItem is not AIRbuy.not-available
    • InventoryUtil.canFitbuy.inventory-full
  3. TX UUID, state CREATED.
  4. Remove listing → LISTING_RESERVED. Error: LISTING_REMOVE_FAILED. Favorites for that ID cleared.
  5. Buyer withdrawMONEY_WITHDRAWN. Error: WITHDRAW_FAILED, restore listing.
  6. Seller deposit (price - fee) → SELLER_PAID. Error: SELLER_DEPOSIT_FAILED, refund buyer money, restore listing.
  7. Fee to market-fee.sink-account if non-empty. Failed sink = warning in log, transaction does not fail.
  8. addItem to buyer; remainder → mailbox purchase-overflowITEM_DELIVERED.
  9. COMPLETED, addTransaction (always, regardless of history.enabled), markPurchased, buy.success, seller notification (buy.seller-notified / pending-sales when offline).
  10. TransactionCompletedEvent. When ratings.enabled — rating prompt on chat.
  11. finally: clear ID reservation.

Rollback (rollbackBuy)

Called on exception when TX is not yet committed.

State at exceptionAction
ITEM_DELIVERED or COMPLETEDLeave as COMPLETED, save TX. Do not reverse money (avoid minting money + item).
SELLER_PAIDClaw-back from seller, refund buyer, restore listing → ROLLED_BACK. If claw-back fails: ROLLBACK_SELLER_WITHDRAW_FAILED, no buyer refund.
MONEY_WITHDRAWNRefund buyer + restore listing → ROLLED_BACK
LISTING_RESERVEDRestore listing → ROLLED_BACK
OtherEXCEPTION_AFTER_<STATE>FAILED
Exception in rollbackROLLBACK_FAILED:<msg>

Error strings (transaction.error)

StringWhen
LISTING_REMOVE_FAILEDFailed to remove listing
WITHDRAW_FAILEDVault did not withdraw buyer money
SELLER_DEPOSIT_FAILEDVault did not deposit to seller
ROLLBACK_SELLER_WITHDRAW_FAILEDSeller claw-back failed
ROLLBACK_FAILED:<msg>Exception in rollback
EXCEPTION_AFTER_<STATE>Exception in unhandled state
REFUND:<timestamp>Admin /market admin refund (then state ROLLED_BACK)

Admin refund

/market admin refund <tx-id> [reclaim] — only COMPLETED without a prior REFUND:.

  • Withdraws sellerReceived from seller (or nothing when 0).
  • Deposits that amount to buyer (or full price when sellerReceived was 0).
  • Option reclaim: tries to take item from buyer (if online) and puts a copy in seller mailbox with reason admin-refund.

History vs flag

Every completed TX is saved always. history.enabled only disables the /market history command. history.retention-days removes only records in state COMPLETED older than the threshold. ROLLED_BACK / FAILED remain.

What is missing

  • Buy command.
  • Partial stack purchase.
  • Vault nick fallback — deposit by UUID.