package ca.recrown.islandsurvivalcraft;

import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import ca.recrown.islandsurvivalcraft.world.WorldInfoManager;
import ca.recrown.islandsurvivalcraft.world.generation.GeneratorModes;

public class IslandSurvivalCraft extends JavaPlugin implements Listener {
    private PluginManager pluginManager;
    private WorldInfoManager worldInfos;

    public IslandSurvivalCraft() {
        worldInfos = new WorldInfoManager();
    }
    
    @Override
    public void onEnable() {
        pluginManager = getServer().getPluginManager();
        pluginManager.registerEvents(worldInfos, this);
        super.onEnable();
    }

    @Override
    public void onDisable() {
        super.onDisable();
    }

    @Override
    public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
        GeneratorModes gID = null;
        try {
            gID = GeneratorModes.valueOf(id);
        } catch (NullPointerException | IllegalArgumentException e) {
            gID = GeneratorModes.UNIQUE;
        }
        return worldInfos.getChunkGenerator(getServer().getWorld(worldName), gID);
    }

}
