#include <BlockRegistry/BlockRegistry.hpp>
#include <filesystem>
#include <string>
#include <iostream>
#include <VoxelverseSession/VoxelverseServer/VoxelverseServer.hpp>
#include <Server/Server.hpp>
#include <Utilities/ServerInit.hpp>
#include <Settings/Settings.hpp>

int VoxelverseServer::run()
{
    blockRegistry.loadBoxesOnServer();
    std::filesystem::create_directories("server");

    if (args.size() == 1)
    {
        return startServer();
    }

    std::string cmd = args[1];
    if (cmd == "--init")
    {
        serverInit();
        return 0;
    }
    else
    {
        std::cerr << args[0] << ": unknown command '" << cmd << "'" << std::endl;
        return 1;
    }
}

std::string VoxelverseServer::getSessionTypeName()
{
    return "server";
}