registerEvent deprecated?

Discussion in 'Plugin Development' started by matejdro, Jan 17, 2012.

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

    matejdro

    It appears that default registerEvent method is deprecated now.

    I have seen on javadocs that new non-deprecated method needs something called Event Executor.

    Is there any documentation about that?
     
  2. Offline

    Fyre

    Since when? Is this in one of the new dev builds?
     
  3. Offline

    matejdro

    Yes, dev builds.
     
  4. Offline

    Fyre

    Ah, well for now registerevent should still work even if it is deprecated, might as well still use it until the javadocs are updated.
     
  5. Yep, the whole Bukkit event system just changed. I'm assuming Dinnerbone will make a post soon, but now it looks something like this (afaik, might have errors)
    Code:java
    1.  
    2. public class MyListener implements Listener {
    3. @EventHandler(PlayerChatEvent.class, EventPriority.Normal)
    4. public void onPlayerChat(PlayerChatEvent event) {
    5. // Do Stuff
    6. }
    7. }
    8.  

    Then to register, its something like
    Code:java
    1.  
    2. getServer().getPluginManager().registerEvents(this, new MyListener());
    3.  

    And you can probably also register them one at a time, but I haven't looked at it yet
     
  6. Offline

    Fyre

    Sounds like more trouble than it's worth.
     
  7. Offline

    ZNickq

    it is much much muuuuuch faster!
     
  8. Offline

    matejdro

    So old system was slow?
     
  9. Offline

    Fyre

    You're probably right, I was just referring to trouble of memorizing the new method (and expelling the old).
     
  10. Offline

    Lolmewn

    Very. You've got NO idea how slow it was :confused:
     
  11. Offline

    Fyre

    Slow as in slow to start up the server, or slow as in slow to type.
     
  12. Offline

    Lolmewn

    afaik slow as in handling the events, not at startup, not as in typing.
    Example: Block gets broken. Before this, it took 0.001 second to process. After this, it takes 0.0001 second to process :)
     
  13. Offline

    phaed

    Looks like this:

    @EventHandler(event = PlayerChatEvent.class, priority = EventPriority.NORMAL)
     
  14. Offline

    Zacherl

    Thats correct. Works fine on my test server.
     
  15. Yea, my bad phaed . I posted that before actually working with them :p
     
  16. Offline

    Fyre

    Does it have to implement Listener? Or can it, for example, extend PlayerListener.
     
  17. Offline

    Zacherl

    PlayerListener and all the other listener classes are marked as deprecated, but i guess extending some of the old classes will still work. Its just important to add the new annotations to your methods.

    In general its better to implement the new Listener interface instead of extending one of the old classes.
     
  18. Offline

    Fyre

    Should I still keep my EntityListener and PlayerListener in their own classes?
     
  19. Thats up to you. As long as it implements Listener, you could have every method in its own class (Not that you already couldn't). Also, remember that means you can have your own method names!
     
  20. Offline

    Fyre

    What I meant by that, is that using the new interface could I put the EntityListener and the PlayerListener in the same class?
     
  21. Offline

    BloodShura

    "public class PlayerListener implements Listener {
    @EventHandler(PlayerChatEvent.class, EventPriority.Normal)"

    I get error in PlayerChatEevent.class. I put JogadorListener.class, it doesn't work too.

    @Edit:

    SHIT!!!! It doesn't call the plugin. my 'static ShuraCore plugin' isn't working.
     
  22. Offline

    CXdur

  23. Offline

    Fyre

  24. Offline

    Zacherl

    Should work ...
     
Thread Status:
Not open for further replies.

Share This Page