From fcf1e6faec981e35bbed0b88d03f50ea81e658a8 Mon Sep 17 00:00:00 2001 From: toxicity188 <114675706+toxicity188@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:09:42 +0900 Subject: [PATCH] Fix minecraft default image. --- .../kr/toxicity/hud/manager/MinecraftManager.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/src/main/kotlin/kr/toxicity/hud/manager/MinecraftManager.kt b/dist/src/main/kotlin/kr/toxicity/hud/manager/MinecraftManager.kt index b343ac95..0b8acbbc 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/manager/MinecraftManager.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/manager/MinecraftManager.kt @@ -31,7 +31,7 @@ object MinecraftManager : BetterHudManager { return map } - private class MinecraftAsset(val namespace: String, val width: Int, val height: Int) { + private data class MinecraftAsset(val namespace: String, val width: Int, val height: Int) { fun toJson(json: JsonArray, char: String, ascent: Int, scale: Double, font: Key): WidthComponent { val newHeight = (height.toDouble() * scale).roundToInt() val newWidth = (width.toDouble() / height.toDouble() * newHeight).roundToInt() @@ -49,8 +49,15 @@ object MinecraftManager : BetterHudManager { override fun start() { } + private var previous = "" + override fun reload(sender: Audience, resource: GlobalResource) { if (ConfigManagerImpl.loadMinecraftDefaultTextures) { + val current = if (ConfigManagerImpl.minecraftJarVersion == "bukkit") BOOTSTRAP.minecraftVersion() else ConfigManagerImpl.minecraftJarVersion + if (previous != current) { + previous = current + } else return + assetsMap.clear() val cache = DATA_FOLDER.subFolder(".cache") runWithExceptionHandling(sender, "Unable to load minecraft default textures.") { val client = HttpClient.newHttpClient() @@ -61,7 +68,6 @@ object MinecraftManager : BetterHudManager { .build(), HttpResponse.BodyHandlers.ofInputStream()).body()).buffered().use { parseJson(it) }.asJsonObject - val current = if (ConfigManagerImpl.minecraftJarVersion == "bukkit") BOOTSTRAP.minecraftVersion() else ConfigManagerImpl.minecraftJarVersion info("Current minecraft version: $current") val file = File(cache, "$current.jar") if (!file.exists() || file.length() == 0L) { @@ -118,4 +124,4 @@ object MinecraftManager : BetterHudManager { override fun end() { } -} \ No newline at end of file +}