SpigotMC / BungeeCord

BungeeCord, the 6th in a generation of server portal suites. Efficiently proxies and maintains connections and transport between multiple Minecraft servers.
https://www.spigotmc.org/go/bungeecord
Other
1.54k stars 1.1k forks source link

Possible unintentional functionality with "formatless" strings #3623

Open bob7l opened 5 months ago

bob7l commented 5 months ago

Bungeecord version

BungeeCord-Proxy 1.20-R0.3-SNAPSHOT ( build 1800)

Server version

No response

Client version

1.8, 1.20.2

Bungeecord plugins

None

The bug

Not sure if this is intended behavior, but if we readBaseComponent a String which has no format (example: 'asdasd'), the string will be given a default white color.

Upon being converted back to legacy text through toLegacyText(), the string will now contain the white format symbols at the beginning of the string therefor incrementing it's original length by 2

I managed to "fix" this by simply adding this check to verify the component actually has a set color:

void addFormat(StringBuilder builder) { if (!(!style.hasColor() && parent == null)) builder.append(getColor());

At BaseComponent's addFormat function

Log output (links)

No response

Checking

Outfluencer commented 4 months ago

i think you probably right

Janmm14 commented 3 months ago

This implementation causes wrong results of toLegacyText(BaseComponent...). I updated my PR (mentioned above) with new context-aware toLegacyText implementations.