Solved Synchronous packet listening + creation + modification

Discussion in 'Spigot Plugin Development' started by iso2013, Jul 20, 2019.

Thread Status:
Not open for further replies.
  1. Hello, I am currently trying to update an API of mine and I was wondering how it would be possible to listen for, intercept, and modify as well as create packets in the inbound and outbound direction on the main server thread. I am aware of how to do it on another thread; however, I want to do it on the main server thread.

    I know this is possible because this is done with ProtocolLib - which I've been using, but I don't want to wait for it to update anymore, so I'd like to modify the packets myself.

    How would I go about doing this? Thanks!
  2. You might want to build your own version of bukkit then and add your hook wherever you want it to be at.
  3. Not feasible - this is a publicly downloadable project.
  4. It's very feasible. Its called Pulling the Project and editing the source to your needs. This is what Paper does.
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  5. x86


    If protocollib can do it just look at the source?
    • Creative Creative x 1
  6. You aren't familiar with git by any chance?
    • Funny Funny x 1
    • Like Like x 2
  7. Via the Netty channels it is not the main thread it is at least one Netty thread or multiple.
  8. Wasn't talking about netty here but about what he said:

  9. MiniDigger


    protocollib only does it for one direction iirc.

    for sending, how would you want to modify the packet sync if it was send async? the only way would be to cancel the packet and resend it sync, which is kinda ugly I guess.
    for receiving stuff should be easy, depending on where you hook in, minecraft already does most of the packet processing on the main thread.

    if you just create a netty handler, you could just cancel the incoming packet, sync to main thread and then call the processing methods minecraft has manually (its a method in the packet, so thats easy)
    • Winner Winner x 1
Thread Status:
Not open for further replies.