BlockDamageEvent not firing

Discussion in 'Plugin Development' started by zoominx55, Feb 3, 2014.

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

    zoominx55

    Working on my first plugin. I have the BlockPlaceEvent and ProjectileHitEvent working just fine. But in the same Listener class the BlockDamageEvent is not working. It never makes it in the code block for that event handler.
    Code:
    public final class BullsEye extends JavaPlugin {
           private BullsEyeBlockListener _beBlockListener;
        public BullsEye()
        {
            _beBlockListener = new BullsEyeBlockListener(this);
        }
     
        @Override
        public void onEnable(){
            //register the block listener
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvents(_beBlockListener, this);
        }
    }
    Then in the BlockListener class I have
    Code:
    public class BullsEyeBlockListener implements Listener
    {
     
        @EventHandler
        public void onBlockDamage(BlockDamageEvent event)
        {
            myBullsEye.LogEntry("In onBlockDamage");
        }
     
    }
    The LogEntry call should output the text to the server console, but nothing shows up on any block damage. I'm assuming it should show up when I break a block. I know LogEntry works because I can put it in the BlockPlaceEvent code and it works fine.
    Am I missing something? I did have an extra { that wasn't getting caught, but I've double checked that all { match the proper }.
    Like I said, the other events are getting handled in the same class. Not sure what I'm missing.

    And I answered my own question. I seem to do that after posting a question. I guess it clears up my mind for other possibilities.

    The Answer: Use the correct event handler. :oops:
    Code:
        @EventHandler
        public void onBlockBreak(BlockBreakEvent event)
        {
            myBullsEye.LogEntry("In onBlockBreak");
            return;
        }
    
    I would probably get the BlockDamageEvent if I was in Survival mode, but doing development in Creative mode blocks just break, they don't take damage. Learning, learning, learning.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page