package in.twizmwaz.cardinal.module.modules.Tnt;

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.module.Module;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.metadata.FixedMetadataValue;

import java.util.logging.Level;

public class Tnt implements Module {

    private final boolean instantignite;
    private final boolean blockdamage;
    private final double yield;
    private final double power;
    private final int fuse;

    @Override
    public void unload() {
        HandlerList.unregisterAll(this);
    }

    protected Tnt(final boolean instantignite, final boolean blockdamage, final double yield, final double power, final int fuse) {
        this.instantignite = instantignite;
        this.blockdamage = blockdamage;
        this.yield = yield;
        this.power = power;
        this.fuse = fuse;
    }

    @EventHandler
    public void onBlockPlace(BlockPlaceEvent event) {
        Block block = event.getBlock();
        if (block.getType().equals(Material.TNT) && instantignite) {
            event.setCancelled(true);
            Entity tntPrimed = GameHandler.getGameHandler().getMatchWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT);
            tntPrimed.setMetadata("instantignite", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
        }
    }

    @EventHandler
    public void onExplosionPrime(ExplosionPrimeEvent event) {
        if (event.getEntity() instanceof TNTPrimed && fuse != 4) {
            ((TNTPrimed) event.getEntity()).setFuseTicks(fuse * 20);
        }
    }

    @EventHandler
    public void onEntityExplode(EntityExplodeEvent event) {
        if (event.getEntity() instanceof TNTPrimed) {
            if (blockdamage) {
                if (instantignite && event.getEntity().getMetadata("instantignite").get(0).value().equals(true)) {
                    Bukkit.broadcastMessage("Has meta");
                    event.setCancelled(true);
                    GameHandler.getGameHandler().getMatchWorld().createExplosion(event.getLocation(), (float) power);
                }
                if (power != 4.0) {
                    event.setCancelled(true);
                    GameHandler.getGameHandler().getMatchWorld().createExplosion(event.getLocation(), (float) power);
                }
                if (yield != 0.3) {
                   // event.setYield((float) yield);
                }
            } else {
                Bukkit.broadcastMessage("!blockdamage - canceling");
                event.setCancelled(true);
                GameHandler.getGameHandler().getMatchWorld().createExplosion(event.getLocation().getX(), event.getLocation().getY(), event.getLocation().getZ(), (float) power, false, false);
            }
        }
    }


}

@@ -2284,65 +2284,8 @@
 ) %7B%0A
-                    Bukkit.broadcastMessage(%22Has meta%22);%0A
     
@@ -2812,77 +2812,8 @@
 e %7B%0A
-                Bukkit.broadcastMessage(%22!blockdamage - canceling%22);%0A
     

Remove debug messages