retrooper / packetevents

Precision meets performance—a powerful tool for mastering Minecraft packet manipulation with speed and finesse.
GNU General Public License v3.0
555 stars 150 forks source link

Synchronize packet encoding #995

Closed booky10 closed 2 months ago

booky10 commented 2 months ago

Resolves concurrency issues which may happen when sending the same packet wrapper to different players, concurrently

This is not a perfect solution, but the alternative would be refactoring the packetwrapper to be based on buffers passed during encoding as parameters, which would be too much effort and would require breaking changes

Fixes https://github.com/retrooper/packetevents/issues/991

retrooper commented 2 months ago

My question would be why you didn't opt for the Java Lock class?

booky10 commented 2 months ago

I don't see a reason to use locks when we can just use synchronized If you would prefer locks I can change this logic to use locks, but that should not make a difference