Efficiency question.

Discussion in 'Plugin Development' started by Vilsol, Nov 26, 2013.

?

Does it do an impact?

  1. Yes

    0 vote(s)
    0.0%
  2. No

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    Vilsol

    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.
     
  2. Offline

    L33m4n123

    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
     
  3. Offline

    Garris0n

    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 :p
     
  4. Offline

    Vilsol

    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.
     
Thread Status:
Not open for further replies.

Share This Page