Skip to content

feat: per-type return rates and return what was actually used - #26

Merged
XxFran10xX merged 2 commits into
mainfrom
feat/per-type-return-rates
Sep 30, 2026
Merged

XxFran10xX merged 2 commits into
mainfrom
feat/per-type-return-rates

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Per-type return rates. Every item type Recycler handles now has its own ratio in config.yml, like scrap_return_rate already did:

return_rates:
  advanced_crafting: 0.8
  alloy_scrap: 0.5
  magic_gear: 0.8
  guns: 0.8
  goldsmith_jewelry: 0.8
  recipes: 1.0

Values are clamped to 0.0-1.0 (non-finite values use the default). A missing entry falls back to the old max_return_rate (crafted items) or scrap_return_rate (scrap), so an existing server config keeps its current behaviour until return_rates is added. RecycleProvider.returnRate() is now required per provider; appliesMaxReturnRate() is gone.

Return what was actually used. Previously:

  • Goldsmithing returned the project recipe, although a bench slot accepts any gold of its type (a Golden Ring made from shiny gold gave back rough gold).
  • Magic weapons and guns returned today's part costs, which is wrong after a cost change and returned materials for staff bypass crafts.

Now those three providers read the materials their plugin recorded at craft time:

Items crafted before those versions have no record and are refused (same approach as pre-2.2.0 scrap). AdvancedCrafting gear already records its deposited inputs and is unchanged.

Pins bump to GemInfusion 2.2.5, GunsAndGadgets 2.0.6 and Magic 0.4.7. CI needs those releases first; ship the four jars together.

Testing

  • Provider, loader and utility tests updated; mvn verify passes locally with the 100% coverage gate (built against the three branches installed locally under the new versions).
  • End-to-end on TFMCDev01 before merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Configure material return rates separately for crafted equipment, magic gear, guns, jewelry, alloy scrap, and recipe outputs.
    • Eligible gear and jewelry return their recorded crafting materials. Items without recorded materials cannot be recycled; broken magic gear and guns, and jewelry with socketed gems, are ineligible.
  • Bug Fixes
    • Invalid return rates fall back to category defaults; finite values outside the supported range are clamped.
    • Recycling amounts are rounded down after return-rate and durability scaling.
  • Compatibility
    • Existing return-rate settings remain supported as fallbacks for applicable item categories.

Each item type now has its own ratio under return_rates in config.yml
(advanced_crafting, alloy_scrap, magic_gear, guns, goldsmith_jewelry,
recipes), clamped to 0.0-1.0. The old max_return_rate/scrap_return_rate
keys still apply when an entry is missing.

Magic weapons, guns and goldsmithing jewelry now return the materials
their plugin recorded as used at craft time (Magic 0.4.6, GunsAndGadgets
2.0.6, GemInfusion 2.2.5) instead of today's part costs or the project
recipe. Items crafted before those versions are not recyclable.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 638efd2e-ea32-4fd3-a228-a0375bc37ea3

📥 Commits

Reviewing files that changed from the base of the PR and between f09fd7e and 249b523.

📒 Files selected for processing (1)
  • pom.xml
🚧 Files skipped from review as they are similar to previous changes (1)
  • pom.xml

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


📝 Walkthrough

Walkthrough

Recycling providers now use recorded crafting materials for supported items. Return rates are configurable by item category, with legacy configuration fallbacks. The configured versions of GemInfusion, GunsAndGadgets, and Magic also changed.

Changes

Recycling behavior and configuration

Layer / File(s) Summary
Configure and apply category return rates
src/main/java/net/tfminecraft/recycler/Cache.java, src/main/java/net/tfminecraft/recycler/loader/ConfigLoader.java, src/main/java/net/tfminecraft/recycler/provider/RecycleProvider.java, src/main/java/net/tfminecraft/recycler/provider/RecycleContext.java, src/main/java/net/tfminecraft/recycler/provider/AdvancedCraftingProvider.java, src/main/java/net/tfminecraft/recycler/provider/ConfigProvider.java, src/main/java/net/tfminecraft/recycler/provider/GunsAndGadgetsProvider.java, src/main/java/net/tfminecraft/recycler/provider/MagicGearProvider.java, src/main/resources/config.yml, src/test/java/net/tfminecraft/recycler/LoadersTest.java, src/test/java/net/tfminecraft/recycler/ProvidersTest.java, src/test/java/net/tfminecraft/recycler/UtilitiesTest.java
The shared return-rate setting is replaced by per-category rates. Configuration loading validates rates from 0.0 to 1.0, clamps finite out-of-range values, and applies documented legacy fallbacks. Providers expose their configured rate, which the recycle context uses before durability scaling.
Build outputs from recorded materials
src/main/java/net/tfminecraft/recycler/model/RecycleOutput.java, src/main/java/net/tfminecraft/recycler/provider/GoldsmithProvider.java, src/main/java/net/tfminecraft/recycler/provider/GunsAndGadgetsProvider.java, src/main/java/net/tfminecraft/recycler/provider/MagicGearProvider.java, src/test/java/net/tfminecraft/recycler/ProvidersTest.java, src/test/java/net/tfminecraft/recycler/SocketProvidersTest.java, README.md, pom.xml
Magic gear, guns, and jewelry providers use recorded material amounts to build outputs and reject items without required recorded inputs. The output conversion skips invalid paths and non-positive amounts. Documentation describes recorded-material support, and the configured dependency versions change.

Priority: ⬇️ Low

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

Change: Feature

Merge Risk: ⚪ Minimal · up to 249b5

No concrete merge-blocking issue was identified. Normal build checks should confirm the pinned dependencies, and deployment should include the compatible plugin jars together.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f09fd

The recycling controls examined remain in place, and no introduced security vulnerability was established. Remaining risk concerns validation of the companion plugins’ recorded-material contracts and deployment of compatible versions together.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant exposure is the deployed game server’s material economy: station users can submit owned items, and accepted provenance determines server-created returns. Station use is permitted by default, so the material-return contract affects ordinary players rather than only administrators.

Trust Boundaries and Controls

  • observed — Recycler delegates recorded-input interpretation to companion plugins and locally filters output shape. The inspected tests mock those readers, so they do not establish authentic crafting-record binding, per-item quantity semantics, or malformed-record rejection in the real companion implementations.
  • observed — Specialized-provider refusal is not a chain-wide denial: the generic fallback may still accept a configured matching path. This administrator-controlled fallback predates the PR; its existence alone does not establish a newly introduced provenance or socket-control bypass.

Resilience and Maintainability Implications

  • observed — Escrow is keyed by player UUID and cloned on retrieval. Confirmation rechecks provider eligibility and blocks zero yield by default; rejection leaves escrow intact. Cancellation and close return escrow, while startup recovery moves saved inputs to pending returns. Consumption before staggered output delivery remains a pre-existing interruption window, not a demonstrated PR regression.

Hardening Proposals

  • proposed — Validate the coordinated release with real companion-produced items, including zero-cost crafts, stacked items, malformed records, and legacy items. Consider checking required reader availability before activating each integration, so incompatible jars fail predictably rather than during recycling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 14 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the two primary changes: per-type return rates and returning materials actually used to craft supported items.
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 14 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

I’m a rabbit with a crafting plan,
I gather saved materials where I can.
Rates are set for each item kind,
Old recipes leave their traces behind.
I hop past scraps and outputs anew,
With tidy little returns to brew.

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 29, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@XxFran10xX
XxFran10xX merged commit da737ea into main Sep 30, 2026
2 of 3 checks passed
@XxFran10xX
XxFran10xX deleted the feat/per-type-return-rates branch September 30, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant