ProtocolLib

3M Downloads

ProtocolLib build 624 ignores any attempt at modifying WrappedServerPing

Andre601 opened this issue ยท 10 comments

commented
  • This issue is not solved in a development build

Describe the bug
Using the latest build of ProtocolLib (624 as of writing this), trying to alter the WrappedServerPing by for example modifying the MOTD are completely ignored by ProtocolLib.

Has something changed in the more recent builds? Like requiring to manually trigger an update?

To Reproduce
Steps to reproduce the behavior:

  1. Listen for a PacketEvent of PacketType Status.Server.SERVER_INFO
  2. Try modifying the MOTD using WrappedServerPing#setMotD(WrappedChatComponent)
    1. Please note that I'm using AdventureComponentConverter.fromComponent here, but it shouldn't do a difference as other methods not using components (i.e. Sample Players) also won't work
  3. Ping the server with the client
  4. See MOTD not changing in Server list

Expected behavior
The changes applied should be used.

Screenshots

Version Info
https://paste.helpch.at/arimifiwic.rb

Additional context
My plugin modifies the Server list entry in various ways such as MOTD, Favicon, Player count and hover of the player count and none of the options are working now with the latest builds on a 1.19.4 Spigot server, while the previous builds on 1.19.3 worked fine and without complications.

My plugin supports multiple platforms, which is why I use a Wrapper class and this has worked ever since I implemented it, except now. And from all platforms is Spigot not working due to the ProtocolLib dependency which by extension means it's an issue on ProtocolLib's end most likely.

In case this may help are here links to the classes I set up and use in order of their usage:

Through basic testing have I confirmed that my plugin is setting the MotD and other things (Methods are called) and ProtocolLib even causes Spigot to print a warn about it accessing a dependency in my plugin while not being defined as a (soft)depend or loadbefore of ProtocolLib:

[22:05:27] [Netty Server IO #1/WARN]: [ProtocolLib] Loaded class net.kyori.adventure.text.Component from AdvancedServerList v3.0.0-b1 which is not a depend or softdepend of this plugin.

This means that the component parsers is trying to work.

Perhaps the issue is an outdated Adventure dependency? Other plugins had similar issues.

commented

Would it be like this?

// event is a PacketEvent
event.getPacket().getServerPings().write(0, ping);

And if it is that, would I need to do anything regarding Ping (in terms of updating values) since as you said, the MC ping is now a record and immutable? Or does PL handle the stuff and create a new instance or whatever that is mutable?

You are right but for some reason the list of fake players and the favicon from me is not updated.

commented

Want to say stuff works, so I for my part close this.

commented

my guess is that you will need to write the resulting server ping back to the packet. in 1.19.4 mojang changed server info to be immutable (its a record instead of a class) so modifications to the wrapper aren't automatically passed through anymore

commented

Just write changed WrappedServerPing back to the StructureModifier<>
In my case everything works after this

I never did that so idk how this would look like.

Also, can this safely be used on former versions or would I need to do checks to only do that on the newer builds?

commented

I think for old versions it will look like you writing object (WSP) to map (SM<>) with key (0) while that map already contains this object with same key โ€” so nothing will change and no need to add version checks. Anyway just try and see

commented

So, what is the best way now to do this then?

commented

Just write changed WrappedServerPing back to the StructureModifier<>
In my case everything works after this

commented

I think for old versions it will look like you writing object (WSP) to map (SM<>) with key (0) while that map already contains this object with same key โ€” so nothing will change and no need to add version checks. Anyway just try and see

Giving the equivalent of "just do it" doesn't help me here.
Like I said did I never do this before, so I have no idea how this would even remotely look like.

commented

Would it be like this?

// event is a PacketEvent
event.getPacket().getServerPings().write(0, ping);

And if it is that, would I need to do anything regarding Ping (in terms of updating values) since as you said, the MC ping is now a record and immutable?
Or does PL handle the stuff and create a new instance or whatever that is mutable?

commented

yeah that's right. PL will handle all the mutability under the hood