PlotSquared icon indicating copy to clipboard operation
PlotSquared copied to clipboard

fix: /plot info escapes MiniMessage colors #3911

Open Leviaria opened this issue 4 months ago • 5 comments

Overview

#3911 Fix MiniMessage formatting being escaped in /plot info command

Description

Fixed an issue where MiniMessage formatting in plot flags (greeting, farewell, description, plot-title) was being displayed as escaped/literal text in the /plot info command instead of being properly rendered with formatting.

image

Problem: When setting flags with MiniMessage formatting like:

/plot flag set greeting <rainbow>Welcome to my plot</rainbow>

The /plot info command would display:

Flags: greeting: <rainbow>Welcome to my plot

Instead of showing the text with proper rainbow formatting.

image

Root Cause: The flag display logic in Plot.java was using Component.text() for all flag values, which treats MiniMessage markup as literal text instead of parsing it as formatting.

Solution:

  1. Added isMiniMessageFlag() method in CaptionUtility.java to identify flags that should be parsed as MiniMessage (greeting, farewell, description, plot-title)
  2. Enhanced flag display logic in Plot.java to conditionally parse MiniMessage flags using MINI_MESSAGE.deserialize() while keeping other flags as plain text
  3. Added error handling with fallback to plain text if MiniMessage parsing fails

Benefits:

  • ✅ MiniMessage flags now display with proper formatting in /plot info
  • ✅ Non-MiniMessage flags continue to work exactly as before
  • ✅ Robust error handling prevents crashes from malformed MiniMessage
  • ✅ Backward compatibility maintained

Test Cases:

  • /plot flag set greeting <rainbow>Welcome!</rainbow> → displays with rainbow formatting
  • /p flag set greeting <gradient:red:blue>Cool plot</gradient> → displays with correct formatting

Submitter Checklist

  • [X] Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • [X] Ensure that the pull request title represents the desired changelog entry.
  • [X] New public fields and methods are annotated with @since TODO.
  • [X] I read and followed the contribution guidelines.

Leviaria avatar Aug 03 '25 12:08 Leviaria

Hm, this might be a conflict of interests. An admin might want to see e.g., hyperlinks, clickable commands, etc. that are part of the message.

SirYwell avatar Aug 03 '25 13:08 SirYwell

Hm, this might be a conflict of interests. An admin might want to see e.g., hyperlinks, clickable commands, etc. that are part of the message.

I can add -raw as well, no problem — but I’d open that as a separate enhancement, since this issue is mainly about fixing the 'bug', right? Or did I get that wrong?

Leviaria avatar Aug 03 '25 13:08 Leviaria

I can add -raw as well, no problem — but I’d open that as a separate enhancement, since this issue is mainly about fixing the 'bug', right? Or did I get that wrong?

It's probably best to add the option in this PR, as the old behaviour is effectively established now, so we should continue to support it

dordsor21 avatar Aug 03 '25 13:08 dordsor21

Animation

Like this?

Leviaria avatar Aug 03 '25 13:08 Leviaria

FWIW I'd really recommend learning how to use git... It'll make everything a lot easier than copy-pasting files into GitHub from (ngl what I assume to be vibe-coded) local changes.

Otherwise, surely it's easier to just add an overload to the Plot#format method and add a new boolean for rawOutput than using metadata (which just feels janky)

dordsor21 avatar Aug 03 '25 16:08 dordsor21