Understanding the new event system..

Discussion in 'Plugin Development' started by Liam Allan, Aug 16, 2012.

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

    Liam Allan

    Hi everyone.

    Haven't been on in a while and I saw the new event system.

    I tried getting it work for an old plugin, and here's the code I have:

    Code:
    public class SimpleCMD extends JavaPlugin {
      // private static Warps warp;
        public Plugin plugin;
       
       
        @Override
        public void onDisable() {
            System.out.println("[SimpleCMD] Disabled");
        }
        @Override
        public void onEnable() {
            System.out.println("[SimpleCMD] Enabled");
        }
       
        public class Events implements Listener {
            public Events() {
            Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
            }
           
            @EventHandler(priority = EventPriority.LOW)
            public void onPlayerJoin(final PlayerJoinEvent event) {
                event.getPlayer().sendMessage("Testing");
            }
        }
    }
    So, can someone update me on how to make this work?

    Thank you in advanced.
     
  2. Offline

    sayaad


    Code:java
    1. public class SimpleCMD extends JavaPlugin implements Listener{
    2.  
    3. @Override
    4. public void onDisable() {
    5. System.out.println("[SimpleCMD] Disabled");
    6. }
    7. @Override
    8. public void onEnable() {
    9. System.out.println("[SimpleCMD] Enabled");
    10. this.getServer().getPluginManager().registerEvents(this, this);
    11. }
    12.  
    13. @EventHandler(priority = EventPriority.LOW)
    14. public void onPlayerJoin(final PlayerJoinEvent event) {
    15. event.getPlayer().sendMessage("Testing");
    16. }
    17. }
    18. }
     
  3. Offline

    Liam Allan

    Thank you very much this this.

    /thread closed.
     
Thread Status:
Not open for further replies.

Share This Page