diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-06-08 23:46:53 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 23:46:53 +1000 |
commit | a2f29b2bfe846c9d0cd2a45b2b8352bab556da37 (patch) | |
tree | 53f830999399a1d005e16a53beec041337629285 /src/main/java/at/hannibal2/skyhanni/features/combat | |
parent | f5aa000de598fd4f367ca37cb8f2e1935f64b634 (diff) | |
download | skyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.tar.gz skyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.tar.bz2 skyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.zip |
Even more annotation (#2031)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/combat')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt | 63 |
1 files changed, 31 insertions, 32 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 80b912aa5..33bb20a52 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 @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper.setHellionShield +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.put @@ -64,7 +65,8 @@ import kotlin.math.max import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -class DamageIndicatorManager { +@SkyHanniModule +object DamageIndicatorManager { private var mobFinder: MobFinder? = null private val maxHealth = mutableMapOf<UUID, Long>() @@ -72,45 +74,42 @@ class DamageIndicatorManager { private val enderSlayerHitsNumberPattern = ".* §[5fd]§l(?<hits>\\d+) Hits?".toPattern() - companion object { + private var data = mapOf<UUID, EntityData>() + private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() - private var data = mapOf<UUID, EntityData>() - private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() + fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } - fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } + fun isDamageSplash(entity: EntityLivingBase): Boolean { + if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false + if (!entity.hasCustomName()) return false + if (entity.isDead) return false + val name = entity.customNameTag.removeColor().replace(",", "") - fun isDamageSplash(entity: EntityLivingBase): Boolean { - if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false - if (!entity.hasCustomName()) return false - if (entity.isDead) return false - val name = entity.customNameTag.removeColor().replace(",", "") - - return damagePattern.matcher(name).matches() - } + return damagePattern.matcher(name).matches() + } - fun isBossSpawned(type: BossType) = data.entries.find { it.value.bossType == type } != null + fun isBossSpawned(type: BossType) = data.entries.find { it.value.bossType == type } != null - fun isBossSpawned(vararg types: BossType) = types.any { isBossSpawned(it) } + fun isBossSpawned(vararg types: BossType) = types.any { isBossSpawned(it) } - fun getDistanceTo(vararg types: BossType): Double { - val playerLocation = LocationUtils.playerLocation() - return data.values.filter { it.bossType in types } - .map { it.entity.getLorenzVec().distance(playerLocation) } - .let { list -> - if (list.isEmpty()) Double.MAX_VALUE else list.minOf { it } - } - } + fun getDistanceTo(vararg types: BossType): Double { + val playerLocation = LocationUtils.playerLocation() + return data.values.filter { it.bossType in types } + .map { it.entity.getLorenzVec().distance(playerLocation) } + .let { list -> + if (list.isEmpty()) Double.MAX_VALUE else list.minOf { it } + } + } - fun getNearestDistanceTo(location: LorenzVec): Double { - return data.values - .map { it.entity.getLorenzVec() } - .minOfOrNull { it.distance(location) } ?: Double.MAX_VALUE - } + fun getNearestDistanceTo(location: LorenzVec): Double { + return data.values + .map { it.entity.getLorenzVec() } + .minOfOrNull { it.distance(location) } ?: Double.MAX_VALUE + } - fun removeDamageIndicator(type: BossType) { - data = data.editCopy { - values.removeIf { it.bossType == type } - } + fun removeDamageIndicator(type: BossType) { + data = data.editCopy { + values.removeIf { it.bossType == type } } } |