/*
 * Copyright (c) 2017 "JackWhite20"
 *
 * This file is part of Sycorax.
 *
 * Sycorax 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 de.jackwhite20.sycorax.server;

import com.google.gson.Gson;
import de.jackwhite20.sycorax.server.config.Config;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.stream.Collectors;

/**
 * Created by JackWhite20 on 28.11.2015.
 */
public class Main {

    public static void main(String[] args) throws Exception {

        Path path = Paths.get("config.json");
        if (!path.toFile().exists()) {
            Files.copy(Main.class.getClassLoader().getResourceAsStream("config.json"), Paths.get("config.json"), StandardCopyOption.REPLACE_EXISTING);
        }

        String config = Files.lines(path).collect(Collectors.joining());

        SycoraxServer sycoraxServer = new SycoraxServer(new Gson().fromJson(config, Config.class));
        sycoraxServer.start();
    }
}
