aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/event
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-07-06 09:03:49 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-07-06 09:03:49 +0200
commitb2079e539284b34892d24ab4f2411fbe8d920b3e (patch)
treee37b2346ea3bfd936205bf1970548f0e2cd1a879 /src/main/java/at/hannibal2/skyhanni/features/event
parenta30e2437c657bbecb8039e783ce4d164b1e08631 (diff)
downloadskyhanni-b2079e539284b34892d24ab4f2411fbe8d920b3e.tar.gz
skyhanni-b2079e539284b34892d24ab4f2411fbe8d920b3e.tar.bz2
skyhanni-b2079e539284b34892d24ab4f2411fbe8d920b3e.zip
moved hoppity egg display logic into another class
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt57
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt46
2 files changed, 58 insertions, 45 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt
index 55d6bc01d..06948f27a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt
@@ -1,11 +1,18 @@
package at.hannibal2.skyhanni.features.event.hoppity
import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent
import at.hannibal2.skyhanni.events.render.EntityRenderLayersEvent
+import at.hannibal2.skyhanni.features.fame.ReminderUtils
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
@@ -18,6 +25,8 @@ object HoppityEggDisplayManager {
private val config get() = HoppityEggsManager.config
private var shouldHidePlayer: Boolean = false
+ var display = listOf<Renderable>()
+
private fun canChangeOpacity(entity: EntityLivingBase): Boolean {
if (!HoppityEggLocator.isEnabled()) return false
if (entity !is EntityPlayer) return false
@@ -55,4 +64,52 @@ object HoppityEggDisplayManager {
if (!shouldHidePlayer) return
event.cancel()
}
+
+ @SubscribeEvent
+ fun onSecondPassed(event: SecondPassedEvent) {
+ display = updateDisplay()
+ }
+
+ private fun updateDisplay(): List<Renderable> {
+ if (!HoppityEggsManager.isActive()) return emptyList()
+ if (!HoppityEggsManager.config.showClaimedEggs) return emptyList()
+ if (ReminderUtils.isBusy() && !HoppityEggsManager.config.showWhileBusy) return emptyList()
+
+ val displayList =
+ HoppityEggType.entries.map { "§7 - ${it.formattedName} ${it.timeUntil().format()}" }.toMutableList()
+ displayList.add(0, "§bUnclaimed Eggs:")
+
+ if (HoppityEggsManager.config.showCollectedLocationCount && LorenzUtils.inSkyBlock) {
+ val totalEggs = HoppityEggLocations.islandLocations.size
+ if (totalEggs > 0) {
+ val collectedEggs = HoppityEggLocations.islandCollectedLocations.size
+ val collectedFormat = formatEggsCollected(collectedEggs)
+ displayList.add("§7Locations: $collectedFormat$collectedEggs§7/§a$totalEggs")
+ }
+ }
+ if (displayList.size == 1) return emptyList()
+
+ return listOf(
+ Renderable.clickAndHover(
+ Renderable.verticalContainer(displayList.map(Renderable::string)),
+ tips = listOf("§eClick to ${"/warp ${HoppityEggsManager.config.warpDestination}".trim()}!"),
+ onClick = { HypixelCommands.warp(HoppityEggsManager.config.warpDestination) },
+ ),
+ )
+ }
+
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent) {
+ if (!HoppityEggsManager.isActive()) return
+ HoppityEggsManager.config.position.renderRenderables(display, posLabel = "Hoppity Eggs")
+ }
+
+ private fun formatEggsCollected(collectedEggs: Int): String =
+ when (collectedEggs) {
+ in 0 until 5 -> "§c"
+ in 5 until 10 -> "§6"
+ in 10 until 15 -> "§e"
+ else -> "§a"
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt
index de37de625..8a60516b3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt
@@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.event.hoppity
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
-import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
@@ -16,7 +15,6 @@ import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
-import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
@@ -25,7 +23,6 @@ import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils.format
-import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
@@ -194,45 +191,6 @@ object HoppityEggsManager {
}
}
- // TODO move logic into second passed event and cache
- @SubscribeEvent
- fun onRenderOverlay(event: GuiRenderEvent) {
- if (!isActive()) return
- if (!config.showClaimedEggs) return
- if (isBusy() && !config.showWhileBusy) return
-
- val displayList =
- HoppityEggType.entries.map { "§7 - ${it.formattedName} ${it.timeUntil().format()}" }.toMutableList()
- displayList.add(0, "§bUnclaimed Eggs:")
-
- if (config.showCollectedLocationCount && LorenzUtils.inSkyBlock) {
- val totalEggs = HoppityEggLocations.islandLocations.size
- if (totalEggs > 0) {
- val collectedEggs = HoppityEggLocations.islandCollectedLocations.size
- val collectedFormat = formatEggsCollected(collectedEggs)
- displayList.add("§7Locations: $collectedFormat$collectedEggs§7/§a$totalEggs")
- }
- }
- if (displayList.size == 1) return
-
- val clickableDisplayList = listOf(
- Renderable.clickAndHover(
- Renderable.verticalContainer(displayList.map(Renderable::string)),
- tips = listOf("§eClick to ${"/warp ${config.warpDestination}".trim()}!"),
- onClick = { HypixelCommands.warp(config.warpDestination) },
- ),
- )
- config.position.renderRenderables(clickableDisplayList, posLabel = "Hoppity Eggs")
- }
-
- private fun formatEggsCollected(collectedEggs: Int): String =
- when (collectedEggs) {
- in 0 until 5 -> "§c"
- in 5 until 10 -> "§6"
- in 10 until 15 -> "§e"
- else -> "§a"
- }
-
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isActive()) return
@@ -253,7 +211,7 @@ object HoppityEggsManager {
private fun warn() {
if (!config.warnUnclaimedEggs) return
- if (isBusy() && !config.warnWhileBusy) return
+ if (ReminderUtils.isBusy() && !config.warnWhileBusy) return
if (lastWarnTime.passedSince() < 30.seconds) return
lastWarnTime = now()
@@ -278,8 +236,6 @@ object HoppityEggsManager {
SoundUtils.repeatSound(100, 10, SoundUtils.plingSound)
}
- private fun isBusy() = ReminderUtils.isBusy()
-
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
event.move(