package me.km;

import me.km.utils.ExplosionUtils;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class CommonEvents
{
    @SubscribeEvent
    public void onExplosionDetonation(ExplosionEvent.Detonate e)
    {
        if(!e.isCanceled())
        {
            ExplosionUtils.explosion(e.getExplosion(), e.getWorld());
        }
    }

    /*private static final java.util.HashSet<Class> test = new java.util.HashSet<>();
    
    static
    {
        test.add(net.minecraftforge.event.world.ChunkDataEvent.class);
        test.add(net.minecraftforge.event.TickEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingSpawnEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingEvent.class);
        test.add(net.minecraftforge.event.TickEvent.class);
        test.add(net.minecraftforge.event.AttachCapabilitiesEvent.class);
        test.add(net.minecraftforge.event.entity.EntityMobGriefingEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingDestroyBlockEvent.class);
        test.add(net.minecraftforge.event.entity.PlaySoundAtEntityEvent.class);
        test.add(net.minecraftforge.event.entity.EntityEvent.class);
        test.add(net.minecraftforge.event.LootTableLoadEvent.class);
        test.add(net.minecraftforge.event.world.ChunkEvent.class);
        test.add(net.minecraftforge.event.world.WorldEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingFallEvent.class);
        test.add(net.minecraftforge.event.entity.player.PlayerEvent.class);
        test.add(net.minecraftforge.event.world.ChunkWatchEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingEntityUseItemEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent.class);
        test.add(net.minecraftforge.event.entity.EntityJoinWorldEvent.class);
        test.add(net.minecraftforge.event.entity.living.LivingPackSizeEvent.class);
    }
    
    @SubscribeEvent
    public void onChat(net.minecraftforge.event.ServerChatEvent e)
    {
        try
        {
            Class c = Class.forName(e.getMessage());
            if(!test.add(c))
            {
                test.remove(c);
            }
        }
        catch(Exception ex)
        {
        }
    }
    
    @SubscribeEvent
    public void test(net.minecraftforge.eventbus.api.Event e)
    {
        Class c = e.getClass();
        if(c.getEnclosingClass() != null)
        {
            c = c.getEnclosingClass();
        }
        if(test.contains(c))
        {
            return;
        }
        org.apache.logging.log4j.LogManager.getLogger().warn(c);
    }*/
}
