Implement pre via version injection support for spigot module#1446
Implement pre via version injection support for spigot module#1446ytnoos wants to merge 8 commits intoretrooper:2.0from
Conversation
|
Damn |
|
W |
|
Pure ViaVersion evilness:tm: |
|
Hm, I'm not quite sure whether it is a good idea to lock this behavior behind a setting - would it be possible to dynamically inject our handlers if someone wants to register a pre-via listener? |
Injection is mostly done during PacketEvents init, and since anyone can register listeners at any time, it would mean that in order to do it correctly, we would reinject server channel and all connected players the first time a pre-via listener is registered. I think it can be done but the possibility of creating new problems increases. Is it worth it? |
|
The problem with settings is that they are shared globally across all plugins using packetevents (except when you're shading) I can take a look at dynamic injection later |
|
After some thought, dynamic injection may actually be the smartest option here. Based on the type of listener the developer(s) register, a handler (pre or post ViaVersion) will be added to the pipeline (dynamically). If developers register both, then we will have two handlers for incoming packets and two for outgoing. I think this is actually a decent solution, the only issue is PacketEvents has an internal listener which, by default, listens post ViaVersion. So on PE installations, the post ViaVersion handler would always be there no matter what. |
|
I haven't tested this yet, let me know if the logic is fine. I couldn't find any other way to actually intercept registered listeners without exposing methods to EventManager that anyone could call |
|
Looking forward towards this pull request! |
|
Tested on 1.8.8 and 1.21.8 and works well! |
|
I suppose we can start reviewing and editing this PR. I have not received any PR from Axionize, a Grim maintainer. |
|
So far, I've not been able to reach a resolution with the Grim team. I can start reviewing this PR starting on April 20th; feel free to send me reminders around that time. If possible, could you resolve the conflicts? @ytnoos |
|
Don't review it yet. I'm still testing a few new things |
|
[17:31:19 INFO]: [packetevents] Failed to map the Packet ID 334 to a PacketType constant. Bound: CLIENT, Connection state: LOGIN, Server version: 1.20.4 It seems that support for some server versions has been broken |
Can you tell me client version and plugin list? |
|
ClientVersion: 1.20.4 |
|
@Dg32z try this version, apparently the encoder was not in the right spot compared to the compression. I also fixed the fact that the PreViaInternalListener was always forcing packetevents to inject pre-via handlers. |
seem fixed |
Since Retrooper gave us the opportunity to possibly accept the pre-via patch, here we are. I merged my patch with the fixes [1] [2] made by @Axionize, whom I thank very much for contributing and making this possible. Currently, an old version of this patch is used by both Grim and LPX.
By default, PacketEvents keeps the standard post-Via behavior.
Pre-Via support is enabled dynamically when a Pre-Via listener is registered: in order to do that just override
isPreVia()in your listener:I apologize in advance for any errors and look forward to hearing from you if any changes or improvements to the code are needed.