Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy serializer doesn't apply color for empty content #1030

Open
WhatCats opened this issue Jan 28, 2024 · 3 comments
Open

Legacy serializer doesn't apply color for empty content #1030

WhatCats opened this issue Jan 28, 2024 · 3 comments

Comments

@WhatCats
Copy link

Code

Component component = Component.text().color(NamedTextColor.GRAY).build();
Loggers.debug(
    "%s -> %s",
    GsonComponentSerializer.gson().serialize(component),
    LegacyComponentSerializer.legacyAmpersand().serialize(component)
);

Ouput

{"color":"gray","text":""} ->

Expected Output

{"color":"gray","text":""} -> &7

Reason

If you are using Components for prefix's in 1.8 for example you might have this condition where you want a color but no text.

@kangarko
Copy link

That was a big issue for us too and I fixed by caching the last style of each component, and then appending it in the legacy serializer method. It's a bit of a more complex solution so I made a class called SimpleComponent which you can use.

It also fixes the color disappearing from new lines of multi-line hover text on 1.8.8 and adds support for both mini and legacy tags.

To get Adventure Component from it just use ".toAdventure()".

Hope that helps!

@zml2008
Copy link
Member

zml2008 commented Dec 1, 2024

Duplicate of #50

@zml2008 zml2008 marked this as a duplicate of #50 Dec 1, 2024
@zml2008 zml2008 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2024
@zml2008 zml2008 reopened this Dec 1, 2024
@zml2008
Copy link
Member

zml2008 commented Dec 1, 2024

Sorry, got confused with another issue. We've gone back and forth on whether this is considered WAI -- the output is visually identical, and it's pretty commonly accepted that the legacy serializer is lossy.

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

No branches or pull requests

3 participants