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 decode does not consider options of builder... #1116

Open
nicolube opened this issue Oct 9, 2024 · 7 comments
Open

Legacy decode does not consider options of builder... #1116

nicolube opened this issue Oct 9, 2024 · 7 comments

Comments

@nicolube
Copy link

nicolube commented Oct 9, 2024

Hello,

I have build a serializes looking like this.

                LegacyComponentSerializer.builder()
                        .character(LegacyComponentSerializer.AMPERSAND_CHAR)
                        .formats(LEGACY_COLOR)
                        .build());

I wanted to use it to translate just ChatColors, but it still docdes stuff like this:
&x&f&f&f&f&f&eYour Text

Which I think should only work when useUnusualXRepeatedCharacterHexFormat() was used in the builder.

@zml2008
Copy link
Member

zml2008 commented Oct 9, 2024

What is the use case for this? Changing these defaults will likely break plugins currently in use.

@nicolube
Copy link
Author

nicolube commented Oct 9, 2024

@zml2008 As mentioned above, we use it for converting chat colors.

If a user types &x&f&f&f&f&f&eYour Text, we get something like this.
Image

But it is disabled by default, the issue is just that is not checked on deserialize , only in serialize.
So we cannot disable useUnusualXRepeatedCharacterHexFormat() is we want to.

@nicolube
Copy link
Author

nicolube commented Oct 9, 2024

Also the same issue exists with Kyori chat colors &#FF0000Some text, which needs also needs be enabled via hexColors() in builder to work.

But currently it also works without enabling on deserialize.

@zml2008
Copy link
Member

zml2008 commented Oct 9, 2024

Why are you checking the style in the serializer, which is specific to the legacy format? You could just as easily strip formatting from the resulting component after deserializing (which would apply to any formatting option supported in the legacy serializer, not just the RGB colours).

As-is, it sounds like you're asking for an incomplete solution that changes behaviour. If more flexibility were added, I think it'd make sense to be done similarly to the JSONOptions flags, where the default options are as-is, but individual options can be toggled to match specific game versions.

@nicolube
Copy link
Author

nicolube commented Oct 9, 2024

Ahh ok, I see always de-serializer is a feature of this.

Would it be fine to add something to the builder one could disable it?

Builder#format has a different behavior as Builder#hexColor and Builder#useUnusualXRepeatedCharacterHexFormat

Builder#format allows u to change the behavior of both serialization and deserialization

Builder#hexColor and Builder#useUnusualXRepeatedCharacterHexFormat only lets one change the serialization behavior...

Is that wanted?

@zml2008
Copy link
Member

zml2008 commented Oct 9, 2024

No. Please read what I said about the system that the gson serializer uses.

@nicolube
Copy link
Author

nicolube commented Oct 9, 2024

Yes I have seen that.

I just got a bit confused because Builder#format changes both and the other 2 does not...

Should in this case LegacyComponentSerializerImpl#decodeTextFormat not rater use CharacterAndFormatImpl.Defaults.DEFAULTS instead of this.formats so that it also only apply to serialize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants