aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 01:15:19 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 01:15:19 +0200
commit1cb9faf8fd116595b13083320b444da7a9e7b8a1 (patch)
tree80dec530c4f88f319eff4a7f4c19fe5c5311f985 /src/main/java
parent51fa51d422a83a7cfcc22dfd2e4925b5e66ae205 (diff)
downloadskyhanni-1cb9faf8fd116595b13083320b444da7a9e7b8a1.tar.gz
skyhanni-1cb9faf8fd116595b13083320b444da7a9e7b8a1.tar.bz2
skyhanni-1cb9faf8fd116595b13083320b444da7a9e7b8a1.zip
Fixed damage indicator errors during enderman slayer.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
index 7735c5835..8de8e7f54 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt
@@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield
import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield
+import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith
import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith
@@ -21,7 +22,6 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
-import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.LorenzUtils.put
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -29,6 +29,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.getLorenzVec
@@ -55,6 +56,8 @@ class DamageIndicatorManager {
private val maxHealth = mutableMapOf<UUID, Long>()
private val config get() = SkyHanniMod.feature.combat.damageIndicator
+ private val enderSlayerHitsNumberPattern = "§c☠ §bVoidgloom Seraph .* §[5fd]§l(?<hits>\\d+) Hits?".toPattern()
+
companion object {
private var data = mapOf<UUID, EntityData>()
private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern()
@@ -162,8 +165,8 @@ class DamageIndicatorManager {
var healthText = data.healthText
val delayedStart = data.delayedStart
if (delayedStart != -1L && delayedStart > System.currentTimeMillis()) {
- val delay = delayedStart - System.currentTimeMillis()
- healthText = formatDelay(delay)
+ val delay = delayedStart - System.currentTimeMillis()
+ healthText = formatDelay(delay)
}
val location = if (data.dead && data.deathLocation != null) {
@@ -615,7 +618,6 @@ class DamageIndicatorManager {
entityData.namePrefix = ""
}
-
//Hit phase
val armorStandHits = entity.getNameTagWith(3, " Hit")
if (armorStandHits != null) {
@@ -626,15 +628,9 @@ class DamageIndicatorManager {
BossType.SLAYER_ENDERMAN_4 -> 100
else -> 100
}
- val name = armorStandHits.name.removeColor()
-
- // TODO replace this super ugly workaround with regex
- val text = name.between("Seraph ", " Hit")
- val hits = try {
- text.toInt()
- } catch (e: NumberFormatException) {
- text.substring(2).toInt()
- }
+ val hits = enderSlayerHitsNumberPattern.matchMatcher(armorStandHits.name) {
+ group("hits").toInt()
+ } ?: error("No hits number found in ender slayer name '${armorStandHits.name}'")
return NumberUtil.percentageColor(hits.toLong(), maxHits.toLong()).getChatColor() + "$hits Hits"
}
@@ -779,7 +775,6 @@ class DamageIndicatorManager {
private fun grabData(entity: EntityLivingBase): EntityData? {
if (data.contains(entity.uniqueID)) return data[entity.uniqueID]
-
val entityResult = mobFinder?.tryAdd(entity) ?: return null
val entityData = EntityData(
@@ -859,4 +854,4 @@ class DamageIndicatorManager {
}
fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
-} \ No newline at end of file
+}