1. Welcome to LilyPad. Download the project, explore the forums, and create your own LilyPad network.


    If you use the software and enjoy it or have a question, or would like to contribute to the future of the software directly or through resources, please sign up and join our little community.

Notice Event API Change

Discussion in 'Development' started by Coelho, Aug 19, 2013.

  1. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

    We have changed the Connect Event API to better accommodate for continued growth of LilyPad's API.

    Previously, you would do this:
    Code (text):

    import lilypad.client.connect.api.Connect;
    public class Plugin {
        private Listener listener = new Listener();
        public void onEnable() {
            Connect connect = ...
            connect.registerMessageEventListener(listener);
        }
        public void onDisable() {
            Connect connect = ...
            connect.unregisterMessageEventListener(listener);
        }
    }
    import lilypad.client.connect.api.MessageEvent;
    import lilypad.client.connect.api.MessageEventListener;
    public class Listener implements MessageEventListener {
        public void onMessage(Connect connect, MessageEvent event) {
        }
    }
     
    Now, you will be doing this:
    Code (text):

    import lilypad.client.connect.api.Connect;
    public class Plugin {
        private Listener listener = new Listener();
        public void onEnable() {
            Connect connect = ...
            connect.registerEvents(listener);
        }
        public void onDisable() {
            Connect connect = ...
            connect.unregisterEvents(listener);
        }
    }
    import lilypad.client.connect.api.event.EventListener;
    import lilypad.client.connect.api.event.MessageEvent;
    public class Listener {
        @EventListener
        public void onMessage(MessageEvent event) {
        }
    }
     
    As you can likely tell, this is a lot easier to work with than the previous system, is alike that of Bukkit's system, and will allow for the easy addition of events onto LilyPad's API.

    We recommend you update your plugins to suit this as soon as possible, as although the old API currently works, we will be removing it in a month or so.

    Thank you.
    • Like Like x 1
  2. boboman13

    boboman13 Member Contributor

    Great to see it implemented, @Coelho.
  3. bobacadodl

    bobacadodl Member

    This doesnt seem to be implemented? Even though the old methods are marked depracated
  4. boboman13

    boboman13 Member Contributor

    I've implemented it into my plugins, but I had the same problem as @bobacadodl. I think I fixed it by removing the dependency from Eclipse, deleting the file, then redownloading the new file and adding the new dependency in Eclipse. Beware, the package is different for the events.
  5. Coelho

    Coelho Software Engineer Staff Member Administrator Maintainer

    Very good to note.
  6. bobacadodl

    bobacadodl Member

    Thanks! Fixed it now :)

Share This Page