// Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
//     // Permission prefix
//     public final static String PERMPREFIX = "askygrid.";
//     // The island command
//     public final static String ISLANDCOMMAND = "asg";
//     // The challenge command
//     public static final String CHALLENGECOMMAND = "asgc";
//     // The spawn command (Essentials spawn for example)
//     public final static String SPAWNCOMMAND = "spawn";
//     // Admin command
//     public static final String ADMINCOMMAND = "asgadmin";
//    
//     public static Set<String> challengeList;
//     public static int waiverAmount;
//     public static List<String> challengeLevels;
//     public static String worldName;
//     public static int monsterSpawnLimit;
//     public static int animalSpawnLimit;
//     public static int waterAnimalSpawnLimit;
//     // IslandGuard settings
//     public static boolean allowPvP;
//     public static int spawnDistance;
//     public static int islandXOffset;
//     public static int islandZOffset;
//     public static int claim_protectionRange;
//     public static Double startingMoney;
//     public static boolean resetMoney;
// 
//     // public static boolean ultraSafeBoats;
//     public static boolean logInRemoveMobs;
//     public static boolean removeMobs;
// 
//     // Challenge completion broadcast
//     public static boolean broadcastMessages;
//     // Nether world
//     public static boolean createNether;
//     public static boolean clearInventory;
//     // Use control panel for /island
//     public static boolean useControlPanel;
//     // Prevent /island when falling
//     public static boolean allowTeleportWhenFalling;
//    // Challenges - show or remove completed on-time challenges
//     public static boolean removeCompleteOntimeChallenges;
//     public static boolean addCompletedGlow;
// 
//     // Use Economy
//     public static boolean useEconomy;
// 
//     // Use physics when pasting schematic blocks
//     public static boolean usePhysics;
// 
//     // Falling blocked commands
//     public static List<String> fallingCommandBlockList;
//     public static boolean resetEnderChest;
//     public static boolean updateCheck;
//     public static long islandStartX;
//     public static long islandStartZ;
//     public static boolean allowNetherPvP;
//     public static int maxHomes;
//     public static boolean immediateTeleport;
//     public static int debug;
//     public static boolean respawnAtHome;
//     public static boolean restrictWither;
//     public static List<String> startCommands;
//     public static boolean useWarpPanel;
//     public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
//     public static boolean muteDeathMessages;
//     public static boolean allowFireSpread;
//     public static int gridHeight;
//     public static boolean allowBreakBlocks;
//     public static boolean allowPlaceBlocks;
//     public static boolean allowBedUse;
//     public static boolean allowBucketUse;
//     public static boolean allowShearing;
//     public static boolean allowEnderPearls;
//     public static boolean allowDoorUse;
//     public static boolean allowLeverButtonUse;
//     public static boolean allowCropTrample;
//     public static boolean allowChestAccess;
//     public static boolean allowFurnaceUse;
//     public static boolean allowRedStone;
//     public static boolean allowMusic;
//     public static boolean allowCrafting;
//     public static boolean allowBrewing;
//     public static boolean allowGateUse;
//     public static boolean allowMobHarm;
//     public static boolean allowFlowIn;
//     public static boolean allowFlowOut;
//     public static int spawnHeight;
//     public static boolean allowTNTDamage;
//     public static boolean allowChestDamage;
//     public static List<String> bannedCommandList;
//     
//     
//     public static boolean allowHorseInvAccess;
//     public static boolean createEnd;
//     public static double endPortalProb;
//     public static long spawnCenterX;
//     public static long spawnCenterZ;
//     public static boolean allowFallDamage;
//     public static boolean createBiomes;
//     public static boolean growTrees;
//     public static Sound warpSound;
// }


import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.material.SpawnEgg;
import com.wasteofplastic.askygrid.Settings;
	    if (type.isAlive()) {
		//Bukkit.getLogger().info("DEBUG: " + type.toString() + "=>" + (index));
		spawnEggData.put(type.toString(), index);
	    }
	    index++;
	}	
    }

    /**
     * @param size
     */
    public SkyGridPop(int size) {
	this.size = size;
	// Work out if SpawnEgg method is available
	if (getMethod("SpawnEggMeta", ItemMeta.class) != null) {
	    spawnEggMeta = true;
	}
    }

    @Override
    public void populate(World world, Random random, Chunk chunk) {
	if (DEBUG)
	    Bukkit.getLogger().info("DEBUG: populate chunk");
	boolean chunkHasPortal = false;
	int r = 0;
	for (int x = 0; x < 16; x += 4) {
	    for (int y = 0; y < size; y += 4) {
		for (int z = 0; z < 16; z +=4) {
		    Block b = chunk.getBlock(x, y, z);
		    // Do an end portal check
// Path: src/com/wasteofplastic/askygrid/Settings.java
// public class Settings {
//     // Permission prefix
//     public final static String PERMPREFIX = "askygrid.";
//     // The island command
//     public final static String ISLANDCOMMAND = "asg";
//     // The challenge command
//     public static final String CHALLENGECOMMAND = "asgc";
//     // The spawn command (Essentials spawn for example)
//     public final static String SPAWNCOMMAND = "spawn";
//     // Admin command
//     public static final String ADMINCOMMAND = "asgadmin";
//    
//     public static Set<String> challengeList;
//     public static int waiverAmount;
//     public static List<String> challengeLevels;
//     public static String worldName;
//     public static int monsterSpawnLimit;
//     public static int animalSpawnLimit;
//     public static int waterAnimalSpawnLimit;
//     // IslandGuard settings
//     public static boolean allowPvP;
//     public static int spawnDistance;
//     public static int islandXOffset;
//     public static int islandZOffset;
//     public static int claim_protectionRange;
//     public static Double startingMoney;
//     public static boolean resetMoney;
// 
//     // public static boolean ultraSafeBoats;
//     public static boolean logInRemoveMobs;
//     public static boolean removeMobs;
// 
//     // Challenge completion broadcast
//     public static boolean broadcastMessages;
//     // Nether world
//     public static boolean createNether;
//     public static boolean clearInventory;
//     // Use control panel for /island
//     public static boolean useControlPanel;
//     // Prevent /island when falling
//     public static boolean allowTeleportWhenFalling;
//    // Challenges - show or remove completed on-time challenges
//     public static boolean removeCompleteOntimeChallenges;
//     public static boolean addCompletedGlow;
// 
//     // Use Economy
//     public static boolean useEconomy;
// 
//     // Use physics when pasting schematic blocks
//     public static boolean usePhysics;
// 
//     // Falling blocked commands
//     public static List<String> fallingCommandBlockList;
//     public static boolean resetEnderChest;
//     public static boolean updateCheck;
//     public static long islandStartX;
//     public static long islandStartZ;
//     public static boolean allowNetherPvP;
//     public static int maxHomes;
//     public static boolean immediateTeleport;
//     public static int debug;
//     public static boolean respawnAtHome;
//     public static boolean restrictWither;
//     public static List<String> startCommands;
//     public static boolean useWarpPanel;
//     public static List<EntityType> mobWhiteList = new ArrayList<EntityType>();
//     public static boolean muteDeathMessages;
//     public static boolean allowFireSpread;
//     public static int gridHeight;
//     public static boolean allowBreakBlocks;
//     public static boolean allowPlaceBlocks;
//     public static boolean allowBedUse;
//     public static boolean allowBucketUse;
//     public static boolean allowShearing;
//     public static boolean allowEnderPearls;
//     public static boolean allowDoorUse;
//     public static boolean allowLeverButtonUse;
//     public static boolean allowCropTrample;
//     public static boolean allowChestAccess;
//     public static boolean allowFurnaceUse;
//     public static boolean allowRedStone;
//     public static boolean allowMusic;
//     public static boolean allowCrafting;
//     public static boolean allowBrewing;
//     public static boolean allowGateUse;
//     public static boolean allowMobHarm;
//     public static boolean allowFlowIn;
//     public static boolean allowFlowOut;
//     public static int spawnHeight;
//     public static boolean allowTNTDamage;
//     public static boolean allowChestDamage;
//     public static List<String> bannedCommandList;
//     
//     
//     public static boolean allowHorseInvAccess;
//     public static boolean createEnd;
//     public static double endPortalProb;
//     public static long spawnCenterX;
//     public static long spawnCenterZ;
//     public static boolean allowFallDamage;
//     public static boolean createBiomes;
//     public static boolean growTrees;
//     public static Sound warpSound;
// }


// Path: src/com/wasteofplastic/askygrid/generators/SkyGridPop.java
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.TreeMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SpawnEggMeta;
import org.bukkit.material.SpawnEgg;
import com.wasteofplastic.askygrid.Settings;

	    if (type.isAlive()) {
		//Bukkit.getLogger().info("DEBUG: " + type.toString() + "=>" + (index));
		spawnEggData.put(type.toString(), index);
	    }
	    index++;
	}	
    }

    /**
     * @param size
     */
    public SkyGridPop(int size) {
	this.size = size;
	// Work out if SpawnEgg method is available
	if (getMethod("SpawnEggMeta", ItemMeta.class) != null) {
	    spawnEggMeta = true;
	}
    }

    @Override
    public void populate(World world, Random random, Chunk chunk) {
	if (DEBUG)
	    Bukkit.getLogger().info("DEBUG: populate chunk");
	boolean chunkHasPortal = false;
	int r = 0;
	for (int x = 0; x < 16; x += 4) {
	    for (int y = 0; y < size; y += 4) {
		for (int z = 0; z < 16; z +=4) {
		    Block b = chunk.getBlock(x, y, z);
		    // Do an end portal check
		    if (Settings.createEnd && world.getEnvironment().equals(Environment.NORMAL)