Skip to content

SPIGOT-8024, #3811: Add versioned chat serialization #3812

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

Closed
wants to merge 2 commits into from

Conversation

@md-5 md-5 requested a review from Outfluencer March 27, 2025 09:38
@md-5
Copy link
Member Author

md-5 commented Mar 27, 2025

cc/ @Janmm14

@Outfluencer
Copy link
Collaborator

Outfluencer commented Mar 27, 2025

Shouldn't we also deserialize by version?

For example here?

we should do it like this right?

JsonObject clickEvent = serializer.getVersion() == ChatVersion.V1_21_5 ? object.getAsJsonObject( "click_event" ) : object.getAsJsonObject( "clickEvent" );

if ( clickEvent != null )
{
    ClickEvent.Action action = ClickEvent.Action.valueOf( clickEvent.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
    if ( serializer.getVersion() == ChatVersion.V1_21_5 )
    {

@NEZNAMY
Copy link

NEZNAMY commented Mar 27, 2025

It would be great to also translate ChatColor to nearest legacy color for <1.16 players.

@md-5
Copy link
Member Author

md-5 commented Mar 27, 2025

Shouldn't we also deserialize by version?

For example here?

we should do it like this right?

JsonObject clickEvent = serializer.getVersion() == ChatVersion.V1_21_5 ? object.getAsJsonObject( "click_event" ) : object.getAsJsonObject( "clickEvent" );

if ( clickEvent != null )
{
    ClickEvent.Action action = ClickEvent.Action.valueOf( clickEvent.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
    if ( serializer.getVersion() == ChatVersion.V1_21_5 )
    {

I think it's OK for the moment to have the deserialization be universal (especially for compatibility).

It would be great to also translate ChatColor to nearest legacy color for <1.16 players.

Not really related to this PR

@Outfluencer
Copy link
Collaborator

do hover events work in server list motd?
If so we should probably also have a second PingHandler json for the new version, if not its probably okay if we just ignore it as it won't be displayed anyway

@md-5
Copy link
Member Author

md-5 commented Mar 27, 2025

I'm not sure - can you check please?

@Outfluencer
Copy link
Collaborator

Yes i'll check now

@Outfluencer
Copy link
Collaborator

Outfluencer commented Mar 27, 2025

Adding a hover event to the motd components clears the full motd on 1.21.4
on old versions like 1.8.9 it just does nothing
But in both cases no hover text is displayed

And click event does not work at all

this is the json that makes the motd disabear

{"version":{"name":"BungeeCord 1.8.x-1.21.x","protocol":769},"players":{"max":1,"online":0},"description":{"hoverEvent":{"action":"show_text","contents":{"value":"HALLLOOO"}},"extra":[{"color":"dark_blue","text":"Another Bungee server"}],"text":""},"modinfo":{"type":"FML","modList":[]}}

I think we can it ignore it for now

@Janmm14
Copy link
Contributor

Janmm14 commented Mar 27, 2025

Codewise I do not see anything bad. Didn't test it tho.

@md-5 md-5 closed this Mar 27, 2025
@md-5 md-5 deleted the versioned-chat branch March 27, 2025 20:01
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.

4 participants