diff --git a/src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt b/src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt index b7df234..affc59c 100644 --- a/src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt +++ b/src/main/kotlin/com/sentrysmp/CommandApiPlugin.kt @@ -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 @@ -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() }) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 054a80d..5787a5c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -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. +host: "0.0.0.0" api-key: "sentry_51Hk9ZQmX7pL3v9aB8cD2eF0gHiJkLmNoPqRsTuVwXyZ1234567890AbCdEfGhIj" # Hologram settings hologram-ttl-seconds: 0