From 11f1f83390e617457628adfc0d3ad9e6b79d2c68 Mon Sep 17 00:00:00 2001 From: toxicity Date: Mon, 18 Nov 2024 21:05:33 +0900 Subject: [PATCH] [CI Skip] traffic optimize. --- .../api/bukkit/bedrock/BedrockAdapter.java | 4 +- .../hud/api/component/WidthComponent.java | 2 +- .../java/kr/toxicity/hud/api/hud/Hud.java | 4 +- .../hud/api/listener/HudListener.java | 6 +- .../java/kr/toxicity/hud/api/popup/Popup.java | 6 +- .../api/volatilecode/VolatileCodeHandler.java | 28 +-- .../bukkit/player/HudPlayerBukkit.kt | 3 +- .../fabric/player/HudPlayerFabric.kt | 3 +- build.gradle.kts | 2 +- changelog/{1.10.md => 1.9.1.md} | 8 +- .../hud/compass/type/CircleCompass.kt | 187 ++++++++++++++---- .../kr/toxicity/hud/hud/HudImageElement.kt | 13 +- .../kotlin/kr/toxicity/hud/hud/HudImpl.kt | 10 +- .../kr/toxicity/hud/hud/HudTextElement.kt | 3 +- .../kr/toxicity/hud/player/HudPlayerImpl.kt | 4 +- .../kotlin/kr/toxicity/hud/popup/PopupImpl.kt | 10 +- .../kr/toxicity/hud/popup/PopupLayout.kt | 32 ++- .../kr/toxicity/hud/renderer/ImageRenderer.kt | 7 +- .../kr/toxicity/hud/renderer/TextRenderer.kt | 9 +- .../kotlin/kr/toxicity/hud/text/CharWidth.kt | 2 +- .../kr/toxicity/hud/text/ImageCharWidth.kt | 4 +- .../kotlin/kr/toxicity/hud/util/Adventures.kt | 13 +- .../default/compasses/default_compass.yml | 4 +- .../kr/toxicity/hud/nms/v1_18_R2/NMSImpl.kt | 4 +- .../kr/toxicity/hud/nms/v1_19_R1/NMSImpl.kt | 16 +- .../kr/toxicity/hud/nms/v1_19_R2/NMSImpl.kt | 12 +- .../kr/toxicity/hud/nms/v1_19_R3/NMSImpl.kt | 16 +- .../kr/toxicity/hud/nms/v1_20_R1/NMSImpl.kt | 12 +- .../kr/toxicity/hud/nms/v1_20_R2/NMSImpl.kt | 4 +- .../kr/toxicity/hud/nms/v1_20_R3/NMSImpl.kt | 16 +- .../kr/toxicity/hud/nms/v1_20_R4/NMSImpl.kt | 18 +- 31 files changed, 290 insertions(+), 172 deletions(-) rename changelog/{1.10.md => 1.9.1.md} (51%) diff --git a/api/bukkit-api/src/main/java/kr/toxicity/hud/api/bukkit/bedrock/BedrockAdapter.java b/api/bukkit-api/src/main/java/kr/toxicity/hud/api/bukkit/bedrock/BedrockAdapter.java index b1642e56..4ae69311 100644 --- a/api/bukkit-api/src/main/java/kr/toxicity/hud/api/bukkit/bedrock/BedrockAdapter.java +++ b/api/bukkit-api/src/main/java/kr/toxicity/hud/api/bukkit/bedrock/BedrockAdapter.java @@ -5,11 +5,11 @@ import java.util.UUID; /** - * Checks some HudPlayer is bedrock hudPlayer. + * Checks some player is bedrock player. */ public interface BedrockAdapter { /** - * Returns whether given uuid's HudPlayer is from bedrock. + * Returns whether given uuid's player is from bedrock. * @param uuid player's uuid * @return whether This player is from bedrock client */ diff --git a/api/standard-api/src/main/java/kr/toxicity/hud/api/component/WidthComponent.java b/api/standard-api/src/main/java/kr/toxicity/hud/api/component/WidthComponent.java index 2ce2ec42..2e281227 100644 --- a/api/standard-api/src/main/java/kr/toxicity/hud/api/component/WidthComponent.java +++ b/api/standard-api/src/main/java/kr/toxicity/hud/api/component/WidthComponent.java @@ -15,6 +15,6 @@ public record WidthComponent(@NotNull TextComponent.Builder component, int width * @return Merged component */ public @NotNull WidthComponent plus(@NotNull WidthComponent other) { - return new WidthComponent(component.append(other.component), width + other.width); + return other.component.content().isEmpty() && other.component.children().isEmpty() ? this : new WidthComponent(component.append(other.component), width + other.width); } } diff --git a/api/standard-api/src/main/java/kr/toxicity/hud/api/hud/Hud.java b/api/standard-api/src/main/java/kr/toxicity/hud/api/hud/Hud.java index 03277b63..40688f6e 100644 --- a/api/standard-api/src/main/java/kr/toxicity/hud/api/hud/Hud.java +++ b/api/standard-api/src/main/java/kr/toxicity/hud/api/hud/Hud.java @@ -14,8 +14,8 @@ public interface Hud extends HudObject { /** * Returns the output of hud. - * @param hudPlayer target HudPlayer + * @param player target player * @return component of hud */ - @NotNull List getComponents(@NotNull HudPlayer hudPlayer); + @NotNull List getComponents(@NotNull HudPlayer player); } diff --git a/api/standard-api/src/main/java/kr/toxicity/hud/api/listener/HudListener.java b/api/standard-api/src/main/java/kr/toxicity/hud/api/listener/HudListener.java index 36926fdb..943311db 100644 --- a/api/standard-api/src/main/java/kr/toxicity/hud/api/listener/HudListener.java +++ b/api/standard-api/src/main/java/kr/toxicity/hud/api/listener/HudListener.java @@ -8,12 +8,12 @@ */ public interface HudListener { /** - * Gets the index of given hudPlayer. + * Gets the index of given player. * value must be 0..1. - * @param hudPlayer target HudPlayer + * @param player target player * @return index range */ - double getValue(@NotNull HudPlayer hudPlayer); + double getValue(@NotNull HudPlayer player); HudListener ZERO = p -> 0; HudListener EMPTY = p -> -1; diff --git a/api/standard-api/src/main/java/kr/toxicity/hud/api/popup/Popup.java b/api/standard-api/src/main/java/kr/toxicity/hud/api/popup/Popup.java index 47e4c3d3..c0ecadcf 100644 --- a/api/standard-api/src/main/java/kr/toxicity/hud/api/popup/Popup.java +++ b/api/standard-api/src/main/java/kr/toxicity/hud/api/popup/Popup.java @@ -24,12 +24,12 @@ public interface Popup extends HudObject { int getMaxStack(); /** - * Shows popup to some hudPlayer. + * Shows popup to some player. * @param reason causes - * @param hudPlayer target HudPlayer + * @param player target player * @return updater of popup or null if showing has failed. */ - @Nullable PopupUpdater show(@NotNull UpdateEvent reason, @NotNull HudPlayer hudPlayer); + @Nullable PopupUpdater show(@NotNull UpdateEvent reason, @NotNull HudPlayer player); /** * Hides popup to some hudPlayer. diff --git a/api/standard-api/src/main/java/kr/toxicity/hud/api/volatilecode/VolatileCodeHandler.java b/api/standard-api/src/main/java/kr/toxicity/hud/api/volatilecode/VolatileCodeHandler.java index 8790818d..a9339cfa 100644 --- a/api/standard-api/src/main/java/kr/toxicity/hud/api/volatilecode/VolatileCodeHandler.java +++ b/api/standard-api/src/main/java/kr/toxicity/hud/api/volatilecode/VolatileCodeHandler.java @@ -7,38 +7,38 @@ public interface VolatileCodeHandler { /** - * Injects hudPlayer. - * This method calls when HudPlayer joined. - * @param hudPlayer target HudPlayer + * Injects player. + * This method calls when player joined. + * @param player target player * @param color bar's color */ - void inject(@NotNull HudPlayer hudPlayer, @NotNull BossBar.Color color); + void inject(@NotNull HudPlayer player, @NotNull BossBar.Color color); /** - * Shows bar to some hudPlayer. - * @param hudPlayer target HudPlayer + * Shows bar to some player. + * @param player target player * @param color bar's color * @param component bar's title */ - void showBossBar(@NotNull HudPlayer hudPlayer, @NotNull BossBar.Color color, @NotNull Component component); + void showBossBar(@NotNull HudPlayer player, @NotNull BossBar.Color color, @NotNull Component component); /** - * Removes bar from hudPlayer. - * @param hudPlayer target HudPlayer + * Removes bar from player. + * @param player target player */ - void removeBossBar(@NotNull HudPlayer hudPlayer); + void removeBossBar(@NotNull HudPlayer player); /** * Gets textures value of player's game profile. - * @param hudPlayer target HudPlayer + * @param player target player * @return textures value */ - @NotNull String getTextureValue(@NotNull HudPlayer hudPlayer); + @NotNull String getTextureValue(@NotNull HudPlayer player); /** * Reloads player's boss bar. - * @param hudPlayer target HudPlayer + * @param player target player * @param color color */ - void reloadBossBar(@NotNull HudPlayer hudPlayer, @NotNull BossBar.Color color); + void reloadBossBar(@NotNull HudPlayer player, @NotNull BossBar.Color color); } diff --git a/bootstrap/bukkit/src/main/kotlin/kr/toxicity/hud/bootstrap/bukkit/player/HudPlayerBukkit.kt b/bootstrap/bukkit/src/main/kotlin/kr/toxicity/hud/bootstrap/bukkit/player/HudPlayerBukkit.kt index 0c089a3c..0f20bfba 100644 --- a/bootstrap/bukkit/src/main/kotlin/kr/toxicity/hud/bootstrap/bukkit/player/HudPlayerBukkit.kt +++ b/bootstrap/bukkit/src/main/kotlin/kr/toxicity/hud/bootstrap/bukkit/player/HudPlayerBukkit.kt @@ -24,9 +24,10 @@ class HudPlayerBukkit( player.world.uid ) + @Suppress("DEPRECATION") override fun locale(): Locale = player.locale.let { val split = it.split('_') - if (split.size == 1) Locale.of(split[0].lowercase()) else Locale.of(split[0].lowercase(), split[1].uppercase()) + if (split.size == 1) Locale(split[0].lowercase()) else Locale(split[0].lowercase(), split[1].uppercase()) } override fun location(): LocationWrapper { diff --git a/bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/player/HudPlayerFabric.kt b/bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/player/HudPlayerFabric.kt index 23f1327d..64a6e3ff 100644 --- a/bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/player/HudPlayerFabric.kt +++ b/bootstrap/fabric/src/main/kotlin/kr/toxicity/hud/bootstrap/fabric/player/HudPlayerFabric.kt @@ -39,9 +39,10 @@ class HudPlayerFabric( override fun audience(): Audience = audience + @Suppress("DEPRECATION") override fun locale(): Locale { val split = player.clientInformation().language.split('_') - return if (split.size == 1) Locale.of(split[0].lowercase()) else Locale.of(split[0].lowercase(), split[1].uppercase()) + return if (split.size == 1) Locale(split[0].lowercase()) else Locale.of(split[0].lowercase(), split[1].uppercase()) } override fun hasPermission(perm: String): Boolean = player.hasPermission(perm) diff --git a/build.gradle.kts b/build.gradle.kts index fbbde936..0976eaad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,7 +72,7 @@ allprojects { apply(plugin = "org.jetbrains.dokka") group = "kr.toxicity.hud" - version = "1.9" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "") + version = "1.9.1" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "") repositories { mavenCentral() diff --git a/changelog/1.10.md b/changelog/1.9.1.md similarity index 51% rename from changelog/1.10.md rename to changelog/1.9.1.md index 4733a4b8..a277154c 100644 --- a/changelog/1.10.md +++ b/changelog/1.9.1.md @@ -1,9 +1,15 @@ -# BetterHud 1.10 +# BetterHud 1.9.1 + +## Notice +- Version support about 1.18 will be dropped soon. ## Fix +- More optimized compass and image (above 1.19) - Now load-minecraft-default-textures is restored. - Fix a problem that built core shader has comment. - Fix mmocore_casting_slot placeholder. +- Fix compass pointer (Fabric) +- Fix locale problem in Java 17 ## Add - Add more uniform value in shaders json. \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt b/dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt index 7f6eb4b8..278175ea 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/compass/type/CircleCompass.kt @@ -19,6 +19,7 @@ import kr.toxicity.hud.shader.RenderScale import kr.toxicity.hud.shader.ShaderProperty import kr.toxicity.hud.util.* import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.format.TextColor import java.awt.image.BufferedImage import java.io.File @@ -42,10 +43,9 @@ class CircleCompass( } private var resourceRef: GlobalResource? = resource private val length = section.getAsInt("length", 20).coerceAtLeast(20).coerceAtMost(360) - private val encode = internalName.encodeKey() + private val encode = "compass_$internalName".encodeKey() private val key = createAdventureKey(encode) private var center = 0xC0000 - private var array: JsonArray? = JsonArray() private val applyOpacity = section.getAsBoolean("apply-opacity", false) private val scale = section.getAsDouble("scale", 1.0).apply { if (this <= 0) throw RuntimeException("scale cannot be <= 0") @@ -67,11 +67,29 @@ class CircleCompass( pixel.opacity, ShaderProperty.properties(section.get("properties")?.asArray()) ) + private var array: JsonArray? = JsonArray() private val images = CompassImage(assets, section.get("file")?.asObject().ifNull("file value not set.")) private val conditions = section.toConditions().build(UpdateEvent.EMPTY) private val isDefault = ConfigManagerImpl.defaultCompass.contains(internalName) || section.getAsBoolean("default", false) - private fun getKey(imageName: String, scaleMultiplier: Double, color: TextColor, image: BufferedImage, y: Int): WidthComponent { + + private inner class CompassComponent( + val x: Int, + val char: String, + val color: TextColor?, + val width: Int + ) { + fun toWidthComponent(): WidthComponent { + val comp = WidthComponent(Component.text() + .content(char) + .color(color) + .font(key) + .append(NEGATIVE_ONE_SPACE_COMPONENT.component), width) + return if (x == 0) comp else x.toSpaceComponent() + comp + } + } + + private fun getKey(imageName: String, scaleMultiplier: Double, color: TextColor, image: BufferedImage, x: Int, y: Int): CompassComponent { val char = center++.parseChar() val nameEncoded = imageName.encodeKey() val maxHeight = (image.height.toDouble() * scale).roundToInt() @@ -93,11 +111,7 @@ class CircleCompass( image.toByteArray() } } - return WidthComponent(Component.text() - .content(char) - .color(color) - .font(key) - .append(NEGATIVE_ONE_SPACE_COMPONENT.component), (image.width.toDouble() * div).roundToInt()) + return CompassComponent(x, char, if (color.value() != NamedTextColor.WHITE.value()) color else null, (image.width.toDouble() * div).roundToInt()) } override fun getType(): HudObjectType<*> = HudObjectType.COMPASS @@ -210,17 +224,19 @@ class CircleCompass( }, colorEquation.evaluate(i.toDouble()), image.withOpacity(sin(reverse.toDouble() / div.toDouble() * PI / 2) * opacity), - location.y, + location.x, + location.y ) } } else (0.. - CompassData(div - i) to location.x.toSpaceComponent() + getKey( + CompassData(div - i) to getKey( "compass_image_${internalName}_${imageName}_${i + 1}", scaleEquation.evaluate(i.toDouble()).apply { if (this <= 0.0) throw RuntimeException("scale equation returns <= 0") } * scale, colorEquation.evaluate(i.toDouble()), image.withOpacity(opacity), + location.x, location.y ) } @@ -235,12 +251,130 @@ class CircleCompass( init { array?.let { + if (!BOOTSTRAP.useLegacyFont()) { + val max = images.max + 2 * space + length + val center = CURRENT_CENTER_SPACE_CODEPOINT + it.add(buildJsonObject { + addProperty("type", "space") + add("advances", buildJsonObject { + for (i in -max..max) { + addProperty((center + i).parseChar(), i) + } + }) + }) + } PackGenerator.addTask(resource.font + "$encode.json") { jsonObjectOf("providers" to it).toByteArray() } } } + private interface CompassComponentBuilder { + infix fun append(component: CompassComponent?) + infix fun build(player: HudPlayer): WidthComponent + } + + private fun builder(yaw: Double, mod: Double) = if (BOOTSTRAP.useLegacyFont()) LegacyComponentBuilder(yaw, mod) else CurrentComponentBuilder(yaw, mod) + + //<=1.18 + private inner class LegacyComponentBuilder( + private val yaw: Double, + private val mod: Double + ) : CompassComponentBuilder { + + private var comp = (-(images.max / 2 + space)).toSpaceComponent() + + override fun append(component: CompassComponent?) { + comp += component?.let { + val build = it.toWidthComponent() + val move = (mod * (space * 2 + build.width)).roundToInt() + (space + move).toSpaceComponent() + build + (space - move).toSpaceComponent() + } ?: (space * 2).toSpaceComponent() + } + + override fun build(player: HudPlayer): WidthComponent { + val loc = player.location() + val world = player.world() + player.pointedLocation.forEach { + val selectedPointer = it.icon?.let { s -> images.customIcon[s] } ?: images.point ?: return@forEach + + val targetLoc = it.location + if (targetLoc.world.uuid != world.uuid) return@forEach + var get = atan2(targetLoc.z - loc.z, targetLoc.x - loc.x) / PI + if (get < 0) get += 2 + var yawCal = (if (yaw > 90) -270 + yaw else 90 + yaw) / 180 + if (yawCal < 0) yawCal += 2 + + val min = absMin(get - yawCal, -(yawCal - get)) + val minus = absMin(if (min > 0) -(2 - min) else 2 + min, min) + + selectedPointer.map[CompassData(ceil((length - abs(minus * length)) / 2).toInt())]?.let { pointComponent -> + val build = pointComponent.toWidthComponent() + val value = (minus * comp.width / 2 - comp.width / 2).roundToInt() + val halfPoint = build.width.toDouble() / 2 + comp += (value - floor(halfPoint).toInt()).toSpaceComponent() + build + (-value - ceil(halfPoint).toInt()).toSpaceComponent() + } + } + return (-comp.width / 2).toSpaceComponent() + comp + } + } + private inner class CurrentComponentBuilder( + private val yaw: Double, + private val mod: Double + ) : CompassComponentBuilder { + + private var comp = (-(images.max / 2 + space)).toSpaceComponent() + private var append = EMPTY_WIDTH_COMPONENT + private fun Int.spaceChar() = (CURRENT_CENTER_SPACE_CODEPOINT + this).parseChar() + + override fun append(component: CompassComponent?) { + append += component?.let { + val move = (mod * (space * 2 + it.width)).roundToInt() + val build = WidthComponent( + Component.text() + .content(buildString { + append((space + move).spaceChar()) + append(it.char) + append((space - move - 1).spaceChar()) + }) + .color(it.color), + space * 2 + it.width + ) + if (it.x != 0) it.x.toSpaceComponent() + build else build + } ?: (space * 2).toSpaceComponent() + } + + override fun build(player: HudPlayer): WidthComponent { + val loc = player.location() + val world = player.world() + append.component.font(key) + comp += append + player.pointedLocation.forEach { + val selectedPointer = it.icon?.let { s -> images.customIcon[s] } ?: images.point ?: return@forEach + + val targetLoc = it.location + if (targetLoc.world.uuid != world.uuid) return@forEach + var get = atan2(targetLoc.z - loc.z, targetLoc.x - loc.x) / PI + if (get < 0) get += 2 + var yawCal = (if (yaw > 90) -270 + yaw else 90 + yaw) / 180 + if (yawCal < 0) yawCal += 2 + + val min = absMin(get - yawCal, -(yawCal - get)) + val minus = absMin(if (min > 0) -(2 - min) else 2 + min, min) + + selectedPointer.map[CompassData(ceil((length - abs(minus * length)) / 2).toInt())]?.let { pointComponent -> + val build = pointComponent.toWidthComponent() + val value = (minus * comp.width / 2 - comp.width / 2).roundToInt() + val halfPoint = build.width.toDouble() / 2 + comp += (value - floor(halfPoint).toInt()).toSpaceComponent() + build + (-value - ceil(halfPoint).toInt()).toSpaceComponent() + } + } + return (-comp.width / 2).toSpaceComponent() + comp + } + } + + + override fun indicate(player: HudPlayer): WidthComponent { if (!conditions(player)) return EMPTY_WIDTH_COMPONENT val yaw = player.location().yaw.toDouble() @@ -250,8 +384,8 @@ class CircleCompass( val div = ceil(quarterDegree).toInt() val lengthDiv = length / 2 val mod = quarterDegree - div + 0.5 - val loc = player.location() - val world = player.world() + + val builder = builder(yaw, mod) fun getKey(index: Int) = when (div - index + lengthDiv) { (length * 0.5).roundToInt() -> images.sw @@ -265,33 +399,10 @@ class CircleCompass( else -> images.chain }?.map?.get(CompassData(if (index > lengthDiv) length - index else index)) //var comp = (-((getKey(length / 2)?.width ?: 0) + space)).toSpaceComponent() - var comp = (-(images.max / 2 + space)).toSpaceComponent() for (i in 1.. images.customIcon[s] } ?: images.point ?: return@forEach - - val targetLoc = it.location - if (targetLoc.world.uuid != world.uuid) return@forEach - var get = atan2(targetLoc.z - loc.z, targetLoc.x - loc.x) / PI - if (get < 0) get += 2 - var yawCal = (if (yaw > 90) -270 + yaw else 90 + yaw) / 180 - if (yawCal < 0) yawCal += 2 - - val min = absMin(get - yawCal, -(yawCal - get)) - val minus = absMin(if (min > 0) -(2 - min) else 2 + min, min) - - selectedPointer.map[CompassData(ceil((length - abs(minus * length)) / 2).toInt())]?.let { pointComponent -> - val value = (minus * comp.width / 2 - comp.width / 2).roundToInt() - val halfPoint = pointComponent.width.toDouble() / 2 - comp += (value - floor(halfPoint).toInt()).toSpaceComponent() + pointComponent + (-value - ceil(halfPoint).toInt()).toSpaceComponent() - } + builder append getKey(i) } - return (-comp.width / 2).toSpaceComponent() + comp + return builder build player } private fun absMin(d1: Double, d2: Double): Double { @@ -310,6 +421,4 @@ class CircleCompass( override fun hashCode(): Int { return internalName.hashCode() } - - } \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImageElement.kt b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImageElement.kt index 345797a9..b5039934 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImageElement.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImageElement.kt @@ -34,19 +34,22 @@ class HudImageElement(parent: HudImpl, private val image: ImageLayout, gui: GuiL if (hud.listener != null) { list.add(EMPTY_PIXEL_COMPONENT) } + val negativeSpace = parent.getOrCreateSpace(-1) hud.image.forEach { pair -> val fileName = "$NAME_SPACE_ENCODED:${pair.name}" - val height = Math.round(pair.image.image.height.toDouble() * image.scale).toInt() + val height = (pair.image.image.height.toDouble() * image.scale).roundToInt() val scale = height.toDouble() / pair.image.image.height val ascent = finalPixel.y.coerceAtLeast(-HudImpl.ADD_HEIGHT).coerceAtMost(HudImpl.ADD_HEIGHT) val shaderGroup = ShaderGroup(shader, fileName, image.scale, ascent) val component = ImageManager.getImage(shaderGroup) ?: run { val c = (++parent.imageChar).parseChar() - val finalWidth = WidthComponent(Component.text() - .content(c) + val comp = Component.text() .font(parent.imageKey) - .append(NEGATIVE_ONE_SPACE_COMPONENT.component), (pair.image.image.width.toDouble() * scale).roundToInt()) + val finalWidth = WidthComponent( + if (BOOTSTRAP.useLegacyFont()) comp.content(c).append(NEGATIVE_ONE_SPACE_COMPONENT.component) else comp.content("$c$negativeSpace"), + (pair.image.image.width.toDouble() * scale).roundToInt() + ) parent.jsonArray?.let { array -> HudImpl.createBit(shader, ascent) { y -> array.add(jsonObjectOf( @@ -62,7 +65,7 @@ class HudImageElement(parent: HudImpl, private val image: ImageLayout, gui: GuiL finalWidth } - list.add(component.toPixelComponent(finalPixel.x + Math.round(pair.image.xOffset * scale).toInt())) + list.add(component.toPixelComponent(finalPixel.x + (pair.image.xOffset * scale).roundToInt())) } val renderer = ImageRenderer( hud, diff --git a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImpl.kt b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImpl.kt index 4f53ce2b..30277519 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImpl.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudImpl.kt @@ -98,14 +98,14 @@ class HudImpl( private val conditions = section.toConditions().build(UpdateEvent.EMPTY) - override fun getComponents(hudPlayer: HudPlayer): List { - if (!conditions(hudPlayer)) return emptyList() + override fun getComponents(player: HudPlayer): List { + if (!conditions(player)) return emptyList() return elements.map { val elements = it.elements elements[when (it.animationType) { - AnimationType.LOOP -> (hudPlayer.tick % elements.size).toInt() - AnimationType.PLAY_ONCE -> hudPlayer.tick.toInt().coerceAtMost(elements.lastIndex) - }].getComponent(hudPlayer) + AnimationType.LOOP -> (player.tick % elements.size).toInt() + AnimationType.PLAY_ONCE -> player.tick.toInt().coerceAtMost(elements.lastIndex) + }].getComponent(player) } } diff --git a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudTextElement.kt b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudTextElement.kt index 9af6eed1..f3af1bd9 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/hud/HudTextElement.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/hud/HudTextElement.kt @@ -104,9 +104,8 @@ class HudTextElement( )) } return WidthComponent(Component.text() - .font(key) .content(result) - .append(NEGATIVE_ONE_SPACE_COMPONENT.component), (image.image.width.toDouble() * div).roundToInt()) + .append(NEGATIVE_ONE_SPACE_COMPONENT.finalizeFont().component), (image.image.width.toDouble() * div).roundToInt()) } BackgroundLayout( it.location.x, diff --git a/dist/src/main/kotlin/kr/toxicity/hud/player/HudPlayerImpl.kt b/dist/src/main/kotlin/kr/toxicity/hud/player/HudPlayerImpl.kt index cc4c1bfd..202cd40a 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/player/HudPlayerImpl.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/player/HudPlayerImpl.kt @@ -123,11 +123,11 @@ abstract class HudPlayerImpl : HudPlayer { additionalComp?.let { compList.add((-it.width / 2).toSpaceComponent() + it) } - var comp = EMPTY_WIDTH_COMPONENT + NEGATIVE_ONE_SPACE_COMPONENT + var comp = NEGATIVE_ONE_SPACE_COMPONENT compList.forEach { comp += it + (-it.width).toSpaceComponent() } - last = comp + last = comp.finalizeFont() VOLATILE_CODE.showBossBar(this, color ?: ShaderManagerImpl.barColor, comp.component.build()) } else VOLATILE_CODE.showBossBar(this, color ?: ShaderManagerImpl.barColor, EMPTY_COMPONENT) diff --git a/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupImpl.kt b/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupImpl.kt index bd3a004c..fcd24ac5 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupImpl.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupImpl.kt @@ -129,16 +129,16 @@ class PopupImpl( override fun getType(): HudObjectType<*> = HudObjectType.POPUP override fun getMaxStack(): Int = move.locations.size - override fun show(reason: UpdateEvent, hudPlayer: HudPlayer): PopupUpdater? { + override fun show(reason: UpdateEvent, player: HudPlayer): PopupUpdater? { if (keyMapping) { - hudPlayer.popupKeyMap[reason.key]?.let { + player.popupKeyMap[reason.key]?.let { if (it.update()) return null - else hudPlayer.popupKeyMap.remove(reason.key) + else player.popupKeyMap.remove(reason.key) } } - return show0(reason, hudPlayer)?.apply { + return show0(reason, player)?.apply { if (keyMapping) { - hudPlayer.popupKeyMap[reason.key] = this + player.popupKeyMap[reason.key] = this } } } diff --git a/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt b/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt index 35a9d24d..5b4ad368 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt @@ -120,14 +120,15 @@ class PopupLayout( target.property ) val list = ArrayList() + val negativeSpace = parent.getOrCreateSpace(-1) if (hudImage.listener != null) list.add(EMPTY_PIXEL_COMPONENT) - if (hudImage.image.size > 1) hudImage.image.forEach { + hudImage.image.forEach { val fileName = "$NAME_SPACE_ENCODED:${it.name}" - val height = (it.image.image.height * target.scale).roundToInt().toInt() + val height = (it.image.image.height * target.scale).roundToInt() val scale = height.toDouble() / it.image.image.height - val xOffset = (it.image.xOffset * scale).roundToInt().toInt() + val xOffset = (it.image.xOffset * scale).roundToInt() val ascent = pixel.y val shaderGroup = ShaderGroup(imageShader, fileName, target.scale, ascent) @@ -143,28 +144,18 @@ class PopupLayout( )) } val xWidth = (it.image.image.width.toDouble() * scale).roundToInt() - val comp = WidthComponent(Component.text().content(char).font(parent.imageKey), xWidth) + NEGATIVE_ONE_SPACE_COMPONENT + val build = Component.text() + .font(parent.imageKey) + val comp = WidthComponent( + if (BOOTSTRAP.useLegacyFont()) build.content(char).append(NEGATIVE_ONE_SPACE_COMPONENT.component) else build.content("$char$negativeSpace"), + xWidth + ) ImageManager.setImage(shaderGroup, comp) comp } list.add(component.toPixelComponent(pixel.x + xOffset)) - } else hudImage.image[0].let { - val char = parent.newChar() - HudImpl.createBit(imageShader, pixel.y) { y -> - array.add(jsonObjectOf( - "type" to "bitmap", - "file" to "$NAME_SPACE_ENCODED:${it.name}", - "ascent" to y, - "height" to (it.image.image.height * target.scale).roundToInt(), - "chars" to jsonArrayOf(char) - )) - } - val comp = WidthComponent(Component.text().content(char).font(parent.imageKey), (it.image.image.width.toDouble() * target.scale).roundToInt() - .toInt()) + NEGATIVE_ONE_SPACE_COMPONENT - list.add(comp.toPixelComponent(pixel.x)) } - ImageRenderer( hudImage, target.color, @@ -258,9 +249,8 @@ class PopupLayout( )) } return WidthComponent(Component.text() - .font(key) .content(result) - .append(NEGATIVE_ONE_SPACE_COMPONENT.component), (image.image.width.toDouble() * div).roundToInt()) + .append(NEGATIVE_ONE_SPACE_COMPONENT.finalizeFont().component), (image.image.width.toDouble() * div).roundToInt()) } BackgroundLayout( it.location.x, diff --git a/dist/src/main/kotlin/kr/toxicity/hud/renderer/ImageRenderer.kt b/dist/src/main/kotlin/kr/toxicity/hud/renderer/ImageRenderer.kt index 1dee795e..433d001f 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/renderer/ImageRenderer.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/renderer/ImageRenderer.kt @@ -12,7 +12,7 @@ import kr.toxicity.hud.placeholder.ConditionBuilder import kr.toxicity.hud.placeholder.PlaceholderBuilder import kr.toxicity.hud.util.EMPTY_PIXEL_COMPONENT import kr.toxicity.hud.util.append -import net.kyori.adventure.text.Component +import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.format.TextColor import kotlin.math.ceil import kotlin.math.roundToInt @@ -31,7 +31,10 @@ class ImageRenderer( private val type = image.type private val components = components.map { val comp = it.component - PixelComponent(WidthComponent(Component.text().append(comp.component.build().color(color)), comp.width), it.pixel) + PixelComponent(if (color.value() == NamedTextColor.WHITE.value()) comp else WidthComponent( + comp.component.build().toBuilder().color(color), + comp.width + ), it.pixel) } private val followHudPlayer = follow?.let { diff --git a/dist/src/main/kotlin/kr/toxicity/hud/renderer/TextRenderer.kt b/dist/src/main/kotlin/kr/toxicity/hud/renderer/TextRenderer.kt index 3b3bc69d..9f04e5c8 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/renderer/TextRenderer.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/renderer/TextRenderer.kt @@ -115,10 +115,13 @@ class TextRenderer( } val total = it.left.width + length + it.right.width val minus = -total + (length - comp.width) / 2 + it.left.width - it.x - finalComp = it.x.toSpaceComponent() + WidthComponent(builder.append(it.right.component), total) + minus.toSpaceComponent() + finalComp + + var build = EMPTY_WIDTH_COMPONENT.finalizeFont() + if (it.x != 0) build += it.x.toSpaceComponent() + finalComp = build + WidthComponent(builder.append(it.right.component).font(backgroundKey.key), total) + minus.toSpaceComponent() + finalComp } if (finalComp.width > max) max = finalComp.width - widthComp = if (widthComp.width == 0) finalComp else widthComp plusWithAlign finalComp + widthComp = widthComp plusWithAlign finalComp } widthComp.toPixelComponent(when (align) { LayoutAlign.LEFT -> x @@ -159,7 +162,7 @@ class TextRenderer( .replacement { r, _ -> when (r.group(1)) { "image" -> data.imageCodepoint[r.group(3)]?.let { Component.text(it.parseChar()) } ?: Component.empty() - "space" -> r.group(3).toIntOrNull()?.toSpaceComponent()?.component ?: Component.empty() + "space" -> r.group(3).toIntOrNull()?.toSpaceComponent()?.finalizeFont()?.component ?: Component.empty() else -> Component.empty() } } diff --git a/dist/src/main/kotlin/kr/toxicity/hud/text/CharWidth.kt b/dist/src/main/kotlin/kr/toxicity/hud/text/CharWidth.kt index 972d4877..514f3a37 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/text/CharWidth.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/text/CharWidth.kt @@ -3,5 +3,5 @@ package kr.toxicity.hud.text import kotlin.math.roundToInt open class CharWidth(val width: Int, val height: Int) { - fun scaledWidth(scale: Double) = (width.toDouble() / height.toDouble() * (height * scale).roundToInt()).roundToInt() + open fun scaledWidth(scale: Double) = (width.toDouble() / height.toDouble() * (height * scale).roundToInt()).roundToInt() } \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/text/ImageCharWidth.kt b/dist/src/main/kotlin/kr/toxicity/hud/text/ImageCharWidth.kt index aef92dda..b89100be 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/text/ImageCharWidth.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/text/ImageCharWidth.kt @@ -9,4 +9,6 @@ class ImageCharWidth( val scale: Double, width: Int, height: Int -) : CharWidth(width, height) \ No newline at end of file +) : CharWidth(width, height) { + override fun scaledWidth(scale: Double) = super.scaledWidth(scale * this.scale) +} \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/util/Adventures.kt b/dist/src/main/kotlin/kr/toxicity/hud/util/Adventures.kt index 1c615166..b7551eb7 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/util/Adventures.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/util/Adventures.kt @@ -44,7 +44,7 @@ fun String.toComponent() = Component.text(this).color(NamedTextColor.WHITE).deco val EMPTY_COMPONENT: Component = Component.empty() val EMPTY_WIDTH_COMPONENT - get() = WidthComponent(Component.text().color(NamedTextColor.WHITE), 0) + get() = WidthComponent(Component.text(), 0) val EMPTY_PIXEL_COMPONENT get() = PixelComponent(EMPTY_WIDTH_COMPONENT, 0) @@ -52,9 +52,9 @@ const val LEGACY_CENTER_SPACE_CODEPOINT = 0xFFC00 const val CURRENT_CENTER_SPACE_CODEPOINT = 0xD0000 private val LEGACY_NEGATIVE_ONE_SPACE_COMPONENT - get() = WidthComponent(Component.text().content((LEGACY_CENTER_SPACE_CODEPOINT - 1).parseChar()).font(LEGACY_SPACE_KEY), 0) + get() = WidthComponent(Component.text().content((LEGACY_CENTER_SPACE_CODEPOINT - 1).parseChar()), 0) private val CURRENT_NEGATIVE_ONE_SPACE_COMPONENT - get() = WidthComponent(Component.text().content((CURRENT_CENTER_SPACE_CODEPOINT - 1).parseChar()).font(SPACE_KEY), 0) + get() = WidthComponent(Component.text().content((CURRENT_CENTER_SPACE_CODEPOINT - 1).parseChar()), 0) val NEGATIVE_ONE_SPACE_COMPONENT get() = if (BOOTSTRAP.useLegacyFont()) { LEGACY_NEGATIVE_ONE_SPACE_COMPONENT @@ -93,25 +93,26 @@ fun Int.toSpaceComponent(width: Int) = if (BOOTSTRAP.useLegacyFont()) { val i = if (this > 0) 1 else -1 WidthComponent( Component.text() - .font(LEGACY_SPACE_KEY) .content("${((abs / 256 + 255) * i + 0xFFC00).parseChar()}${(abs % 256 * i + 0xFFC00).parseChar()}"), width ) } else WidthComponent( Component.text() - .font(LEGACY_SPACE_KEY) .content((this + 0xFFC00).parseChar()), width ) } else { WidthComponent( Component.text() - .font(SPACE_KEY) .content((this + 0xD0000).parseChar()), width ) } +fun WidthComponent.finalizeFont() = apply { + if (BOOTSTRAP.useLegacyFont()) component.font(LEGACY_SPACE_KEY) else component.font(SPACE_KEY) +} + private class SplitBuilder( private val chain: (TextComponent.Builder) -> Unit ) { diff --git a/dist/src/main/resources/default/compasses/default_compass.yml b/dist/src/main/resources/default/compasses/default_compass.yml index 9e8028e0..4e9dcdc7 100644 --- a/dist/src/main/resources/default/compasses/default_compass.yml +++ b/dist/src/main/resources/default/compasses/default_compass.yml @@ -33,8 +33,8 @@ default_compass: space: 2 gui: x: 50 - y: 20 + y: 0 pixel: x: 0 - y: 0 + y: 80 apply-opacity: true \ No newline at end of file diff --git a/nms/v1_18_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_18_R2/NMSImpl.kt b/nms/v1_18_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_18_R2/NMSImpl.kt index 400d0352..c982ec6a 100644 --- a/nms/v1_18_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_18_R2/NMSImpl.kt +++ b/nms/v1_18_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_18_R2/NMSImpl.kt @@ -85,8 +85,8 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { PlayerBossBar(h, h.handle.connection, color, Component.empty()) } diff --git a/nms/v1_19_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R1/NMSImpl.kt b/nms/v1_19_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R1/NMSImpl.kt index 8fcdbd50..70fc1663 100644 --- a/nms/v1_19_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R1/NMSImpl.kt +++ b/nms/v1_19_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R1/NMSImpl.kt @@ -85,22 +85,22 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { HudPlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } - override fun reloadBossBar(hudPlayer: HudPlayer, color: BossBar.Color) { - bossBarMap[hudPlayer.uuid()]?.resetDummy(color) + override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { + bossBarMap[player.uuid()]?.resetDummy(color) } override fun getVersion(): NMSVersion { diff --git a/nms/v1_19_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R2/NMSImpl.kt b/nms/v1_19_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R2/NMSImpl.kt index f661a13d..d8497f69 100644 --- a/nms/v1_19_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R2/NMSImpl.kt +++ b/nms/v1_19_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R2/NMSImpl.kt @@ -85,18 +85,18 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { PlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { diff --git a/nms/v1_19_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R3/NMSImpl.kt b/nms/v1_19_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R3/NMSImpl.kt index b5509e7b..860dc73d 100644 --- a/nms/v1_19_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R3/NMSImpl.kt +++ b/nms/v1_19_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_19_R3/NMSImpl.kt @@ -85,22 +85,22 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { HudPlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } - override fun reloadBossBar(hudPlayer: HudPlayer, color: BossBar.Color) { - bossBarMap[hudPlayer.uuid()]?.resetDummy(color) + override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { + bossBarMap[player.uuid()]?.resetDummy(color) } override fun getVersion(): NMSVersion { diff --git a/nms/v1_20_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R1/NMSImpl.kt b/nms/v1_20_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R1/NMSImpl.kt index 101b0d14..8b5bfccd 100644 --- a/nms/v1_20_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R1/NMSImpl.kt +++ b/nms/v1_20_R1/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R1/NMSImpl.kt @@ -85,18 +85,18 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { PlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { diff --git a/nms/v1_20_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R2/NMSImpl.kt b/nms/v1_20_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R2/NMSImpl.kt index 35bbb92c..bd416853 100644 --- a/nms/v1_20_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R2/NMSImpl.kt +++ b/nms/v1_20_R2/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R2/NMSImpl.kt @@ -86,8 +86,8 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() h as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { PlayerBossBar(h, h.handle.connection, color, Component.empty()) diff --git a/nms/v1_20_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R3/NMSImpl.kt b/nms/v1_20_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R3/NMSImpl.kt index 2c2d2fa5..6e406fc6 100644 --- a/nms/v1_20_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R3/NMSImpl.kt +++ b/nms/v1_20_R3/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R3/NMSImpl.kt @@ -86,22 +86,22 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { HudPlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } - override fun reloadBossBar(hudPlayer: HudPlayer, color: BossBar.Color) { - bossBarMap[hudPlayer.uuid()]?.resetDummy(color) + override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { + bossBarMap[player.uuid()]?.resetDummy(color) } override fun getVersion(): NMSVersion { diff --git a/nms/v1_20_R4/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R4/NMSImpl.kt b/nms/v1_20_R4/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R4/NMSImpl.kt index 7ce57301..29e92030 100644 --- a/nms/v1_20_R4/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R4/NMSImpl.kt +++ b/nms/v1_20_R4/src/main/kotlin/kr/toxicity/hud/nms/v1_20_R4/NMSImpl.kt @@ -92,22 +92,22 @@ class NMSImpl : NMS { } } - override fun inject(hudPlayer: HudPlayer, color: BossBar.Color) { - val h = hudPlayer.handle() as CraftPlayer + override fun inject(player: HudPlayer, color: BossBar.Color) { + val h = player.handle() as CraftPlayer bossBarMap.computeIfAbsent(h.uniqueId) { HudPlayerBossBar(h, h.handle.connection, color, Component.empty()) } } - override fun showBossBar(hudPlayer: HudPlayer, color: BossBar.Color, component: Component) { - bossBarMap[hudPlayer.uuid()]?.update(color, component) + override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) { + bossBarMap[player.uuid()]?.update(color, component) } - override fun removeBossBar(hudPlayer: HudPlayer) { - bossBarMap.remove(hudPlayer.uuid())?.remove() + override fun removeBossBar(player: HudPlayer) { + bossBarMap.remove(player.uuid())?.remove() } - override fun reloadBossBar(hudPlayer: HudPlayer, color: BossBar.Color) { - bossBarMap[hudPlayer.uuid()]?.resetDummy(color) + override fun reloadBossBar(player: HudPlayer, color: BossBar.Color) { + bossBarMap[player.uuid()]?.resetDummy(color) } override fun getVersion(): NMSVersion { @@ -507,7 +507,7 @@ class NMSImpl : NMS { constructor(uuid: UUID, component: Component, color: BossBar.Color): this( uuid, fromAdventure(component), - Companion.getColor(color) + getColor(color) ) override fun getProgress(): Float { return 0F