package de.hessj.environmentex;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.Listener;

public class MobBurner implements Listener {

    public static Boolean isRaining(){
        World w = Bukkit.getServer().getWorlds().get(0);
        if(w.hasStorm() || w.isThundering()){
            return true;
        }
        return false;
    }

    
    public static void tryBurning() {
        if(App.isDay() && !isRaining()){
        World w = Bukkit.getServer().getWorlds().get(0);
        List<Entity> entities = new ArrayList<Entity>(w.getLivingEntities());
        for(Entity e: entities){
            if(e.getType().equals(EntityType.CREEPER)){
                Location loc = e.getLocation();
                if (loc.getBlockY() >= w.getHighestBlockYAt(loc))
                {   
                  e.setFireTicks(1000 * 20 / 1000);
                }
            }
        }
    }
}
}
