Skip to content

Commit

Permalink
Improvement: Royal Pigeon Left Click (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsEmpa authored Jul 21, 2024
1 parent 1da1de3 commit 3b80141
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class TunnelMapsConfig {
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
public int nextSpotHotkey = Keyboard.KEY_NONE;

@Expose
@ConfigOption(name = "Left Click Pigeon", desc = "Left click the Royal Pigeon to go to the next spot.")
@ConfigEditorBoolean
public boolean leftClickPigeon = true;

@Expose
@ConfigOption(name = "Dynamic Path Colour", desc = "Instead of the selected color use the color of the target as line colour.")
@ConfigEditorBoolean
Expand Down
26 changes: 20 additions & 6 deletions src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.mining

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.model.Graph
import at.hannibal2.skyhanni.data.model.GraphNode
Expand All @@ -10,6 +11,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiContainerEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.ItemClickEvent
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
Expand All @@ -24,6 +26,7 @@ import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor
import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.itemName
import at.hannibal2.skyhanni.utils.LocationUtils
Expand Down Expand Up @@ -141,11 +144,13 @@ object TunnelsMaps {

/** @return Errors with an empty String */
private fun getGenericName(input: String): String = translateTable.getOrPut(input) {
possibleLocations.keys.firstOrNull() { it.uppercase().removeColor().contains(input.uppercase()) } ?: ""
possibleLocations.keys.firstOrNull { it.uppercase().removeColor().contains(input.uppercase()) } ?: ""
}

private var clickTranslate = mapOf<Int, String>()

private val ROYAL_PIGEON by lazy { "ROYAL_PIGEON".asInternalName() }

@SubscribeEvent
fun onInventoryFullyOpened(event: InventoryFullyOpenedEvent) {
if (!isEnabled()) return
Expand Down Expand Up @@ -423,6 +428,14 @@ object TunnelsMaps {
nextSpotKey(event)
}

@SubscribeEvent
fun onItemClick(event: ItemClickEvent) {
if (!isEnabled() || !config.leftClickPigeon) return
if (event.clickType != ClickType.LEFT_CLICK) return
if (event.itemInHand?.getInternalNameOrNull() != ROYAL_PIGEON) return
nextSpot()
}

private fun campfireKey(event: LorenzKeyPressEvent) {
if (event.keyCode != config.campfireKey) return
if (config.travelScroll) {
Expand All @@ -446,15 +459,16 @@ object TunnelsMaps {

private fun nextSpotKey(event: LorenzKeyPressEvent) {
if (event.keyCode != config.nextSpotHotkey) return
nextSpot()
}

private fun nextSpot() {
if (!nextSpotDelay.isInPast()) return
nextSpotDelay = 0.5.seconds.fromNow()
goal = getNext()
}

val areas = setOf(
"Glacite Tunnels", "Dwarven Base Camp", "Glacite Lake", "Fossil Research Center"
)
private val areas = setOf("Glacite Tunnels", "Dwarven Base Camp", "Glacite Lake", "Fossil Research Center")

private fun isEnabled() =
IslandType.DWARVEN_MINES.isInIsland() && config.enable && areas.contains(LorenzUtils.skyBlockArea)
private fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enable && LorenzUtils.skyBlockArea in areas
}

0 comments on commit 3b80141

Please sign in to comment.