From 56b2f2f8a79caae96557406771203061c360468c Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:23:49 +0200 Subject: Improvement: Cookie Buff Timer (#1292) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/storage/ProfileSpecificStorage.java | 3 ++ .../java/at/hannibal2/skyhanni/data/BitsAPI.kt | 63 ++++++++++++++++++++-- .../gui/customscoreboard/ScoreboardElements.kt | 42 +++------------ .../at/hannibal2/skyhanni/utils/SimpleTimeMark.kt | 2 + 4 files changed, 72 insertions(+), 38 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 967e9b02d..68761ef3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -80,6 +80,9 @@ public class ProfileSpecificStorage { @Expose public int bitsToClaim = -1; + + @Expose + public Long boosterCookieExpiryTime = null; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 72210ad63..a13ee259b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -8,16 +8,21 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace +import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.days object BitsAPI { private val profileStorage get() = ProfileStorageData.profileSpecific?.bits @@ -41,6 +46,12 @@ object BitsAPI { profileStorage?.bitsToClaim = value } + var cookieBuffTime: SimpleTimeMark? + get() = profileStorage?.boosterCookieExpiryTime?.asTimeMark() + private set(value) { + profileStorage?.boosterCookieExpiryTime = value?.toMillis() + } + private const val defaultcookiebits = 4800 private val bitsDataGroup = RepoPattern.group("data.bits") @@ -77,6 +88,24 @@ object BitsAPI { "§7Your rank: §e(?.*)" ) + /** + * REGEX-TEST: §7Duration: §a140d 8h 35m 36s + */ + private val cookieDurationPattern by bitsGuiGroup.pattern( + "cookieduration", + "\\s*§7Duration: §a(?