Uh oh!
There was an error while loading. Please reload this page.
Compare base potion type when metadata is ignored - #409
Merged
Conversation
When a potion material was in the ignore-metadata list, items were matched by Material alone, so any potion matched any other potion and removal could consume the wrong ones. Now potion-like items (POTION, SPLASH_POTION, LINGERING_POTION, TIPPED_ARROW) still compare their base PotionType while ignoring other metadata. Fixes#320 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NKxodNE4h3TsSHMqDEeC8v
Remove the always-false inventory null check (User#getInventory is non-null for players), use Stream.toList(), use pattern-matching instanceof in Utils, and drop an unused test variable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NKxodNE4h3TsSHMqDEeC8v
Keep both the #320 potion tests and the #111 consumption tests in TryToCompleteTest. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NKxodNE4h3TsSHMqDEeC8v
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes#320
Problem
When a potion material was in a challenge's ignore-metadata list, items were matched by
Materialalone. Since every potion sharesMaterial.POTION, any potion matched any required potion — a Speed II potion satisfied (and could be consumed for!) a Water Bottle requirement.Fix
A single shared matcher now handles the ignore-metadata logic at every comparison site (requirement counting,
countInInventory,removeFromInventory,removeItems, andUtils.groupEqualItemsused for GUI grouping — counting and removal always agree):POTION,SPLASH_POTION,LINGERING_POTION,TIPPED_ARROW): still compare the basePotionTypefromPotionMeta, ignoring names, lore, custom model data, and NBT added by other plugins. Same base potion = match.isSimilarcomparison, unchanged.The potion helpers live in
Utilsso display grouping and completion logic share one implementation.Tests
Four new tests in
TryToCompleteTest: same base type with extra meta matches; different base types don't; helper methods directly; non-potion ignore-metadata behaviour unchanged. Suite: 61/61 inTryToCompleteTest, full run green (462 tests).In-game verification
POTIONin ignore-metadata.🤖 Generated with Claude Code
https://claude.ai/code/session_01NKxodNE4h3TsSHMqDEeC8v