aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-09-07 23:00:02 +0200
committerGitHub <noreply@github.com>2024-09-07 23:00:02 +0200
commit88416edd2f5a50e1ba88e9adb574e3c60c49abca (patch)
treea2b98d9abb6273dbc11b098c737f087c9bfa4c7c /src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
parentae587b6cb7964fbe36a7d70f4b5c944a1671225f (diff)
downloadskyhanni-88416edd2f5a50e1ba88e9adb574e3c60c49abca.tar.gz
skyhanni-88416edd2f5a50e1ba88e9adb574e3c60c49abca.tar.bz2
skyhanni-88416edd2f5a50e1ba88e9adb574e3c60c49abca.zip
Feature: Rift time Nametag Format (#2015)
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: ItsEmpa <itsempa@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/EntityData.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityData.kt10
1 files changed, 10 insertions, 0 deletions
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<EntityLivingBase, Int>()
private val nametagCache = TimeLimitedCache<Entity, ChatComponentText>(50.milliseconds)
+ private val healthDisplayCache = TimeLimitedCache<String, String>(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
+ }
+
}