Skip to content

feat: support MiniMessage and hex colours in phase text - #20

Merged
tastybento merged 1 commit into
developfrom
feat/minimessage-phase-text
Aug 8, 2026
Merged

feat: support MiniMessage and hex colours in phase text#20
tastybento merged 1 commit into
developfrom
feat/minimessage-phase-text

Conversation

@tastybento

Copy link
Copy Markdown
Member

Ported from AOneBlock, which this addon is forked from and shares the display code with. See BentoBoxWorld/AOneBlock#551.

The report

An admin coloured a phase hologram with <green><bold>Начало (Равнина)</bold></green> and got white text with the tags rendered literally.

Why

Holograms deserialized with LegacyComponentSerializer.legacyAmpersand(), which understands the 16 legacy & codes and nothing else. Adventure builds that instance with hexColours = false, so even &#RRGGBB did not work there.

The action bar used a second, separately configured serializer that did support hex but not MiniMessage.

Display Before After
Hologram & only &, §, hex, MiniMessage
Action bar & + hex &, §, hex, MiniMessage
Boss bar title unchanged — String API, BentoBox already resolves it unchanged

The fix

Both Component paths now use Util.parseMiniMessageOrLegacy, which accepts MiniMessage, & and § codes, hex, and any mixture — and is cached on the BentoBox side, so the per-block hologram and action bar rebuilds do not re-parse the same strings.

This also fixes § codes being rendered as literal text. Translations come back from User.getTranslation already converted to § codes, so anything locale-sourced was being handed to a serializer bound to &. That affected the starting hologram and the action bar. Phase file hologram lines never see the translation layer, which is why the reported case showed raw MiniMessage tags rather than raw § codes.

Compatibility

  • Existing configs are unaffected. & codes keep working and are covered by tests.
  • BentoBox's MiniMessage instance is the non-strict MiniMessage.miniMessage(), so a hologram containing stray angle brackets (<-- break this) is left as literal text rather than throwing.
  • Util.parseMiniMessageOrLegacy is BentoBox 3.2.0 API — no dependency bump needed. This branch is based on develop and is independent of fix: do not lose island progress when the server restarts #18.

Tests

637 passing. New coverage on both paths for MiniMessage, gradients, & codes, § codes and hex, asserting on the serialized formatting rather than the component tree shape.

Not boot-tested on a live server — the behaviour is exercised through the real Util code path in tests, but I have not watched a hologram render in-game.

🤖 Generated with Claude Code

https://claude.ai/code/session_014t1DSo2wMbTWZLcwXpwUmQ

Ported from AOneBlock, which this addon is forked from and shares the display
code with. See BentoBoxWorld/AOneBlock#551.

An admin coloured a phase hologram with <green><bold>...</green> and got white
text with the tags shown literally.

Holograms deserialized with LegacyComponentSerializer.legacyAmpersand(), which
understands the 16 legacy & codes and nothing else - Adventure builds that
instance with hexColours=false, so even &#RRGGBB did not work. The action bar
used a second, separately configured serializer that did support hex but not
MiniMessage. Two display paths, two different answers to "what formatting can
I use here", neither documented where anyone would look.

Both now go through Util.parseMiniMessageOrLegacy, which accepts MiniMessage,
& and section codes, hex, and any mixture, and is cached on the BentoBox side.

This also fixes section codes being rendered as literal text. Translations come
back from User.getTranslation already converted to section codes, so anything
locale-sourced was being handed to a serializer bound to '&' - the starting
hologram and the action bar both took that path. Phase file hologram lines
never see the translation layer, which is why the reported case showed raw
MiniMessage tags rather than raw section codes.

The boss bar title is untouched: it uses the String-based Bukkit BossBar API
and BentoBox has already resolved its formatting by then.

Existing configs are unaffected. BentoBox's MiniMessage instance is the
non-strict one, so text containing stray angle brackets is left as literal
text rather than throwing.

Util.parseMiniMessageOrLegacy is BentoBox 3.2.0 API, so this needs no
dependency bump.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014t1DSo2wMbTWZLcwXpwUmQ
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@tastybento
tastybento merged commit a0de563 into develop Aug 8, 2026
3 checks passed
@tastybento
tastybento deleted the feat/minimessage-phase-text branch August 8, 2026 21:44
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