Skip to content

Conversation

@Skullians
Copy link
Contributor

@Skullians Skullians commented Mar 8, 2025

! THIS IS A DRAFT PR. This is purely to track progress and to allow code reviewing. It is not yet completed nor is it stable. !

PR Summary:
This PR adds compatibility for PacketEvents, while maintaining ProtocolLib compatibility as well.

The default selected plugin is PacketEvents, and is found in the config.yml under Settings.

TODO:

  • Refactor some ProtocolLib code - mainly splitting them up into smaller methods where possible, and splitting ones into platform independent methods to reduce code duplication: some duplication is inevitable.
  • Barebones abstraction layer for protocol platforms
  • Actual Packetevents implementation

Skullians added 12 commits March 8, 2025 17:34
Also began implementing ProtocolPlatform instance for PacketEvents.

Made some adjustments to PreChatPacketSendEvent, as that directly references ProtocolLib PacketContainers, which isn't ideal as PE code also needs to trigger that event.

We've thought of making a wrapper but more thought needs to be invested concerning what information would actually be stored within that wrapper that would actually be useful (after all, it's in the API so it needs to be relatively usable), as well as needing to figure out a nice way to map the PacketWrapper<?>(s) (PE) and PacketContainer(s) (PLib) to this wrapper.
DummyPlayer used to just use the shaded version of ByteBuddy within ProtocolLib (along with a utility class).

To remove the dependency on ProtocolLib, we have shaded and relocated ByteBuddy ourselves, and implemented the necessary utility classes.
1. Previously I installed the latest version of ByteBuddy, which uses Java 24 (class ver 68). As IC compiles with Java 8, I had to downgrade to v1.15.11 which compiles with java 8.
2. A PlayerUtils method used PLib code directly.
@Skullians
Copy link
Contributor Author

Skullians commented Mar 10, 2025

This PR is now able to be compiled.
Feel free to test on a development server.

This message will be edited with updates.

  • Server boots (I'd hope it would)

Identified an issue where placeholders are not parsed. Likely a result of reflection issues. Investigating. UPDATE: PE is throwing an error while attempting to clone the PacketSendEvent to preserve the original event and packet. A bug report has been issued. UPDATE: Turns out cloning events must be done on the Netty thread. This has been solved by cloning the event before passing everything to the executor for further processing. There are also several component related issues that I need to fix.

Thanks to the FANTASTIC decision of PacketEvents to shade Adventure API and NOT shade it, we encounter a large amount of errors, where we try to provide our own instance of Adventure (which is shaded and relocated), which obviously won't work.

We can't have any helper classes that convert to PE's shaded adventure because it's shaded but not relocated, so any instance of it will just be relocated by the compiler to our shaded version.

In the end, we do a bunch of reflection fuckery.
@Skullians
Copy link
Contributor Author

Okay.
Here's the deal.

Due to PacketEvents not relocating Adventure, and have confirmed they won't be (at least for a while), PacketEvents support will be provided in two steps:

  1. InteractiveChat will be adapted to not have an absolute dependency on ProtocolLib. The next few commits will completely strip the PacketEvents implementation from this codebase, however some code will remain that allows anyone to register their own ProtocolProvider.
  2. The PacketEvents implementation will be moved over to https://github.com/TerraByteDev/InteractiveChat-PacketEvents - this will improve maintainability.

This PR won't be ready for review until the actual addon is created.

@Skullians
Copy link
Contributor Author

Will be finishing and testing later this week.

@Skullians Skullians marked this pull request as ready for review March 21, 2025 16:20
@Skullians
Copy link
Contributor Author

Skullians commented Mar 21, 2025

This PR is ready for review.

If you wish to test, please download the latest release from https://github.com/TerraByteDev/InteractiveChat-PacketEvents/releases/tag/v1.0.5 and the following InteractiveChat plugin https://github.com/Skullians/InteractiveChatPacketEvents/releases/tag/v4.2.17.0

That release will be periodically updated with future commits (the file will be different, same name)

@LOOHP LOOHP mentioned this pull request Mar 21, 2025
@LOOHP LOOHP merged commit a12c07c into LOOHP:master Mar 22, 2025
1 check passed
@MVanilla
Copy link

MVanilla commented Jul 6, 2025

@Skullians Is this project discontinued? Or is it just for your server?

@Skullians
Copy link
Contributor Author

@MVanilla This isn’t quite ready yet, I’m still ironing out some bugs, and my time is limited.

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.

3 participants