diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-08-31 20:55:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-31 20:55:30 +0200 |
commit | 2507d18717f0477b9641fbd8c6ec163720022e6a (patch) | |
tree | 5792b907b16b58424034d6113eda857095947d86 /src/main/java/at/hannibal2/skyhanni/features/fame | |
parent | 025073ba4d380d696530c28536a0667478c3ebb6 (diff) | |
download | skyhanni-2507d18717f0477b9641fbd8c6ec163720022e6a.tar.gz skyhanni-2507d18717f0477b9641fbd8c6ec163720022e6a.tar.bz2 skyhanni-2507d18717f0477b9641fbd8c6ec163720022e6a.zip |
Improvement: Click on chat (#2428)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fame')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt | 24 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt | 43 |
2 files changed, 32 insertions, 35 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index 445714402..5a1e1361a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -53,18 +54,13 @@ object CityProjectFeatures { private val patternGroup = RepoPattern.group("fame.projects") private val contributeAgainPattern by patternGroup.pattern( "contribute", - "§7Contribute again: §e(?<time>.*)" + "§7Contribute again: §e(?<time>.*)", ) private val completedPattern by patternGroup.pattern( "completed", - "§aProject is (?:being built|released)!" + "§aProject is (?:being built|released)!", ) - fun disable() { - config.dailyReminder = false - ChatUtils.chat("Disabled city project reminder messages!") - } - @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!config.dailyReminder) return @@ -79,11 +75,11 @@ object CityProjectFeatures { if (lastReminderSend.passedSince() < 30.seconds) return lastReminderSend = SimpleTimeMark.now() - ChatUtils.clickableChat( - "Daily City Project Reminder! (Click here to disable this reminder)", - onClick = { disable() }, - "§eClick to disable!", - oneTimeClick = true + ChatUtils.clickToActionOrDisable( + "Daily City Project Reminder!", + config::dailyReminder, + actionName = "warp to Hub", + action = { HypixelCommands.warp("hub") }, ) } @@ -166,8 +162,8 @@ object CityProjectFeatures { } else { BazaarApi.searchForBazaarItem(name, amount) } - } - ) { inInventory && !NEUItems.neuHasFocus() } + }, + ) { inInventory && !NEUItems.neuHasFocus() }, ) val price = internalName.getPrice() * amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt index 22171ed3b..d5f33204c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches @@ -27,31 +28,33 @@ import kotlin.time.Duration.Companion.seconds @SkyHanniModule object UpgradeReminder { + private val config get() = SkyHanniMod.feature.misc + private val patternGroup = RepoPattern.group("fame.upgrades") private val accountUpgradePattern by patternGroup.pattern( "account", - "§8Account Upgrade" + "§8Account Upgrade", ) private val profileUpgradePattern by patternGroup.pattern( "profile", - "§8Profile Upgrade" + "§8Profile Upgrade", ) private val upgradeDurationPattern by patternGroup.pattern( "duration", - "§8Duration: (?<duration>.+)" + "§8Duration: (?<duration>.+)", ) private val upgradeStartedPattern by patternGroup.pattern( "started", - "§eYou started the §r§a(?<upgrade>.+) §r§eupgrade!" + "§eYou started the §r§a(?<upgrade>.+) §r§eupgrade!", ) private val upgradeClaimedPattern by patternGroup.pattern( "claimed", - "§eYou claimed the §r§a(?<upgrade>.+) §r§eupgrade!" + "§eYou claimed the §r§a(?<upgrade>.+) §r§eupgrade!", ) private val upgradePattern by patternGroup.pattern( "upgrade", - "§eClick to start upgrade!" + "§eClick to start upgrade!", ) private var currentProfileUpgrade: CommunityShopUpgrade? @@ -74,7 +77,6 @@ object UpgradeReminder { // TODO: (for 0.27) merge this logic with reminder manager @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { - if (!LorenzUtils.inSkyBlock) return if (!isEnabled()) return if (ReminderUtils.isBusy()) return if (inInventory || LorenzUtils.skyBlockArea == "Community Center") return @@ -127,28 +129,26 @@ object UpgradeReminder { } } - private fun isEnabled() = SkyHanniMod.feature.misc.accountUpgradeReminder - - fun disable() { - SkyHanniMod.feature.misc.accountUpgradeReminder = false - } + private fun isEnabled() = LorenzUtils.inSkyBlock && config.accountUpgradeReminder @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(49, + event.move( + 49, "#player.currentAccountUpgrade", - "#player.communityShopAccountUpgrade.name" + "#player.communityShopAccountUpgrade.name", ) - event.move(49, + event.move( + 49, "#player.nextAccountUpgradeCompletionTime", - "#player.communityShopAccountUpgrade.completionTime" + "#player.communityShopAccountUpgrade.completionTime", ) } class CommunityShopUpgrade( @Expose val name: String?, - @Expose var completionTime: SimpleTimeMark = SimpleTimeMark.farFuture() + @Expose var completionTime: SimpleTimeMark = SimpleTimeMark.farFuture(), ) { private var duration: Duration = Duration.ZERO @@ -158,10 +158,11 @@ object UpgradeReminder { fun sendReminderIfClaimable() { if (this.name == null || this.completionTime.isInFuture()) return - ChatUtils.clickableChat( - "The §a$name §eupgrade has completed! §c(Click to disable these reminders)", onClick = { - disable() - }, oneTimeClick = true + ChatUtils.clickToActionOrDisable( + "The §a$name §eupgrade has completed!", + config::accountUpgradeReminder, + actionName = "warp to Hub", + action = { HypixelCommands.warp("hub") }, ) } |