aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorSeRaid <77941535+SeRaid743@users.noreply.github.com>2024-05-03 22:04:06 +1200
committerGitHub <noreply@github.com>2024-05-03 12:04:06 +0200
commit29b1129ec9a55878e41e574415d76781cfaefe0e (patch)
treecffaf6ef1b8d9ae597414d6762af00e9d9839bee /src/main/java/at
parentdf8b39c8812c6d44079f07d674bbfb249bffeea1 (diff)
downloadskyhanni-29b1129ec9a55878e41e574415d76781cfaefe0e.tar.gz
skyhanni-29b1129ec9a55878e41e574415d76781cfaefe0e.tar.bz2
skyhanni-29b1129ec9a55878e41e574415d76781cfaefe0e.zip
added timer to hoppity egg gui and chat messages (#1625)
Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt28
2 files changed, 38 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt
index 15f463884..086b13029 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt
@@ -1,6 +1,8 @@
package at.hannibal2.skyhanni.features.event.hoppity
+import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+import kotlin.time.Duration
enum class HoppityEggType(
val mealName: String,
@@ -14,6 +16,15 @@ enum class HoppityEggType(
DINNER("Dinner", 21, "§6"),
;
+ fun timeUntil(): Duration {
+ val now = SkyBlockTime.now()
+ if (now.hour >= resetsAt) {
+ return now.copy(day = now.day + 1, hour = resetsAt, minute = 0, second = 0)
+ .asTimeMark().timeUntil()
+ }
+ return now.copy(hour = resetsAt, minute = 0, second = 0).asTimeMark().timeUntil()
+ }
+
fun markClaimed() {
claimed = true
}
@@ -23,7 +34,7 @@ enum class HoppityEggType(
}
fun isClaimed() = claimed
- val formattedName by lazy { "$mealColour$mealName" }
+ val formattedName get() = "${if (isClaimed()) "§7§m" else mealColour}$mealName:$mealColour"
companion object {
fun allFound() = entries.forEach { it.markClaimed() }
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 8b3d81c44..1702a9667 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
@@ -14,8 +14,11 @@ import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
@@ -40,6 +43,10 @@ object HoppityEggsManager {
"egg.alreadycollected",
"§cYou have already collected this Chocolate (?<meal>\\w+) Egg§r§c! Try again when it respawns!"
)
+ private val hoppityEventNotOn by ChocolateFactoryAPI.patternGroup.pattern(
+ "egg.notevent",
+ "§cThis only works during Hoppity's Hunt!"
+ )
private var lastMeal: HoppityEggType? = null
@@ -57,19 +64,35 @@ object HoppityEggsManager {
val meal = getEggType(event)
meal.markClaimed()
lastMeal = meal
+ return
}
noEggsLeftPattern.matchMatcher(event.message) {
HoppityEggType.allFound()
+
+ val nextEgg = HoppityEggType.entries.minByOrNull { it.timeUntil() } ?: return
+ event.chatComponent.appendText("\n§eNext egg available in §b${nextEgg.timeUntil().format()}")
return
}
eggAlreadyCollectedPattern.matchMatcher(event.message) {
getEggType(event).markClaimed()
+ val nextEgg = HoppityEggType.entries.minByOrNull { it.timeUntil() } ?: return
+ event.chatComponent.appendText("\n§eNext egg available in §b${nextEgg.timeUntil().format()}")
+ return
}
eggSpawnedPattern.matchMatcher(event.message) {
getEggType(event).markSpawned()
+ return
+ }
+
+ hoppityEventNotOn.matchMatcher(event.message) {
+ val currentYear = SkyBlockTime.now().year
+ val timeUntil = SkyBlockTime(currentYear + 1).asTimeMark().timeUntil()
+
+ event.chatComponent.appendText("\n§eNext Hoppity's Hunt in §b${timeUntil.format()}")
+ return
}
}
@@ -104,8 +127,7 @@ object HoppityEggsManager {
if (!ChocolateFactoryAPI.isHoppityEvent()) return
val displayList = HoppityEggType.entries
- .filter { !it.isClaimed() }
- .map { "§7 - ${it.formattedName}" }
+ .map { "§7 - ${it.formattedName} ${it.timeUntil().format()}" }
.toMutableList()
displayList.add(0, "§bUnfound Eggs:")
if (displayList.size == 1) return
@@ -127,4 +149,6 @@ object HoppityEggsManager {
)
event.move(44, "event.chocolateFactory.hoppityEggs", "event.hoppityEggs")
}
+
+
}