Skip to content

Keep faction vehicle records when a vehicle's chunk unloads - #65

Merged
Drefvelin merged 1 commit into
mainfrom
fix/keep-faction-vehicles-on-unload
Sep 27, 2026
Merged

Drefvelin merged 1 commit into
mainfrom
fix/keep-faction-vehicles-on-unload

Conversation

@Drefvelin

@Drefvelin Drefvelin commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

VehicleFramework fires VehicleRemoveEvent when a vehicle's chunk unloads (VehicleRemoveReason.UNLOAD), not only when it is destroyed. VehicleIntegrationListener.onVehicleRemove dropped the vehicle's registry record on any removal and saved the registry. So a pool or installation vehicle whose chunk unloaded lost its faction record and came back as the leader's personal vehicle: the faction stopped paying its upkeep, it counted against the leader's personal slots, and it was no longer berthed.

Fix. A new VehicleRemovals.isGoneForGood(payload) returns false only for UNLOAD. Deaths, player destroy, admin kill, GENERIC and a missing payload still count as removal, as before. The listener only drops the record when the vehicle is gone for good. The vehicle fee last-owner listener (#64) now uses the same helper instead of its own copy. It also now forgets the last owner on GENERIC removals, which VehicleFramework only sends when a vehicle dies.

The only VehicleFramework paths that remove without destroying are the chunk-unload persist and a failed spawn setup. Both use UNLOAD.

Impact on Main. Main's registry is currently empty and nobody has pooled or berthed a vehicle there yet, so nothing has been lost so far.

Tests. VehicleRemovalsTest and VehicleRemoveKeepsFactionVehiclesTest (a pool record survives an unload and is dropped on death). mvn verify passes locally (2271 tests).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Vehicle records are now preserved when vehicles unload, including berthed or pool vehicles. Records are removed only when the vehicle is gone for good, such as after death or destruction.
    • Vehicle reclaim ownership records now follow the same removal behavior.

VehicleFramework fires VehicleRemoveEvent when a chunk unloads, and the
integration listener dropped the pool or installation record for any removal.
A faction vehicle whose chunk unloaded lost its record, so it came back as the
leader's personal vehicle. Records are now only dropped when the vehicle is
gone for good, which the vehicle fee listener shares through VehicleRemovals.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 27, 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: 4b36a9a9-edaa-46cc-be84-ce1bb6d75051

📥 Commits

Reviewing files that changed from the base of the PR and between 97fc696 and e83aa66.

📒 Files selected for processing (6)
  • src/main/java/net/tfminecraft/simplefactions/vehicles/VehicleIntegrationListener.java
  • src/main/java/net/tfminecraft/simplefactions/vehicles/VehicleRemovals.java
  • src/main/java/net/tfminecraft/simplefactions/vehicles/fees/VehicleReclaimFeeListener.java
  • src/test/java/net/tfminecraft/simplefactions/vehicles/VehicleRemovalsTest.java
  • src/test/java/net/tfminecraft/simplefactions/vehicles/VehicleRemoveKeepsFactionVehiclesTest.java
  • src/test/java/net/tfminecraft/simplefactions/vehicles/fees/VehicleReclaimFeeListenerTest.java
💤 Files with no reviewable changes (1)
  • src/test/java/net/tfminecraft/simplefactions/vehicles/fees/VehicleReclaimFeeListenerTest.java

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


📝 Walkthrough

Walkthrough

Vehicle removal handling now preserves faction records when vehicles unload. A shared utility classifies permanent removals, and both faction-record and reclaim-fee listeners use that classification.

Changes

Vehicle removal handling

Layer / File(s) Summary
Permanent-removal policy
src/main/java/net/tfminecraft/simplefactions/vehicles/VehicleRemovals.java, src/test/java/net/tfminecraft/simplefactions/vehicles/VehicleRemovalsTest.java
VehicleRemovals.isGoneForGood treats null payloads and death as permanent. Other removals are permanent unless their reason is UNLOAD. Tests cover these cases.
Listener updates and faction-record tests
src/main/java/net/tfminecraft/simplefactions/vehicles/VehicleIntegrationListener.java, src/main/java/net/tfminecraft/simplefactions/vehicles/fees/VehicleReclaimFeeListener.java, src/test/java/net/tfminecraft/simplefactions/vehicles/VehicleRemoveKeepsFactionVehiclesTest.java, src/test/java/net/tfminecraft/simplefactions/vehicles/fees/VehicleReclaimFeeListenerTest.java
The listeners use the shared permanence check. The faction registry retains records on unload and unregisters them for permanent removals. Tests cover unload and death behavior; the previous reclaim-fee listener test class was removed.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to e83aa

Vehicle records are retained on unload, and no confirmed issue blocks merging after normal checks. The effect of other removal reasons on reclaim-fee records remains unverified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e83aa

The change preserves existing faction records during temporary unloads without adding a way to create or transfer ownership. No newly exposed access path was established. Its correctness still depends on the vehicle framework reporting removal reasons accurately.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A misclassified removal would affect ownership and last-owner records for the event's vehicle UUID; the reviewed removal handlers show no new path to create records or change another vehicle's UUID.

Trust Boundaries and Controls

  • inferred — The removal reason is supplied by the external vehicle framework and becomes the authority for retaining registry and fee state. Repository-local evidence does not establish that a player can forge an UNLOAD event or that every genuine permanent removal is labeled correctly.

Hardening Proposals

  • proposed — Validate the supported framework versions' removal-reason and UUID-on-reload contracts before relying on them as the durable ownership lifecycle boundary.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: retaining faction vehicle records when a vehicle's chunk unloads.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

A rabbit watched the carts roll by,
Then saw them pause beneath the sky.
“An unload leaves their records here,
A final end makes that path clear.”
I twitch my nose and hop away.

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

@Drefvelin
Drefvelin merged commit e5aa57e into main Sep 27, 2026
2 checks passed
@Drefvelin
Drefvelin deleted the fix/keep-faction-vehicles-on-unload branch September 27, 2026 13:50
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.

2 participants