diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-10-13 14:53:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-13 20:53:16 +0200 |
commit | 3293490627911421dd8fa5afd124045f5319c922 (patch) | |
tree | 61051d157c62bbcb84462a3a7bf32489e2883667 /src/main/java/at | |
parent | 29a07adbf6a21dabcb67ee8aae1dde81b0bb102d (diff) | |
download | skyhanni-3293490627911421dd8fa5afd124045f5319c922.tar.gz skyhanni-3293490627911421dd8fa5afd124045f5319c922.tar.bz2 skyhanni-3293490627911421dd8fa5afd124045f5319c922.zip |
Feature: Chocolate Factory Booster Cookie Blocker (#2713)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at')
2 files changed, 43 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 5d1c63f8d..93d7d6f61 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -233,6 +233,12 @@ public class ChocolateFactoryConfig { public boolean mythicRabbitRequirement = false; @Expose + @ConfigOption(name = "Booster Cookie", desc = "Blocks running /cf without a §6§lBooster Cookie §7active.") + @ConfigEditorBoolean + @FeatureToggle + public boolean boosterCookieRequirement = false; + + @Expose @ConfigOption(name = "Stray Tracker", desc = "Track stray rabbits found in the Chocolate Factory menu.") @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt index a797ca2d6..c9ff65273 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt @@ -1,12 +1,17 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.EntityMovementData +import at.hannibal2.skyhanni.data.IslandGraphs +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.ProfileStorageData 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.LorenzVec import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -16,6 +21,7 @@ import kotlin.time.Duration.Companion.seconds @SkyHanniModule object ChocolateFactoryBlockOpen { private val config get() = SkyHanniMod.feature.inventory.chocolateFactory + private val profileStorage get() = ProfileStorageData.profileSpecific?.bits /** * REGEX-TEST: /cf @@ -26,27 +32,46 @@ object ChocolateFactoryBlockOpen { */ private val commandPattern by RepoPattern.pattern( "inventory.chocolatefactory.opencommand", - "\\/(?:cf|(?:chocolate)?factory)(?: .*)?", + "/(?:cf|(?:chocolate)?factory)(?: .*)?", ) private var commandSentTimer = SimpleTimeMark.farPast() @SubscribeEvent fun onCommandSend(event: MessageSendToServerEvent) { - if (!isEnabled()) return + if (!LorenzUtils.inSkyBlock) return if (!commandPattern.matches(event.message)) return if (commandSentTimer.passedSince() < 5.seconds) return - if (MythicRabbitPetWarning.correctPet()) return - commandSentTimer = SimpleTimeMark.now() - event.cancel() - ChatUtils.clickToActionOrDisable( - "§cBlocked opening the Chocolate Factory without a §dMythic Rabbit Pet §cequipped!", - config::mythicRabbitRequirement, - actionName = "open pets menu", - action = { HypixelCommands.pet() }, - ) + if (config.mythicRabbitRequirement && !MythicRabbitPetWarning.correctPet()) { + event.cancelOpen() + ChatUtils.clickToActionOrDisable( + "§cBlocked opening the Chocolate Factory without a §dMythic Rabbit Pet §cequipped!", + config::mythicRabbitRequirement, + actionName = "open pets menu", + action = { HypixelCommands.pet() }, + ) + } else if (config.boosterCookieRequirement) { + profileStorage?.boosterCookieExpiryTime?.let { + if (it.timeUntil() > 0.seconds) return + event.cancelOpen() + ChatUtils.clickToActionOrDisable( + "§cBlocked opening the Chocolate Factory without a §dBooster Cookie §cactive!", + config::boosterCookieRequirement, + actionName = "warp to hub", + action = { + HypixelCommands.warp("hub") + EntityMovementData.onNextTeleport(IslandType.HUB) { + IslandGraphs.pathFind(LorenzVec(-32.5, 71.0, -76.5), "§aBazaar", condition = { true }) + } + }, + ) + } + } } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.mythicRabbitRequirement + private fun MessageSendToServerEvent.cancelOpen() { + commandSentTimer = SimpleTimeMark.now() + this.cancel() + } } |