Skip to content

Record the constructor's character beside the account - #31

Merged
ryanbarlow97 merged 2 commits into
mainfrom
stage6/constructor-character
Oct 13, 2026
Merged

ryanbarlow97 merged 2 commits into
mainfrom
stage6/constructor-character

Conversation

@ryanbarlow97

@ryanbarlow97 ryanbarlow97 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Stage 6a, VFBuilders part: constructor credit becomes character-aware without changing what constructorUuid means.

What changes

  • constructorUuid stays the account. Each build also records constructorCharacterId, taken from Characters.currentSession(p).filter(Characters::isCurrent) when the build starts (StationManager.onPlayerLeftClick), before BeginVehicleConstructionEvent fires. The same value goes on the event and the station.
  • The station saves constructorCharacterId in data/stations.json. Saves written before this change have no field and load with a null character. VFBuilders does not resolve heirs; SimpleFactions does.
  • BeginVehicleConstructionEvent, VehicleConstructEvent and VehicleConstructionCancelEvent expose UUID getConstructorCharacterId(). The old constructors remain and pass a null character, so existing callers and tests compile unchanged.
  • ConstructionFreeze gains default String freezeReason(UUID account, UUID character), which asks the existing account method. ConstructionFreezes.reason(account, character) calls it, and stations use it every second. An account-only provider (today's SimpleFactions) behaves exactly as before.
  • Building without a current character session is allowed and records a null character (design rule 2: a placement is allowed but left without an owner). SimpleFactions treats null as "resolve the heir or quarantine".
  • TLibs' session API is probed once on first use (Class.forName/getMethod, catching ReflectiveOperationException | LinkageError). On an older TLibs, builds record no character instead of failing.
  • TLibs pin 2.0.0 → 2.4.1. folia-supported is removed from plugin.yml, because the Characters API is main-thread only.

Probing from SimpleFactions

VehicleConstructEvent.class.getMethod("getConstructorCharacterId")      // returns UUID
ConstructionFreeze.class.getMethod("freezeReason", UUID.class, UUID.class) // default method

The same accessor exists on BeginVehicleConstructionEvent and VehicleConstructionCancelEvent. A test asserts these signatures.

Validation

tfmc-mvn -o -B clean verify: 40 tests, 0 failures. JaCoCo 100% of instructions (3992/3992), branches (412/412) and lines (950/950). Installed locally as 2.2.0 (vfbuilders-2.2.0.jar SHA-256 83b8d0f49c2555044bd4b0cc5311b4e6f2fad834c3684e1621d6ea8224a00b0b). CI may 404 until TLibs 2.4.1 is available to the pinned installer; that is expected before release.

New tests cover the persistence round trip (including a save in the old format without the field, and an invalid character id), the character on all three events, freeze delegation from the two-argument form to account-only providers, the station asking freezes with both ids, capture at build start with a current, stale and missing session, and the probe on an older TLibs.

Docs: TF-Minecraft/Docs#206

Not merged, released or deployed. Release order for the set: TLibs, RPCharacters, VehicleFramework, VFBuilders, Thievery, SimpleFactions.

🤖 Generated with Claude Code

ryanbarlow97 and others added 2 commits October 13, 2026 01:00
The character session API in TLibs is main-thread only, so VFBuilders no
longer claims Folia support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
constructorUuid stays the account. Each build now also records
constructorCharacterId, the player's current character session when the
build starts (null without one, or when TLibs lacks the session API). The
station saves it, older saves load with null, and the begin, construct
and cancel events expose it as getConstructorCharacterId().

ConstructionFreeze gains a default freezeReason(account, character) that
asks the account form; stations call the two-argument form each second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:L 100-499 effective changed lines (tests excluded in mixed PRs). label Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 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: 84d01d0b-2a60-4e38-a45d-213097c52f46
📥 Commits

Reviewing files that changed from the base of the PR and between 05c6b10 and 86e3281.

📒 Files selected for processing (16)
  • pom.xml
  • src/main/java/net/tfminecraft/vfbuilders/api/ConstructionFreeze.java
  • src/main/java/net/tfminecraft/vfbuilders/api/ConstructionFreezes.java
  • src/main/java/net/tfminecraft/vfbuilders/core/ActiveStation.java
  • src/main/java/net/tfminecraft/vfbuilders/core/ConstructorCharacter.java
  • src/main/java/net/tfminecraft/vfbuilders/data/Database.java
  • src/main/java/net/tfminecraft/vfbuilders/events/BeginVehicleConstructionEvent.java
  • src/main/java/net/tfminecraft/vfbuilders/events/VehicleConstructEvent.java
  • src/main/java/net/tfminecraft/vfbuilders/events/VehicleConstructionCancelEvent.java
  • src/main/java/net/tfminecraft/vfbuilders/managers/StationManager.java
  • src/main/resources/plugin.yml
  • src/test/java/net/tfminecraft/vfbuilders/DatabaseTest.java
  • src/test/java/net/tfminecraft/vfbuilders/DomainTest.java
  • src/test/java/net/tfminecraft/vfbuilders/ManagerTest.java
  • src/test/java/net/tfminecraft/vfbuilders/StationTest.java
  • src/test/java/net/tfminecraft/vfbuilders/core/ConstructorCharacterTest.java
💤 Files with no reviewable changes (1)
  • src/main/resources/plugin.yml

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
    • Construction records now include the constructor’s current character ID when available. This information is retained when stations are saved and restored, and is included in construction and cancellation events.
    • Construction freeze checks can now take the constructor’s character ID into account, while continuing to support account-only checks.
  • Compatibility
    • Existing integrations and saved stations without character IDs remain supported; construction can proceed when no current character session is available.

The change adds optional constructor character UUIDs to construction selection, freeze checks, events, station state and saved data. It also updates the TLibs version and removes the Folia support declaration.

Changes: Constructor character attribution

Layer / File(s) Summary
Character lookup and API contracts
pom.xml, src/main/java/net/tfminecraft/vfbuilders/api/ConstructionFreeze.java, src/main/java/net/tfminecraft/vfbuilders/api/ConstructionFreezes.java, src/main/java/net/tfminecraft/vfbuilders/core/ConstructorCharacter.java, src/main/java/net/tfminecraft/vfbuilders/events/*, src/test/java/net/tfminecraft/vfbuilders/DomainTest.java, src/test/java/net/tfminecraft/vfbuilders/core/ConstructorCharacterTest.java
The TLibs version changes to 2.4.1. A helper resolves the current character UUID. The freeze API and construction events accept or expose an optional character UUID, while existing signatures remain available. Tests cover lookup, null values and freeze-provider delegation.
Station attribution and lifecycle
src/main/java/net/tfminecraft/vfbuilders/core/ActiveStation.java, src/main/java/net/tfminecraft/vfbuilders/managers/StationManager.java, src/test/java/net/tfminecraft/vfbuilders/ManagerTest.java, src/test/java/net/tfminecraft/vfbuilders/StationTest.java
Construction-site selection resolves the current character UUID and passes it to the event and station. The station supplies both UUIDs to freeze checks and construction events, then clears the character UUID on completion or cancellation.
Persist constructor identifiers
src/main/java/net/tfminecraft/vfbuilders/data/Database.java, src/test/java/net/tfminecraft/vfbuilders/DatabaseTest.java
Station saves include nullable constructor account and character UUIDs. Loading handles missing or invalid values as null. Tests cover round-tripping and older saves.

Plugin descriptor

Layer / File(s) Summary
Remove Folia support declaration
src/main/resources/plugin.yml
The folia-supported: true entry is removed.

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant StationManager
  participant ConstructorCharacter
  participant ActiveStation
  participant ConstructionFreezes
  Player->>StationManager: select construction site
  StationManager->>ConstructorCharacter: resolve current character UUID
  ConstructorCharacter-->>StationManager: character UUID or null
  StationManager->>ActiveStation: select blueprint with account and character UUIDs
  ActiveStation->>ConstructionFreezes: check freeze with both UUIDs
  ActiveStation-->>ActiveStation: include both UUIDs in construction or cancellation event
Loading
Merge Risk: ⚪ Minimal · up to 86e32

The change records the constructor's character beside the account while keeping older saves and existing providers working. No concrete merge-blocking risk was found.

- [ ] 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.

@ryanbarlow97
ryanbarlow97 merged commit 5f34832 into main Oct 13, 2026
4 checks passed
@ryanbarlow97
ryanbarlow97 deleted the stage6/constructor-character branch October 13, 2026 10:14
@ryanbarlow97

Copy link
Copy Markdown
Contributor Author

Muse (independent reviewer) reviewed this PR after merge, against the stage 6a design: verdict OK. One minor note: if a character provider threw from currentSession/isCurrent, the build-start click would abort instead of recording no character. This is theoretical with RPCharacters as the only provider. Catching and logging once is a follow-up; v2.2.0 stands.

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