Skip to content

fix: protect husbandry records, ride trust and companion pets - #15

Merged
Nowkoo merged 5 commits into
feat/absorb-husbandryfrom
fix/husbandry-migration-and-trust
Oct 16, 2026
Merged

Nowkoo merged 5 commits into
feat/absorb-husbandryfrom
fix/husbandry-migration-and-trust

Conversation

@Nowkoo

@Nowkoo Nowkoo commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Interrupted Cooking takeovers could replay old WAL records, and failed snapshot recovery could delete an animal together with its owners and only recovery copy. Migration now clears residual WAL/SHM files and publishes a staged database with an atomic rename. Snapshot recovery distinguishes skipped, scheduled and failed attempts; failed attempts preserve all SQLite records and mark the animal missing for retry or staff review.

Ride trust is awarded at MONITOR with ignoreCancelled, after ownership checks and other plugins have had their chance to cancel the mount event. Cancelled rides preserve both trust and the daily pet cooldown.

Chunk-load and startup cleanup also used to delete CompanionPets dogs and cats as unowned animals. It now excludes bodies carrying the persistent companionpets:pet marker, including before CompanionPets enables, while untagged wild animals still follow remove-unowned. Deaths of those bodies also keep their drops and experience instead of being cleared as unowned livestock. A snapshot that has no world to restore into now logs which animal it is.

Based on feat/absorb-husbandry (#13).

Validation: mvn verify passes all 303 tests and the 100% line coverage gate. Regression tests cover real SQLite stale-WAL replay, interrupted database copying, cancelled and successful owner rides, snapshot recovery failures, and tagged wolves/cats surviving chunk loads, startup cleanup and death-drop clearing while wild animals are still removed.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 16, 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: 22e49fc2-61ba-402e-a30c-d4fb7110b8b9
📥 Commits

Reviewing files that changed from the base of the PR and between b146b5f and 4f9110b.

📒 Files selected for processing: 16
  • src/main/java/net/tfminecraft/breedingbuddies/CookingMigration.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryDeathListener.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryEntities.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryKeys.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryLifecycleListener.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryLocator.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryMountListener.java
  • src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandrySnapshots.java
  • src/test/java/net/tfminecraft/breedingbuddies/CookingMigrationTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryCompanionPetsTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryMaintenanceRegressionTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryOwnedMountTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryRemainingCoverageTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryRuntimeCoverageTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandrySnapshotsTest.java
  • src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryTrustTest.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

  • Bug Fixes
    • CompanionPets animals are now excluded from husbandry cleanup and death handling, preserving their drops and experience.
    • Trust is awarded for completed, uncancelled rides on a player’s own husbandry mount.
    • Animals are kept marked as missing when snapshot restoration fails, allowing recovery to be retried.
    • Database migration retries now handle stale journal files and failed copies without leaving incomplete staged files.

The changes update Cooking database migration and husbandry handling for CompanionPets, snapshot restoration, and mount trust rewards. Tests cover migration retries, entity handling, restoration outcomes, and ride eligibility.

Changes: Cooking database migration

Layer / File(s) Summary
Stage and verify database migration
src/main/java/net/tfminecraft/breedingbuddies/CookingMigration.java, src/test/java/net/tfminecraft/breedingbuddies/CookingMigrationTest.java
Migration stages the database copy, clears target WAL and SHM files, and removes the staging file after failure. Tests cover retries, stale files, and failed copies.

CompanionPets handling

Layer / File(s) Summary
Identify and exclude CompanionPets
src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryKeys.java, src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryEntities.java, src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryLifecycleListener.java, src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryDeathListener.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryCompanionPetsTest.java
Husbandry checks the CompanionPets persistent-data key and skips its load and death handling for tagged entities. Tests cover tagged and untagged wolves and cats.

Snapshot restoration outcomes

Layer / File(s) Summary
Return and handle restoration outcomes
src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandrySnapshots.java, src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryLocator.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandrySnapshotsTest.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryMaintenanceRegressionTest.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryRemainingCoverageTest.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryRuntimeCoverageTest.java
Snapshot restoration returns SKIPPED, SCHEDULED, or FAILED. The locator keeps failed records marked missing and avoids ghost deletion. Tests check the outcomes and retention of records after restoration errors.

Mount trust rewards

Layer / File(s) Summary
Award trust for eligible rides
src/main/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryMountListener.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryTrustTest.java, src/test/java/net/tfminecraft/breedingbuddies/husbandry/HusbandryOwnedMountTest.java
The listener awards the pet interaction at monitor priority for eligible, uncancelled rides. Tests cover cancelled events, ownership, rider type, and mount type.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Player
  participant BukkitEventManager
  participant HusbandryMountListener
  Player->>BukkitEventManager: Trigger EntityMountEvent
  BukkitEventManager->>HusbandryMountListener: Dispatch mount event
  HusbandryMountListener->>HusbandryMountListener: Check cancellation, rider, mount, and ownership
  HusbandryMountListener->>HusbandryMountListener: Award pet interaction when eligible
Loading
Merge Risk: ⚪ Minimal · up to 4f911

No actionable merge-blocking risk remains from the reviewed changes; proceed with normal checks.

- [ ] 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:S 10-29 effective changed lines (tests excluded in mixed PRs). label Oct 16, 2026
@github-actions github-actions Bot added size:M 30-99 effective changed lines (tests excluded in mixed PRs). and removed size:S 10-29 effective changed lines (tests excluded in mixed PRs). labels Oct 16, 2026
@Nowkoo Nowkoo changed the title fix: make husbandry migration retries and ride trust safe fix: protect husbandry migration, recovery and ride trust Oct 16, 2026
@Nowkoo Nowkoo changed the title fix: protect husbandry migration, recovery and ride trust fix: protect husbandry records, ride trust and companion pets Oct 16, 2026
Nowkoo and others added 2 commits October 16, 2026 13:11
Wolves and cats are remove-unowned animals, so a CompanionPets body that
died lost its drops and experience as if it were unowned livestock. The
death listener now skips bodies carrying companionpets:pet, through the
same check the chunk-load cleanup uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This failure kept the records but logged nothing, so the scan reported
an animal still missing without saying which one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Nowkoo
Nowkoo marked this pull request as ready for review October 16, 2026 11:20
@Nowkoo

Nowkoo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Nowkoo
Nowkoo merged commit a3b5d16 into feat/absorb-husbandry Oct 16, 2026
3 checks passed
@Nowkoo
Nowkoo deleted the fix/husbandry-migration-and-trust branch October 16, 2026 11:24
Nowkoo added a commit that referenced this pull request Oct 16, 2026
* feat: run livestock on Cooking's husbandry engine

Replace the JSON engine with the husbandry module from Cooking, including
its character ownership, estates, lost-animal snapshots, /animals and
tests. Products come from Cooking's food API, so Cooking stays the owner
of food. BreedingBuddies refuses to start while Cooking still runs
livestock, and staff use /breedingbuddies with breedingbuddies.admin.
The estate participant keeps the cooking-animals ID so estates already
open carry on. Private build inputs are now MMOCore and MythicLib.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: take over Cooking's animal records and settings

On the first start BreedingBuddies copies plugins/Cooking/Data/husbandry.db
(with its journal) and husbandry.yml, which already hold the character
owners, estates and snapshots. Cooking's files stay as a backup, the
database is copied last so an interrupted copy is redone, and a failed
copy stops startup instead of opening an empty database. Entities and
tokens marked with Cooking's keys keep working; new marks use ours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: earn trust only through an owner's care

Care becomes trust, shown as five hearts. Happy time no longer raises it
by itself: owners earn it by feeding a hungry animal (trust.feed), brushing
a dirty one (trust.glove) and a daily pet (trust.pet, once per
trust.pet-cooldown). A pet is an empty-handed, standing right-click; for
mounts, riding counts. Staff can still tend any animal, but only owners
build its trust. Neglect still costs trust after decay-grace. The old
care.up and offline-care keys are ignored. The last pet is stored in
last_pet_at, added by column name so Cooking's schema numbering cannot
skip it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: breed mounts stat by stat

Mounts carry separate health, speed and jump genes, inherited with the
old BreedingBuddies roll: from a little below the weaker parent up to a
quarter of the headroom above the better one, with very different parents
lowering that ceiling. Parents' trust and the breeding food's stars open
that headroom, so neglected or poorly fed parents cannot produce a better
foal. Wild mounts roll each stat; staff spawns get the chosen value for
all three. The animal's genetics is the average of the three, and records
from before keep their genetics for every stat until bred or reset.
Default shares are now 40% base, 50% genes and 10% trust, so full genes
and full trust reach the type's maximum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: make living products believable and earned

A cow now leaves manure for the fields (bone meal by default) instead of
leather, which only comes from slaughter. A pig roots about, with dirt
and a rooting sound, before turning up its enchanted dust; a chicken
moults its feathers. Milk and the extra wool from shearing need a happy
animal, like eggs and shedding already did; vanilla sheep wool still
always comes off. Llamas give leather at slaughter rather than feathers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: start from BreedingBuddies' own settings

Copying Cooking's husbandry.yml would have kept the old leather shedding,
llama feathers and mount shares, so the takeover now copies only the
animal records and config.yml starts from BreedingBuddies' defaults.
Those defaults carry the horse maximums tuned on TF Main (27 health,
0.27 speed, 0.8 jump strength).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: bring back the BreedingBuddies animal menu

The menu follows the original layout again instead of 54 slots of
concrete bars: a header row (owners, name and growth, products, status,
neutered), a row of five trust hearts in red and grey dye, a row of five
genetics eggs with the star rating, and for mounts a row with health,
speed and jump and each stat's gene. Names drop the italics, the status
says what to do (feed, brush, pet or ride) and when trust starts to drop,
and giving an animal up now takes a second click within five seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: bring back the BreedingBuddies effects

Taming, linking a co-ownership token and gaining a co-owner play the
original cherry petals and amethyst chime. Feeding and brushing play a
softer sparkle, leaving hearts to the trust they earn. Neutering a horse
plays the foal's cry it used to; other animals give a short yelp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: name the mount stat shares mounts.shares

The shares set health, speed and jump alike, so mounts.speed was a
misleading name inherited from Cooking. mounts.shares is read first;
mounts.speed still loads with a warning to rename it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep TF Main's mount shares

Trust keeps counting for 30% of a mount's stats, as it does on TF Main
today: 40% base, 30% genes and 30% trust, which still reaches the type's
maximum with full genes and trust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: say so when the plugin folder cannot be created

On TF Dev the server may not create folders in plugins/, so the first
start failed with a missing husbandry.db while copying Cooking's records.
Startup now stops with a message saying to create the folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: protect husbandry records, ride trust and companion pets (#15)

Failed Cooking takeovers no longer replay stale WAL records: the database
is staged, residual WAL/SHM files are cleared and the copy is published by
an atomic rename. Failed snapshot recovery keeps the animal, its owners and
its snapshot, marking it missing for retry or staff review instead of
deleting it, and a snapshot without a world names its animal in the log.

Ride trust is awarded at MONITOR after other plugins could cancel the ride.
CompanionPets bodies, tagged companionpets:pet, are left out of chunk-load
and startup cleanup and keep their drops and experience when they die.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant