diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-01 06:50:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 14:50:58 +1000 |
commit | a2abc8845169a5bf2f729e629fee5a9c69c938fb (patch) | |
tree | 0eada21af0961ccf20cb954f159906f6dcf6d727 /src/main/java/at/hannibal2 | |
parent | 4251909d9dd304410f575efa87f0bc9f4bfaf784 (diff) | |
download | skyhanni-a2abc8845169a5bf2f729e629fee5a9c69c938fb.tar.gz skyhanni-a2abc8845169a5bf2f729e629fee5a9c69c938fb.tar.bz2 skyhanni-a2abc8845169a5bf2f729e629fee5a9c69c938fb.zip |
Feature: Chocolate Shop Price (#1601)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
10 files changed, 162 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index b59e6bd9f..0ef928e65 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -276,6 +276,7 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTimeTowerManager import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltip import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltipCompact +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer @@ -637,6 +638,7 @@ class SkyHanniMod { loadModule(ChocolateFactoryTooltipCompact) loadModule(ChocolateFactoryTimeTowerManager) loadModule(ChocolateFactoryTooltip) + loadModule(ChocolateShopPrice) loadModule(HoppityNpc) loadModule(HoppityEggsManager) loadModule(HoppityEggLocator) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index f42470966..86403f24a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config.features.inventory; import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.HasLegacyId; +import at.hannibal2.skyhanni.config.features.inventory.chocolatefactory.ChocolateFactoryConfig; import at.hannibal2.skyhanni.config.features.inventory.helper.HelperConfig; import at.hannibal2.skyhanni.config.features.itemability.ItemAbilityConfig; import at.hannibal2.skyhanni.config.features.misc.EstimatedItemValueConfig; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 7692d28c6..96386bf76 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -1,9 +1,10 @@ -package at.hannibal2.skyhanni.config.features.inventory; +package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory; import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStats.ChocolateFactoryStat; import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; @@ -133,4 +134,10 @@ public class ChocolateFactoryConfig { @ConfigEditorBoolean @FeatureToggle public boolean hoppityMenuShortcut = true; + + @Expose + @ConfigOption(name = "Chocolate Shop Price", desc = "") + @Accordion + public ChocolateShopPriceConfig chocolateShopPrice = new ChocolateShopPriceConfig(); + } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateShopPriceConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateShopPriceConfig.java new file mode 100644 index 000000000..081a5bd93 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateShopPriceConfig.java @@ -0,0 +1,27 @@ +package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class ChocolateShopPriceConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show chocolate to coin prices inside the Chocolate Shop inventory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigLink(owner = ChocolateFactoryConfig.class, field = "chocolateShopPrice") + public Position position = new Position(200, 150, false, true); + + @Expose + @ConfigOption(name = "Item Scale", desc = "Change the size of the items.") + @ConfigEditorSlider(minValue = 0.3f, maxValue = 3, minStep = 0.1f) + public double itemScale = 0.6; +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index b080e53d1..c386bb3b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -23,6 +23,8 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -167,7 +169,8 @@ object GardenAPI { addItemIcon(crop.icon.copy(), highlight, scale = scale) fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory || - SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory || VisitorAPI.inInventory || FFGuideGUI.isInGui() + SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory || VisitorAPI.inInventory || + FFGuideGUI.isInGui() || ChocolateShopPrice.inInventory || ChocolateFactoryAPI.inChocolateFactory fun clearCropSpeed() { storage?.cropsPerSecond?.clear() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index adedbb150..0d86757ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -76,8 +76,8 @@ class SkyMartCopperPrice { } ?: continue val internalName = item.getInternalName() - val lowestBin = internalName.getPriceOrNull() ?: continue - val profit = lowestBin - (otherItemsPrice ?: 0.0) + val itemPrice = internalName.getPriceOrNull() ?: continue + val profit = itemPrice - (otherItemsPrice ?: 0.0) val factor = profit / copper val perFormat = NumberUtil.format(factor) @@ -86,7 +86,7 @@ class SkyMartCopperPrice { val hover = buildList { add(itemName) add("") - add("§7Item price: §6${NumberUtil.format(lowestBin)} ") + add("§7Item price: §6${NumberUtil.format(itemPrice)} ") otherItemsPrice?.let { add("§7Additional cost: §6${NumberUtil.format(it)} ") } @@ -130,8 +130,6 @@ class SkyMartCopperPrice { } } - private fun isEnabled() = GardenAPI.inGarden() && config.copperPrice - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "garden.skyMartCopperPrice", "garden.skyMart.copperPrice") @@ -141,4 +139,6 @@ class SkyMartCopperPrice { JsonPrimitive((it.asDouble / 1.851).round(1)) } } + + private fun isEnabled() = GardenAPI.inGarden() && config.copperPrice } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index 76fd47489..37ddb9a8e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.inventory.chocolatefactory.ChocolateFactoryConfig import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage.ChocolateFactoryStorage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.HoppityEggLocationsJson @@ -35,7 +36,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ChocolateFactoryAPI { - val config get() = SkyHanniMod.feature.inventory.chocolateFactory + val config: ChocolateFactoryConfig get() = SkyHanniMod.feature.inventory.chocolateFactory val profileStorage: ChocolateFactoryStorage? get() = ProfileStorageData.profileSpecific?.chocolateFactory val patternGroup = RepoPattern.group("misc.chocolatefactory") @@ -97,7 +98,7 @@ object ChocolateFactoryAPI { ) private val chocolateFactoryInventoryNamePattern by patternGroup.pattern( "inventory.name", - "Hoppity|Chocolate Shop|Chocolate Factory Milestones" + "Hoppity|Chocolate Factory Milestones" ) var rabbitSlots = mapOf<Int, Int>() @@ -176,7 +177,7 @@ object ChocolateFactoryAPI { } val lore = item.getLore() - val upgradeCost = getChocolateUpgradeCost(lore) ?: continue + val upgradeCost = getChocolateBuyCost(lore) ?: continue val canAfford = upgradeCost <= ChocolateAmount.CURRENT.chocolate() if (canAfford) upgradeableSlots.add(slotIndex) @@ -351,7 +352,7 @@ object ChocolateFactoryAPI { event.move(44, "$old.hoppityStatsPosition", "$new.hoppityStatsPosition") } - fun getChocolateUpgradeCost(lore: List<String>): Long? { + fun getChocolateBuyCost(lore: List<String>): Long? { val nextLine = lore.nextAfter({ UtilsPatterns.costLinePattern.matches(it) }) ?: return null return chocolateAmountPattern.matchMatcher(nextLine.removeColor()) { group("amount").formatLong() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt index 227ece8d9..9d556f64b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt @@ -31,7 +31,7 @@ object ChocolateFactoryTooltip { if (slotIndex == ChocolateFactoryAPI.prestigeIndex) return if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) return - val upgradeCost = ChocolateFactoryAPI.getChocolateUpgradeCost(event.toolTip) ?: return + val upgradeCost = ChocolateFactoryAPI.getChocolateBuyCost(event.toolTip) ?: return event.toolTip.add("§8§m-----------------") val timeToUpgrade = ChocolateAmount.CURRENT.formattedTimeUntilGoal(upgradeCost) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt new file mode 100644 index 000000000..37127d11b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -0,0 +1,99 @@ +package at.hannibal2.skyhanni.features.inventory.chocolatefactory + +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.utils.DisplayTableEntry +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.million +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object ChocolateShopPrice { + private val config get() = ChocolateFactoryAPI.config.chocolateShopPrice + + private var display = emptyList<Renderable>() + + private val menuNamePattern by ChocolateFactoryAPI.patternGroup.pattern( + "shop.title", + "Chocolate Shop" + ) + + var inInventory = false + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!isEnabled()) return + if (!menuNamePattern.matches(event.inventoryName)) return + + val multiplier = 1.million + + inInventory = true + // TODO merge core with SkyMartCopperPrice into a utils + val table = mutableListOf<DisplayTableEntry>() + for ((slot, item) in event.inventoryItems) { + val lore = item.getLore() + val chocolate = ChocolateFactoryAPI.getChocolateBuyCost(lore) ?: continue + val internalName = item.getInternalName() + val itemPrice = internalName.getPriceOrNull() ?: continue + + val factor = (itemPrice / chocolate) * multiplier + val perFormat = NumberUtil.format(factor) + + val itemName = item.itemName + val hover = buildList { + add(itemName) + + add("") + add("§7Item price: §6${NumberUtil.format(itemPrice)} ") + add("§7Chocolate amount: §c${NumberUtil.format(chocolate)} ") + + add("") + add("§7Profit per million chocolate: §6${perFormat} ") + } + table.add( + DisplayTableEntry( + "$itemName§f:", + "§6§l$perFormat", + factor, + internalName, + hover, + highlightsOnHoverSlots = listOf(slot) + ) + ) + } + + val newList = mutableListOf<Renderable>() + newList.add(Renderable.string("§eCoins per million chocolate§f:")) + // TODO update this value every second + // TODO add time until can afford + newList.add(Renderable.string("§eChocolate available: §6${ChocolateAmount.CURRENT.formatted}")) + newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = config.itemScale)) + display = newList + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent + fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { + if (inInventory) { + config.position.renderRenderables( + display, + extraSpace = 5, + posLabel = "Chocolate Shop Price" + ) + } + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index 8aa031b2d..9d9654353 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -84,12 +84,12 @@ object DiscordRPCManager : IPCListener { } catch (ex: Exception) { logger.warn("Failed to connect to RPC!", ex) ChatUtils.clickableChat( - "Discord Rich Presence was unable to start! " + + "Discord Rich Presence was unable to start! " + "This usually happens when you join SkyBlock when Discord is not started. " + "Please run /shrpcstart to retry once you have launched Discord.", - onClick = { - startCommand() - } + onClick = { + startCommand() + } ) } } @@ -125,10 +125,12 @@ object DiscordRPCManager : IPCListener { setLargeImage(discordIconKey, location) if (config.showSkyCryptButton.get()) { - addButton(RichPresenceButton( - "https://sky.shiiyu.moe/stats/${LorenzUtils.getPlayerName()}/${HypixelData.profileName}", - "Open SkyCrypt Profile" - )) + addButton( + RichPresenceButton( + "https://sky.shiiyu.moe/stats/${LorenzUtils.getPlayerName()}/${HypixelData.profileName}", + "Open SkyCrypt Profile" + ) + ) } }.build()) } |