Skip to content

Fix multi-line lore/text losing colour after the first line#2999

Merged
tastybento merged 3 commits into
developfrom
fix/multiline-lore-colour
Jul 1, 2026
Merged

Fix multi-line lore/text losing colour after the first line#2999
tastybento merged 3 commits into
developfrom
fix/multiline-lore-colour

Conversation

@tastybento

Copy link
Copy Markdown
Member

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.componentToLegacy walks 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\nline2 serialised 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\nb now 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).

LegacyToMiniMessageTest and UtilTest pass.

Bumps version to 3.18.1.

🤖 Generated with Claude Code

…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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/test/java/world/bentobox/bentobox/util/LegacyToMiniMessageTest.java Outdated
Comment thread src/test/java/world/bentobox/bentobox/util/LegacyToMiniMessageTest.java Outdated
tastybento and others added 2 commits June 30, 2026 21:02
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>
@tastybento tastybento merged commit b12e963 into develop Jul 1, 2026
1 check failed
@tastybento tastybento deleted the fix/multiline-lore-colour branch July 1, 2026 05:08
@tastybento tastybento mentioned this pull request Jul 1, 2026
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.

2 participants