Skip to content

Commit

Permalink
Improvement: Option for optimal speed warning when not wearing ranche…
Browse files Browse the repository at this point in the history
…r's (#2859)

Co-authored-by: CalMWolfs <[email protected]>
  • Loading branch information
Obsidianninja11 and CalMWolfs authored Dec 8, 2024
1 parent 9fb3897 commit 8c40adb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class OptimalSpeedConfig {
@ConfigEditorBoolean
public boolean warning = false;

@Expose
@ConfigOption(name = "Only Warn With Rancher's", desc = "Only send a warning when wearing Rancher's Boots.")
@ConfigEditorBoolean
public boolean onlyWarnRanchers = false;

@Expose
@ConfigOption(name = "Rancher Boots", desc = "Set the optimal speed in the Rancher Boots overlay by clicking on the presets.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.ConfigUtils.jumpToEditor
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
Expand Down Expand Up @@ -186,21 +187,32 @@ object GardenOptimalSpeed {
if (GardenAPI.onBarnPlot) return
if (!config.warning) return
if (!GardenAPI.isCurrentlyFarming()) return
if (InventoryUtils.getBoots()?.getInternalNameOrNull() != rancherBoots) return
if (lastWarnTime.passedSince() < 20.seconds) return
val ranchersEquipped = InventoryUtils.getBoots()?.getInternalNameOrNull() == rancherBoots
if (!ranchersEquipped && config.onlyWarnRanchers) return

lastWarnTime = SimpleTimeMark.now()
LorenzUtils.sendTitle("§cWrong speed!", 3.seconds)
val cropInHand = cropInHand ?: return

var text = "§cWrong speed while farming ${cropInHand.cropName} detected!"
text += "\n§eCurrent Speed: §f$currentSpeed§e, Optimal Speed: §f$optimalSpeed"
ChatUtils.clickToActionOrDisable(
text,
config::warning,
actionName = "change the speed",
action = { HypixelCommands.setMaxSpeed(optimalSpeed) },
)
val text = "§cWrong speed while farming ${cropInHand.cropName} detected!" +
"\n§eCurrent Speed: §f$currentSpeed§e, Optimal Speed: §f$optimalSpeed"

if (ranchersEquipped) {
ChatUtils.clickToActionOrDisable(
text,
config::warning,
actionName = "change the speed",
action = { HypixelCommands.setMaxSpeed(optimalSpeed) },
)
} else {
ChatUtils.clickableChat(
text,
onClick = { config::onlyWarnRanchers.jumpToEditor() },
hover = "§eClick to disable this feature!",
replaceSameMessage = true,
)
}
}

private fun isRancherOverlayEnabled() = GardenAPI.inGarden() && config.signEnabled
Expand Down

0 comments on commit 8c40adb

Please sign in to comment.