@SuppressWarnings("deprecation")
	@Override
	public void onEnable()
	{
		enabled = true;
		islandSpacing = getConfig().getInt("island.spacing", 8);
		getConfig().set("island.spacing", islandSpacing);
		islandHeightScalar = getConfig().getDouble("island.heightscale", 1);
		getConfig().set("island.heightscale", islandHeightScalar);
		islandUnderbellyScalar = getConfig().getDouble("island.underbellyscale", 1);
		getConfig().set("island.underbellyscale", islandUnderbellyScalar);
		if(getConfig().isSet("island.height") && getConfig().isInt("island.height"))
		{
			int islandStartY = getConfig().getInt("island.height", 150);
			minIslandHeight = islandStartY;
			maxIslandHeight = islandStartY+60;
		}
		else
		{
			minIslandHeight = getConfig().getInt("island.height.low", 150);
			maxIslandHeight = getConfig().getInt("island.height.high", 210);
		}
		getConfig().set("island.height.low", minIslandHeight);
		getConfig().set("island.height.high", maxIslandHeight);
		minIslandSize = getConfig().getInt("island.size.min", 70);
		getConfig().set("island.size.min", minIslandSize);
		maxIslandSize = getConfig().getInt("island.size.max", 180);
		getConfig().set("island.size.max", maxIslandSize);
		rarityModifiers = new double[14];
		rarityModifiers[0] = getConfig().getDouble("rarity.coalore", 1);
		getConfig().set("rarity.coalore", rarityModifiers[0]);
		rarityModifiers[1] = getConfig().getDouble("rarity.ironore", 1);
		getConfig().set("rarity.ironore", rarityModifiers[1]);
		rarityModifiers[2] = getConfig().getDouble("rarity.goldore", 1);
		getConfig().set("rarity.goldore", rarityModifiers[2]);
		rarityModifiers[3] = getConfig().getDouble("rarity.redstoneore", 1);
		getConfig().set("rarity.redstoneore", rarityModifiers[3]);
		rarityModifiers[4] = getConfig().getDouble("rarity.diamondore", 1);
		getConfig().set("rarity.diamondore", rarityModifiers[4]);
		rarityModifiers[5] = getConfig().getDouble("rarity.emeraldore", 1);
		getConfig().set("rarity.emeraldore", rarityModifiers[5]);
		rarityModifiers[6] = getConfig().getDouble("rarity.fluidpool", 1);
		getConfig().set("rarity.fluidpool", rarityModifiers[6]);
		rarityModifiers[7] = getConfig().getDouble("rarity.gravelpatch", 1);
		getConfig().set("rarity.gravelpatch", rarityModifiers[7]);
		rarityModifiers[8] = getConfig().getDouble("rarity.caves", 1);
		getConfig().set("rarity.caves", rarityModifiers[8]);
		rarityModifiers[9] = getConfig().getDouble("rarity.quartzore", 1);
		getConfig().set("rarity.quartzore", rarityModifiers[9]);
		rarityModifiers[10] = getConfig().getDouble("rarity.clay", 1);
		getConfig().set("rarity.clay", rarityModifiers[10]);
		rarityModifiers[11] = getConfig().getDouble("rarity.sugarcane", 1);
		getConfig().set("rarity.sugarcane", rarityModifiers[11]);
		rarityModifiers[12] = getConfig().getDouble("rarity.glowstone", 1);
		getConfig().set("rarity.glowstone", rarityModifiers[12]);
		rarityModifiers[13] = getConfig().getDouble("rarity.lapisore", 1);
		getConfig().set("rarity.lapisore", rarityModifiers[13]);
		
		if(getConfig().isDouble("dungeonchance"))
			dungeonChance = getConfig().getDouble("dungeonchance");
		else dungeonChance = getConfig().getDouble("dungeonchance", 0.02);
		getConfig().set("dungeonchance.linked", dungeonChance);
		regularDungeonChance = getConfig().getDouble("dungeonchance.regular", 0.15);
		getConfig().set("dungeonchance.regular", regularDungeonChance);
		
		islandChances = new int[11];
		islandChances[0] = getConfig().getInt("islandchance.plains", 4);
		getConfig().set("islandchance.plains", islandChances[0]);
		islandChances[1] = getConfig().getInt("islandchance.forest", 8);
		getConfig().set("islandchance.forest", islandChances[1]);
		islandChances[2] = getConfig().getInt("islandchance.taiga", 6);
		getConfig().set("islandchance.taiga", islandChances[2]);
		islandChances[3] = getConfig().getInt("islandchance.swamp", 3);
		getConfig().set("islandchance.swamp", islandChances[3]);
		islandChances[4] = getConfig().getInt("islandchance.jungle", 4);
		getConfig().set("islandchance.jungle", islandChances[4]);
		islandChances[5] = getConfig().getInt("islandchance.desert", 4);
		getConfig().set("islandchance.desert", islandChances[5]);
		islandChances[6] = getConfig().getInt("islandchance.nether", 1);
		getConfig().set("islandchance.nether", islandChances[6]);
		islandChances[7] = getConfig().getInt("islandchance.ender", 1);
		getConfig().set("islandchance.ender", islandChances[7]);
		islandChances[8] = getConfig().getInt("islandchance.mushroom", 1);
		getConfig().set("islandchance.mushroom", islandChances[8]);
		islandChances[9] = getConfig().getInt("islandchance.lake", 4);
		getConfig().set("islandchance.lake", islandChances[9]);
		islandChances[10] = getConfig().getInt("islandchance.none", 6);
		getConfig().set("islandchance.none", islandChances[10]);
		islandTotalChance = 0;
		for(int a = 0; a < islandChances.length; a++)
		{
			if(islandChances[a] < 0) islandChances[a] = 0;
			islandTotalChance += islandChances[a];
		}
		
		coverSnowWithGrass = getConfig().getBoolean("rarity.grass.coversnow", false);
		getConfig().set("rarity.grass.coversnow", coverSnowWithGrass);
		grassChance = getConfig().getDouble("rarity.grass.coverchance", 0.4);
		getConfig().set("rarity.grass.coverchance", grassChance);
		flowerChance = getConfig().getDouble("rarity.grass.flowerchance", 0.15);
		getConfig().set("rarity.grass.flowerchance", flowerChance);
		
		pigZombieSpawners = getConfig().getBoolean("features.pigzombiespawners", true);
		getConfig().set("features.pigzombiespawners", pigZombieSpawners);
		endPortals = getConfig().getBoolean("features.endportals", true);
		getConfig().set("features.endportals", endPortals);
		netherPortals = getConfig().getBoolean("features.netherportals", true);
		getConfig().set("features.netherportals", netherPortals);
		obsidianPillars = getConfig().getBoolean("features.obsidiantowers", true);
		getConfig().set("features.obsidiantowers", obsidianPillars);
		
		maxDungeonSize = getConfig().getInt("dungeon.maxrooms", 0);
		getConfig().set("dungeon.maxrooms", maxDungeonSize);
		dungeonMinChests = getConfig().getInt("dungeon.chests.min", 2);
		getConfig().set("dungeon.chests.min", dungeonMinChests);
		dungeonMaxChests = getConfig().getInt("dungeon.chests.max", 3);
		getConfig().set("dungeon.chests.max", dungeonMaxChests);
		dungeonExtraDoorChance = getConfig().getDouble("dungeon.extradoorchance", 0.75);
		getConfig().set("dungeon.extradoorchance", dungeonExtraDoorChance);
		
		randomSpawnPoint = getConfig().getBoolean("random_spawn_point", false);
		getConfig().set("random_spawn_point", randomSpawnPoint);
		
		taskRepeatTimer = getConfig().getInt("minutes_between_update_checks", 15);
		getConfig().set("minutes_between_update_checks", taskRepeatTimer);
		
		parentGen = getConfig().getString("parent_generator", "");
		getConfig().set("parent_generator", parentGen);
		saveConfig();
		
		loadOres();
		loadStructures();
		loadDungeonChests();
		
		if(taskRepeatTimer > 0)
		{
			try
			{
				UpdateChecker c = new UpdateChecker(this, getDescription().getVersion());
				taskID = getServer().getScheduler().scheduleAsyncRepeatingTask(this, c, 0, 20*60*taskRepeatTimer);
			}
			catch (MalformedURLException e)
			{
				e.printStackTrace();
				getLogger().severe("Error with starting update checker, disabling!");
			}
		}
		
		try
		{
			Metrics m = new Metrics(this);
			/*Graph g = m.createGraph("Island Chances");
			g.addPlotter(new Plotter("Plains"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[0]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Forest"){
				public int getValue()
				{
					return islandTotalChance==0?1000:islandChances[1]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Taiga"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[2]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Swamp"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[3]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Jungle"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[4]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Desert"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[5]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Nether"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[6]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Ender"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[7]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Mushroom"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[8]*1000/islandTotalChance;
				}
			});
			g.addPlotter(new Plotter("Ocean"){
				public int getValue()
				{
					return islandTotalChance==0?0:islandChances[9]*1000/islandTotalChance;
				}
			});
			m.addGraph(g);
			g = m.createGraph("Island Positions");
			g.addPlotter(new Plotter("Spacing"){
				public int getValue()
				{
					return islandSpacing;
				}
			});
			g.addPlotter(new Plotter("Height"){
				public int getValue()
				{
					return islandStartY;
				}
			});
			m.addGraph(g);
			g = m.createGraph("Number of Custom Ores");
			g.addPlotter(new Plotter("Count"){
				public int getValue()
				{
					return IslePopulator.placableOres.length-9;
				}
			});
			m.addGraph(g);
			g = m.createGraph("Plugin Version");
			g.addPlotter(new Plotter(getDescription().getVersion()){
				public int getValue()
				{
					return 1;
				}
			});
			m.addGraph(g);*/
			m.start();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}