Benefits of not putting listener in Main class

Discussion in 'Facepalm' started by ethaniccc, Apr 15, 2020.

  1. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    190
    GitHub:
    ethaniccc
    I don't really know where to put this thread, so I decided to put it here.
    I want to ask the question "Is there really benefits from not putting my Listener in my Main class (other than being organized)?"

    Really would appreciate answers :D
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,401
    GitHub:
    HimbeersaftLP
    You can more easily dynamically register different listeners.
    e.g. Plugins that have different modular features
     
  3. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    hehe take another one :facepalm:
    jk
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,401
    GitHub:
    HimbeersaftLP
    Thank you for your incredibly valuable contribution to this thread. Not.
     
  5. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    You are welcome. I was just messing around
     
  6. Seeker

    Seeker Spider Jockey

    Messages:
    45
    GitHub:
    seeker-devs
    there is legit no benefit except:
    a) if your plugin is open-source, make beginners jump off a roof... or confuse them in other words.
    b) it's a bit less messy... but you can just add big ascii text comments UwU
    c) if you want to listen for something that is not already included in PM (or is a vanilla method)... well, in other words, make custom events.
    For people who say "it looks more professional!", IT DOESN'T.
     
  7. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,401
    GitHub:
    HimbeersaftLP
    If your plugin has an API, it's easier for developers who want to use that API to find API methods if the main class isn't filled with other methods.
     
  8. Seeker

    Seeker Spider Jockey

    Messages:
    45
    GitHub:
    seeker-devs
    why use a listener for that?
    *By, 'listener' I meant the listener interface of pm*
     
  9. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,401
    GitHub:
    HimbeersaftLP
    So the event handlers of the listener aren't mixed in with your api methods.
     

Share This Page

  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.