packetevents icon indicating copy to clipboard operation
packetevents copied to clipboard

Adding ability to add player-specific packet listeners

Open OOP-778 opened this issue 9 months ago • 8 comments

My motivate for this PR is simple, I'm too performance obsessed and doing ConcurrentHashMap calls to get data based is not for me, maybe others feel the same way, so the whole point of this PR is to make so you can register player-specific listeners so you can store state within the listener itself.

TODO:

  • [x] Separate EventManager impl to BaseEventManager
  • [x] Recreate the whole EventManager structure to allow inheriting packet listeners
  • [x] Store EventManager in user object itself
  • [x] Change the calls to be made for the User EventManager not global.

OOP-778 avatar Mar 14 '25 13:03 OOP-778

Would Java cry that the class has been changed from class to Interface? since none of the methods been removed.

OOP-778 avatar Mar 14 '25 13:03 OOP-778

So in theory the signature did not change of it apart that it became an interface

OOP-778 avatar Mar 14 '25 13:03 OOP-778

Would Java cry that the class has been changed from class to Interface? since none of the methods been removed.

Yes, it will

booky10 avatar Mar 14 '25 13:03 booky10

Okay imma make it abstract class

OOP-778 avatar Mar 14 '25 13:03 OOP-778

Gotta change the naming a bit of the event managers butt I think the structure-rework is done and should be backwards compatible.

OOP-778 avatar Mar 14 '25 14:03 OOP-778

@booky10 Pretty much done, apart from cleaning up some parts, lmk what your thoughts on the changes

OOP-778 avatar Mar 15 '25 08:03 OOP-778

P.S: Tested with Grim for backwards-compatability

OOP-778 avatar Mar 15 '25 08:03 OOP-778

You could also use a ThreadLocal to store state bound to netty threads, example: https://github.com/Beaness/UnnamedAC/blob/6042a33fa1fb53ca6b49188a53f4c399a8202975/plugin/src/main/java/me/beanes/acid/plugin/player/PlayerManager.java#L10

Beaness avatar Aug 01 '25 15:08 Beaness