Tnt Explosion Event Help

Discussion in 'Plugin Development' started by frogman6102, Dec 14, 2014.

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

    frogman6102

    Hello! I want to put a block regeneration event into my plugin (it's a minigame one).

    My Code:
    Code:
        public void onEnable(){
            p = this;
            l = new Lobby();
       
            Bukkit.getPluginManager().registerEvents(l, p);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
           
        }
       
        public void onDisable(){
            p = null;
        }
       
        @EventHandler
        public void explosion(EntityExplodeEvent e){
            Bukkit.getServer().broadcastMessage("Event Fired.");
        }
    }
    Bukkit isn't saying, "Event Fired"???
     
  2. Offline

    3ShotGod

    No if statement for if it exploded?

    http://jd.bukkit.org/rb/doxygen/d6/...1_1event_1_1entity_1_1EntityExplodeEvent.html
     
  3. Offline

    pookeythekid

    @frogman6102 Something like having WorldGuard installed may cancel the explosion.
     
  4. Offline

    frogman6102

  5. Offline

    oPryzeLP

    Do you mind showing the top of the class as well please? The part above onEnable?
     
  6. Offline

    DeadlyScone

    @frogman6102
    I believe the event you are looking foris called EntityDamageEvent.

    Btw you don't need to include "Bukkit" in your main.

    Edit: there is a lot of weird unnecessary code in that class. If I was on a comp I would go ocd on that.

    But here is this.

    Code:java
    1.  
    2. @Override
    3. public void onEnable(){
    4.  
    5. getServer().getPluginManager().registerEvents(this, this);
    6. }
    7. @Override
    8. public void onDisable(){
    9. }
    10.  
    11. @EventHandler
    12. public void explosion(EntityDamageEvent e){
    13. getLogger().info("Event Fired.");
    14. }
    15. }


    Now that code you see I did on my phone so bear with me. As long as your main extends JavaPlugin and implements Listener , this should work.
     
    Last edited: Dec 15, 2014
Thread Status:
Not open for further replies.

Share This Page