[SOLVED] BlockIgniteEvent not registering

Discussion in 'Plugin Development' started by varesa, Sep 22, 2012.

Thread Status:
Not open for further replies.
  1. It's been a while since I have done anything bukkit-related, so this might be something really simple...

    I currently just trying to make my plugin send a message to the console, when a block has ignited (using flint and steel). The purpose of this message is just to see that it works.

    A cut from my "main" java file:
    Code:java
    1.  
    2. FWPortalCreationListener portalCreationListener = new FWPortalCreationListener(this);
    3.  
    4. FWPortalDestroyListener portalDestroyListener = new FWPortalDestroyListener(this);
    5. FWPortalTravelListener portalTravelListener = new FWPortalTravelListener(this);
    6.  
    7. public void onEnable() {
    8. log.info(this.getDescription().getName() + " version "
    9. + this.getDescription().getVersion() + " started.");
    10.  
    11. PluginManager pm = this.getServer().getPluginManager();
    12. pm.registerEvents(portalCreationListener, this);
    13. pm.registerEvents(portalDestroyListener, this);
    14. pm.registerEvents(portalTravelListener, this);
    15. }

    The important parts of my FWPortalCreationListener.java:
    Code:java
    1.  
    2.  
    3. public class FWPortalCreationListener implements Listener {
    4.  
    5. public static FourthWorld plugin;
    6. Logger log = Logger.getLogger("FourthWorld");
    7.  
    8. public FWPortalCreationListener(FourthWorld instance) {
    9. plugin = instance;
    10. }
    11.  
    12. @EventHandler(priority = EventPriority.NORMAL)
    13. public void onBlockIgnite(BlockIgniteEvent e) {
    14. log.log(Level.FINE, "block ignited");
    15. }
    16. }
    17.  
    18.  
    I don't see anything wrong with that, but still I can play around with Flint and Steel as much as I want without seeing anything appear in the console.

    I'm pretty sure somebody quickly spots a small mistake I have not been able to see :)
    Thanks to the one who does
     
  2. Offline

    Assult

    pm.registerEvents(new classnamehere(this), this);

    You might need to create a constrctor
     
  3. FWPortalCreationListener portalCreationListener =new FWPortalCreationListener(this);
    pm.registerEvents(portalCreationListener, this);

    If you look at the second "file" I have, I also have created a constructor for the listener
    Isn't that the same thing?
     
  4. Offline

    Assult

    No
     
  5. What's the difference then?
     
  6. Offline

    Assult

    Its a better way of registering the event, the way you are using is outdated i think
     
  7. The only difference I can see is
    that you are instantiating the listener, and passing is directly to registerEvents(), while I store the instantiated listener in a variable that gets passed to the registerEvents(). In the end the listener sent to registerEvents() should be the same. The only practical difference I see is that my way might consume a tiny amount of more memory...

    EDIT: Anyways it works in my other plugins, so I do not believe that is the issue...

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  8. Offline

    Comphenix

    You should do your logging at the INFO level or higher, otherwise Bukkit won't display your message:
    Code:
    log.log(Level.INFO, "block ignited");
     
    varesa likes this.
  9. I think I have solved this. There were two reasons:
    1) For whatever reason I had accidentally specified a too fine logging level, that doesn't get logged by default. Thanks to Comphenix for pointing that out.
    2) I have set up a script that uploads the new version to one of my servers for testing. This script was silently failing, so any changes I tried never got pushed to the server...
     
Thread Status:
Not open for further replies.

Share This Page