aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/event
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-08 17:02:57 -0800
committerGitHub <noreply@github.com>2023-12-09 02:02:57 +0100
commite791dff4d2dff8203f5198fb4d0e90bbf457380a (patch)
treec23f478fce349745eda3fa0f3c6a162f875c7631 /src/main/java/at/hannibal2/skyhanni/features/event
parent5b9de0632fd1a9d14550804934785ef33df54134 (diff)
downloadskyhanni-e791dff4d2dff8203f5198fb4d0e90bbf457380a.tar.gz
skyhanni-e791dff4d2dff8203f5198fb4d0e90bbf457380a.tar.bz2
skyhanni-e791dff4d2dff8203f5198fb4d0e90bbf457380a.zip
Add Waypoints for 2023 Lobby Presents (#772)
Added Waypoints for 2023 Lobby Presents. #772
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt114
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/Basket.kt34
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketEntrances.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt105
5 files changed, 290 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt
new file mode 100644
index 000000000..da537d4c0
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt
@@ -0,0 +1,20 @@
+package at.hannibal2.skyhanni.features.event.lobby.waypoints
+
+import at.hannibal2.skyhanni.data.jsonobjects.repo.EventWaypointsJson
+import at.hannibal2.skyhanni.utils.LorenzVec
+
+data class EventWaypoint(
+ val name: String,
+ val position: LorenzVec,
+ var isFound: Boolean = false
+)
+
+fun loadEventWaypoints(waypoints: Map<String, List<EventWaypointsJson.Waypoint>>): Map<String, MutableSet<EventWaypoint>> {
+ return buildMap {
+ waypoints.forEach { lobby ->
+ val set = mutableSetOf<EventWaypoint>()
+ lobby.value.forEach { waypoint -> set.add(EventWaypoint(waypoint.name, waypoint.position)) }
+ this[lobby.key] = set
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt
new file mode 100644
index 000000000..c400da59b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt
@@ -0,0 +1,114 @@
+package at.hannibal2.skyhanni.features.event.lobby.waypoints.christmas
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.jsonobjects.repo.EventWaypointsJson
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.features.event.lobby.waypoints.EventWaypoint
+import at.hannibal2.skyhanni.features.event.lobby.waypoints.loadEventWaypoints
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+// todo: create abstract class for this and BasketWaypoints
+class PresentWaypoints {
+ private val config get() = SkyHanniMod.feature.event.lobbyWaypoints.christmasPresent
+ private var presentLocations = mapOf<String, MutableSet<EventWaypoint>>()
+ private var presentEntranceLocations = mapOf<String, MutableSet<EventWaypoint>>()
+ private var closest: EventWaypoint? = null
+
+ private val presentSet get() = presentLocations[HypixelData.lobbyType]
+ private val presentEntranceSet get() = presentEntranceLocations[HypixelData.lobbyType]
+
+ private val presentAlreadyFoundPattern = "§cYou have already found this present!".toPattern()
+ private val presentFoundPattern = "§aYou found a.*present! §r§e\\(§r§b\\d+§r§e/§r§b\\d+§r§e\\)".toPattern()
+ private val allFoundPattern = "§aCongratulations! You found all the presents in every lobby!".toPattern()
+
+ @SubscribeEvent
+ fun onWorldChange(event: LorenzWorldChangeEvent) {
+ if (!isEnabled()) return
+ closest = null
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ processChatMessage(event.message)
+ }
+
+ // <editor-fold desc = "Chat Message Processing">
+ private fun processChatMessage(message: String) {
+ when {
+ presentFoundPattern.matches(message) || presentAlreadyFoundPattern.matches(message) -> handlePresentFound()
+ allFoundPattern.matches(message) -> handleAllPresentsFound()
+ }
+ }
+
+ private fun handlePresentFound() {
+ presentSet?.minByOrNull { it.position.distanceSqToPlayer() }?.let { present ->
+ present.isFound = true
+ markEntranceAsFound(present)
+ if (closest == present) closest = null
+ }
+ }
+
+ private fun markEntranceAsFound(present: EventWaypoint) {
+ presentEntranceSet?.find { present.name == it.name }?.let { it.isFound = true }
+ }
+
+ private fun handleAllPresentsFound() {
+ // If all presents are found, disable the feature
+ LorenzUtils.chat("Congratulations! As all presents are found, we are disabling the Christmas Present Waypoints feature.")
+ config.allWaypoints = false
+ config.allEntranceWaypoints = false
+ }
+
+ // </editor-fold>
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled() && config.onlyClosest && HypixelData.locrawData != null && closest == null) return
+ val notFoundPresents = presentSet?.filterNot { it.isFound }
+ if (notFoundPresents?.isEmpty() == true) return
+ closest = notFoundPresents?.minByOrNull { it.position.distanceSqToPlayer() } ?: return
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!isEnabled()) return
+ presentSet?.let { event.drawWaypoints(it, config.allWaypoints, LorenzColor.GOLD, "§6") }
+ presentEntranceSet?.let { event.drawWaypoints(it, config.allEntranceWaypoints, LorenzColor.YELLOW, "§e") }
+ }
+
+ private fun LorenzRenderWorldEvent.drawWaypoints(
+ waypoints: Set<EventWaypoint>, shouldDraw: Boolean, color: LorenzColor, prefix: String
+ ) {
+ if (!shouldDraw) return
+ waypoints.forEach { waypoint ->
+ if (!waypoint.shouldShow()) return@forEach
+ this.drawWaypointFilled(waypoint.position, color.toColor())
+ this.drawDynamicText(waypoint.position, "$prefix${waypoint.name}", 1.5)
+ }
+ }
+
+ private fun EventWaypoint.shouldShow(): Boolean = !isFound && (!config.onlyClosest || closest == this)
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ val data = event.getConstant<EventWaypointsJson>("EventWaypoints")
+ presentLocations = loadEventWaypoints(data.presents ?: error("'presents' is null in EventWaypoints!"))
+ presentEntranceLocations =
+ loadEventWaypoints(data.presents_entrances ?: error("'presents_entrances' is null in EventWaypoints!"))
+ }
+
+ private fun isEnabled(): Boolean =
+ LorenzUtils.onHypixel && HypixelData.inLobby && (config.allWaypoints || config.allEntranceWaypoints)
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/Basket.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/Basket.kt
new file mode 100644
index 000000000..af36c46e7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/Basket.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween
+
+import at.hannibal2.skyhanni.utils.LorenzVec
+
+enum class Basket(val basketName: String, val waypoint: LorenzVec) {
+ BASKET_1("#1", LorenzVec(-31, 91, -19)),
+ BASKET_2("#2", LorenzVec(-14, 85, -78)),
+ BASKET_3("#3", LorenzVec(24, 68, -29)),
+ BASKET_4("#4", LorenzVec(57, 64, -90)),
+ BASKET_5("#5", LorenzVec(129, 70, -130)),
+ BASKET_6("#6", LorenzVec(-5, 62, -181)),
+ BASKET_7("#7", LorenzVec(-145, 74, -137)),
+ BASKET_8("#8", LorenzVec(-7, 65, 130)),
+ BASKET_9("#9", LorenzVec(-7, 57, 196)),
+ BASKET_10("#10", LorenzVec(-75, 61, 195)),
+ BASKET_11("#11", LorenzVec(-131, 61, 152)),
+ BASKET_12("#12", LorenzVec(-107, 24, 27)),
+ BASKET_13("#13", LorenzVec(-6, 63, 23)),
+ BASKET_14("#14", LorenzVec(29, 71, 24)),
+ BASKET_15("#15", LorenzVec(136, 64, -10)),
+ BASKET_16("#16", LorenzVec(199, 85, -41)),
+ BASKET_17("#17", LorenzVec(199, 58, -41)),
+ BASKET_18("#18", LorenzVec(112, 45, -15)),
+ BASKET_19("#19", LorenzVec(111, 65, 31)),
+ BASKET_20("#20", LorenzVec(138, 62, 94)),
+ BASKET_21("#21", LorenzVec(109, 67, 149)),
+ BASKET_22("#22", LorenzVec(94, 53, 238)),
+ BASKET_23("#23", LorenzVec(-84, 72, 8)),
+ BASKET_24("#24", LorenzVec(-13, 31, -26)),
+ BASKET_25("#25 (get your code first!)", LorenzVec(-32, 14, 102)),
+ ;
+
+ var found = false
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketEntrances.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketEntrances.kt
new file mode 100644
index 000000000..e2904f99e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketEntrances.kt
@@ -0,0 +1,17 @@
+package at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween
+
+import at.hannibal2.skyhanni.utils.LorenzVec
+
+enum class BasketEntrances(
+ val basketEntranceName: String,
+ val waypoint: LorenzVec,
+ vararg val basket: Basket
+) {
+ BASKET_ENTER_23("#23, #24 (behind the lava)", LorenzVec(-138, 74, -4), Basket.BASKET_23, Basket.BASKET_24),
+ BASKET_ENTER_24("#24 (within this tunnel)", LorenzVec(-80, 72, -4), Basket.BASKET_24),
+ BASKET_ENTER_25_1("#25 (1st digit, SNEAK + RCLICK)", LorenzVec(143, 65, -30), Basket.BASKET_25),
+ BASKET_ENTER_25_2("#25 (3rd digit, open chest)", LorenzVec(205, 34, -157), Basket.BASKET_25),
+ BASKET_ENTER_25_3("#25 (inside this well)", LorenzVec(10, 63, 0), Basket.BASKET_25),
+ BASKET_ENTER_25_4("#25 (left turn [<--] here)", LorenzVec(-28, 41, 14), Basket.BASKET_25),
+ BASKET_ENTER_25_5("#25 Vault (brute force 2nd digit)", LorenzVec(-35, 25, 63), Basket.BASKET_25),
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt
new file mode 100644
index 000000000..d9d90ca4a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt
@@ -0,0 +1,105 @@
+package at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.ScoreboardData
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.anyContains
+import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class BasketWaypoints {
+ private val config get() = SkyHanniMod.feature.event.lobbyWaypoints.halloweenBasket
+ private var closest: Basket? = null
+ private var isHalloween: Boolean = false
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!config.allWaypoints && !config.allEntranceWaypoints) return
+ if (!isHalloween) return
+
+ if (!HypixelData.hypixelLive) return // don't show outside live hypixel network (it's disabled on alpha)
+ if (LorenzUtils.inSkyBlock) return
+
+ val message = event.message
+ if (message.startsWith("§a§lYou found a Candy Basket! §r") || message == "§cYou already found this Candy Basket!") {
+ val basket = Basket.entries.minByOrNull { it.waypoint.distanceSqToPlayer() }!!
+ basket.found = true
+ if (closest == basket) {
+ closest = null
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!config.allWaypoints && !config.allEntranceWaypoints) return
+ if (!HypixelData.hypixelLive) return // don't show outside live hypixel network (it's disabled on alpha)
+ if (LorenzUtils.inSkyBlock) return
+
+ if (event.repeatSeconds(1)) {
+ isHalloween = checkScoreboardHalloweenSpecific()
+ }
+
+ if (isHalloween) {
+ if (config.onlyClosest) {
+ if (closest == null) {
+ val notFoundBaskets = Basket.entries.filter { !it.found }
+ if (notFoundBaskets.isEmpty()) return
+ closest = notFoundBaskets.minByOrNull { it.waypoint.distanceSqToPlayer() }!!
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderWorld(event: LorenzRenderWorldEvent) {
+ if (!HypixelData.hypixelLive) return // don't show outside live hypixel network (it's disabled on alpha)
+ if (LorenzUtils.inSkyBlock) return
+ if (!isHalloween) return
+
+ if (config.allWaypoints) {
+ for (basket in Basket.entries) {
+ if (!basket.shouldShow()) continue
+ event.drawWaypointFilled(basket.waypoint, LorenzColor.GOLD.toColor())
+ event.drawDynamicText(basket.waypoint, "§6" + basket.basketName, 1.5)
+ }
+ }
+
+ if (config.allEntranceWaypoints) {
+ for (basketEntrance in BasketEntrances.entries) {
+ if (!basketEntrance.basket.any { it.shouldShow() }) continue
+ event.drawWaypointFilled(basketEntrance.waypoint, LorenzColor.YELLOW.toColor())
+ event.drawDynamicText(basketEntrance.waypoint, "§e" + basketEntrance.basketEntranceName, 1.5)
+ }
+ return
+ }
+
+ if (LorenzUtils.skyBlockArea == "?") return
+ }
+
+ private fun Basket.shouldShow(): Boolean {
+ if (found) {
+ return false
+ }
+
+ return if (config.onlyClosest) closest == this else true
+ }
+
+ private fun checkScoreboardHalloweenSpecific(): Boolean {
+ val list = ScoreboardData.sidebarLinesFormatted
+ return list.anyContains("Hypixel Level") && list.anyContains("Halloween") && list.anyContains("Baskets")
+ }
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(13, "event.halloweenBasket", "event.lobbyWaypoints.halloweenBasket")
+ }
+}