From ec8284613100fc5fdda5061a2de8578ce00d8ec6 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Thu, 3 Oct 2024 16:24:09 +0200 Subject: [PATCH] feat: add simple frontend for in-game preview --- .../net/kyori/adventure/webui/Constants.kt | 6 ++--- .../kyori/adventure/webui/websocket/Packet.kt | 6 +++++ src/commonMain/resources/web/index.html | 3 +++ .../net/kyori/adventure/webui/js/Main.kt | 16 ++++++++++++ .../webui/jvm/minimessage/MiniMessage.kt | 22 ++++++++-------- .../preview/ServerStatusPreviewManager.kt | 25 ++++--------------- 6 files changed, 42 insertions(+), 36 deletions(-) diff --git a/src/commonMain/kotlin/net/kyori/adventure/webui/Constants.kt b/src/commonMain/kotlin/net/kyori/adventure/webui/Constants.kt index e4e4e30..bd49c33 100644 --- a/src/commonMain/kotlin/net/kyori/adventure/webui/Constants.kt +++ b/src/commonMain/kotlin/net/kyori/adventure/webui/Constants.kt @@ -42,10 +42,8 @@ public const val PARAM_EDITOR_TOKEN: String = "token" /** Path for getting a short link for a MiniMessage input. */ public const val URL_MINI_SHORTEN: String = "/mini-shorten" -/** Path for getting a hostname for an in-game MiniMessage motd preview. */ -public const val URL_SETUP_MOTD_PREVIEW: String = "/setup-motd-preview" -/** Path for getting a hostname for an in-game MiniMessage kick preview. */ -public const val URL_SETUP_KICK_PREVIEW: String = "/setup-kick-preview" +/** Path for getting a hostname for an in-game MiniMessage preview. */ +public const val URL_IN_GAME_PREVIEW: String = "/in-game-preview" /** Path for getting the configuration of this WebUI instance */ public const val URL_BUILD_INFO: String = "/build" diff --git a/src/commonMain/kotlin/net/kyori/adventure/webui/websocket/Packet.kt b/src/commonMain/kotlin/net/kyori/adventure/webui/websocket/Packet.kt index dc796d0..6ffabc6 100644 --- a/src/commonMain/kotlin/net/kyori/adventure/webui/websocket/Packet.kt +++ b/src/commonMain/kotlin/net/kyori/adventure/webui/websocket/Packet.kt @@ -28,3 +28,9 @@ public data class Combined( public val background: String? = null, public val mode: String? = null ) + +@Serializable +public data class InGamePreview( + public val miniMessage: String? = null, + public val key: String? = null +) diff --git a/src/commonMain/resources/web/index.html b/src/commonMain/resources/web/index.html index 803d312..0ef3cb8 100644 --- a/src/commonMain/resources/web/index.html +++ b/src/commonMain/resources/web/index.html @@ -61,6 +61,9 @@

MiniMessage Viewer

+