aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/rift
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/features/rift
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/features/rift')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
index a4d277ceb..21f13c156 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt
@@ -4,11 +4,13 @@ import at.hannibal2.skyhanni.events.ActionBarUpdateEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.entity.EntityHealthDisplayEvent
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.TimeUtils.format
@@ -23,11 +25,20 @@ object RiftTimer {
private val config get() = RiftAPI.config.timer
- private val timePattern by RepoPattern.pattern(
- "rift.everywhere.timer",
+ private val repoGroup = RepoPattern.group("rift.everywhere")
+ private val timePattern by repoGroup.pattern(
+ "timer",
"§(?<color>[a7])(?<time>.*)ф Left.*"
)
+ /**
+ * REGEX-TEST: 3150 §aф
+ */
+ private val nametagPattern by repoGroup.pattern(
+ "nametag.timer",
+ "(?<time>\\d+) §aф"
+ )
+
private var display = emptyList<String>()
private var maxTime = 0.seconds
private var currentTime = 0.seconds
@@ -117,5 +128,14 @@ object RiftTimer {
config.timerPosition.renderStrings(display, posLabel = "Rift Timer")
}
+ @SubscribeEvent
+ fun onEntityHealthDisplay(event: EntityHealthDisplayEvent) {
+ if (!RiftAPI.inRift() || !config.nametag) return
+ val time = nametagPattern.matchMatcher(event.text) {
+ group("time")?.toIntOrNull()
+ } ?: return
+ event.text = "${time.seconds.format()} §aф"
+ }
+
fun isEnabled() = RiftAPI.inRift() && config.enabled
}