package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.FameRanks.getFameRankByNameOrNull import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent 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 private val playerStorage get() = SkyHanniMod.feature.storage var bits: Int get() = profileStorage?.bits ?: 0 private set(value) { profileStorage?.bits = value } var currentFameRank: FameRank? get() = playerStorage?.currentFameRank?.let { getFameRankByNameOrNull(it) } private set(value) { if (value != null) { playerStorage?.currentFameRank = value.name } } var bitsAvailable: Int get() = profileStorage?.bitsAvailable ?: 0 private set(value) { profileStorage?.bitsAvailable = 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") // Scoreboard patterns val bitsScoreboardPattern by bitsDataGroup.pattern( "scoreboard", "^Bits: §b(?[\\d,.]+).*$" ) // Chat patterns private val bitsChatGroup = bitsDataGroup.group("chat") private val bitsFromFameRankUpChatPattern by bitsChatGroup.pattern( "famerankup", "§eYou gained §3(?.*) Bits Available §ecompounded from all your §epreviously eaten §6cookies§e! Click here to open §6cookie menu§e!" ) private val boosterCookieAte by bitsChatGroup.pattern( "boostercookieate", "§eYou consumed a §6Booster Cookie§e!.*" ) // GUI patterns private val bitsGuiGroup = bitsDataGroup.group("gui") private val bitsAvailableMenuPattern by bitsGuiGroup.pattern( "availablemenu", "§7Bits Available: §b(?[\\d,]+)(§3.+)?" ) private val fameRankSbMenuPattern by bitsGuiGroup.pattern( "sbmenufamerank", "§7Your rank: §e(?.*)" ) /** * REGEX-TEST: §7Duration: §a140d 8h 35m 36s */ private val cookieDurationPattern by bitsGuiGroup.pattern( "cookieduration", "\\s*§7Duration: §a(?