fix: handle and exclude dotless sound keys (intentionally_empty)#909
Merged
Conversation
SoundEvents whose minimal key contains no '.' (e.g. intentionally_empty)
caused makeSoundButton to call id.substring(0, id.indexOf('.')) with an
index of -1, throwing StringIndexOutOfBoundsException. Guard the dotless
case so the whole id is used as the key and falls through to the default
icon.
intentionally_empty is a placeholder no-op sound, not something a user would want to pick. Skip it when building the sound search index so it never appears in results.
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 free
to 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.
Problem
Selecting/rendering the
minecraft:intentionally_emptysound in the action editor crashed a scheduled task with:makeSoundButtonparses a sound's minimal key ascategory.path…to pick an icon, assuming every key contains a.:intentionally_empty(asMinimalString()→intentionally_empty, 19 chars, no dot) is a placeholder "no sound" event that has no category prefix, soindexOf('.')returns-1andsubstring(0, -1)throws. It surfaced inside the debounced anvil-search update, hence "Exception in scheduled task."Fix
PlaySoundEditor.makeSoundButton— guard the dotless case: the whole id is used as the key and falls through to the default icon. Also computes eachindexOfonce instead of recomputing the second dot. Defends against any other dotless sound key.Autocompletors— excludeSoundEvent.INTENTIONALLY_EMPTYwhen building the sound search index, so the no-op placeholder sound never appears as a pickable option in the first place.Both modules compile clean.
PostHog issue
https://us.posthog.com/project/72878/error_tracking/019cf337-116b-7323-a8b6-6baeba2d2630