diff --git a/src/main/kotlin/cc/lixou/stracciatella/ServerConfig.kt b/src/main/kotlin/cc/lixou/stracciatella/ServerConfig.kt new file mode 100644 index 0000000..e1aad48 --- /dev/null +++ b/src/main/kotlin/cc/lixou/stracciatella/ServerConfig.kt @@ -0,0 +1,9 @@ +package cc.lixou.stracciatella + +import kotlinx.serialization.Serializable + +@Serializable +data class ServerConfig( + @Serializable + var port: Int = 25565 +) \ No newline at end of file diff --git a/src/main/kotlin/cc/lixou/stracciatella/Stracciatella.kt b/src/main/kotlin/cc/lixou/stracciatella/Stracciatella.kt index 5ead7a8..56bbfbc 100644 --- a/src/main/kotlin/cc/lixou/stracciatella/Stracciatella.kt +++ b/src/main/kotlin/cc/lixou/stracciatella/Stracciatella.kt @@ -1,17 +1,32 @@ package cc.lixou.stracciatella +import cc.lixou.stracciatella.config.Config import cc.lixou.stracciatella.game.GameManager import net.minestom.server.MinecraftServer import net.minestom.server.coordinate.Pos import net.minestom.server.event.player.PlayerDisconnectEvent import net.minestom.server.event.player.PlayerLoginEvent import net.minestom.server.instance.block.Block +import org.slf4j.LoggerFactory +import java.nio.file.Path class Stracciatella { private val server = MinecraftServer.init() + private val LOGGER = LoggerFactory.getLogger(Stracciatella::class.java) + + var config = ServerConfig() + private set + init { + // region [Server Config] + LOGGER.info("Loading Configuration (stracciatella.yml)") + config = ServerConfig() + config = Config.loadConfig(Path.of("stracciatella.yml"), config) + // endregion + + val eventHandler = MinecraftServer.getGlobalEventHandler() eventHandler.addListener(PlayerDisconnectEvent::class.java) { event -> GameManager.unregisterPlayer(event.player) @@ -36,7 +51,8 @@ class Stracciatella { } fun start() { - server.start("0.0.0.0", 25565) + LOGGER.info("Starting Stracciatella on Port ${config.port}") + server.start("0.0.0.0", config.port) } } \ No newline at end of file