/**
 *
 * EventoZero - Advanced event factory and executor for Bukkit and Spigot.
 * Copyright � 2016 BlackHub OS and contributors.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package br.com.blackhubos.eventozero.factory;

import br.com.blackhubos.eventozero.ability.Ability;
import br.com.blackhubos.eventozero.handlers.AbilityHandler;
import br.com.blackhubos.eventozero.util.Framework;
import java.io.File;
import java.util.Vector;

import org.bukkit.plugin.Plugin;

import br.com.blackhubos.eventozero.util.Framework.Configuration;
import java.util.List;
import org.bukkit.Location;

public final class EventFactory {

    private static final Vector<Event> events = new Vector<>();

    public static Event createMyEvent(final String name) {
        return new Event(name).updateDescription("");
    }

    public static void loadEvents(final Plugin plugin) {
        final File folder = new File(plugin.getDataFolder() + File.separator + "eventos" + File.separator);
        for (final File file : folder.listFiles()) {
            if (file.getName().endsWith(".yml")) {
                final Configuration configuration = new Configuration(file); // Já carrega automaticamente
                final Event event = new Event(configuration.getString("name"))
                        .updateDescription(configuration.getString("description"))
                        .updateDisplayName(configuration.getString("display_name"));

                event.getEventData()
                        .updateData("options.signs.line.1", configuration.getString("signs.lines.1"))
                        .updateData("options.signs.line.2", configuration.getString("signs.lines.2"))
                        .updateData("options.signs.line.3", configuration.getString("signs.lines.3"))
                        .updateData("options.signs.line.4", configuration.getString("signs.lines.4"))

                        .updateData("options.message.opened", configuration.getString("options.message.opened"))
                        .updateData("options.message.prestarted", configuration.getString("options.message.prestarted"))
                        .updateData("options.message.occurring", configuration.getString("options.message.occurring"))
                        .updateData("options.message.ending", configuration.getString("options.message.ending"))
                        .updateData("options.message.closed", configuration.getString("options.message.closed"))

                        .updateData("options.player_max", configuration.getInt("options.player_max"))
                        .updateData("options.player_min", configuration.getInt("options.player_min"))
                        .updateData("options.seconds_to_stop", configuration.getInt("options.seconds_to_stop"))
                        .updateData("options.ability.fixed_ability", AbilityHandler.getAbilityByName(configuration.getString("options.ability.fixed_ability")))
                        .updateData("options.ability.abilitys", parseAbilitys(configuration.getStringList("options.ability.abilitys")))
                        .updateData("options.shop.shops", configuration.getStringList("options..shop.shops"))
                        
                        .updateData("teleport.lobby", parseList(configuration.getStringList("teleport.lobby")))
                        .updateData("teleport.spawn", parseList(configuration.getStringList("teleport.spawn")));

                events.add(event);
            }
        }
    }
    
    private static Vector<Ability> parseAbilitys(final List<String> list){
        final Vector<Ability> vector = new Vector<>();
        for(String loop: list){
            if(AbilityHandler.hasAbilityByName(loop)){
                vector.add(AbilityHandler.getAbilityByName(loop));
            }
        }
        return vector;
    }
    
    private static Vector<Location> parseList(final List<String> list){
        final Vector<Location> vector = new Vector<>();
        for(String loop : list){
            if(loop != null && !loop.isEmpty())
                vector.add(Framework.toLocation(loop));
        }
        return vector;
    }
    

}

@@ -826,16 +826,64 @@
 ctory;%0A%0A
+import br.com.blackhubos.eventozero.EventoZero;%0A
 import b
@@ -1278,73 +1278,8 @@
  %7B%0A%0A
-    private static final Vector%3CEvent%3E events = new Vector%3C%3E();%0A%0A
     
@@ -4037,50 +4037,202 @@
     
-events.add(event);%0A            %7D%0A        %7D
+EventoZero.getEventHandler().loadEvent(event);%0A            %7D%0A        %7D%0A        EventoZero.consoleMessage(%22Foram carregado(s) %22 + EventoZero.getEventHandler().getEvents().size() + %22 evento(s).%22);
 %0A   

O que foi alterado: Adicionado mensagem no console O que foi corrigido: NADA PARA SER CORRIGIDO