package ru.dbotthepony.kstarbound

import org.apache.logging.log4j.LogManager
import org.lwjgl.Version
import ru.dbotthepony.kstarbound.client.StarboundClient
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
import ru.dbotthepony.kstarbound.util.random.random
import java.io.File
import java.net.InetSocketAddress

private val LOGGER = LogManager.getLogger()

fun main() {
	Starbound.addArchive(File("J:\\Steam\\steamapps\\common\\Starbound\\assets\\packed.pak"))

	/*for (f in File("J:\\Steam\\steamapps\\workshop\\content\\211820").listFiles()!!) {
		for (f2 in f.listFiles()!!) {
			if (f2.isFile) {
				Starbound.addArchive(f2)
			}
		}
	}*/

	LOGGER.info("Running LWJGL ${Version.getVersion()}")

	val client = StarboundClient()

	Starbound.initializeGame().thenApply {
		val server = IntegratedStarboundServer(client, File("./"))
		server.channels.createChannel(InetSocketAddress(21060))
	}.exceptionally { LOGGER.error("what", it); null }
}
