Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CommandApiPlugin : JavaPlugin() {
override fun onEnable() {
saveDefaultConfig()
val port = config.getInt("port", 8080)
val host = config.getString("host") ?: "0.0.0.0"
val apiKey = config.getString("api-key") ?: "change-me"

// build scoreboard client from config
Expand All @@ -35,12 +36,12 @@ class CommandApiPlugin : JavaPlugin() {
holoCommand = holo
this.getCommand("sentrysmp")?.setExecutor(holo)

val server = embeddedServer(Netty, host = "127.0.0.1", port = port) {
val server = embeddedServer(Netty, host = host, port = port) {
configureRoutes(this@CommandApiPlugin, apiKey)
}
server.start(false)
httpServer = server
logger.info("SentryAPI HTTP server started on 127.0.0.1:$port")
logger.info("SentryAPI HTTP server started on $host:$port")

// Restore persisted holograms on the next tick (worlds are guaranteed loaded)
Bukkit.getScheduler().runTask(this, Runnable { holo.restoreHolograms() })
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
port: 8080
# Host to bind the HTTP server to.
# Use "0.0.0.0" to listen on all interfaces (required for dedicated servers / VPS).
# Use "127.0.0.1" to restrict access to localhost only.
Comment on lines +3 to +4
host: "0.0.0.0"
api-key: "sentry_51Hk9ZQmX7pL3v9aB8cD2eF0gHiJkLmNoPqRsTuVwXyZ1234567890AbCdEfGhIj"
# Hologram settings
hologram-ttl-seconds: 0
Expand Down