ProtocolLib build 624 ignores any attempt at modifying WrappedServerPing
Andre601 opened this issue ยท 10 comments
- 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:
- Listen for a PacketEvent of PacketType
Status.Server.SERVER_INFO
- Try modifying the MOTD using
WrappedServerPing#setMotD(WrappedChatComponent)
- 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
- Please note that I'm using
- Ping the server with the client
- 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:
- Listening to ProtocolLib events:
https://github.com/Andre601/AdvancedServerList/blob/master/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/events/ProtocolLibEvents.java#L71 - Calling the central PingEventHandler class with a newly created ProtocolLibEventWrapper class containing important values:
https://github.com/Andre601/AdvancedServerList/blob/master/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/events/ProtocolLibEvents.java#L74 - The ProtocolLibEventWrapper class:
https://github.com/Andre601/AdvancedServerList/blob/master/bukkit/src/main/java/ch/andre601/advancedserverlist/spigot/events/ProtocolLibEventWrapper.java - The central PingEventHandler:
https://github.com/Andre601/AdvancedServerList/blob/master/core/src/main/java/ch/andre601/advancedserverlist/core/events/PingEventHandler.java- It simply calls the methods of the Wrapper class provided, which itself sets the stuff using the provided values.
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.
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.
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
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?
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
Just write changed WrappedServerPing back to the StructureModifier<>
In my case everything works after this
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.
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?