Skip to content

Commit

Permalink
Fix popup text.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Dec 14, 2024
1 parent 7e1b3c9 commit 9fab55b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ allprojects {
apply(plugin = "org.jetbrains.dokka")

group = "kr.toxicity.hud"
version = "1.10.2" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")
version = "1.10.3" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")

repositories {
mavenCentral()
Expand Down
7 changes: 7 additions & 0 deletions changelog/1.10.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# BetterHud 1.10.3

## Notice
- This is a bug fix version of 1.10.2

## Fix
- Fix popup text.
5 changes: 4 additions & 1 deletion dist/src/main/kotlin/kr/toxicity/hud/popup/PopupLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class PopupLayout(
pixel.opacity,
textLayout.property
)
val scaledMap = textLayout.source.charWidth.entries.associate { (k, v) ->
k to v * textLayout.scale
}
val scaledImageMap = textLayout.imageCharMap.entries.associate { (k, v) ->
k to v * textLayout.scale * textLayout.emoji.scale
}
Expand Down Expand Up @@ -258,7 +261,7 @@ class PopupLayout(
textLayout,
HudTextData(
keys,
textLayout.source.charWidth.entries.associate { (k, v) ->
scaledMap.entries.associate { (k, v) ->
k to v.normalizedWidth
} + scaledImageMap.entries.associate { (k, v) ->
k to v.normalizedWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
class NMSImpl : NMS {
companion object {
private const val INJECT_NAME = BetterHud.DEFAULT_NAMESPACE
private val bossBarMap = ConcurrentHashMap<UUID, HudPlayerBossBar>()
private val bossBarMap = ConcurrentHashMap<UUID, PlayerBossBar>()

@Suppress("UNCHECKED_CAST")
private val operation = ClientboundBossEventPacket::class.java.declaredClasses.first {
Expand Down Expand Up @@ -88,7 +88,7 @@ class NMSImpl : NMS {
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())
PlayerBossBar(h, h.handle.connection, color, Component.empty())
}
}
override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) {
Expand Down Expand Up @@ -200,8 +200,8 @@ class NMSImpl : NMS {
}

private class CachedHudBossbar(val hud: HudBossBar, val cacheUUID: UUID, val buf: FriendlyByteBuf)
private class HudPlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class HudPlayerDummyBossBar(color: BossBar.Color) {
private class PlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class PlayerDummyBossBar(color: BossBar.Color) {
val line = BetterHudAPI.inst().configManager.bossbarLine - 1
val dummyBars = (0..<line).map {
HudBossBar(UUID.randomUUID(), Component.empty(), color).apply {
Expand All @@ -212,7 +212,7 @@ class NMSImpl : NMS {
it.uuid
}
}
private var dummy = HudPlayerDummyBossBar(color)
private var dummy = PlayerDummyBossBar(color)
private val dummyBarHandleMap = Collections.synchronizedMap(LinkedHashMap<UUID, CachedHudBossbar>())
private val otherBarCache = ConcurrentLinkedQueue<Pair<UUID, HudByteBuf>>()
private val uuid = UUID.randomUUID().apply {
Expand Down Expand Up @@ -240,7 +240,7 @@ class NMSImpl : NMS {
dummy.dummyBarsUUID.forEach {
listener.send(ClientboundBossEventPacket.createRemovePacket(it))
}
dummy = HudPlayerDummyBossBar(color)
dummy = PlayerDummyBossBar(color)
dummy.dummyBars.forEach {
listener.send(ClientboundBossEventPacket.createAddPacket(it))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
class NMSImpl : NMS {
companion object {
private const val INJECT_NAME = BetterHud.DEFAULT_NAMESPACE
private val bossBarMap = ConcurrentHashMap<UUID, HudPlayerBossBar>()
private val bossBarMap = ConcurrentHashMap<UUID, PlayerBossBar>()

@Suppress("UNCHECKED_CAST")
private val operation = ClientboundBossEventPacket::class.java.declaredClasses.first {
Expand Down Expand Up @@ -88,7 +88,7 @@ class NMSImpl : NMS {
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())
PlayerBossBar(h, h.handle.connection, color, Component.empty())
}
}
override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) {
Expand Down Expand Up @@ -200,8 +200,8 @@ class NMSImpl : NMS {
}

private class CachedHudBossbar(val hud: HudBossBar, val cacheUUID: UUID, val buf: FriendlyByteBuf)
private class HudPlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class HudPlayerDummyBossBar(color: BossBar.Color) {
private class PlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class PlayerDummyBossBar(color: BossBar.Color) {
val line = BetterHudAPI.inst().configManager.bossbarLine - 1
val dummyBars = (0..<line).map {
HudBossBar(UUID.randomUUID(), Component.empty(), color).apply {
Expand All @@ -212,7 +212,7 @@ class NMSImpl : NMS {
it.uuid
}
}
private var dummy = HudPlayerDummyBossBar(color)
private var dummy = PlayerDummyBossBar(color)
private val dummyBarHandleMap = Collections.synchronizedMap(LinkedHashMap<UUID, CachedHudBossbar>())
private val otherBarCache = ConcurrentLinkedQueue<Pair<UUID, HudByteBuf>>()
private val uuid = UUID.randomUUID().apply {
Expand Down Expand Up @@ -240,7 +240,7 @@ class NMSImpl : NMS {
dummy.dummyBarsUUID.forEach {
listener.send(ClientboundBossEventPacket.createRemovePacket(it))
}
dummy = HudPlayerDummyBossBar(color)
dummy = PlayerDummyBossBar(color)
dummy.dummyBars.forEach {
listener.send(ClientboundBossEventPacket.createAddPacket(it))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class NMSImpl : NMS {
}

override fun inject(player: HudPlayer, color: BossBar.Color) {
val h = player.handle()
h as CraftPlayer
val h = player.handle() as CraftPlayer
bossBarMap.computeIfAbsent(h.uniqueId) {
PlayerBossBar(h, h.handle.connection, color, Component.empty())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
class NMSImpl : NMS {
companion object {
private const val INJECT_NAME = BetterHud.DEFAULT_NAMESPACE
private val bossBarMap = ConcurrentHashMap<UUID, HudPlayerBossBar>()
private val bossBarMap = ConcurrentHashMap<UUID, PlayerBossBar>()

@Suppress("UNCHECKED_CAST")
private val operation = ClientboundBossEventPacket::class.java.declaredClasses.first {
Expand Down Expand Up @@ -89,7 +89,7 @@ class NMSImpl : NMS {
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())
PlayerBossBar(h, h.handle.connection, color, Component.empty())
}
}
override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) {
Expand Down Expand Up @@ -199,8 +199,8 @@ class NMSImpl : NMS {


private class CachedHudBossbar(val hud: HudBossBar, val cacheUUID: UUID, val buf: FriendlyByteBuf)
private class HudPlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class HudPlayerDummyBossBar(color: BossBar.Color) {
private class PlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class PlayerDummyBossBar(color: BossBar.Color) {
val line = BetterHudAPI.inst().configManager.bossbarLine - 1
val dummyBars = (0..<line).map {
HudBossBar(UUID.randomUUID(), Component.empty(), color).apply {
Expand All @@ -211,7 +211,7 @@ class NMSImpl : NMS {
it.uuid
}
}
private var dummy = HudPlayerDummyBossBar(color)
private var dummy = PlayerDummyBossBar(color)
private val dummyBarHandleMap = Collections.synchronizedMap(LinkedHashMap<UUID, CachedHudBossbar>())
private val otherBarCache = ConcurrentLinkedQueue<Pair<UUID, HudByteBuf>>()
private val uuid = UUID.randomUUID().apply {
Expand Down Expand Up @@ -239,7 +239,7 @@ class NMSImpl : NMS {
dummy.dummyBarsUUID.forEach {
listener.send(ClientboundBossEventPacket.createRemovePacket(it))
}
dummy = HudPlayerDummyBossBar(color)
dummy = PlayerDummyBossBar(color)
dummy.dummyBars.forEach {
listener.send(ClientboundBossEventPacket.createAddPacket(it))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
class NMSImpl : NMS {
companion object {
private const val INJECT_NAME = BetterHud.DEFAULT_NAMESPACE
private val bossBarMap = ConcurrentHashMap<UUID, HudPlayerBossBar>()
private val bossBarMap = ConcurrentHashMap<UUID, PlayerBossBar>()

@Suppress("UNCHECKED_CAST")
private val operation = ClientboundBossEventPacket::class.java.declaredClasses.first {
Expand Down Expand Up @@ -95,7 +95,7 @@ class NMSImpl : NMS {
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())
PlayerBossBar(h, h.handle.connection, color, Component.empty())
}
}
override fun showBossBar(player: HudPlayer, color: BossBar.Color, component: Component) {
Expand Down Expand Up @@ -208,8 +208,8 @@ class NMSImpl : NMS {


private class CachedHudBossbar(val hud: HudBossBar, val cacheUUID: UUID, val buf: HudByteBuf)
private class HudPlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class HudPlayerDummyBossBar(color: BossBar.Color) {
private class PlayerBossBar(val player: Player, val listener: ServerGamePacketListenerImpl, color: BossBar.Color, component: Component): ChannelDuplexHandler() {
private inner class PlayerDummyBossBar(color: BossBar.Color) {
val line = BetterHudAPI.inst().configManager.bossbarLine - 1
val dummyBars = (0..<line).map {
HudBossBar(UUID.randomUUID(), Component.empty(), color).apply {
Expand All @@ -220,7 +220,7 @@ class NMSImpl : NMS {
it.uuid
}
}
private var dummy = HudPlayerDummyBossBar(color)
private var dummy = PlayerDummyBossBar(color)
private val dummyBarHandleMap = Collections.synchronizedMap(LinkedHashMap<UUID, CachedHudBossbar>())
private val otherBarCache = ConcurrentLinkedQueue<Pair<UUID, HudByteBuf>>()
private val uuid = UUID.randomUUID().apply {
Expand Down Expand Up @@ -248,7 +248,7 @@ class NMSImpl : NMS {
dummy.dummyBarsUUID.forEach {
listener.send(ClientboundBossEventPacket.createRemovePacket(it))
}
dummy = HudPlayerDummyBossBar(color)
dummy = PlayerDummyBossBar(color)
dummy.dummyBars.forEach {
listener.send(ClientboundBossEventPacket.createAddPacket(it))
}
Expand Down

0 comments on commit 9fab55b

Please sign in to comment.