aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt109
2 files changed, 62 insertions, 53 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 64f14947a..154c93b3a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -80,6 +80,12 @@ public class Misc {
public boolean nonGodPotEffectDisplay = false;
@Expose
+ @ConfigOption(name = "Show Mixins", desc = "Include god pot mixins in the non god pot effects display.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 5)
+ public boolean nonGodPotEffectShowMixins = true;
+
+ @Expose
public Position nonGodPotEffectPos = new Position(10, 10, false, true);
@Expose
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 ff7c4e6fd..8fe96ca4e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt
@@ -21,28 +21,29 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
class NonGodPotEffectDisplay {
-
+ private val config get() = SkyHanniMod.feature.misc
private var checkFooter = false
- private val activeEffects = mutableMapOf<String, Long>()
+ private val effectDuration = mutableMapOf<NonGodPotEffect, Long>()
private var display = listOf<String>()
private var lastTick = 0L
- private var nonGodPotEffects = mapOf(
- "smoldering_polarization" to "§aSmoldering Polarization I",
- "mushed_glowy_tonic" to "§2Mushed Glowy Tonic I",
- "wisp_ice" to "§bWisp's Ice-Flavored Water I",
- "goblin_king_scent" to "§2King's Scent I",
+ enum class NonGodPotEffect(val apiName: String, val displayName: String, val isMixin: Boolean = false) {
+ SMOLDERING("smoldering_polarization", "§aSmoldering Polarization I"),
+ GLOWY("mushed_glowy_tonic", "§2Mushed Glowy Tonic I"),
+ WISP("wisp_ice", "§bWisp's Ice-Flavored Water I"),
+ GOBLIN("goblin_king_scent", "§2King's Scent I"),
+
+ INVISIBILITY("invisibility", "§8Invisibility I"), // when wearing sorrow armor
- "invisibility" to "§8Invisibility I", // when wearing sorrow armor
+ REV("ZOMBIE_BRAIN", "§9Zombie Brain Mixin", true),
+ TARA("SPIDER_EGG", "§9Spider Egg Mixin", true),
+ SVEN("WOLF_FUR", "§9Wolf Fur Mixin", true),
+ VOID("END_PORTAL_FUMES", "§9End Portal Fumes", true),
+ BLAZE("GABAGOEY", "§9Gabagoey", true),
- // Bartender Mixins
- "ZOMBIE_BRAIN" to "§9Zombie Brain Mixin",
- "SPIDER_EGG" to "§9Spider Egg Mixin",
- "WOLF_FUR" to "§9Wolf Fur Mixin",
- "END_PORTAL_FUMES" to "§9End Portal Fumes",
- //TODO fix typo
- "GABAGOEY" to "§9Gabagoey Mixin",
- )
+ DEEP_TERROR("DEEPTERROR", "§4Deepterror", true),
+ ;
+ }
private var patternEffectsCount = "§7You have §e(?<name>\\d+) §7non-god effects\\.".toPattern()
private var totalEffectsCount = 0
@@ -50,39 +51,39 @@ class NonGodPotEffectDisplay {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
if (event.message == "§aYou cleared all of your active effects!") {
- activeEffects.clear()
+ effectDuration.clear()
update()
}
if (event.message == "§aYou ate a §r§aRe-heated Gummy Polar Bear§r§a!") {
checkFooter = true
- activeEffects["§aSmoldering Polarization I"] = System.currentTimeMillis() + 1000 * 60 * 60
+ effectDuration[NonGodPotEffect.SMOLDERING] = System.currentTimeMillis() + 1000 * 60 * 60
update()
}
if (event.message == "§a§lBUFF! §fYou have gained §r§2Mushed Glowy Tonic I§r§f! Press TAB or type /effects to view your active effects!") {
checkFooter = true
- activeEffects["§2Mushed Glowy Tonic I"] = System.currentTimeMillis() + 1000 * 60 * 60
+ effectDuration[NonGodPotEffect.GLOWY] = System.currentTimeMillis() + 1000 * 60 * 60
update()
}
if (event.message == "§a§lBUFF! §fYou splashed yourself with §r§bWisp's Ice-Flavored Water I§r§f! Press TAB or type /effects to view your active effects!") {
checkFooter = true
- activeEffects["§bWisp's Ice-Flavored Water I"] = System.currentTimeMillis() + 1000 * 60 * 5
+ effectDuration[NonGodPotEffect.WISP] = System.currentTimeMillis() + 1000 * 60 * 5
update()
}
if (event.message == "§e[NPC] §6King Yolkar§f: §rThese eggs will help me stomach my pain.") {
checkFooter = true
- activeEffects["§2King's Scent I"] = System.currentTimeMillis() + 1000 * 60 * 20
+ effectDuration[NonGodPotEffect.GOBLIN] = System.currentTimeMillis() + 1000 * 60 * 20
update()
}
}
private fun update() {
val now = System.currentTimeMillis()
- if (activeEffects.values.removeIf { now > it }) {
+ if (effectDuration.values.removeIf { now > it }) {
//to fetch the real amount of active pots
totalEffectsCount = 0
checkFooter = true
@@ -93,21 +94,19 @@ class NonGodPotEffectDisplay {
private fun drawDisplay(now: Long): MutableList<String> {
val newDisplay = mutableListOf<String>()
- for (effect in activeEffects.sorted()) {
- val label = effect.key
- if (label.contains("Invisibility")) continue
- if (label.contains("Mixin")) continue
- if (label.contains("Fumes")) continue
-
- val until = effect.value
- val seconds = until - now
- val format = TimeUtils.formatDuration(seconds, TimeUnit.HOUR)
+ for ((effect, time) in effectDuration.sorted()) {
+ if (effect == NonGodPotEffect.INVISIBILITY) continue
+
+ if (effect.isMixin && !config.nonGodPotEffectShowMixins) continue
+ val seconds = time - now
+ val format = TimeUtils.formatDuration(seconds, TimeUnit.HOUR)
val color = colorForTime(seconds)
- newDisplay.add("$label $color$format")
+ val displayName = effect.displayName
+ newDisplay.add("$displayName $color$format")
}
- val diff = totalEffectsCount - activeEffects.size
+ val diff = totalEffectsCount - effectDuration.size
if (diff > 0) {
newDisplay.add("§eOpen the /effects inventory")
newDisplay.add("§eto show the missing $diff effects!")
@@ -123,9 +122,7 @@ class NonGodPotEffectDisplay {
"§6"
} else if (seconds <= 60 * 10) {
"§e"
- } else {
- "§f"
- }
+ } else "§f"
}
@SubscribeEvent
@@ -148,11 +145,12 @@ class NonGodPotEffectDisplay {
if (packet is S30PacketWindowItems) {
for (stack in packet.itemStacks) {
val name = stack?.name ?: continue
- if (name in nonGodPotEffects.values) {
+ for (effect in NonGodPotEffect.values()) {
+ if (name == effect.displayName) continue
for (line in stack.getLore()) {
if (line.contains("Remaining")) {
val duration = TimeUtils.getMillis(line.split("§f")[1])
- activeEffects[name] = System.currentTimeMillis() + duration
+ effectDuration[effect] = System.currentTimeMillis() + duration
update()
}
}
@@ -170,10 +168,12 @@ class NonGodPotEffectDisplay {
var effectsCount = 0
for (line in lines) {
- if (line.startsWith("§2Mushed Glowy Tonic I")) {
- val duration = TimeUtils.getMillis(line.split("§f")[1])
- activeEffects["§2Mushed Glowy Tonic I"] = System.currentTimeMillis() + duration
- update()
+ for (effect in NonGodPotEffect.values()) {
+ if (line.startsWith(effect.displayName)) {
+ val duration = TimeUtils.getMillis(line.split("§f")[1])
+ effectDuration[effect] = System.currentTimeMillis() + duration
+ update()
+ }
}
patternEffectsCount.matchMatcher(line) {
val group = group("name")
@@ -188,7 +188,11 @@ class NonGodPotEffectDisplay {
fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
if (!isEnabled()) return
- SkyHanniMod.feature.misc.nonGodPotEffectPos.renderStrings(display, extraSpace = 3, posLabel = "Non God Pot Effects")
+ config.nonGodPotEffectPos.renderStrings(
+ display,
+ extraSpace = 3,
+ posLabel = "Non God Pot Effects"
+ )
}
@SubscribeEvent
@@ -196,21 +200,20 @@ class NonGodPotEffectDisplay {
val profileData = event.profileData
val effects = profileData["active_effects"]?.asJsonArray ?: return
for (element in effects) {
- val effect = element.asJsonObject
- val name = effect["effect"].asString
- val label = nonGodPotEffects[name] ?: continue
+ val effectJson = element.asJsonObject
+ val name = effectJson["effect"].asString
+ val effect = NonGodPotEffect.values().find { it.apiName == name } ?: continue
- val time = effect["ticks_remaining"].asLong / 20
+ val time = effectJson["ticks_remaining"].asLong / 20
val newValue = System.currentTimeMillis() + time * 1000
- if (label.contains("Invisibility")) {
- activeEffects[label] = System.currentTimeMillis() + 1000 * 60 * 60 * 24
- } else {
- activeEffects[label] = newValue
- }
+
+ effectDuration[effect] = if (effect == NonGodPotEffect.INVISIBILITY) {
+ System.currentTimeMillis() + 1000 * 60 * 60 * 24
+ } else newValue
}
}
private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.nonGodPotEffectDisplay && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
+ return LorenzUtils.inSkyBlock && config.nonGodPotEffectDisplay && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight
}
} \ No newline at end of file