1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Why put event listener in separate class/file?

Discussion in 'Facepalm' started by Thouv, May 3, 2017.

  1. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    So, I've seen that most plugins have their event listener in a file/class that is not their main class? What's the point of that and what are the effects of doing so?
     
  2. Lowkey

    Lowkey Slime

    Messages:
    94
    This is mainly just to keep their classes in their plugin cleaner. There isn't any known effects. However, if you are still learning about classes and objects I strongly advise that you do not do this, as it may get you confused quite easily.
     
  3. Thouv

    Thouv Slime

    Messages:
    84
    GitHub:
    adeynes
    Ok, so it doesn't matter if I register my events in my main class or in an EventListener class? I'll just keep everything in my main class then, it makes it easier for me (even though it's less organized)
     
  4. Lowkey

    Lowkey Slime

    Messages:
    94
    Yep, totally fine.
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    You can even assign both classes as listeners if you want, but that just makes it even more confusing!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.