Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {

val logger = SkyHanniLogger("ConfigMigration")
const val CONFIG_VERSION = 129
const val CONFIG_VERSION = 130
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class SlayerConfig {
@Accordion
val slayerBossWarning: SlayerBossWarningConfig = SlayerBossWarningConfig()

@Expose
@ConfigOption(name = "Slayer Time Messages", desc = "")
@Accordion
val slayerTimeMessages: SlayerTimeMessagesConfig = SlayerTimeMessagesConfig()

@Expose
@ConfigOption(name = "Remaining Kills", desc = "Display the names and remaining amount of mob kills needed until the boss spawns.")
@ConfigEditorBoolean
Expand Down Expand Up @@ -167,23 +172,6 @@ class SlayerConfig {
@ConfigEditorSlider(minValue = 0f, maxValue = 100f, minStep = 1f)
var hideIrrelevantMobsTransparency: Int = 40

@Expose
@ConfigOption(name = "Time to Kill Message", desc = "Sends time to kill a slayer in chat.")
@ConfigEditorBoolean
@FeatureToggle
var timeToKillMessage: Boolean = true

@Expose
@ConfigOption(name = "Quest Complete Message", desc = "Sends time to complete (Spawn & Kill) a slayer quest in chat.")
@ConfigEditorBoolean
@FeatureToggle
var questCompleteMessage: Boolean = true

@Expose
@ConfigOption(name = "Compact Time Messages", desc = "Shorter Time to Kill and Quest Complete messages.")
@ConfigEditorBoolean
var compactTimeMessage: Boolean = false

@Expose
@ConfigOption(name = "Slayer Cocoon Title", desc = "Send title when Slayer Boss is cocooned.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package at.hannibal2.skyhanni.config.features.slayer

import at.hannibal2.skyhanni.config.FeatureToggle
import com.google.gson.annotations.Expose
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption

class SlayerTimeMessagesConfig {

@Expose
@ConfigOption(name = "Time to Kill", desc = "Sends time to kill a slayer in chat.")
@ConfigEditorBoolean
@FeatureToggle
var timeToKill: Boolean = true

@Expose
@ConfigOption(name = "Time to Kill Personal Bests", desc = "Sends personal best for killing a slayer in chat.")
@ConfigEditorBoolean
@FeatureToggle
var timeToKillPersonalBests: Boolean = false

@Expose
@ConfigOption(name = "Quest Complete", desc = "Sends time to complete (Spawn & Kill) a slayer quest in chat.")
@ConfigEditorBoolean
@FeatureToggle
var questComplete: Boolean = true

@Expose
@ConfigOption(name = "Compact Time Messages", desc = "Shorter Time to Kill and Quest Complete messages.")
@ConfigEditorBoolean
var compact: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.config.storage

import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal
import at.hannibal2.skyhanni.features.chat.CurrentChatDisplay
import at.hannibal2.skyhanni.features.combat.damageindicator.BossType
import at.hannibal2.skyhanni.features.fame.UpgradeReminder.CommunityShopUpgrade
import at.hannibal2.skyhanni.features.misc.UserLuckBreakdown
import at.hannibal2.skyhanni.utils.NeuInternalName
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.farPast
import com.google.gson.annotations.Expose
import java.time.LocalDate
import kotlin.time.Duration

class PlayerSpecificStorage {
@Expose
Expand Down Expand Up @@ -95,4 +97,7 @@ class PlayerSpecificStorage {
@Expose
var userLuck: Float = 0f
}

@Expose
var slayerPersonalBests: MutableMap<BossType, Duration> = mutableMapOf()
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,83 @@
package at.hannibal2.skyhanni.features.slayer

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.SlayerApi
import at.hannibal2.skyhanni.data.mob.Mob.Companion.belongsToPlayer
import at.hannibal2.skyhanni.events.DamageIndicatorDeathEvent
import at.hannibal2.skyhanni.features.combat.damageindicator.BossType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.TimeUtils.format
import kotlin.time.Duration

@SkyHanniModule
object SlayerTimeMessages {

private val config get() = SlayerApi.config
private val config get() = SkyHanniMod.feature.slayer.slayerTimeMessages

@HandleEvent
fun onDamageIndicatorDeathEvent(event: DamageIndicatorDeathEvent) {
val (bossType, timeToKill) = with(event.data) { bossType to timeToKill }
if (!config.timeToKillMessage || !bossType.isSlayer || !event.data.entity.belongsToPlayer()) return
if (!bossType.isSlayer || !event.data.entity.belongsToPlayer()) return

if (event.data.bossType == BossType.SLAYER_SPIDER_5_1) return

ChatUtils.chat(
if (config.compactTimeMessage)
"${bossType.shortName}§e took §b$timeToKill§e."
else
"It took §b$timeToKill§e to kill ${bossType.fullName}.",
)
val compact = config.compact

val bossDisplayName = if (compact) bossType.shortName else bossType.fullName

val currentPb = ProfileStorageData.playerSpecific?.slayerPersonalBests?.get(bossType)
val timeToKillDuration = Duration.parse(timeToKill)

val isNewPersonalBest = timeToKillDuration < (currentPb ?: Duration.INFINITE)
if (isNewPersonalBest) ProfileStorageData.playerSpecific?.slayerPersonalBests?.set(bossType, timeToKillDuration)

val messages = buildList {
if (config.timeToKill) add(
if (compact) "$bossDisplayName §etook §b$timeToKill"
else "It took §b$timeToKill§e to kill $bossDisplayName",
)

if (config.timeToKillPersonalBests) {
val currentPbDisplay = currentPb?.format(showMilliSeconds = true) ?: "None"

add(
if (isNewPersonalBest) {
if (compact) "§e§lNEW PB! $bossDisplayName §ein §c$currentPbDisplay §e-> §a$timeToKill"
else "§e§lNEW PERSONAL BEST! §a$timeToKill §7(Previous $currentPbDisplay) §efor $bossDisplayName"
} else {
if (compact) "$bossDisplayName §ePB: §6$currentPbDisplay"
else "$bossDisplayName §ePersonal best: §6$currentPbDisplay"
},
)
}
}

messages.forEach { ChatUtils.chat(it) }
}

@HandleEvent
fun onSlayerQuestComplete() {
val startTime = SlayerApi.questStartTime
if (!config.questCompleteMessage || startTime.isFarPast()) return
if (!config.questComplete || startTime.isFarPast()) return

val duration = startTime.passedSince().format()

ChatUtils.chat(
if (config.compactTimeMessage)
if (config.compact)
"Quest took §b$duration§e in total."
else
"Slayer quest took §b$duration§e to complete.",
)
}

@HandleEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(130, "slayer.timeToKillMessage", "slayer.slayerTimeMessages.timeToKill")
event.move(130, "slayer.questCompleteMessage", "slayer.slayerTimeMessages.questComplete")
event.move(130, "slayer.compactTimeMessage", "slayer.slayerTimeMessages.compact")
}
}
Loading