I have been coding plugins for a while, and I could never come to an agreement with myself. I always try to make my plugins as efficient as possible, but I might not be doing it without even knowing. My question is does it do any big impact on the server if I am creating a lot of listeners. Would it be better to fit all in one, but do a lot more checks? I am asking this question, because I have to make a class and item system. As I want it so each item has an owner (So I can track inventory, and block changes), then each time I am creating a new instance of that item. In each instance there are listeners that would respond only when that specific player has done something. If it doesn't matter, by creating many listeners, then I have also done it so the first check is if the player is the owner, so the system doesn't do any other useless checks. Thank you in advance.
I am not 100% sure. HoweverI think firing an event once and then check the corresponding if-clause / switch-case might be in the end more efficcent then 20 events that fire simultaniously and still would need to check the if-clause/ switch-case
It's probably more efficient to use one Listener, not that I do it... I really should, though. At some point I'll switch all my plugins over
That is why I am checking if the owner is for that specific item. Also, I am checking only the entity id, so there is a very tiny check each time.