aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateUpgradeWarningsConfig.java29
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt2
7 files changed, 109 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index b9b7846de..ff58c9e61 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -278,6 +278,7 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTimeTowerManager
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltip
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltipCompact
+import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryUpgradeWarning
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice
import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper
import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints
@@ -643,6 +644,7 @@ class SkyHanniMod {
loadModule(ChocolateFactoryTimeTowerManager)
loadModule(ChocolateFactoryTooltip)
loadModule(ChocolateShopPrice)
+ loadModule(ChocolateFactoryUpgradeWarning)
loadModule(HoppityNpc)
loadModule(HoppityEggsManager)
loadModule(HoppityEggLocator)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
index 773fe7fcf..fab7e5ce3 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
@@ -95,6 +95,11 @@ public class ChocolateFactoryConfig {
public boolean timeTowerWarning = false;
@Expose
+ @ConfigOption(name = "Upgrade Warnings", desc = "")
+ @Accordion
+ public ChocolateUpgradeWarningsConfig chocolateUpgradeWarnings = new ChocolateUpgradeWarningsConfig();
+
+ @Expose
@ConfigLink(owner = ChocolateFactoryConfig.class, field = "statsDisplay")
public Position position = new Position(163, 160, false, true);
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateUpgradeWarningsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateUpgradeWarningsConfig.java
new file mode 100644
index 000000000..befe79b1a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateUpgradeWarningsConfig.java
@@ -0,0 +1,29 @@
+package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory;
+
+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.ConfigEditorSlider;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class ChocolateUpgradeWarningsConfig {
+ @Expose
+ @ConfigOption(name = "Upgrade Warning", desc = "Chat notification when you have an upgrade available to purchase.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean upgradeWarning = true;
+
+ @Expose
+ @ConfigOption(name = "Upgrade Warning Sound", desc = "Also plays a sound when an upgrade is available. " +
+ "§eUpgrade warning must be turned on.")
+ @ConfigEditorBoolean
+ public boolean upgradeWarningSound = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Upgrade Warning Interval",
+ desc = "How often the warning an upgrade is available is repeated in minutes."
+ )
+ @ConfigEditorSlider(minValue = 0, maxValue = 10, minStep = 0.25f)
+ public float timeBetweenWarnings = 1;
+}
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
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
index 2aa542699..bf4a11686 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
@@ -166,6 +166,8 @@ object TimeUtils {
val Long.ticks get() = (this * 50).milliseconds
val Int.ticks get() = (this * 50).milliseconds
+
+ val Float.minutes get() = toDouble().minutes
}
private const val FACTOR_SECONDS = 1000L