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

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.module.Module;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.metadata.FixedMetadataValue;

public class InvisibleBlock implements Module {

    protected InvisibleBlock() {
        Bukkit.getScheduler().runTaskAsynchronously(GameHandler.getGameHandler().getPlugin(), new Runnable() {
            @Override
            public void run() {
                for (Chunk chunk : GameHandler.getGameHandler().getMatchWorld().getLoadedChunks()) {
                    for (Block block36 : chunk.getBlocks(Material.getMaterial(36))) {
                        block36.setType(Material.AIR);
                        block36.setMetadata("block36", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
                    }
                }
            }
        });
    }

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

    @EventHandler
    public void onChunkLoad(ChunkLoadEvent event) {
        final Chunk chunk = event.getChunk();
        Bukkit.getScheduler().runTaskAsynchronously(GameHandler.getGameHandler().getPlugin(), new Runnable() {
            @Override
            public void run() {
                for (Block block36 : chunk.getBlocks(Material.getMaterial(36))) {
                    block36.setType(Material.AIR);
                    block36.setMetadata("block36", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
                }
            }
        });
    }

}

@@ -248,16 +248,51 @@
 .Block;%0A
+import org.bukkit.block.BlockFace;%0A
 import o
@@ -317,24 +317,24 @@
 entHandler;%0A
-
 import org.b
@@ -1083,32 +1083,401 @@
               %7D%0A
+                    for (Block door : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) %7B%0A                        if (door.getRelative(BlockFace.DOWN).getType() != Material.IRON_DOOR_BLOCK%0A                                && door.getRelative(BlockFace.UP).getType() != Material.IRON_DOOR_BLOCK)%0A                            door.setType(Material.BARRIER);%0A                    %7D%0A
                 
@@ -2006,32 +2006,32 @@
 (Material.AIR);%0A
-
                 
@@ -2148,32 +2148,381 @@
               %7D%0A
+                for (Block door : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) %7B%0A                    if (door.getRelative(BlockFace.DOWN).getType() != Material.IRON_DOOR_BLOCK%0A                            && door.getRelative(BlockFace.UP).getType() != Material.IRON_DOOR_BLOCK)%0A                        door.setType(Material.BARRIER);%0A                %7D%0A
             %7D%0A  

Replace single iron doors wih barriers