Registering Events

Discussion in 'Plugin Development' started by xXRobbie21Xx, May 12, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    xXRobbie21Xx

    Hey guys, i know this is a nooby question but im trying to register multiple events from different classes and i was wondering if there was an easyier/smarter/more efficient, way to do it.

    This is what i do.
    Code:
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
            this.getServer().getPluginManager().registerEvents(new Example(), this);
            this.getServer().getPluginManager().registerEvents(new Example(), this);
            this.getServer().getPluginManager().registerEvents(new Example(), this);
    
     
  2. Offline

    JBoss925

    I do this:
    Code:java
    1. PluginManager pm = Bukkit.getServer().getPluginManager();

    then use it like:
    Code:java
    1. pm.registerEvents(this, this);
     
  3. Offline

    metalhedd

    Code:
    public class MyListener implements Listener {
        private MyPlugin plugin;
        public MyListener(MyPlugin plugin) {
            this.plugin = plugin;
            this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
    }
     
     
    public class MyPlugin extends JavaPlugin {
     
        public void onEnable() {
            new MyListener(this);
            new MyOtherListener(this);
            new MyOtherOTHERListener(this);  
        }
    }
     
  4. Offline

    xXRobbie21Xx

  5. Offline

    JBoss925

Thread Status:
Not open for further replies.

Share This Page