Fix multi-line lore/text losing colour after the first line#2999
Merged
Conversation
…3.18.1) componentToLegacy walked the component tree and emitted a style transition once per text node, then appended the node's content verbatim. When that content spanned newlines, the colour/format code was written only before the first line. Legacy lore/text is split on '\n' downstream (each line becomes a separate tooltip line) and a colour code only applies to the end of its line, so every line after the first rendered in the default colour. Re-emit the active style after each newline: colour first (a colour code clears decorations in vanilla), then any active decorations. So "<gray>a\nb" now serialises to "§7a\n§7b" and each split line keeps its colour. Fixes multi-line names and lore across all addons. Adds LegacyToMiniMessageTest#testColourCarriesAcrossNewlines and #testColourAndBoldCarryAcrossNewlines. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Jyeq1kNrXsAkNssTCTyqZ
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a legacy-serialization edge case in Util.componentToLegacy where multi-line component text (\n) would lose its active colour/decoration on the second and subsequent lines after downstream splitting into lore/tooltip lines.
Changes:
- Update the legacy component serializer to re-emit the active legacy style codes after each newline while appending text content.
- Add regression tests covering colour-only and colour+bold multi-line cases.
- Bump the project version to
3.18.1.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main/java/world/bentobox/bentobox/util/Util.java |
Re-emits active legacy style codes after \n when serializing component text to preserve formatting per lore line. |
src/test/java/world/bentobox/bentobox/util/LegacyToMiniMessageTest.java |
Adds regression tests ensuring each newline-separated line restates the expected legacy codes. |
build.gradle.kts |
Updates buildVersion to 3.18.1. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Multi-line names and lore lose their formatting after the first line — the second and subsequent lines render in the default (purple) colour, even when each source line specifies a colour. This affects GUI tooltips across all addons (reported on Challenges).
Root cause
Util.componentToLegacywalks the component tree and emits a style transition once per text node, then appends the node's content verbatim. When a text node's content spans newlines, the colour/format code is written only before the first line. Downstream, legacy lore/text is split on\n(each line becomes a separate tooltip line) and a legacy colour code only applies to the end of its line — so every line after the first renders uncoloured.Concretely,
<gray>line1\nline2serialised to§7line1\nline2; after the\n-split the second line had no colour code left.Fix
When appended text spans newlines, re-emit the active style after each
\n: colour first (a colour code clears decorations in vanilla), then any active decorations. So<gray>a\nbnow serialises to§7a\n§7b, and each split line keeps its colour. Multi-decoration state (e.g. gold + bold) is restated in the correct order too.Tests
Adds to
LegacyToMiniMessageTest:testColourCarriesAcrossNewlines— each line of a two-line gray string starts with§7.testColourAndBoldCarryAcrossNewlines— each line restates§6§l(colour then bold).LegacyToMiniMessageTestandUtilTestpass.Bumps version to 3.18.1.
🤖 Generated with Claude Code