Skip to content

feat: optional invulnerable pets - #47

Merged
Nowkoo merged 1 commit into
mainfrom
feat/invulnerable-pets
Oct 25, 2026
Merged

Nowkoo merged 1 commit into
mainfrom
feat/invulnerable-pets

Conversation

@Nowkoo

@Nowkoo Nowkoo commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Problem

A pet's death permanently deletes it. #45 stopped owners from hurting their own pets, but pets can still be killed by other players, mobs, projectiles and the environment (fall, fire, lava, void, /kill...).

Change

New option care.invulnerable (default false):

  • true: PetListener.onProtectedDamage cancels every EntityDamageEvent on a pet at LOWEST, whatever its cause or source.
  • false: unchanged behaviour, only damage whose responsible player is the pet's owner is cancelled (fix: pets take no damage from their owner #45).

The owner check and the new switch share one handler, which now listens to EntityDamageEvent instead of EntityDamageByEntityEvent. Because the event is cancelled early, the pet loses no mood and plays no hurt animation.

Neglect deaths are unaffected: they set health directly and still follow care.death-on-neglect.

Config

care:
  invulnerable: false           # true cancels all damage to pets; false only blocks damage from their owner.

Missing key = false, so existing configs keep today's behaviour.

Tests

  • New: with care.invulnerable: true, stranger melee, a stranger's projectile, another mob, and fall/lava/fire/void/kill damage are all cancelled before other plugins see them, with no mood loss and no animation; non-pet entities are still damaged.
  • Existing owner-only tests still pass with the default false.
  • PetListenerCoverageTest 34/34 and NeedClockTest 19/19 pass locally. The full local suite on Windows shows the usual environment-only failures (directory fsync AccessDeniedException, cascading into "Already mocking"); CI on Linux is the authoritative run.

🤖 Generated with Claude Code

care.invulnerable: true cancels every damage event on a pet at LOWEST, from
players, mobs, projectiles and the environment alike, because a pet's death
deletes it. The default false keeps the current behaviour, where only the
pet's own owner is blocked from hurting it.

Neglect deaths are unaffected: they set health directly and still follow
care.death-on-neglect.

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

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55031e0d-cd4b-4298-b3c3-4a3d423f483f
  • 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 25, 2026
@Nowkoo
Nowkoo merged commit 1f4a62b into main Oct 25, 2026
3 checks passed
@Nowkoo
Nowkoo deleted the feat/invulnerable-pets branch October 25, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant