aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsaga <45262877+saga-00@users.noreply.github.com>2024-09-07 18:15:06 -0300
committerGitHub <noreply@github.com>2024-09-07 23:15:06 +0200
commit270788e2ee876450f62a63197cb8914a803f5cc4 (patch)
tree28a362076b7e25ef24ab68c52c45b17c112a49ae
parentbb625d127fbbf14c780d57b0bda798503778f201 (diff)
downloadskyhanni-270788e2ee876450f62a63197cb8914a803f5cc4.tar.gz
skyhanni-270788e2ee876450f62a63197cb8914a803f5cc4.tar.bz2
skyhanni-270788e2ee876450f62a63197cb8914a803f5cc4.zip
Feature: Notifications for Non God Pot Effects almost ending (#2004)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/PotionEffectsConfig.java25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt50
3 files changed, 56 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index d27d3a0e3..a06055f97 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -48,8 +48,9 @@ public class MiscConfig {
public HideArmorConfig hideArmor2 = new HideArmorConfig();
@Expose
- @ConfigOption(name = "Potion Effects", desc = "")
+ @ConfigOption(name = "Non-God Pot Effects", desc = "")
@Accordion
+ // TODO rename nonGodPotEffect
public PotionEffectsConfig potionEffect = new PotionEffectsConfig();
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/PotionEffectsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/PotionEffectsConfig.java
index 6ead17186..34af9fbf2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/PotionEffectsConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/PotionEffectsConfig.java
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle;
import at.hannibal2.skyhanni.config.core.config.Position;
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.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
@@ -21,6 +22,30 @@ public class PotionEffectsConfig {
public boolean nonGodPotEffectShowMixins = false;
@Expose
+ @ConfigOption(name = "Expire Warning", desc = "Sends a title when one of the Non God Pot Effects is expiring.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean expireWarning = false;
+
+ @Expose
+ @ConfigOption(name = "Expire Sound", desc = "Makes a sound when one of the Non God Pot Effects is expiring.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean expireSound = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Expire Warning Time",
+ desc = "Change the time in seconds before the potion expries to warn you.")
+ @ConfigEditorSlider(
+ minValue = 30,
+ maxValue = 300,
+ minStep = 5
+ )
+ public int expireWarnTime = 30;
+
+ @Expose
@ConfigLink(owner = PotionEffectsConfig.class, field = "nonGodPotEffectDisplay")
+ // TODO rename position
public Position nonGodPotEffectPos = new Position(10, 10, false, true);
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
index 7f0775889..89db21304 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
@@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound
import at.hannibal2.skyhanni.utils.TimeUnit
import at.hannibal2.skyhanni.utils.TimeUtils
import at.hannibal2.skyhanni.utils.TimeUtils.format
@@ -80,7 +81,7 @@ object NonGodPotEffectDisplay {
private val effectsCountPattern by RepoPattern.pattern(
"misc.nongodpot.effects",
- "§7You have §e(?<name>\\d+) §7non-god effects\\."
+ "§7You have §e(?<name>\\d+) §7non-god effects\\.",
)
private var totalEffectsCount = 0
@@ -181,7 +182,19 @@ object NonGodPotEffectDisplay {
if (!isEnabled()) return
if (!ProfileStorageData.loaded) return
- update()
+ if (config.nonGodPotEffectDisplay) update()
+
+ val effectWarning = config.expireWarning
+ val effectSound = config.expireSound
+
+ if (!effectWarning && !effectSound) return
+
+ effectDuration.sorted().forEach { (effect, time) ->
+ if (time.remaining.inWholeSeconds != config.expireWarnTime.toLong()) return
+
+ if (effectWarning) LorenzUtils.sendTitle(effect.tabListName, 3.seconds)
+ if (effectSound) repeat(5) { playPlingSound() }
+ }
}
@SubscribeEvent
@@ -199,22 +212,18 @@ object NonGodPotEffectDisplay {
for (effect in NonGodPotEffect.entries) {
if (!name.contains(effect.inventoryItemName)) continue
for (line in stack.getLore()) {
- if (line.contains("Remaining") &&
- line != "§7Time Remaining: §aCompleted!" &&
- !line.contains("Remaining Uses")
- ) {
- val duration = try {
- TimeUtils.getDuration(line.split("§f")[1])
- } catch (e: IndexOutOfBoundsException) {
- ErrorManager.logErrorWithData(
- e, "Error while reading Non God-Potion effects from tab list",
- "line" to line
- )
- continue
- }
- effectDuration[effect] = Timer(duration)
- update()
+ if (!line.contains("Remaining") || line == "§7Time Remaining: §aCompleted!" || line.contains("Remaining Uses")) continue
+ val duration = try {
+ TimeUtils.getDuration(line.split("§f")[1])
+ } catch (e: IndexOutOfBoundsException) {
+ ErrorManager.logErrorWithData(
+ e, "Error while reading Non God-Potion effects from tab list",
+ "line" to line,
+ )
+ continue
}
+ effectDuration[effect] = Timer(duration)
+ update()
}
}
}
@@ -258,13 +267,13 @@ object NonGodPotEffectDisplay {
@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
- if (!isEnabled()) return
+ if (!isEnabled() || !config.nonGodPotEffectDisplay) return
if (RiftAPI.inRift()) return
config.nonGodPotEffectPos.renderStrings(
display,
extraSpace = 3,
- posLabel = "Non God Pot Effects"
+ posLabel = "Non God Pot Effects",
)
}
@@ -275,6 +284,5 @@ object NonGodPotEffectDisplay {
event.move(3, "misc.nonGodPotEffectPos", "misc.potionEffect.nonGodPotEffectPos")
}
- private fun isEnabled() =
- LorenzUtils.inSkyBlock && config.nonGodPotEffectDisplay && !DungeonAPI.inDungeon() && !LorenzUtils.inKuudraFight
+ private fun isEnabled() = LorenzUtils.inSkyBlock && !DungeonAPI.inDungeon() && !LorenzUtils.inKuudraFight
}