Skip to content

fix: keep personalized instruments playable - #19

Merged
ryanbarlow97 merged 1 commit into
mainfrom
fix/renamed-instruments
Sep 25, 2026
Merged

ryanbarlow97 merged 1 commit into
mainfrom
fix/renamed-instruments

Conversation

@ryanbarlow97

@ryanbarlow97 ryanbarlow97 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Namestones and lorestones currently stop lutes and other instruments from playing because detection requires an exact item-metadata match. Keep the existing exact-match pass, then compare cached copies with only display name and lore removed. Material, model data and provider metadata must still match; ambiguous cosmetic-only variants are rejected. Detection never changes the held item or the templates returned by /instruments give.

Validation: reproduced both rename and lore failures before the fix; all 7 regression tests now pass with no skips under Java 21/Paper 1.21.10, including identity rejection, item preservation, ambiguity and reload coverage. mvn clean verify, runtime JAR validation and git diff --check pass. Diff review found no remaining blockers.

Summary by CodeRabbit

  • Bug Fixes
    • Instruments are now recognized despite changes to their stack size, display name, or lore when there is a single matching instrument.
    • Exact instrument matches take priority. Items that could match multiple instruments are not identified as a match, and empty hands or items with different materials, model data, or provider identity are rejected.
    • Reloading instrument templates no longer leaves outdated matches available.

@coderabbitai

coderabbitai Bot commented Sep 25, 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: d232e11d-8939-446d-a16e-9ef1bfd35553

📥 Commits

Reviewing files that changed from the base of the PR and between 535df3f and b18902d.

📒 Files selected for processing (3)
  • pom.xml
  • src/main/java/net/tfminecraft/musicalinstruments/managers/InstrumentManager.java
  • src/test/java/net/tfminecraft/musicalinstruments/managers/InstrumentManagerTest.java

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


📝 Walkthrough

Walkthrough

InstrumentManager now recognizes instruments by exact item match or, when that fails, by a unique match that ignores display names and lore. Template reloads clear both caches. Tests cover recognition, rejection, ambiguity, and reload behavior.

Changes

Instrument Recognition

Layer / File(s) Summary
Template matching and cache lifecycle
src/main/java/net/tfminecraft/musicalinstruments/managers/InstrumentManager.java
InstrumentManager caches cosmetic-free template copies. It checks exact matches first and returns a fallback match only when it is unique. It rejects null and air items, and clears the caches on reload.
Recognition tests and test setup
pom.xml, src/test/java/net/tfminecraft/musicalinstruments/managers/InstrumentManagerTest.java
Maven adds test dependencies and configures Surefire. Tests cover cosmetic edits, item mismatches, ambiguity, and reloads.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b1890

No merge-blocking issue is established; the change is ready for normal merge checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to b1890

Personalized instruments become playable, but recognition still requires a unique match on non-cosmetic item properties. No security bypass was established. The risk remains low rather than minimal because item provenance and possible external callers are not fully known.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The independently player-controlled input is the held item. The established effect of broader recognition is confined to instrument identification and its gameplay playback and event path; downstream event-consumer behavior was not established.

Security Findings and Attack Paths

  • inferred — No bypass is established for an item that differs in non-cosmetic identity or has an ambiguous cosmetic-only match. Whether players can obtain or forge otherwise matching identity metadata remains unverified.

Trust Boundaries and Controls

  • observed — Recognition clones the input before cosmetic removal, retains exact-match precedence, rejects ambiguous fallback matches, and returns null for unmatched items before the listener plays a sound or emits an event.

Resilience and Maintainability Implications

  • inferred — A concurrent recognition call could see partially rebuilt or stale paired caches during reload. Inspected callers use a command, event handler, or synchronous timer; no asynchronous caller was established, so this is a conditional integration risk rather than an observed exploit.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. (1 skipped: … 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: personalized instruments remain playable despite cosmetic name or lore changes.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. (1 skipped: 1 unsupported.)

  • 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 taps a lute at noon
Its name and lore drift like a tune
One clear match hops into view
Old templates leave; fresh ones renew
The rabbit bows, then thumps out two!

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

@ryanbarlow97
ryanbarlow97 merged commit 11a31e3 into main Sep 25, 2026
2 checks passed
@ryanbarlow97
ryanbarlow97 deleted the fix/renamed-instruments branch September 25, 2026 21:41
@ryanbarlow97

Copy link
Copy Markdown
Contributor Author

Reviewed the final diff; CodeRabbit approved with no actionable comments. Its docstring-coverage advisory was non-blocking. PR, merged-main and release builds passed.

Released v3.0.3 from merge commit 11a31e3d8ac12370c4fac168684dfc1652818566; the release JAR checksum and embedded version were verified.

Dev was updated and restarted. A temporary, self-disabling smoke plugin verified all 9 configured instrument items against the real Paper/MMOItems runtime: unchanged items, namestone renames, combined lorestone edits, item/template preservation and plain-item rejection all passed, including the lute. The smoke plugin was removed afterwards. No new startup error lines appeared against the captured baseline.

The identical JAR is installed on main without a restart or reload; the running Java process and start time are unchanged. Main will activate the fix on its next restart. Both servers respond to Minecraft status requests; rollback JARs were preserved and verified.

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.

1 participant