diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-01 05:26:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 13:26:08 +1000 |
commit | 1259d8a657829a9343e3024c031f7bf94f6897b9 (patch) | |
tree | 038892e42260739286f601094ac22ed436fae9a4 /src/main/java/at/hannibal2/skyhanni/features/event | |
parent | 7df31da39359712dd6ec39c8186ad80908ac0a58 (diff) | |
download | skyhanni-1259d8a657829a9343e3024c031f7bf94f6897b9.tar.gz skyhanni-1259d8a657829a9343e3024c031f7bf94f6897b9.tar.bz2 skyhanni-1259d8a657829a9343e3024c031f7bf94f6897b9.zip |
Merge pull request #1599
* doing big moves
* Merge branch 'refs/heads/beta' into splitting-factory-and-hoppity-in-…
* 43 -> 44
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
15 files changed, 27 insertions, 1142 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryAPI.kt deleted file mode 100644 index 377e79072..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryAPI.kt +++ /dev/null @@ -1,345 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.features.event.ChocolateFactoryConfig -import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage.ChocolateFactoryStorage -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.data.jsonobjects.repo.HoppityEggLocationsJson -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.InventoryUpdatedEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity.HoppityEggLocator -import at.hannibal2.skyhanni.features.event.chocolatefactory.menu.ChocolateAmount -import at.hannibal2.skyhanni.features.event.chocolatefactory.menu.ChocolateFactoryStats -import at.hannibal2.skyhanni.features.event.chocolatefactory.menu.ChocolateFactoryTimeTowerManager -import at.hannibal2.skyhanni.features.event.chocolatefactory.menu.ChocolateFactoryTooltip -import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter -import at.hannibal2.skyhanni.utils.DelayedRun -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble -import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.NumberUtil.formatLong -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SkyblockSeason -import at.hannibal2.skyhanni.utils.SoundUtils -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.removeColor -import at.hannibal2.skyhanni.utils.TimeUtils -import at.hannibal2.skyhanni.utils.UtilsPatterns -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object ChocolateFactoryAPI { - - val config: ChocolateFactoryConfig get() = SkyHanniMod.feature.event.chocolateFactory - val profileStorage: ChocolateFactoryStorage? get() = ProfileStorageData.profileSpecific?.chocolateFactory - - val patternGroup = RepoPattern.group("misc.chocolatefactory") - private val chocolateAmountPattern by patternGroup.pattern( - "chocolate.amount", - "(?<amount>[\\d,]+) Chocolate" - ) - private val chocolatePerSecondPattern by patternGroup.pattern( - "chocolate.persecond", - "§6(?<amount>[\\d.,]+) §8per second" - ) - private val chocolateAllTimePattern by patternGroup.pattern( - "chocolate.alltime", - "§7All-time Chocolate: §6(?<amount>[\\d,]+)" - ) - private val chocolateThisPrestigePattern by patternGroup.pattern( - "chocolate.thisprestige", - "§7Chocolate this Prestige: §6(?<amount>[\\d,]+)" - ) - private val chocolateMultiplierPattern by patternGroup.pattern( - "chocolate.multiplier", - "§7Total Multiplier: §6(?<amount>[\\d.]+)x" - ) - private val barnAmountPattern by patternGroup.pattern( - "barn.amount", - "§7Your Barn: §.(?<rabbits>\\d+)§7/§.(?<max>\\d+) Rabbits" - ) - private val prestigeLevelPattern by patternGroup.pattern( - "prestige.level", - "§6Chocolate Factory (?<prestige>[IVX]+)" - ) - private val chocolateForPrestigePattern by patternGroup.pattern( - "chocolate.forprestige", - "§7§cRequires (?<amount>\\w+) Chocolate this.*" - ) - private val clickMeRabbitPattern by patternGroup.pattern( - "rabbit.clickme", - "§e§lCLICK ME!" - ) - private val leaderboardPlacePattern by patternGroup.pattern( - "leaderboard.place", - "§7You are §8#§b(?<position>[\\d,]+)" - ) - private val leaderboardPercentilePattern by patternGroup.pattern( - "leaderboard.percentile", - "§7§8You are in the top §.(?<percent>[\\d.]+)%§8 of players!" - ) - private val timeTowerAmountPattern by patternGroup.pattern( - "timetower.amount", - "§7Charges: §.(?<uses>\\d+)§7/§a(?<max>\\d+)" - ) - private val timeTowerStatusPattern by patternGroup.pattern( - "timetower.status", - "§7Status: §.§l(?<status>INACTIVE|ACTIVE)(?: §f)?(?<acitveTime>\\w*)" - ) - private val timeTowerRechargePattern by patternGroup.pattern( - "timetower.recharge", - "§7Next Charge: §a(?<duration>\\w+)" - ) - private val chocolateFactoryInventoryNamePattern by patternGroup.pattern( - "inventory.name", - "Hoppity|Chocolate Shop|Chocolate Factory Milestones" - ) - - var rabbitSlots = mapOf<Int, Int>() - var otherUpgradeSlots = setOf<Int>() - var noPickblockSlots = setOf<Int>() - var barnIndex = 34 - private var infoIndex = 13 - private var productionInfoIndex = 45 - var prestigeIndex = 28 - var milestoneIndex = 53 - private var leaderboardIndex = 51 - var handCookieIndex = 38 - var timeTowerIndex = 39 - var shrineIndex = 41 - var coachRabbitIndex = 42 - var maxRabbits = 395 - - var inChocolateFactory = false - var chocolateFactoryPaused = false - - var currentPrestige = 1 - var chocolatePerSecond = 0.0 - var leaderboardPosition: Int? = null - var leaderboardPercentile: Double? = null - var chocolateForPrestige = 150_000_000L - - val upgradeableSlots: MutableSet<Int> = mutableSetOf() - var bestUpgrade: Int? = null - var bestRabbitUpgrade: String? = null - var clickRabbitSlot: Int? = null - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!isEnabled()) return - - if (chocolateFactoryInventoryNamePattern.matches(event.inventoryName)) { - chocolateFactoryPaused = true - ChocolateFactoryStats.updateDisplay() - return - } - if (event.inventoryName != "Chocolate Factory") return - inChocolateFactory = true - - DelayedRun.runNextTick { - updateInventoryItems(event.inventoryItems) - } - } - - @SubscribeEvent - fun onInventoryUpdated(event: InventoryUpdatedEvent) { - if (!inChocolateFactory) return - - updateInventoryItems(event.inventoryItems) - } - - private fun updateInventoryItems(inventory: Map<Int, ItemStack>) { - val infoItem = InventoryUtils.getItemAtSlotIndex(infoIndex) ?: return - val prestigeItem = InventoryUtils.getItemAtSlotIndex(prestigeIndex) ?: return - val productionInfoItem = InventoryUtils.getItemAtSlotIndex(productionInfoIndex) ?: return - val leaderboardItem = InventoryUtils.getItemAtSlotIndex(leaderboardIndex) ?: return - val barnItem = InventoryUtils.getItemAtSlotIndex(barnIndex) ?: return - val timeTowerItem = InventoryUtils.getItemAtSlotIndex(timeTowerIndex) ?: return - - processInfoItems(infoItem, prestigeItem, productionInfoItem, leaderboardItem, barnItem, timeTowerItem) - - bestUpgrade = null - upgradeableSlots.clear() - var bestAffordableUpgradeRatio = Double.MAX_VALUE - var bestPossibleUpgradeRatio = Double.MAX_VALUE - clickRabbitSlot = null - - for ((slotIndex, item) in inventory) { - if (config.rabbitWarning && clickMeRabbitPattern.matches(item.name)) { - SoundUtils.playBeepSound() - clickRabbitSlot = slotIndex - } - - val lore = item.getLore() - val upgradeCost = getChocolateUpgradeCost(lore) ?: continue - - val canAfford = upgradeCost <= ChocolateAmount.CURRENT.chocolate() - if (canAfford) upgradeableSlots.add(slotIndex) - - if (slotIndex in rabbitSlots) { - val chocolateIncrease = rabbitSlots[slotIndex] ?: 0 - val upgradeRatio = upgradeCost.toDouble() / chocolateIncrease - - if (canAfford && upgradeRatio < bestAffordableUpgradeRatio) { - bestUpgrade = slotIndex - bestAffordableUpgradeRatio = upgradeRatio - } - if (upgradeRatio < bestPossibleUpgradeRatio) { - bestPossibleUpgradeRatio = upgradeRatio - bestRabbitUpgrade = item.name - } - } - } - } - - private fun processInfoItems( - chocolateItem: ItemStack, - prestigeItem: ItemStack, - productionItem: ItemStack, - leaderboardItem: ItemStack, - barnItem: ItemStack, - timeTowerItem: ItemStack, - ) { - val profileStorage = profileStorage ?: return - - leaderboardPosition = null - leaderboardPercentile = null - - chocolateAmountPattern.matchMatcher(chocolateItem.name.removeColor()) { - profileStorage.currentChocolate = group("amount").formatLong() - } - for (line in chocolateItem.getLore()) { - chocolatePerSecondPattern.matchMatcher(line) { - chocolatePerSecond = group("amount").formatDouble() - } - chocolateAllTimePattern.matchMatcher(line) { - profileStorage.chocolateAllTime = group("amount").formatLong() - } - } - prestigeLevelPattern.matchMatcher(prestigeItem.name) { - currentPrestige = group("prestige").romanToDecimal() - } - for (line in prestigeItem.getLore()) { - chocolateThisPrestigePattern.matchMatcher(line) { - profileStorage.chocolateThisPrestige = group("amount").formatLong() - } - chocolateForPrestigePattern.matchMatcher(line) { - chocolateForPrestige = group("amount").formatLong() - } - } - productionItem.getLore().matchFirst(chocolateMultiplierPattern) { - val currentMultiplier = group("amount").formatDouble() - profileStorage.chocolateMultiplier = currentMultiplier - - if (ChocolateFactoryTimeTowerManager.timeTowerActive()) { - profileStorage.rawChocolateMultiplier = currentMultiplier - profileStorage.timeTowerLevel * 0.1 - } else { - profileStorage.rawChocolateMultiplier = currentMultiplier - } - } - for (line in leaderboardItem.getLore()) { - leaderboardPlacePattern.matchMatcher(line) { - leaderboardPosition = group("position").formatInt() - } - leaderboardPercentilePattern.matchMatcher(line) { - leaderboardPercentile = group("percent").formatDouble() - } - } - barnItem.getLore().matchFirst(barnAmountPattern) { - profileStorage.currentRabbits = group("rabbits").formatInt() - profileStorage.maxRabbits = group("max").formatInt() - ChocolateFactoryBarnManager.trySendBarnFullMessage() - } - for (line in timeTowerItem.getLore()) { - timeTowerAmountPattern.matchMatcher(line) { - profileStorage.currentTimeTowerUses = group("uses").formatInt() - profileStorage.maxTimeTowerUses = group("max").formatInt() - ChocolateFactoryTimeTowerManager.checkTimeTowerWarning(true) - } - timeTowerStatusPattern.matchMatcher(line) { - val activeTime = group("acitveTime") - if (activeTime.isNotEmpty()) { - // todo in future fix this issue with TimeUtils.getDuration - val formattedGroup = activeTime.replace("h", "h ").replace("m", "m ") - - val activeDuration = TimeUtils.getDuration(formattedGroup) - val activeUntil = SimpleTimeMark.now() + activeDuration - profileStorage.currentTimeTowerEnds = activeUntil.toMillis() - } - } - timeTowerRechargePattern.matchMatcher(line) { - // todo in future fix this issue with TimeUtils.getDuration - val formattedGroup = group("duration").replace("h", "h ").replace("m", "m ") - - val timeUntilTower = TimeUtils.getDuration(formattedGroup) - val nextTimeTower = SimpleTimeMark.now() + timeUntilTower - profileStorage.nextTimeTower = nextTimeTower.toMillis() - } - } - profileStorage.rawChocPerSecond = (chocolatePerSecond / profileStorage.chocolateMultiplier).toInt() - profileStorage.lastDataSave = SimpleTimeMark.now().toMillis() - - if (!config.statsDisplay) return - ChocolateFactoryStats.updateDisplay() - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - clearData() - } - - @SubscribeEvent - fun onInventoryClose(event: InventoryCloseEvent) { - clearData() - } - - private fun clearData() { - inChocolateFactory = false - chocolateFactoryPaused = false - } - - @SubscribeEvent - fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant<HoppityEggLocationsJson>("HoppityEggLocations") - - HoppityEggLocator.eggLocations = data.eggLocations - - rabbitSlots = data.rabbitSlots - otherUpgradeSlots = data.otherUpgradeSlots - noPickblockSlots = data.noPickblockSlots - barnIndex = data.barnIndex - infoIndex = data.infoIndex - productionInfoIndex = data.productionInfoIndex - prestigeIndex = data.prestigeIndex - milestoneIndex = data.milestoneIndex - leaderboardIndex = data.leaderboardIndex - handCookieIndex = data.handCookieIndex - timeTowerIndex = data.timeTowerIndex - shrineIndex = data.shrineIndex - coachRabbitIndex = data.coachRabbitIndex - maxRabbits = data.maxRabbits - - ChocolateFactoryTooltip.updateIgnoredSlots() - } - - fun getChocolateUpgradeCost(lore: List<String>): Long? { - val nextLine = lore.nextAfter({ UtilsPatterns.costLinePattern.matches(it) }) ?: return null - return chocolateAmountPattern.matchMatcher(nextLine.removeColor()) { - group("amount").formatLong() - } - } - - fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - - fun isHoppityEvent() = SkyblockSeason.getCurrentSeason() == SkyblockSeason.SPRING -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt deleted file mode 100644 index 7b1be9152..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryBarnManager.kt +++ /dev/null @@ -1,92 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory - -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity.HoppityEggsManager -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.HypixelCommands -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SoundUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.seconds - -object ChocolateFactoryBarnManager { - - private val config get() = ChocolateFactoryAPI.config - private val profileStorage get() = ChocolateFactoryAPI.profileStorage - - private val newRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern( - "rabbit.new", - "§d§lNEW RABBIT! §6\\+\\d Chocolate §7and §6\\+0.\\d+x Chocolate §7per second!" - ) - private val rabbitDuplicatePattern by ChocolateFactoryAPI.patternGroup.pattern( - "rabbit.duplicate", - "§7§lDUPLICATE RABBIT! §6\\+[\\d,]+ Chocolate" - ) - - var barnFull = false - private var lastBarnFullWarning = SimpleTimeMark.farPast() - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!LorenzUtils.inSkyBlock) return - - newRabbitPattern.matchMatcher(event.message) { - val profileStorage = profileStorage ?: return - profileStorage.currentRabbits += 1 - trySendBarnFullMessage() - HoppityEggsManager.shareWaypointPrompt() - } - - rabbitDuplicatePattern.matchMatcher(event.message) { - HoppityEggsManager.shareWaypointPrompt() - } - } - - fun trySendBarnFullMessage() { - if (!ChocolateFactoryAPI.isEnabled()) return - - if (config.barnCapacityThreshold <= 0) { - return - } - - val profileStorage = profileStorage ?: return - - if (profileStorage.maxRabbits >= ChocolateFactoryAPI.maxRabbits) return - - val remainingSpace = profileStorage.maxRabbits - profileStorage.currentRabbits - barnFull = remainingSpace <= config.barnCapacityThreshold - if (!barnFull) return - - if (lastBarnFullWarning.passedSince() < 30.seconds) return - - if (profileStorage.maxRabbits == -1) { - ChatUtils.clickableChat( - "Open your chocolate factory to see your barn's capacity status!", - onClick = { - HypixelCommands.chocolateFactory() - } - ) - return - } - - ChatUtils.clickableChat( - message = if (profileStorage.currentRabbits == profileStorage.maxRabbits) { - "§cYour barn is full! §7(${barnStatus()}). §cUpgrade it so they don't get crushed" - } else { - "§cYour barn is almost full! §7(${barnStatus()}). §cUpgrade it so they don't get crushed" - }, - onClick = { - HypixelCommands.chocolateFactory() - } - ) - SoundUtils.playBeepSound() - lastBarnFullWarning = SimpleTimeMark.now() - } - - fun barnStatus(): String { - val profileStorage = profileStorage ?: return "Unknown" - return "${profileStorage.currentRabbits}/${profileStorage.maxRabbits} Rabbits" - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt deleted file mode 100644 index 6b9fc671e..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/ChocolateFactoryShortcut.kt +++ /dev/null @@ -1,72 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory - -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.utils.HypixelCommands -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent -import io.github.moulberry.notenoughupdates.util.Utils -import net.minecraft.client.player.inventory.ContainerLocalMenu -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.seconds - -class ChocolateFactoryShortcut { - - private val config get() = ChocolateFactoryAPI.config - private var showItem = false - private var lastClick = SimpleTimeMark.farPast() - - private val item by lazy { - val neuItem = "COOKIE".asInternalName().getItemStack() - Utils.createItemStack( - neuItem.item, - "§6Open Chocolate Factory", - "§8(From SkyHanni)", - "", - "§7Click here to run", - "§e/chocolatefactory" - ) - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!LorenzUtils.inSkyBlock) return - if (LorenzUtils.inAnyIsland( - IslandType.THE_RIFT, - IslandType.KUUDRA_ARENA, - IslandType.CATACOMBS, - IslandType.MINESHAFT, - ) - ) return - showItem = config.hoppityMenuShortcut && event.inventoryName == "SkyBlock Menu" - } - - @SubscribeEvent - fun onInventoryClose(event: InventoryCloseEvent) { - showItem = false - } - - @SubscribeEvent - fun replaceItem(event: ReplaceItemEvent) { - if (event.inventory is ContainerLocalMenu && showItem && event.slotNumber == 15) { - event.replaceWith(item) - } - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onStackClick(event: GuiContainerEvent.SlotClickEvent) { - if (showItem && event.slotId == 15) { - event.cancel() - if (lastClick.passedSince() > 2.seconds) { - HypixelCommands.chocolateFactory() - lastClick = SimpleTimeMark.now() - } - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateAmount.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateAmount.kt deleted file mode 100644 index 160023629..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateAmount.kt +++ /dev/null @@ -1,62 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI.profileStorage -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.TimeUtils.format -import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds - -enum class ChocolateAmount(val chocolate: () -> Long) { - CURRENT({ profileStorage?.currentChocolate ?: 0 }), - PRESTIGE({ profileStorage?.chocolateThisPrestige ?: 0 }), - ALL_TIME({ profileStorage?.chocolateAllTime ?: 0 }), - ; - - val formatted get(): String = (chocolate() + chocolateSinceUpdate()).addSeparators() - - fun formattedTimeUntilGoal(goal: Long): String { - val time = timeUntilGoal(goal) - return when { - time.isInfinite() -> "§cNever" - time.isNegative() -> "§aNow" - else -> "§6${time.format()}" - } - } - - private fun timeUntilGoal(goal: Long): Duration { - val profileStorage = ChocolateFactoryAPI.profileStorage ?: return Duration.ZERO - - val updatedAgo = SimpleTimeMark(profileStorage.lastDataSave).passedSince().inWholeSeconds - - val baseMultiplier = profileStorage.rawChocolateMultiplier - val rawChocolatePerSecond = profileStorage.rawChocPerSecond - val timeTowerMultiplier = baseMultiplier + profileStorage.timeTowerLevel * 0.1 - - var needed = goal - chocolate() - val secondsUntilTowerExpires = ChocolateFactoryTimeTowerManager.timeTowerActiveDuration().inWholeSeconds - - val timeTowerChocPerSecond = rawChocolatePerSecond * timeTowerMultiplier - - val secondsAtRate = needed / timeTowerChocPerSecond - if (secondsAtRate < secondsUntilTowerExpires) { - return secondsAtRate.seconds - updatedAgo.seconds - } - - needed -= (secondsUntilTowerExpires * timeTowerChocPerSecond).toLong() - val basePerSecond = rawChocolatePerSecond * baseMultiplier - return (needed / basePerSecond + secondsUntilTowerExpires).seconds - updatedAgo.seconds - } - - companion object { - fun chocolateSinceUpdate(): Long { - val lastUpdate = SimpleTimeMark(profileStorage?.lastDataSave ?: return 0) - val currentTime = SimpleTimeMark.now() - val secondsSinceUpdate = (currentTime - lastUpdate).inWholeSeconds - - val perSecond = ChocolateFactoryAPI.chocolatePerSecond - return (perSecond * secondsSinceUpdate).toLong() - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryInventory.kt deleted file mode 100644 index add477bb9..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryInventory.kt +++ /dev/null @@ -1,133 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.GuiRenderItemEvent -import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryBarnManager -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal -import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText -import at.hannibal2.skyhanni.utils.RenderUtils.highlight -import at.hannibal2.skyhanni.utils.StringUtils.matchFirst -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object ChocolateFactoryInventory { - - private val config get() = ChocolateFactoryAPI.config - private val profileStorage get() = ChocolateFactoryAPI.profileStorage - - private val rabbitAmountPattern by ChocolateFactoryAPI.patternGroup.pattern( - "rabbit.amount", - "Rabbit \\S+ - \\[(?<amount>\\d+)].*" - ) - private val upgradeTierPattern by ChocolateFactoryAPI.patternGroup.pattern( - "upgradetier", - ".*\\s(?<tier>[IVXLC]+)" - ) - private val unclaimedRewardsPattern by ChocolateFactoryAPI.patternGroup.pattern( - "unclaimedrewards", - "§7§aYou have \\d+ unclaimed rewards?!" - ) - - @SubscribeEvent - fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - if (!config.highlightUpgrades) return - - val item = event.stack ?: return - val itemName = item.name - if (itemName != ChocolateFactoryAPI.bestRabbitUpgrade) return - - event.drawSlotText(event.x + 18, event.y, "§6✦", .8f) - } - - @SubscribeEvent - fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - if (!config.highlightUpgrades) return - - for (slot in InventoryUtils.getItemsInOpenChest()) { - if (slot.slotIndex in ChocolateFactoryAPI.upgradeableSlots) { - if (slot.slotIndex == ChocolateFactoryAPI.bestUpgrade) { - slot highlight LorenzColor.GREEN.addOpacity(200) - } else { - slot highlight LorenzColor.GREEN.addOpacity(75) - } - } - if (slot.slotIndex == ChocolateFactoryAPI.barnIndex && ChocolateFactoryBarnManager.barnFull) { - slot highlight LorenzColor.RED - } - if (slot.slotIndex == ChocolateFactoryAPI.clickRabbitSlot) { - slot highlight LorenzColor.RED - } - if (slot.slotIndex == ChocolateFactoryAPI.milestoneIndex) { - slot.stack?.getLore()?.matchFirst(unclaimedRewardsPattern) { - slot highlight LorenzColor.RED - } - } - if (slot.slotIndex == ChocolateFactoryAPI.timeTowerIndex) { - if (ChocolateFactoryTimeTowerManager.timeTowerActive()) { - slot highlight LorenzColor.LIGHT_PURPLE - } - if (ChocolateFactoryTimeTowerManager.timeTowerFull()) { - slot highlight LorenzColor.RED - } - } - } - } - - @SubscribeEvent - fun onRenderItemTip(event: RenderInventoryItemTipEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - if (!config.showStackSizes) return - val profileStorage = profileStorage ?: return - - val item = event.stack - val itemName = item.name.removeColor() - val slotNumber = event.slot.slotNumber - - if (slotNumber in ChocolateFactoryAPI.rabbitSlots) { - rabbitAmountPattern.matchMatcher(itemName) { - val rabbitTip = when (val rabbitAmount = group("amount").formatInt()) { - in (0..9) -> "$rabbitAmount" - in (10..74) -> "§a$rabbitAmount" - in (75..124) -> "§9$rabbitAmount" - in (125..174) -> "§5$rabbitAmount" - in (175..199) -> "§6$rabbitAmount" - 200 -> "§d$rabbitAmount" - else -> "§c$rabbitAmount" - } - - event.stackTip = rabbitTip - } - } - if (slotNumber in ChocolateFactoryAPI.otherUpgradeSlots) { - upgradeTierPattern.matchMatcher(itemName) { - val level = group("tier").romanToDecimal() - - if (slotNumber == ChocolateFactoryAPI.timeTowerIndex) profileStorage.timeTowerLevel = level - - event.stackTip = level.toString() - } - } - } - - @SubscribeEvent - fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - val slot = event.slot ?: return - val slotNumber = slot.slotNumber - if (!config.useMiddleClick) return - if (slotNumber in ChocolateFactoryAPI.noPickblockSlots && - (slotNumber != ChocolateFactoryAPI.timeTowerIndex || event.clickedButton == 1)) return - - event.makePickblock() - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryStats.kt deleted file mode 100644 index e1b26fed8..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryStats.kt +++ /dev/null @@ -1,138 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryBarnManager -import at.hannibal2.skyhanni.utils.ClipboardUtils -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.renderables.Renderable -import com.google.gson.JsonPrimitive -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object ChocolateFactoryStats { - - private val config get() = ChocolateFactoryAPI.config - private val profileStorage get() = ChocolateFactoryAPI.profileStorage - - private var display = listOf<Renderable>() - - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!ChocolateFactoryAPI.chocolateFactoryPaused) return - updateDisplay() - } - - @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory && !ChocolateFactoryAPI.chocolateFactoryPaused) return - if (!config.statsDisplay) return - - config.position.renderRenderables(display, posLabel = "Chocolate Factory Stats") - } - - fun updateDisplay() { - val profileStorage = profileStorage ?: return - - val perSecond = ChocolateFactoryAPI.chocolatePerSecond - val perMinute = perSecond * 60 - val perHour = perMinute * 60 - val perDay = perHour * 24 - val position = ChocolateFactoryAPI.leaderboardPosition?.addSeparators() ?: "???" - val percentile = ChocolateFactoryAPI.leaderboardPercentile?.let { "§7Top §a$it%" } ?: "" - val timeTowerInfo = if (ChocolateFactoryTimeTowerManager.timeTowerActive()) { - "§d§lActive" - } else { - "§6${ChocolateFactoryTimeTowerManager.timeTowerCharges()}" - } - - val prestigeEstimate = ChocolateAmount.PRESTIGE.formattedTimeUntilGoal(ChocolateFactoryAPI.chocolateForPrestige) - - val map = buildMap { - put(ChocolateFactoryStat.HEADER, "§6§lChocolate Factory Stats") - - put(ChocolateFactoryStat.CURRENT, "§eCurrent Chocolate: §6${ChocolateAmount.CURRENT.formatted}") - put(ChocolateFactoryStat.THIS_PRESTIGE, "§eThis Prestige: §6${ChocolateAmount.PRESTIGE.formatted}") - put(ChocolateFactoryStat.ALL_TIME, "§eAll-time: §6${ChocolateAmount.ALL_TIME.formatted}") - - put(ChocolateFactoryStat.PER_SECOND, "§ePer Second: §6${perSecond.addSeparators()}") - put(ChocolateFactoryStat.PER_MINUTE, "§ePer Minute: §6${perMinute.addSeparators()}") - put(ChocolateFactoryStat.PER_HOUR, "§ePer Hour: §6${perHour.addSeparators()}") - put(ChocolateFactoryStat.PER_DAY, "§ePer Day: §6${perDay.addSeparators()}") - - put(ChocolateFactoryStat.MULTIPLIER, "§eChocolate Multiplier: §6${profileStorage.chocolateMultiplier}") - put(ChocolateFactoryStat.BARN, "§eBarn: §6${ChocolateFactoryBarnManager.barnStatus()}") - - put(ChocolateFactoryStat.LEADERBOARD_POS, "§ePosition: §7#§b$position $percentile") - - put(ChocolateFactoryStat.EMPTY, "") - put(ChocolateFactoryStat.EMPTY_2, "") - put(ChocolateFactoryStat.EMPTY_3, "") - - put(ChocolateFactoryStat.TIME_TOWER, "§eTime Tower: §6$timeTowerInfo") - put(ChocolateFactoryStat.TIME_TO_PRESTIGE, "§eTime To Prestige: $prestigeEstimate") - put( - ChocolateFactoryStat.RAW_PER_SECOND, - "§eRaw Per Second: §6${profileStorage.rawChocPerSecond.addSeparators()}" - ) - } - val text = config.statsDisplayList.mapNotNull { map[it] } - - display = listOf(Renderable.clickAndHover( - Renderable.verticalContainer(text.map(Renderable::string)), - tips = listOf("§bCopy to Clipboard!"), - onClick = { - val list = text.toMutableList() - val titleHeader = list.indexOf("§6§lChocolate Factory Stats") - if (titleHeader != -1) { - list[titleHeader] = "${LorenzUtils.getPlayerName()}'s Chocolate Factory Stats" - } else { - list.add(0, "${LorenzUtils.getPlayerName()}'s Chocolate Factory Stats") - } - ClipboardUtils.copyToClipboard(list.joinToString("\n") { it.removeColor() }) - } - )) - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.transform(42, "event.chocolateFactory.statsDisplayList") { element -> - val jsonArray = element.asJsonArray - - jsonArray.add(JsonPrimitive("TIME_TOWER")) - jsonArray.add(JsonPrimitive("TIME_TO_PRESTIGE")) - - jsonArray - } - } - - enum class ChocolateFactoryStat(private val display: String, val shouldDisplay: () -> Boolean = { true }) { - HEADER("§6§lChocolate Factory Stats"), - CURRENT("§eCurrent Chocolate: §65,272,230"), - THIS_PRESTIGE("§eThis Prestige: §6483,023,853", { ChocolateFactoryAPI.currentPrestige != 1 }), - ALL_TIME("§eAll-time: §6641,119,115"), - PER_SECOND("§ePer Second: §63,780.72"), - PER_MINUTE("§ePer Minute: §6226,843.2"), - PER_HOUR("§ePer Hour: §613,610,592"), - PER_DAY("§ePer Day: §6326,654,208"), - MULTIPLIER("§eChocolate Multiplier: §61.77"), - BARN("§eBarn: §6171/190 Rabbits"), - LEADERBOARD_POS("§ePosition: §7#§b103 §7Top §a0.87%"), - EMPTY(""), - EMPTY_2(""), - EMPTY_3(""), - TIME_TOWER("§eTime Tower: §62/3 Charges", { ChocolateFactoryTimeTowerManager.currentCharges() != -1 }), - TIME_TO_PRESTIGE("§eTime To Prestige: §61d 13h 59m 4s", { ChocolateFactoryAPI.currentPrestige != 5 }), - RAW_PER_SECOND("§eRaw Per Second: §62,136"), - ; - - override fun toString(): String { - return display - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTimeTowerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTimeTowerManager.kt deleted file mode 100644 index a1b34a1a4..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTimeTowerManager.kt +++ /dev/null @@ -1,114 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.fame.ReminderUtils -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.HypixelCommands -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SoundUtils -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration -import kotlin.time.Duration.Companion.hours -import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.Duration.Companion.minutes -import kotlin.time.Duration.Companion.seconds - -object ChocolateFactoryTimeTowerManager { - - private val config get() = ChocolateFactoryAPI.config - private val profileStorage get() = ChocolateFactoryAPI.profileStorage - - private var lastTimeTowerWarning = SimpleTimeMark.farPast() - - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!LorenzUtils.inSkyBlock) return - val profileStorage = profileStorage ?: return - - if (SimpleTimeMark(profileStorage.currentTimeTowerEnds).isInPast()) { - profileStorage.currentTimeTowerEnds = SimpleTimeMark.farPast().toMillis() - } - - if (ChocolateFactoryAPI.inChocolateFactory) return - - val nextCharge = SimpleTimeMark(profileStorage.nextTimeTower) - - if (nextCharge.isInPast() && !nextCharge.isFarPast() && currentCharges() < maxCharges()) { - profileStorage.currentTimeTowerUses++ - - val nextTimeTower = SimpleTimeMark(profileStorage.nextTimeTower) + (profileStorage.timeTowerCooldown).hours - profileStorage.nextTimeTower = nextTimeTower.toMillis() - - if (!config.timeTowerWarning) return - ChatUtils.clickableChat( - "Your Time Tower has another charge available §7(${timeTowerCharges()})§e, " + - "Click here to use one", - onClick = { - HypixelCommands.chocolateFactory() - } - ) - SoundUtils.playBeepSound() - lastTimeTowerWarning = SimpleTimeMark.now() - return - } - checkTimeTowerWarning(false) - } - - fun checkTimeTowerWarning(inInventory: Boolean) { - if (!ChocolateFactoryAPI.isEnabled()) return - if (!config.timeTowerWarning) return - if (!timeTowerFull()) return - if (ReminderUtils.isBusy()) return - - val warningSeparation = if (inInventory) 30.seconds else 5.minutes - if (lastTimeTowerWarning.passedSince() < warningSeparation) return - - ChatUtils.clickableChat( - "§cYour Time Tower is full §7(${timeTowerCharges()})§c, " + - "Use one to avoid wasting time tower usages!", - onClick = { - HypixelCommands.chocolateFactory() - } - ) - SoundUtils.playBeepSound() - lastTimeTowerWarning = SimpleTimeMark.now() - } - - fun timeTowerCharges(): String { - return "${currentCharges()}/${maxCharges()} Charges" - } - - fun currentCharges(): Int { - return profileStorage?.currentTimeTowerUses ?: -1 - } - - private fun maxCharges(): Int { - return profileStorage?.maxTimeTowerUses ?: 3 - } - - fun timeTowerFull() = currentCharges() >= maxCharges() - - fun timeTowerActive(): Boolean { - val currentTime = profileStorage?.lastDataSave ?: 0 - val endTime = profileStorage?.currentTimeTowerEnds ?: 0 - - return endTime > currentTime - } - - fun timeTowerActiveDuration(): Duration { - if (!timeTowerActive()) return Duration.ZERO - val currentTime = profileStorage?.lastDataSave ?: 0 - val endTime = profileStorage?.currentTimeTowerEnds ?: 0 - - val duration = endTime - currentTime - return duration.milliseconds - } - - @SubscribeEvent - fun onProfileChange(event: ProfileJoinEvent) { - lastTimeTowerWarning = SimpleTimeMark.farPast() - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltip.kt deleted file mode 100644 index dd09a2402..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltip.kt +++ /dev/null @@ -1,93 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.events.LorenzToolTipEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI.profileStorage -import at.hannibal2.skyhanni.utils.LorenzUtils.round -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object ChocolateFactoryTooltip { - - private val config get() = ChocolateFactoryAPI.config - - private var ignoredSlotIndexes = listOf<Int>() - - fun updateIgnoredSlots() { - ignoredSlotIndexes = listOf( - ChocolateFactoryAPI.prestigeIndex, - ChocolateFactoryAPI.handCookieIndex, - ChocolateFactoryAPI.shrineIndex, - ChocolateFactoryAPI.barnIndex, - ) - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onTooltip(event: LorenzToolTipEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - if (!config.extraTooltipStats) return - - val slotIndex = event.slot.slotNumber - if (slotIndex == ChocolateFactoryAPI.prestigeIndex) return - if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) return - - val upgradeCost = ChocolateFactoryAPI.getChocolateUpgradeCost(event.toolTip) ?: return - - event.toolTip.add("§8§m-----------------") - val timeToUpgrade = ChocolateAmount.CURRENT.formattedTimeUntilGoal(upgradeCost) - - event.toolTip.add("§7Time until upgrade: §e$timeToUpgrade") - - if (slotIndex in ignoredSlotIndexes) return - - val averageChocolate = averageChocPerSecond().round(2) - - val newAverageChocolate = when (slotIndex) { - in ChocolateFactoryAPI.rabbitSlots -> { - val chocolateIncrease = ChocolateFactoryAPI.rabbitSlots[slotIndex] ?: 0 - averageChocPerSecond(rawPerSecondIncrease = chocolateIncrease) - } - - ChocolateFactoryAPI.timeTowerIndex -> averageChocPerSecond(timeTowerLevelIncrease = 1) - ChocolateFactoryAPI.coachRabbitIndex -> averageChocPerSecond(baseMultiplierIncrease = 0.01) - else -> averageChocolate - }.round(2) - - val extra = (newAverageChocolate - averageChocolate).round(2) - val ratioForUpgrade = (upgradeCost / extra).round(2) - - event.toolTip.add("§7Extra: §6$extra §7choc/s") - event.toolTip.add("§7Effective Cost: §6${ratioForUpgrade.addSeparators()}") - - if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) { - event.toolTip.add("§7One charge will give: §6${chocPerTimeTower().addSeparators()}") - } - } - - private fun averageChocPerSecond( - baseMultiplierIncrease: Double = 0.0, - rawPerSecondIncrease: Int = 0, - timeTowerLevelIncrease: Int = 0, - ): Double { - val profileStorage = profileStorage ?: return 0.0 - - val baseMultiplier = profileStorage.chocolateMultiplier + baseMultiplierIncrease - val rawPerSecond = profileStorage.rawChocPerSecond + rawPerSecondIncrease - val timeTowerLevel = profileStorage.timeTowerLevel + timeTowerLevelIncrease - - val timeTowerCooldown = profileStorage.timeTowerCooldown - - val basePerSecond = rawPerSecond * baseMultiplier - val towerCalc = (rawPerSecond * timeTowerLevel * .1) / timeTowerCooldown - - return basePerSecond + towerCalc - } - - private fun chocPerTimeTower(): Int { - val profileStorage = profileStorage ?: return 0 - val amountPerSecond = profileStorage.rawChocPerSecond * profileStorage.timeTowerLevel * .1 - val amountPerHour = amountPerSecond * 60 * 60 - return amountPerHour.toInt() - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltipCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltipCompact.kt deleted file mode 100644 index 00d6783ba..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/menu/ChocolateFactoryTooltipCompact.kt +++ /dev/null @@ -1,77 +0,0 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.menu - -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzToolTipEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.Duration.Companion.seconds - -object ChocolateFactoryTooltipCompact { - private val config get() = ChocolateFactoryAPI.config - - private var lastClick = SimpleTimeMark.farPast() - private var lastHover = SimpleTimeMark.farPast() - private var tooltipToHover = listOf<String>() - - @SubscribeEvent - fun onTooltip(event: LorenzToolTipEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - - if (config.tooltipMove) { - if (event.slot.slotNumber <= 44) { - lastHover = SimpleTimeMark.now() - tooltipToHover = event.toolTip.toList() - event.cancel() - } else { - lastHover = SimpleTimeMark.farPast() - } - return - } - - onCompactClick(event) - } - - @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - if (!ChocolateFactoryAPI.inChocolateFactory) return - if (config.tooltipMove) { - if (lastHover.passedSince() < 300.milliseconds) { - config.tooltipMovePosition.renderStrings(tooltipToHover, posLabel = "Tooltip Move") - } - } - } - - private fun onCompactClick(event: LorenzToolTipEvent) { - if (!config.compactOnClick) return - - val itemStack = event.itemStack - val lore = itemStack.getLore() - if (!lore.any { it == "§7§eClick to uncover the meaning of life!" }) return - if (lastClick.passedSince() >= 1.seconds && !config.compactOnClickAlways) return - val list = mutableListOf<String>() - list.add(itemStack.name) - lore.getOrNull(5)?.let { - list.add(it) - } - event.toolTip = list - return - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - - if (ChocolateFactoryAPI.inChocolateFactory) { - if (event.slotId == 13) { - lastClick = SimpleTimeMark.now() - } - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index 09091532a..6f835b760 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -1,10 +1,10 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index b6767f7b8..9a6a8799d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.DebugDataCollectEvent @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -26,7 +26,7 @@ import kotlin.time.Duration.Companion.seconds object HoppityEggLocator { - private val config get() = ChocolateFactoryAPI.config.hoppityEggs + private val config get() = HoppityEggsManager.config private val locatorItem = "EGGLOCATOR".asInternalName() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggType.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt index 295e95d9c..15f463884 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity import io.github.moulberry.notenoughupdates.util.SkyBlockTime diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index f7dfaf99e..8b3d81c44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -1,11 +1,13 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -20,7 +22,7 @@ import kotlin.time.Duration.Companion.seconds object HoppityEggsManager { - private val config get() = ChocolateFactoryAPI.config.hoppityEggs + val config get() = SkyHanniMod.feature.event.hoppityEggs private val eggFoundPattern by ChocolateFactoryAPI.patternGroup.pattern( "egg.found", @@ -115,4 +117,14 @@ object HoppityEggsManager { fun onSecondPassed(event: SecondPassedEvent) { HoppityEggType.checkClaimed() } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move( + 44, + "event.chocolateFactory.highlightHoppityShop", + "event.chocolateFactory.hoppityEggs.highlightHoppityShop" + ) + event.move(44, "event.chocolateFactory.hoppityEggs", "event.hoppityEggs") + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggsShared.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt index effd33500..5577db3fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityEggsShared.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt @@ -1,8 +1,8 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity.HoppityEggsManager.getEggType +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object HoppityEggsShared { - private val config get() = ChocolateFactoryAPI.config.hoppityEggs + private val config get() = HoppityEggsManager.config /** * REGEX-TEST: CalMWolfs: [SkyHanni] Breakfast Chocolate Egg located at x: 142, y: 71, z: -453 diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 8e8e137ae..199535279 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/chocolatefactory/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -1,11 +1,10 @@ -package at.hannibal2.skyhanni.features.event.chocolatefactory.hoppity +package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.features.event.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -15,7 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object HoppityNpc { - private val config get() = ChocolateFactoryAPI.config + private val config get() = HoppityEggsManager.config private var slotsToHighlight = mutableSetOf<Int>() private var inShop = false |