From a2abc8845169a5bf2f729e629fee5a9c69c938fb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 1 May 2024 06:50:58 +0200 Subject: Feature: Chocolate Shop Price (#1601) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../features/inventory/ChocolateFactoryConfig.java | 136 -------------------- .../config/features/inventory/InventoryConfig.java | 1 + .../chocolatefactory/ChocolateFactoryConfig.java | 143 +++++++++++++++++++++ .../chocolatefactory/ChocolateShopPriceConfig.java | 27 ++++ .../skyhanni/features/garden/GardenAPI.kt | 5 +- .../garden/inventory/SkyMartCopperPrice.kt | 10 +- .../chocolatefactory/ChocolateFactoryAPI.kt | 9 +- .../chocolatefactory/ChocolateFactoryTooltip.kt | 2 +- .../chocolatefactory/ChocolateShopPrice.kt | 99 ++++++++++++++ .../features/misc/discordrpc/DiscordRPCManager.kt | 18 +-- 11 files changed, 297 insertions(+), 155 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChocolateFactoryConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateShopPriceConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt (limited to 'src/main/java') 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/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChocolateFactoryConfig.java deleted file mode 100644 index 7692d28c6..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/ChocolateFactoryConfig.java +++ /dev/null @@ -1,136 +0,0 @@ -package at.hannibal2.skyhanni.config.features.inventory; - -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.ConfigEditorBoolean; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; -import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ChocolateFactoryConfig { - - @Expose - @ConfigOption(name = "Chocolate Factory Features", desc = "Global toggle for all chocolate factory features.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; - - @Expose - @ConfigOption(name = "Chocolate Factory Stats", desc = "Show general info about your chocolate factory.") - @ConfigEditorBoolean - @FeatureToggle - public boolean statsDisplay = true; - - @Expose - @ConfigOption( - name = "Stats List", - desc = "Drag text to change what displays in the chocolate factory stats list and what order the text appears in." - ) - @ConfigEditorDraggableList - public List statsDisplayList = new ArrayList<>(Arrays.asList( - ChocolateFactoryStat.HEADER, - ChocolateFactoryStat.CURRENT, - ChocolateFactoryStat.THIS_PRESTIGE, - ChocolateFactoryStat.ALL_TIME, - ChocolateFactoryStat.TIME_TO_PRESTIGE, - ChocolateFactoryStat.EMPTY, - ChocolateFactoryStat.PER_SECOND, - ChocolateFactoryStat.PER_MINUTE, - ChocolateFactoryStat.PER_HOUR, - ChocolateFactoryStat.PER_DAY, - ChocolateFactoryStat.EMPTY_2, - ChocolateFactoryStat.MULTIPLIER, - ChocolateFactoryStat.BARN, - ChocolateFactoryStat.TIME_TOWER, - ChocolateFactoryStat.LEADERBOARD_POS - )); - - @Expose - @ConfigOption(name = "Show Stack Sizes", desc = "Shows additional info as many items in the chocolate menu as the stack size.") - @ConfigEditorBoolean - public boolean showStackSizes = true; - - @Expose - @ConfigOption(name = "Highlight Upgrades", desc = "Highlight any upgrades that you can afford. The upgrade with a star is the most optimal and the lightest colour of green is the most optimal you can afford.") - @ConfigEditorBoolean - public boolean highlightUpgrades = true; - - @Expose - @ConfigOption(name = "Use Middle Click", desc = "Click on slots with middle click to speed up interactions.") - @ConfigEditorBoolean - public boolean useMiddleClick = true; - - @Expose - @ConfigOption(name = "Rabbit Warning", desc = "Warn when the rabbit that needs to be clicked appears.") - @ConfigEditorBoolean - public boolean rabbitWarning = true; - - @Expose - @ConfigOption( - name = "Rabbit Crush Threshold", - desc = "How close should you be to your barn capacity before being warned about needing to upgrade it." - ) - @ConfigEditorSlider(minValue = 0, maxValue = 20, minStep = 1) - public int barnCapacityThreshold = 6; - - @Expose - @ConfigOption(name = "Extra Tooltip Stats", desc = "Shows extra information about upgrades in the tooltip.") - @ConfigEditorBoolean - @FeatureToggle - public boolean extraTooltipStats = true; - - @Expose - @ConfigOption(name = "Time Tower Warning", desc = "Notification when you have a new time tower usage available and " + - "continuously warn when your time tower is full.") - @ConfigEditorBoolean - @FeatureToggle - public boolean timeTowerWarning = false; - - @Expose - @ConfigLink(owner = ChocolateFactoryConfig.class, field = "statsDisplay") - public Position position = new Position(163, 160, false, true); - - @Expose - @ConfigOption(name = "Compact On Click", desc = "Compact the item toolip when clicking on the chocolate.") - @ConfigEditorBoolean - @FeatureToggle - public boolean compactOnClick = true; - - @Expose - @ConfigOption(name = "Always Compact", desc = "Always Compact the item toolip on the chocolate. Requires the above option to be enabled.") - @ConfigEditorBoolean - public boolean compactOnClickAlways = false; - - @Expose - @ConfigOption(name = "Tooltip Move", desc = "Move Tooltip away from the item you hover over while inside the Chocolate Factory.") - @ConfigEditorBoolean - @FeatureToggle - public boolean tooltipMove = false; - - @Expose - @ConfigLink(owner = ChocolateFactoryConfig.class, field = "tooltipMove") - public Position tooltipMovePosition = new Position(-380, 150, false, true); - - @Expose - @ConfigOption(name = "Hoppity Collection Stats", desc = "Shows info about your hoppity rabbit collection.") - @ConfigEditorBoolean - @FeatureToggle - public boolean hoppityCollectionStats = true; - - @Expose - @ConfigLink(owner = ChocolateFactoryConfig.class, field = "hoppityCollectionStats") - public Position hoppityStatsPosition = new Position(163, 160, false, true); - - @Expose - @ConfigOption(name = "Hoppity Menu Shortcut", desc = "Add a Chocolate Factory button in the SkyBlock Menu that runs /chocolatefactory on click.") - @ConfigEditorBoolean - @FeatureToggle - public boolean hoppityMenuShortcut = true; -} 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/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java new file mode 100644 index 000000000..96386bf76 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -0,0 +1,143 @@ +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; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ChocolateFactoryConfig { + + @Expose + @ConfigOption(name = "Chocolate Factory Features", desc = "Global toggle for all chocolate factory features.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Chocolate Factory Stats", desc = "Show general info about your chocolate factory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean statsDisplay = true; + + @Expose + @ConfigOption( + name = "Stats List", + desc = "Drag text to change what displays in the chocolate factory stats list and what order the text appears in." + ) + @ConfigEditorDraggableList + public List statsDisplayList = new ArrayList<>(Arrays.asList( + ChocolateFactoryStat.HEADER, + ChocolateFactoryStat.CURRENT, + ChocolateFactoryStat.THIS_PRESTIGE, + ChocolateFactoryStat.ALL_TIME, + ChocolateFactoryStat.TIME_TO_PRESTIGE, + ChocolateFactoryStat.EMPTY, + ChocolateFactoryStat.PER_SECOND, + ChocolateFactoryStat.PER_MINUTE, + ChocolateFactoryStat.PER_HOUR, + ChocolateFactoryStat.PER_DAY, + ChocolateFactoryStat.EMPTY_2, + ChocolateFactoryStat.MULTIPLIER, + ChocolateFactoryStat.BARN, + ChocolateFactoryStat.TIME_TOWER, + ChocolateFactoryStat.LEADERBOARD_POS + )); + + @Expose + @ConfigOption(name = "Show Stack Sizes", desc = "Shows additional info as many items in the chocolate menu as the stack size.") + @ConfigEditorBoolean + public boolean showStackSizes = true; + + @Expose + @ConfigOption(name = "Highlight Upgrades", desc = "Highlight any upgrades that you can afford. The upgrade with a star is the most optimal and the lightest colour of green is the most optimal you can afford.") + @ConfigEditorBoolean + public boolean highlightUpgrades = true; + + @Expose + @ConfigOption(name = "Use Middle Click", desc = "Click on slots with middle click to speed up interactions.") + @ConfigEditorBoolean + public boolean useMiddleClick = true; + + @Expose + @ConfigOption(name = "Rabbit Warning", desc = "Warn when the rabbit that needs to be clicked appears.") + @ConfigEditorBoolean + public boolean rabbitWarning = true; + + @Expose + @ConfigOption( + name = "Rabbit Crush Threshold", + desc = "How close should you be to your barn capacity before being warned about needing to upgrade it." + ) + @ConfigEditorSlider(minValue = 0, maxValue = 20, minStep = 1) + public int barnCapacityThreshold = 6; + + @Expose + @ConfigOption(name = "Extra Tooltip Stats", desc = "Shows extra information about upgrades in the tooltip.") + @ConfigEditorBoolean + @FeatureToggle + public boolean extraTooltipStats = true; + + @Expose + @ConfigOption(name = "Time Tower Warning", desc = "Notification when you have a new time tower usage available and " + + "continuously warn when your time tower is full.") + @ConfigEditorBoolean + @FeatureToggle + public boolean timeTowerWarning = false; + + @Expose + @ConfigLink(owner = ChocolateFactoryConfig.class, field = "statsDisplay") + public Position position = new Position(163, 160, false, true); + + @Expose + @ConfigOption(name = "Compact On Click", desc = "Compact the item toolip when clicking on the chocolate.") + @ConfigEditorBoolean + @FeatureToggle + public boolean compactOnClick = true; + + @Expose + @ConfigOption(name = "Always Compact", desc = "Always Compact the item toolip on the chocolate. Requires the above option to be enabled.") + @ConfigEditorBoolean + public boolean compactOnClickAlways = false; + + @Expose + @ConfigOption(name = "Tooltip Move", desc = "Move Tooltip away from the item you hover over while inside the Chocolate Factory.") + @ConfigEditorBoolean + @FeatureToggle + public boolean tooltipMove = false; + + @Expose + @ConfigLink(owner = ChocolateFactoryConfig.class, field = "tooltipMove") + public Position tooltipMovePosition = new Position(-380, 150, false, true); + + @Expose + @ConfigOption(name = "Hoppity Collection Stats", desc = "Shows info about your hoppity rabbit collection.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hoppityCollectionStats = true; + + @Expose + @ConfigLink(owner = ChocolateFactoryConfig.class, field = "hoppityCollectionStats") + public Position hoppityStatsPosition = new Position(163, 160, false, true); + + @Expose + @ConfigOption(name = "Hoppity Menu Shortcut", desc = "Add a Chocolate Factory button in the SkyBlock Menu that runs /chocolatefactory on click.") + @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() @@ -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): Long? { + fun getChocolateBuyCost(lore: List): 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() + + 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() + 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() + 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()) } -- cgit