Skip to content

Commit

Permalink
Improvement: Click CF block message to open pets (#2333)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
hannibal002 and hannibal002 authored Aug 13, 2024
1 parent 9f4e281 commit 4b2935b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.features.event.hoppity.MythicRabbitPetWarning
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.SimpleTimeMark
Expand Down Expand Up @@ -39,10 +40,13 @@ object ChocolateFactoryBlockOpen {

commandSentTimer = SimpleTimeMark.now()
event.cancel()
ChatUtils.chatAndOpenConfig(
"Blocked opening the Chocolate Factory without a §dMythic Rabbit Pet §eequipped. Click here to disable!",
ChatUtils.clickToActionOrDisable(
"§cBlocked opening the Chocolate Factory without a §dMythic Rabbit Pet §cequipped!",
config::mythicRabbitRequirement,
)
"open pets menu",
) {
HypixelCommands.pet()
}
}

private fun isEnabled() = LorenzUtils.inSkyBlock && config.mythicRabbitRequirement
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,19 @@ object ChatUtils {
}
return this
}

fun clickToActionOrDisable(message: String, option: KMutableProperty0<*>, actionName: String, action: () -> Unit) {
ChatUtils.clickableChat(
"$message\n§e[CLICK to $actionName or disable this feature]",
onClick = {
if (KeyboardManager.isShiftKeyDown() || KeyboardManager.isModifierKeyDown()) {
option.jumpToEditor()
} else {
action()
}
},
hover = "§eClick to $actionName!\n" +
"§eShift-Click to disable this feature!",
)
}
}
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ object HypixelCommands {
send("cf")
}

fun pet() {
send("pet")
}

fun openBaker() {
send("openbaker")
}
Expand Down

0 comments on commit 4b2935b

Please sign in to comment.