Skip to content

Pay market sales to the selling character - #31

Merged
ryanbarlow97 merged 3 commits into
mainfrom
feat/character-ledger
Oct 12, 2026
Merged

ryanbarlow97 merged 3 commits into
mainfrom
feat/character-ledger

Conversation

@ryanbarlow97

Copy link
Copy Markdown
Contributor

Market sales now credit the selling character's pouch through Denars.earn, with tax in the same posting. A player with no active character keeps their items. Refused or unavailable payments do not consume goods.

Each sale saves and fsyncs its operation ID, captured character, gross cents and inventory plan before posting. Duplicate click callbacks cannot sell another batch. Interrupted intents remain on disk and block new sales until staff reconcile the ledger and items; this deliberately does not promise crash-atomic Minecraft inventories. Retrying an existing intent uses the stored ledger result even if tax policy changed.

Requires DenarEconomy 0.3.0 (TF-Minecraft/DenarEconomy#38) and TLibs 2.4.0. The 0.3.0 artifact is currently a local build, not a release: GitHub dependency installation is expected to fail until the coordinated provider release. Keep this draft with the stage 5 set; do not release it independently.

Validation: tfmc-mvn -o -B --no-transfer-progress clean verify on CachyOS passes all 146 tests and the zero-missed-lines coverage gate. Tests use real SQLite ledgers and cover tax, refusals, no session, callback retries, interrupted postings, preserved intent files and changed inventory.

Docs: TF-Minecraft/Docs#197
Stage 5: TF-Minecraft/RPCharacters#89

ryanbarlow97 and others added 2 commits October 12, 2026 18:15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b34d45a5-00da-41e0-b691-69c8b60b4daa

📥 Commits

Reviewing files that changed from the base of the PR and between a0f54d6 and e2190ce.


📒 Files selected for processing (9)
  • pom.xml
  • src/main/java/net/tfminecraft/marketblock/manager/TradeManager.java
  • src/main/java/net/tfminecraft/marketblock/trade/MarketSale.java
  • src/main/java/net/tfminecraft/marketblock/util/InventoryUtils.java
  • src/main/java/net/tfminecraft/marketblock/util/SaleTake.java
  • src/test/java/net/tfminecraft/marketblock/TestMoney.java
  • src/test/java/net/tfminecraft/marketblock/manager/TradeManagerTest.java
  • src/test/java/net/tfminecraft/marketblock/trade/MarketSaleTest.java
  • src/test/java/net/tfminecraft/marketblock/util/InventoryUtilsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Summary

Summary by CodeRabbit

  • New Features
    • Marketplace sales now settle directly through the seller’s active character, with applicable tax shown in the sale notification.
  • Improvements
    • Items are removed only after payment is confirmed, helping prevent goods from being lost when payment is unavailable or refused.
    • Repeated clicks and interrupted sales are handled to avoid duplicate payments or item removals.

Walkthrough

Trade sales now plan inventory removal before payment. A new sale operation records an intent and settles payment through the Denar ledger. Trade handling and tests cover applied, refused, unavailable, repeated, and interrupted sales.

Changes

Market sale settlement

Layer / File(s) Summary
Plan and validate goods removal
src/main/java/net/tfminecraft/marketblock/util/InventoryUtils.java, src/main/java/net/tfminecraft/marketblock/util/SaleTake.java, src/test/java/net/tfminecraft/marketblock/util/InventoryUtilsTest.java
planTake records selected stacks without changing inventory. SaleTake.apply() checks the recorded stacks before removing items. Tests cover planning and applying the take.
Settle and record a sale
pom.xml, src/main/java/net/tfminecraft/marketblock/trade/MarketSale.java, src/test/java/net/tfminecraft/marketblock/TestMoney.java, src/test/java/net/tfminecraft/marketblock/trade/MarketSaleTest.java
The DenarEconomy and TLibs versions are updated, and a test-scoped SQLite driver is added. MarketSale records an intent and settles payment through the ledger. Tests cover retries, interruptions, goods validation, and tax availability.
Integrate settlement into trade clicks
src/main/java/net/tfminecraft/marketblock/manager/TradeManager.java, src/test/java/net/tfminecraft/marketblock/manager/TradeManagerTest.java
TradeManager checks the active character and planned amount before settling a sale. It ignores repeated handling of the same click event and reports tax when positive. Tests cover sale results, duplicate clicks, interrupted posting, and character availability.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant TradeManager
  participant InventoryUtils
  participant MarketSale
  participant Denars
  participant SaleTake
  TradeManager->>InventoryUtils: planTake for sale goods
  TradeManager->>MarketSale: settle sale
  MarketSale->>Denars: earn seller payment with tax
  MarketSale->>SaleTake: apply goods after APPLIED result
Loading

Merge Risk: ⚪ Minimal · up to e2190

Unavailable payments leave goods untouched and preserve the sale record for reconciliation. The required dependency is available to the documented build workflow; normal checks remain appropriate before merging.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:L 100-499 effective changed lines (tests excluded in mixed PRs). label Oct 12, 2026
@ryanbarlow97
ryanbarlow97 marked this pull request as ready for review October 12, 2026 21:02
@ryanbarlow97
ryanbarlow97 merged commit 3c9dc68 into main Oct 12, 2026
4 of 5 checks passed
@ryanbarlow97
ryanbarlow97 deleted the feat/character-ledger branch October 12, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant