package tech.nevets.jaml.events;

import tech.nevets.jaml.Config;
import tech.nevets.jaml.gui.GuiHandler;
import tech.nevets.jaml.listeners.LaunchListener;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

public class LaunchEvent {
    private List<LaunchListener> listeners = new ArrayList<>();

    public void addListener(LaunchListener eventListener) {
        listeners.add(eventListener);
    }

    public void triggerEvent() {
        if (!Config.CONFIG.getBoolean("launcher.keep-open")) {
            for (LaunchListener ll : listeners){
                for (JFrame frame : GuiHandler.frames) {
                    ll.hideGui(frame);
                }
            }
        }
    }
}
