Skip to content

Commit

Permalink
📜 simple server config
Browse files Browse the repository at this point in the history
  • Loading branch information
DasLixou committed May 9, 2022
1 parent b58587f commit 428a443
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/kotlin/cc/lixou/stracciatella/ServerConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cc.lixou.stracciatella

import kotlinx.serialization.Serializable

@Serializable
data class ServerConfig(
@Serializable
var port: Int = 25565
)
18 changes: 17 additions & 1 deletion src/main/kotlin/cc/lixou/stracciatella/Stracciatella.kt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
}

}

0 comments on commit 428a443

Please sign in to comment.