Skip to content

feat: log nonlethal knockouts in CoreProtect - #125

Merged
ryanbarlow97 merged 1 commit into
mainfrom
feat/log-knockouts-coreprotect
Oct 17, 2026
Merged

ryanbarlow97 merged 1 commit into
mainfrom
feat/log-knockouts-coreprotect

Conversation

@Drefvelin

Copy link
Copy Markdown
Contributor

Summary

CoreProtect now logs every hit, knockout and kill between players (TF-Minecraft/CoreProtect#26), so staff can see who attacked first. It can't see a nonlethal knockout on its own: PvpKnockoutManager cancels the knockout blow, and CoreProtect skips cancelled hits.

PvpKnockoutManager.onLethalDamage now reports each knockout to CoreProtect's new logPvpKnockout(Player attacker, Player victim) API through CoreProtectKnockouts.

  • CoreProtect is reached by reflection, so this adds no depend/softdepend and no load-order risk.
  • Without CoreProtect, or when it's disabled, nothing is logged.
  • An older CoreProtect without the method gets one warning, and the knockout itself always goes ahead.
  • Duel-ending blows are cancelled too but aren't reported, since duels are agreed fights. CoreProtect still logs every hit during a duel.

Testing

  • New CoreProtectKnockoutsTest covers a successful call, a missing, disabled or not-ready CoreProtect, null players, and an older API (warns once).
  • PvpKnockoutManagerTest now checks that a knockout is reported with the right attacker and victim.
  • Locally, all pvp tests pass. Five file-permission tests (DatabaseLoadTest, DatabasePersistenceTest, GraveManagerTest, BodyStoreTest) fail on this host because it runs as root, and they fail on unmodified main there too. CI runs them as a normal user.
  • Next: a live test on TFMCDev together with the CoreProtect PR.

🤖 Generated with Claude Code

CoreProtect now logs every hit between players, but it never sees a
nonlethal knockout: RPCharacters cancels the knockout blow, and CoreProtect
skips cancelled hits. Report each knockout to CoreProtect's new
logPvpKnockout API so staff see it next to the hits that led to it.

CoreProtect is reached by reflection, so RPCharacters gains no load order
against it and keeps working without it or with an older version, which
gets one warning.

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

coderabbitai Bot commented Oct 17, 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: e5818c40-2ed9-4213-95c3-95aa43be6fba
📥 Commits

Reviewing files that changed from the base of the PR and between dafa539 and 03e4d50.

📒 Files selected for processing: 4
  • src/main/java/net/tfminecraft/rpcharacters/pvp/CoreProtectKnockouts.java
  • src/main/java/net/tfminecraft/rpcharacters/pvp/PvpKnockoutManager.java
  • src/test/java/net/tfminecraft/rpcharacters/pvp/CoreProtectKnockoutsTest.java
  • src/test/java/net/tfminecraft/rpcharacters/pvp/PvpKnockoutManagerTest.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

  • New Features
    • PvP knockouts are now recorded in CoreProtect when it is available and supports knockout logging.
    • Knockout handling continues if CoreProtect is unavailable, does not support this feature, or encounters an error. Existing knockout behaviour is unchanged.

When lethal damage is cancelled, the PvP knockout path resolves the attacker, logs the attacker and victim through CoreProtect, and handles the knockout. The logging helper returns false when CoreProtect or its API is unavailable.

Changes: CoreProtect knockout logging

Layer / File(s) Summary
Reflective CoreProtect logging
src/main/java/net/tfminecraft/rpcharacters/pvp/CoreProtectKnockouts.java, src/test/java/net/tfminecraft/rpcharacters/pvp/CoreProtectKnockoutsTest.java
The helper checks for an enabled CoreProtect plugin and a usable API before invoking logPvpKnockout. It returns false for unavailable APIs or failures, and logs a warning once. Tests cover results, missing players or plugins, disabled plugins, older APIs, and exceptions.
Lethal-damage integration
src/main/java/net/tfminecraft/rpcharacters/pvp/PvpKnockoutManager.java, src/test/java/net/tfminecraft/rpcharacters/pvp/PvpKnockoutManagerTest.java
After cancelling lethal damage, the manager resolves the attacker once, logs the knockout, and passes that attacker to PvpStrikeService. The test verifies the logging call.

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PvpKnockoutManager
  participant CoreProtectKnockouts
  participant BukkitPluginManager
  participant CoreProtect
  PvpKnockoutManager->>CoreProtectKnockouts: log(attacker, victim)
  CoreProtectKnockouts->>BukkitPluginManager: Look up CoreProtect plugin
  BukkitPluginManager-->>CoreProtectKnockouts: Return plugin
  CoreProtectKnockouts->>CoreProtect: Get API and invoke logPvpKnockout
  CoreProtect-->>CoreProtectKnockouts: Return result
Loading

Suggested reviewers: xxfran10xx

Merge Risk: ⚪ Minimal · up to 03e4d

This change logs nonlethal knockouts to CoreProtect when it is available. Knockouts continue normally when CoreProtect is absent or too old. No actionable 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 031f363 into main Oct 17, 2026
3 checks passed
@ryanbarlow97
ryanbarlow97 deleted the feat/log-knockouts-coreprotect branch October 17, 2026 12:18
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.

2 participants