summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorSeRaid <77941535+SeRaid743@users.noreply.github.com>2024-05-02 23:17:03 +1200
committerGitHub <noreply@github.com>2024-05-02 13:17:03 +0200
commit382f226797a2fae468c950a6941b74fd5d525404 (patch)
treeab3f302644a8cfedd669206bd5355175689da382 /src/main/java/at/hannibal2/skyhanni/features
parent0b3495878211a456d3cd8773ee09cab1c65aa2a3 (diff)
downloadskyhanni-382f226797a2fae468c950a6941b74fd5d525404.tar.gz
skyhanni-382f226797a2fae468c950a6941b74fd5d525404.tar.bz2
skyhanni-382f226797a2fae468c950a6941b74fd5d525404.zip
warning when upgrade avaliavble (#1642)
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt65
3 files changed, 71 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
index a5de5d15a..7a57e87db 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt
@@ -352,6 +352,9 @@ object ChocolateFactoryDataLoader {
profileStorage.bestUpgradeAvailableAt = bestUpgrade?.canAffordAt?.toMillis() ?: 0
ChocolateFactoryAPI.bestPossibleSlot = bestUpgrade?.getValidUpgradeIndex() ?: -1
+ val bestUpgradeLevel = bestUpgrade?.level ?: 0
+ ChocolateFactoryUpgradeWarning.checkUpgradeChange(ChocolateFactoryAPI.bestPossibleSlot, bestUpgradeLevel)
+
val affordAbleUpgrade = notMaxed.filter { it.canAfford() }.minByOrNull { it.effectiveCost ?: Double.MAX_VALUE }
ChocolateFactoryAPI.bestAffordableSlot = affordAbleUpgrade?.getValidUpgradeIndex() ?: -1
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
index b2f33f09b..4abc48561 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
@@ -17,7 +17,6 @@ object ChocolateFactoryTooltip {
if (!config.extraTooltipStats) return
val slotIndex = event.slot.slotNumber
- if (slotIndex == ChocolateFactoryAPI.prestigeIndex) return
if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) return
val upgradeInfo = ChocolateFactoryAPI.factoryUpgrades.find { it.slotIndex == slotIndex } ?: return
@@ -31,6 +30,9 @@ object ChocolateFactoryTooltip {
event.toolTip.add("§8§m-----------------")
event.toolTip.add("§7Time until upgrade: §e${upgradeInfo.formattedTimeUntilGoal()}")
+
+ if (upgradeInfo.effectiveCost == null) return
+
event.toolTip.add("§7Extra: §6${upgradeInfo.extraPerSecond?.round(2) ?: "N/A"} §7choc/s")
event.toolTip.add("§7Effective Cost: §6${upgradeInfo.effectiveCost?.addSeparators() ?: "N/A"}")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt
new file mode 100644
index 000000000..93581401c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt
@@ -0,0 +1,65 @@
+package at.hannibal2.skyhanni.features.inventory.chocolatefactory
+
+import at.hannibal2.skyhanni.events.ProfileJoinEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
+import at.hannibal2.skyhanni.features.fame.ReminderUtils
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.HypixelCommands
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.TimeUtils.minutes
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object ChocolateFactoryUpgradeWarning {
+
+ private val config get() = ChocolateFactoryAPI.config.chocolateUpgradeWarnings
+ private val profileStorage get() = ChocolateFactoryAPI.profileStorage
+
+ private var lastUpgradeWarning = SimpleTimeMark.farPast()
+ private var lastUpgradeSlot = -1
+ private var lastUpgradeLevel = 0
+
+ @SubscribeEvent
+ fun onSecondPassed(event: SecondPassedEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ val profileStorage = profileStorage ?: return
+
+ val upgradeAvailableAt = SimpleTimeMark(profileStorage.bestUpgradeAvailableAt)
+ if (upgradeAvailableAt.isInPast() && !upgradeAvailableAt.isFarPast()) {
+ checkUpgradeWarning()
+ }
+ }
+
+ private fun checkUpgradeWarning() {
+ if (!ChocolateFactoryAPI.isEnabled()) return
+ if (!config.upgradeWarning) return
+ if (ReminderUtils.isBusy()) return
+ if (lastUpgradeWarning.passedSince() < config.timeBetweenWarnings.minutes) return
+ lastUpgradeWarning = SimpleTimeMark.now()
+
+ ChatUtils.clickableChat(
+ "You have a Chocolate factory upgrade available to purchase!",
+ onClick = {
+ HypixelCommands.chocolateFactory()
+ }
+ )
+ if (config.upgradeWarningSound) {
+ SoundUtils.playBeepSound()
+ }
+
+ }
+
+ @SubscribeEvent
+ fun onProfileChange(event: ProfileJoinEvent) {
+ lastUpgradeWarning = SimpleTimeMark.farPast()
+ }
+
+ fun checkUpgradeChange(slot: Int, level: Int) {
+ if (slot != lastUpgradeSlot || level != lastUpgradeLevel) {
+ lastUpgradeWarning = SimpleTimeMark.farPast()
+ lastUpgradeSlot = slot
+ lastUpgradeLevel = level
+ }
+ }
+}