package org.openautonomousconnection.webserver;

import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor;
import dev.unlegitdqrk.unlegitlibrary.command.CommandManager;
import dev.unlegitdqrk.unlegitlibrary.command.CommandPermission;
import dev.unlegitdqrk.unlegitlibrary.event.EventManager;
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.ProtocolSettings;
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;

import javax.annotation.processing.Generated;
import java.io.File;
import java.util.Scanner;

public class Main {
    private static final CommandPermission PERMISSION_ALL = new CommandPermission("all", 1);
    private static final CommandExecutor commandExecutor = new CommandExecutor("DNS", PERMISSION_ALL) {};
    private static CommandManager commandManager;

    @Getter
    private static ProtocolBridge protocolBridge;

    public static void main(String[] args) throws Exception {
        ProtocolSettings settings = new ProtocolSettings();
        settings.packetHandler = new PacketHandler();
        settings.eventManager = new EventManager();
        settings.port = 9824;

        protocolBridge = new ProtocolBridge(new WebServer(new File("config.properties"),
                new File("auth.ini"), new File("rules.ini")),
                settings, ProtocolVersion.PV_1_0_0_BETA, new File("logs"));

        commandManager = new CommandManager(protocolBridge.getProtocolSettings().eventManager);
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println(commandExecutor.getName() + "> ");
            String line = scanner.nextLine();
            commandManager.execute(commandExecutor, line);
        }

    }
}