From 88416edd2f5a50e1ba88e9adb574e3c60c49abca Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 7 Sep 2024 23:00:02 +0200 Subject: Feature: Rift time Nametag Format (#2015) Co-authored-by: Cal Co-authored-by: ItsEmpa Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/EntityData.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/data/EntityData.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index c4e5fd7e7..d2f81a6d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent +import at.hannibal2.skyhanni.events.entity.EntityHealthDisplayEvent import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils @@ -32,6 +33,7 @@ object EntityData { private val maxHealthMap = mutableMapOf() private val nametagCache = TimeLimitedCache(50.milliseconds) + private val healthDisplayCache = TimeLimitedCache(50.milliseconds) @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -103,4 +105,12 @@ object EntityData { event.postAndCatch() event.chatComponent } + + @JvmStatic + fun getHealthDisplay(text: String) = healthDisplayCache.getOrPut(text) { + val event = EntityHealthDisplayEvent(text) + event.postAndCatch() + event.text + } + } -- cgit