Abstract Classes and Listeners?

Discussion in 'Spigot Plugin Development' started by MangoCodes, Jun 14, 2016.

  1. How would I be able to implement listeners in the main class from an abstract class?
  2. Let's say the abstract class is called 'Module'
    Code (Text):
    public Module() {
         MainClass.getInstance().getServer().getPluginManager().registerEvents(this, MainClass.getInstance());
  3. I tried that it doesn't work
  4. What do you mean it doesn't work? I've done systems like that and it's always worked for me. o_O

    You could try making a method in your main class
    Code (Text):
    public void register(Listener listener) { this.getServer().getPluginManager().registerEvents(listener, this); }
    and in the constructor for the abstract class
    Code (Text):
    Make sure it implements Listener and make sure you put the @EventHandler annotation above events