Solved Disable Fire Damage

Discussion in 'Plugin Development' started by MCJoshua345, Mar 3, 2015.

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

    MCJoshua345

    Does anybody know a way to where I can disable fire damage? This class won't work:
    Code:
    package com.infinity.lobby.listeners;
    
    import com.infinity.lobby.main.Main;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    
    public class FireListener implements Listener{
      Main plugin;
      public FireListener(Main instance)
     
      {
         
        this.plugin = instance;
       
      }
    public void onEntityDamage(EntityDamageEvent event) {
        if (event.getEntity() instanceof Player) {
            event.setCancelled(event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE);
        }
    }
    }
     
  2. Offline

    MrFrozen

    Haha sorry but is this coppied but wrong? Or or did you tried to code this without knowledge or less.
    But no blame or offensive just intrested but
    Code:
    @EventHandler
    is missing above the event and do not forget to register it in you on enable. Here a few variants
    Code:
        getServer().getPluginManager().registerEvents(this, this); // @ Used when Event is in main class
        getServer().getPluginManager().registerEvents(new ExternClass(), this); // @ Used when Event is in a extern class
        getServer().getPluginManager().registerEvents(new ExternClass(null), this); // @ Used when Event is in a extern class with constructor
     
  3. Offline

    MCJoshua345

    @MrFrozen
    Oh my gosh how did I not notice that!?!?!?!?!?
    Srry about the waste of time everybody.
     
  4. Offline

    MrFrozen

    Please set your thread to 'Solved' if the problem is solved ;)
     
  5. Offline

    teej107

    @MCJoshua345 Just saying that it is rather rude to uncancel an event since it could possibly break other plugins. If it isnt your intent to break plugins, I recommend checking to see if the damage cause is fire in an if statement and then cancelling the event if so. If the event is already cancelled, there shouldn't be a need to uncancel it.
     
Thread Status:
Not open for further replies.

Share This Page