From a84a1d72229688773f277a52bb5277bc58785447 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 20 Dec 2023 10:48:21 +0100 Subject: [PATCH 01/22] Bazaar best sell method now warns if an unknown bazaar item is detected. --- .../hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt | 4 ++-- .../at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 8 ++++---- .../skyhanni/features/bazaar/BazaarBestSellMethod.kt | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt index a746d7468b4b..e4995564de97 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/BazaarOpenedProductEvent.kt @@ -2,5 +2,5 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.utils.NEUInternalName -class BazaarOpenedProductEvent(val openedProduct: NEUInternalName, val inventoryOpenEvent: InventoryFullyOpenedEvent) : - LorenzEvent() \ No newline at end of file +class BazaarOpenedProductEvent(val openedProduct: NEUInternalName?, val inventoryOpenEvent: InventoryFullyOpenedEvent) : + LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index 0f14c98c3fef..a7dd3e845244 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -58,20 +58,20 @@ class BazaarApi { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { inBazaarInventory = checkIfInBazaar(event) if (inBazaarInventory) { - val openedProduct = getOpenedProduct(event.inventoryItems) ?: return + val itemName = getOpenedProduct(event.inventoryItems) ?: return + val openedProduct = NEUItems.getInternalNameOrNull(itemName) currentlyOpenedProduct = openedProduct BazaarOpenedProductEvent(openedProduct, event).postAndCatch() } } - private fun getOpenedProduct(inventoryItems: Map): NEUInternalName? { + private fun getOpenedProduct(inventoryItems: Map): String? { val buyInstantly = inventoryItems[10] ?: return null if (buyInstantly.displayName != "§aBuy Instantly") return null val bazaarItem = inventoryItems[13] ?: return null - val itemName = bazaarItem.displayName - return NEUItems.getInternalNameOrNull(itemName) + return bazaarItem.displayName } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt index b42a331fef9b..f78b682d7ece 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarBestSellMethod.kt @@ -42,7 +42,10 @@ class BazaarBestSellMethod { display = updateDisplay(event.openedProduct) } - private fun updateDisplay(internalName: NEUInternalName): String { + private fun updateDisplay(internalName: NEUInternalName?): String { + if (internalName == null) { + return "§cUnknown Bazaar item!" + } try { var having = InventoryUtils.countItemsInLowerInventory { it.getInternalName() == internalName } lastClickedItem?.let { @@ -78,4 +81,4 @@ class BazaarBestSellMethod { } private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.bestSellMethod -} \ No newline at end of file +} From 060d521dfc1358ce36179a1df9b4397d04fe4f3a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 20 Dec 2023 10:50:56 +0100 Subject: [PATCH 02/22] code cleanup --- .../skyhanni/config/features/misc/TrackerConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java index 0451bfb00435..307395a7a733 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java @@ -69,9 +69,9 @@ public String toString() { @Expose @ConfigOption(name = "Item Warnings", desc = "Item Warnings") @Accordion - public TrackerWarningConfig warnings = new TrackerWarningConfig(); + public TrackerItemWarningsConfig warnings = new TrackerItemWarningsConfig(); - public static class TrackerWarningConfig { + public static class TrackerItemWarningsConfig { @Expose @ConfigOption(name = "Price in Chat", desc = "Show an extra chat message when you pick up an expensive item. " + From 1279308d07da76fba65a2a0508bcc9b115a0ee81 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:48:35 +0100 Subject: [PATCH 03/22] Added option to Hide Cheap Items in Slayer, Fishing and Diana Item Profit Trackers. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../config/features/misc/TrackerConfig.java | 24 ++++++++++++ .../hannibal2/skyhanni/data/TrackerManager.kt | 37 +++++++++++++++++++ .../utils/tracker/SkyHanniItemTracker.kt | 18 ++++++++- .../skyhanni/utils/tracker/SkyHanniTracker.kt | 3 +- 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a5e0487c5e68..3cd9830d863c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -41,6 +41,7 @@ import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.data.TitleData import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.data.ToolTipData +import at.hannibal2.skyhanni.data.TrackerManager import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson @@ -415,6 +416,7 @@ class SkyHanniMod { loadModule(AdvancedPlayerList) loadModule(ItemAddManager()) loadModule(BingoCardReader()) + loadModule(TrackerManager) // APIs loadModule(BazaarApi()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java index 307395a7a733..643ce637bee1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/TrackerConfig.java @@ -96,4 +96,28 @@ public static class TrackerItemWarningsConfig { @ConfigEditorSlider(minValue = 1, maxValue = 50_000_000, minStep = 1) public int minimumTitle = 5_000_000; } + + @Expose + @ConfigOption(name = "Hide Cheap Items", desc = "Hide cheap items.") + @Accordion + public HideCheapItemsConfig hideCheapItems = new HideCheapItemsConfig(); + + public static class HideCheapItemsConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Limit how many items should be shown.") + @ConfigEditorBoolean + public Property enabled = Property.of(true); + + @Expose + @ConfigOption(name = "Show Expensive #", desc = "Always show the # most expensive items.") + @ConfigEditorSlider(minValue = 1, maxValue = 40, minStep = 1) + public Property alwaysShowBest = Property.of(8); + + @Expose + @ConfigOption(name = "Still Show Above", desc = "Always show items above this §6price in 1k §7even when not in the top # of items.") + @ConfigEditorSlider(minValue = 5, maxValue = 500, minStep = 5) + public Property minPrice = Property.of(100); + + } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt new file mode 100644 index 000000000000..de9caa02e33f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt @@ -0,0 +1,37 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object TrackerManager { + + private var hasChanged = false + var dirty = false + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val config = SkyHanniMod.feature.misc.tracker.hideCheapItems + LorenzUtils.onToggle(config.alwaysShowBest, config.minPrice, config.enabled) { + hasChanged = true + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + fun onRenderOverlayFirst(event: GuiRenderEvent) { + if (hasChanged) { + dirty = true + } + } + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onRenderOverlayLast(event: GuiRenderEvent) { + if (hasChanged) { + dirty = false + hasChanged = false + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 60d094dbeb6f..9183dad623bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -125,9 +125,25 @@ class SkyHanniItemTracker( } } - for (text in items.sortedDesc().keys) { + val limitList = config.hideCheapItems + var pos = 0 + var hiddenItems = 0 + for ((text, pricePer) in items.sortedDesc()) { + pos++ + if (limitList.enabled.get()) { + if (pos > limitList.alwaysShowBest.get()) { + if (pricePer < limitList.minPrice.get() * 1000) { + hiddenItems++ + continue + } + } + } lists.addAsSingletonList(text) } + if (hiddenItems > 0) { + lists.addAsSingletonList(" §7$hiddenItems cheap items are hidden.") + } + return profit } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index ad3418acebc2..234902c10423 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.TrackerManager import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.utils.ConfigUtils @@ -87,7 +88,7 @@ open class SkyHanniTracker( update() } - if (dirty) { + if (dirty || TrackerManager.dirty) { display = getSharedTracker()?.let { buildFinalDisplay(drawDisplay(it.get(getDisplayMode()))) } ?: emptyList() From aecd1898ddb6db4c1727e98b9b0d7d974c269f7a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:14:07 +0100 Subject: [PATCH 04/22] Fixed medal icon in jacob inventory. --- .../garden/contest/JacobFarmingContestsInventory.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt index dfc83e40458a..f45e909ff630 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -31,7 +32,10 @@ class JacobFarmingContestsInventory { // Render the contests a tick delayed to feel smoother private var hideEverything = true - private val medalPattern = "§7§7You placed in the (?.*)".toPattern() + private val medalPattern by RepoPattern.pattern( + "garden.jacob.contests.inventory.medal", + "§7§7You placed in the (?.*) §7bracket!" + ) @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { From 3a309af2d544a98080645143dcef36dfd1b5633b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:31:57 +0100 Subject: [PATCH 05/22] Added a Patreon because my sister and a good friend were bugging me to do so. --- README.md | 4 ++++ src/main/java/at/hannibal2/skyhanni/config/Features.java | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e1c95c8e83a..3452be12756b 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,8 @@ our [Discord](https://discord.gg/skyhanni-997079228510117908). If you are interested in the technical side of SkyHanni, read the [Contributing Guide](https://github.com/hannibal002/SkyHanni/blob/beta/CONTRIBUTING.md). +Please support me on [Patreon](https://www.patreon.com/hannibal2). +(*Guys I need money to eat* ~Forrick) + + *Check out some other really cool 1.8.9 mods [here](https://sbmw.ca/mod-lists/skyblock-mod-list/)* diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index e4f9e548effd..ded615520457 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -36,6 +36,7 @@ public class Features extends Config { public static final ResourceLocation DISCORD = new ResourceLocation("notenoughupdates:social/discord.png"); public static final ResourceLocation GITHUB = new ResourceLocation("notenoughupdates:social/github.png"); + public static final ResourceLocation PATREON = new ResourceLocation("notenoughupdates:social/patreon.png"); @Override public boolean shouldAutoFocusSearchbar() { @@ -45,8 +46,9 @@ public boolean shouldAutoFocusSearchbar() { @Override public List getSocials() { return Arrays.asList( - Social.forLink("Join our Discord", DISCORD, "https://discord.com/invite/skyhanni-997079228510117908"), - Social.forLink("Look at the code", GITHUB, "https://github.com/hannibal002/SkyHanni") + Social.forLink("Discord", DISCORD, "https://discord.com/invite/skyhanni-997079228510117908"), + Social.forLink("GitHub", GITHUB, "https://github.com/hannibal002/SkyHanni"), + Social.forLink("Patreon", PATREON, "https://www.patreon.com/hannibal2") ); } From b6d939ade1289e7e6170ceaeaaa03658e1439283 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:42:46 +0100 Subject: [PATCH 06/22] Fixed /gfs command counting to slayer profit tracker. --- .../skyhanni/data/OwnInventoryData.kt | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index a7b31159b488..97065766e548 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent @@ -9,10 +10,13 @@ import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull +import at.hannibal2.skyhanni.utils.ItemUtils.getItemName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S0DPacketCollectItem import net.minecraft.network.play.server.S2FPacketSetSlot @@ -24,6 +28,10 @@ import kotlin.time.Duration.Companion.milliseconds class OwnInventoryData { private var itemAmounts = mapOf() private var dirty = false + private val sackToInventoryChatPattern by RepoPattern.pattern( + "data.owninventory.chat.movedsacktoinventory", + "§aMoved §r§e\\d* (?.*)§r§a from your Sacks to your inventory." + ) @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { @@ -96,6 +104,14 @@ class OwnInventoryData { ignoreItem(500.milliseconds) { true } } + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + sackToInventoryChatPattern.matchMatcher(event.message) { + val name = group("name") + ignoreItem(500.milliseconds) { it.getItemName().contains(name) } + } + } + private fun ignoreItem(duration: Duration, condition: (NEUInternalName) -> Boolean) { ignoredItemsUntil.add(IgnoredItem(condition, SimpleTimeMark.now() + duration)) } @@ -109,7 +125,10 @@ class OwnInventoryData { if (diffWorld < 3_000) return ignoredItemsUntil.removeIf { it.blockedUntil.isInPast() } - if (ignoredItemsUntil.any { it.condition(internalName) }) return + if (ignoredItemsUntil.any { it.condition(internalName) }) { +// println("ignored: $internalName") + return + } if (internalName.startsWith("MAP-")) return From 20137951c22863503b1ffe0bc6eada76830cfc06 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 01:55:56 +0100 Subject: [PATCH 07/22] Fixed Hide Healer Fairy not working anymore. --- .../at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt index 801b28ab46d8..e654fc4a939a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt @@ -150,7 +150,8 @@ class DungeonHideItems { } if (config.hideHealerFairy) { - if (skullTexture == healerFairyTexture) { + // Healer Fairy texture is stored in id 0, not id 4 for some reasos. + if (entity.inventory[0]?.getSkullTexture() == healerFairyTexture) { event.isCanceled = true return } From 8307ea7899f6c6a9500f1decccdbe4ef388445b9 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:01:59 +0100 Subject: [PATCH 08/22] Fixed barn fishing reset hotkey triggering while inside a GUI. --- .../at/hannibal2/skyhanni/features/fishing/FishingTimer.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt index 501b217f42f1..8943e74d64da 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils +import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -41,7 +42,9 @@ class FishingTimer { if (event.isMod(5)) checkMobs() if (event.isMod(7)) tryPlaySound() - if (config.manualResetTimer.isKeyHeld()) startTime = System.currentTimeMillis() + if (config.manualResetTimer.isKeyHeld() && Minecraft.getMinecraft().currentScreen == null) { + startTime = System.currentTimeMillis() + } } private fun tryPlaySound() { From abc12e38b28864f2b3aba213e651775ea4cc8f4e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:13:45 +0100 Subject: [PATCH 09/22] SkyHanni position editor hotkey now works outside SkyBlock as well. --- src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 29a344b18478..b7901d078a39 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -28,7 +28,7 @@ class GuiEditManager { @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { - if (!LorenzUtils.inSkyBlock) return + if (!LorenzUtils.onHypixel) return if (event.keyCode != SkyHanniMod.feature.gui.keyBindOpen) return if (isInGui()) return From 0b9eb5560844675e44ef794aa8cf5dd40fdf6ee0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:16:30 +0100 Subject: [PATCH 10/22] Dungeon party finder highlight features now work outside Dungeon Hub as well. --- .../skyhanni/features/dungeon/DungeonFinderFeatures.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt index a1fdc018e895..0413be873c4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt @@ -92,7 +92,7 @@ class DungeonFinderFeatures { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { - if (!LorenzUtils.inSkyBlock || LorenzUtils.skyBlockArea != "Dungeon Hub") return + if (!LorenzUtils.inSkyBlock) return if (event.gui !is GuiChest) return val chest = event.gui.inventorySlots as ContainerChest From 5de98b869c621f71a389f1aae2175547a83926bc Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 02:31:59 +0100 Subject: [PATCH 11/22] Fixed Fire Veil effect and item ability cooldown not working when clicking in the air. --- .../at/hannibal2/skyhanni/data/ItemClickData.kt | 14 +++++++------- .../at/hannibal2/skyhanni/events/ItemClickEvent.kt | 3 ++- .../itemabilities/FireVeilWandParticles.kt | 13 ++++++------- .../abilitycooldown/ItemAbilityCooldown.kt | 11 ++++------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt index 3d154666f07e..3ffc44719486 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -10,7 +10,6 @@ import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft import net.minecraft.network.play.client.C07PacketPlayerDigging import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement -import net.minecraft.network.play.client.C0APacketAnimation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Mouse @@ -20,17 +19,18 @@ class ItemClickData { @SubscribeEvent fun onItemClickSend(event: PacketEvent.SendEvent) { val packet = event.packet - if (packet is C08PacketPlayerBlockPlacement && packet.placedBlockDirection != 255) { - val position = packet.position.toLorenzVec() - BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch() + if (packet is C08PacketPlayerBlockPlacement) { + if (packet.placedBlockDirection != 255) { + val position = packet.position.toLorenzVec() + BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch() + } else { + ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).postAndCatch() + } } if (packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) { val position = packet.position.toLorenzVec() BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).postAndCatch() } - if (packet is C0APacketAnimation) { - ItemClickEvent(InventoryUtils.getItemInHand()).postAndCatch() - } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt index c0c4f4e831c0..5bf89558ad29 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.data.ClickType import net.minecraft.item.ItemStack -class ItemClickEvent(val itemInHand: ItemStack?) : LorenzEvent() \ No newline at end of file +class ItemClickEvent(val itemInHand: ItemStack?, val clickType: ClickType) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt index 9154df2e51a4..2bbf8050254c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.itemability.FireVeilWandConfig.DisplayEntry import at.hannibal2.skyhanni.data.ClickType -import at.hannibal2.skyhanni.events.BlockClickEvent +import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.ConfigUtils @@ -35,15 +35,14 @@ class FireVeilWandParticles { } @SubscribeEvent - fun onBlockClick(event: BlockClickEvent) { + fun onItemClick(event: ItemClickEvent) { if (!LorenzUtils.inSkyBlock) return + if (event.clickType != ClickType.RIGHT_CLICK) return - if (event.clickType == ClickType.RIGHT_CLICK) { - val internalName = event.itemInHand?.getInternalName() ?: return + val internalName = event.itemInHand?.getInternalName() ?: return - if (internalName == item) { - lastClick = System.currentTimeMillis() - } + if (internalName == item) { + lastClick = System.currentTimeMillis() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index 237fca803aab..08e2b9820469 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.ItemRenderBackground.Companion.background -import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzActionBarEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -158,14 +158,11 @@ class ItemAbilityCooldown { } } - @SubscribeEvent - fun onBlockClickSend(event: BlockClickEvent) { - handleItemClick(event.itemInHand) - } - @SubscribeEvent fun onItemClick(event: ItemClickEvent) { - handleItemClick(event.itemInHand) + if (event.clickType == ClickType.RIGHT_CLICK) { + handleItemClick(event.itemInHand) + } } private fun handleItemClick(itemInHand: ItemStack?) { From c341ba399ccc23695ab7c7a7e02b68dd48332269 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:22:11 +0100 Subject: [PATCH 12/22] Fixed ah copy underbid price --- .../features/misc/items/AuctionHouseCopyUnderbidPrice.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt index 0f2a45659dbb..11a51749ed05 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt @@ -24,7 +24,10 @@ class AuctionHouseCopyUnderbidPrice { if (internalName == NEUInternalName.NONE) return val price = internalName.getPrice().toLong() - 1 - if (price <= 0) return + if (price <= 0) { + OSUtils.copyToClipboard("") + return + } OSUtils.copyToClipboard("$price") LorenzUtils.chat("Set §e${price.addSeparators()} §eto clipboard. (Copy Underbid Price)") } From fac81a0d521cbaa6b3feadf31d049fc236fbb039 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:26:43 +0100 Subject: [PATCH 13/22] Version 0.22 Beta 16 --- CHANGELOG.md | 12 ++++++++++++ build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 667899031d86..1cf603c8eb77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,10 @@ + Added an option to not show cooldown when ability is ready. - Obsidian + Added an option to highlight dungeon perm/vc parties. - Cad + Added Glowing Mush Mixin support to the Non-God Pod display. - jani ++ Added options to hide cheap items in item profit trackers. - hannibal2 ++ Bazaar Best Sell Method now warns if an unknown bazaar item is detected. - hannibal2 ++ SkyHanni position editor hotkey now work outside SkyBlock as well. - hannibal2 ++ Dungeon party finder highlight features now works outside Dungeon Hub as well. - hannibal2 ### Fixes @@ -214,6 +218,7 @@ + Fixed sixth visitor warning title showing when disabled. - alexia + Show not revealed brackets in the Jacob Contest time needed display. - hannibal2 + Fixed wrong Rancher Boots item stack size color in combination with Black Cat or Racing Helmet.- hannibal2 ++ Fixed showing medal icons in Jacob inventory. - hannibal2 #### Bingo Fixes @@ -233,6 +238,7 @@ + Fixed Water Hydra warning showing up multiple times. - Cad + Fixed Shark Message missing a color code. - jani + Fixed /shresetfishingtracker description - absterge ++ Fixed barn fishing reset hotkey triggering while inside a GUI. - hannibal2 #### Diana Fixes @@ -245,6 +251,10 @@ + Fixed an error message on /pt. - nea + Fixed the fire sale filter when a rune is selling. - j10a1n15 +#### Dungeon Fixes + ++ Fixed Hide Healer Fairy. - hannibal2 + #### Misc Fixes + Fixed Item Tracker not ignoring manual sack movements. - hannibal2 @@ -264,6 +274,8 @@ + Fixed kick alert triggering instantly. - alexia + Fixed daily boss kill detection in Crimson Isle Reputation Helper. - hannibal2 + Fixed Estimated Item Value error in Jerry's Island Deliveries menu. - hannibal2 ++ Fixed the /gfs command counting in the Slayer Profit Tracker. - hannibal2 ++ Fixed the Fire Veil effect and item ability cooldown not working when clicking in the air. - hannibal2 #### Config Fixes diff --git a/build.gradle.kts b/build.gradle.kts index 10873818e015..67095147ccf7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.22.Beta.15" +version = "0.22.Beta.16" val gitHash by lazy { val baos = ByteArrayOutputStream() diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 3cd9830d863c..c04e67c90f43 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -361,7 +361,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.22.Beta.15", + version = "0.22.Beta.16", ) class SkyHanniMod { @Mod.EventHandler From c9757841e10bb214e8fd7edd0f07e5c5ef88fe4a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:48:55 +0100 Subject: [PATCH 14/22] Highlight underbid own lowest BIN auctions that are outbid. --- .../features/inventory/InventoryConfig.java | 7 ++++++ .../features/inventory/AuctionsHighlighter.kt | 25 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) 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 01d9a29fe87d..1478df3ad2a6 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 @@ -162,6 +162,13 @@ public String toString() { @FeatureToggle public boolean highlightAuctions = true; + @Expose + @ConfigOption(name = "Highlight Underbid Auctions", + desc = "Highlight underbid own lowest BIN auctions that are outbid.") + @ConfigEditorBoolean + @FeatureToggle + public boolean highlightAuctionsUnderbid = false; + @Expose @ConfigOption(name = "Copy Underbid Price", desc = "Copies the price of an item in the \"Create BIN Auction\" minus 1 coin into the clipboard for faster under-bidding.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt index 453707c5b7d2..f512733b8a26 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -3,20 +3,27 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class AuctionsHighlighter { + private val config get() = SkyHanniMod.feature.inventory + private val buyItNowPattern by RepoPattern.pattern("auctions.highlight.buyitnow", "§7Buy it now: §6(?.*) coins") @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.inventory.highlightAuctions) return + if (!config.highlightAuctions) return if (event.gui !is GuiChest) return val guiChest = event.gui @@ -31,10 +38,24 @@ class AuctionsHighlighter { val lore = stack.getLore() if (lore.any { it == "§7Status: §aSold!" }) { slot highlight LorenzColor.GREEN + continue } if (lore.any { it == "§7Status: §cExpired!" }) { slot highlight LorenzColor.RED + continue + } + if (config.highlightAuctionsUnderbid) { + for (line in lore) { + buyItNowPattern.matchMatcher(line) { + val coins = group("coins").formatNumber() + stack.getInternalNameOrNull()?.getPriceOrNull()?.let { + if (coins > it) { + slot highlight LorenzColor.GOLD + } + } + } + } } } } -} \ No newline at end of file +} From 4083660296151f58fab0f0ec3a7a929f32d6448b Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Thu, 21 Dec 2023 12:00:14 +0000 Subject: [PATCH 15/22] Internal Change: Composter overlay NEUInternalName (#614) ComposterOverlay now uses NEUInternalName. #614 --- .../at/hannibal2/skyhanni/config/Storage.java | 4 +- .../data/jsonobjects/repo/GardenJson.java | 5 +- .../garden/composter/ComposterOverlay.kt | 189 ++++++++++-------- .../inventory/HideNotClickableItems.kt | 4 +- 4 files changed, 113 insertions(+), 89 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 7f4d6c183ca6..d18fe35468c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -206,10 +206,10 @@ public static class GardenStorage { public Map toolWithBountiful = new HashMap<>(); @Expose - public String composterCurrentOrganicMatterItem = ""; + public NEUInternalName composterCurrentOrganicMatterItem = NEUInternalName.Companion.getNONE(); @Expose - public String composterCurrentFuelItem = ""; + public NEUInternalName composterCurrentFuelItem = NEUInternalName.Companion.getNONE(); @Expose public int uniqueVisitors = 0; diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java index acb8e08ba118..be015722aea2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.utils.NEUInternalName; import at.hannibal2.skyhanni.utils.LorenzRarity; import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; @@ -23,10 +24,10 @@ public class GardenJson { public Map visitors; @Expose - public Map organic_matter; + public Map organic_matter; @Expose - public Map fuel; + public Map fuel; public static class GardenVisitor { @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index 84b7d35e45e6..04630838e3e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -21,7 +21,7 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils @@ -29,8 +29,12 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.NONE import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary @@ -52,9 +56,9 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.DurationUnit object ComposterOverlay { - private var organicMatterFactors: Map = emptyMap() - private var fuelFactors: Map = emptyMap() - private var organicMatter: Map = emptyMap() + private var organicMatterFactors: Map = emptyMap() + private var fuelFactors: Map = emptyMap() + private var organicMatter: Map = emptyMap() private val config get() = GardenAPI.config.composters private var organicMatterDisplay = emptyList>() @@ -77,13 +81,13 @@ object ComposterOverlay { private var testOffset = 0 - var currentOrganicMatterItem: String? + var currentOrganicMatterItem: NEUInternalName? get() = GardenAPI.storage?.composterCurrentOrganicMatterItem private set(value) { GardenAPI.storage?.composterCurrentOrganicMatterItem = value } - var currentFuelItem: String? + var currentFuelItem: NEUInternalName? get() = GardenAPI.storage?.composterCurrentFuelItem private set(value) { GardenAPI.storage?.composterCurrentFuelItem = value @@ -133,25 +137,24 @@ object ComposterOverlay { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { - if (inComposterUpgrades) { - update() - for (upgrade in ComposterUpgrade.entries) { + if (!inComposterUpgrades) return + update() + for (upgrade in ComposterUpgrade.entries) { event.itemStack.name?.let { - if (it.contains(upgrade.displayName)) { - maxLevel = ComposterUpgrade.regex.matchMatcher(it) { + if (it.contains(upgrade.displayName)) { + maxLevel = ComposterUpgrade.regex.matchMatcher(it) { group("level")?.romanToDecimalIfNecessary() ?: 0 - } == 25 - extraComposterUpgrade = upgrade - update() - return - } + } == 25 + extraComposterUpgrade = upgrade + update() + return } } - if (extraComposterUpgrade != null) { - extraComposterUpgrade = null - maxLevel = false - update() - } + } + if (extraComposterUpgrade != null) { + extraComposterUpgrade = null + maxLevel = false + update() } } @@ -176,8 +179,9 @@ object ComposterOverlay { ) return } - if (currentOrganicMatterItem.let { it !in organicMatterFactors.keys && it != "" }) currentOrganicMatterItem = "" - if (currentFuelItem.let { it !in fuelFactors.keys && it != "" }) currentFuelItem = "" + if (currentOrganicMatterItem.let { it !in organicMatterFactors.keys && it != NONE }) currentOrganicMatterItem = + NONE + if (currentFuelItem.let { it !in fuelFactors.keys && it != NONE }) currentFuelItem = NONE if (inComposter) { organicMatterDisplay = drawOrganicMatterDisplay() @@ -255,7 +259,7 @@ object ComposterOverlay { currentOrganicMatterItem = it update() } - if (currentOrganicMatterItem == "") { + if (currentOrganicMatterItem == NONE) { currentOrganicMatterItem = fillList update() } @@ -276,7 +280,7 @@ object ComposterOverlay { currentFuelItem = it update() } - if (currentFuelItem == "") { + if (currentFuelItem == NONE) { currentFuelItem = fillList update() } @@ -287,7 +291,7 @@ object ComposterOverlay { private fun addExtraData(newList: MutableList>) { val organicMatterItem = currentOrganicMatterItem ?: return val fuelItem = currentFuelItem ?: return - if (organicMatterItem == "" || fuelItem == "") return + if (organicMatterItem == NONE || fuelItem == NONE) return newList.addSelector( "§7Per ", @@ -301,9 +305,9 @@ object ComposterOverlay { val list = mutableListOf() list.add("§7Using: ") - list.add(NEUItems.getItemStack(organicMatterItem)) + list.add(organicMatterItem.getItemStack()) list.add("§7and ") - list.add(NEUItems.getItemStack(fuelItem)) + list.add(fuelItem.getItemStack()) newList.add(list) val timePerCompost = ComposterAPI.timePerCompost(null).toLong(DurationUnit.MILLISECONDS) @@ -375,12 +379,12 @@ object ComposterOverlay { private fun fillList( bigList: MutableList>, - factors: Map, + factors: Map, missing: Double, testOffset_: Int = 0, - onClick: (String) -> Unit, - ): String { - val map = mutableMapOf() + onClick: (NEUInternalName) -> Unit, + ): NEUInternalName { + val map = mutableMapOf() for ((internalName, factor) in factors) { map[internalName] = factor / getPrice(internalName) } @@ -391,15 +395,34 @@ object ComposterOverlay { 0 } else testOffset_ + val first: NEUInternalName? = calculateFirst(map, testOffset, factors, missing, onClick, bigList) + if (testOffset != 0) { + bigList.addAsSingletonList(Renderable.link("testOffset = $testOffset") { + ComposterOverlay.testOffset = 0 + update() + }) + } + + return first ?: error("First is empty!") + } + + private fun calculateFirst( + map: MutableMap, + testOffset: Int, + factors: Map, + missing: Double, + onClick: (NEUInternalName) -> Unit, + bigList: MutableList> + ): NEUInternalName? { var i = 0 - var first: String? = null + var first: NEUInternalName? = null for (internalName in map.sortedDesc().keys) { i++ if (i < testOffset) continue if (first == null) first = internalName val factor = factors[internalName]!! - val item = NEUItems.getItemStack(internalName) + val item = internalName.getItemStack() val itemName = item.name!! val price = getPrice(internalName) val itemsNeeded = if (config.roundDown) { @@ -419,52 +442,54 @@ object ComposterOverlay { list.add("#$i ") } list.add(item) - val format = NumberUtil.format(totalPrice) - val selected = if (internalName == currentOrganicMatterItem || internalName == currentFuelItem) "§n" else "" - val rawItemName = itemName.removeColor() - val name = itemName.substring(0, 2) + selected + rawItemName - list.add(Renderable.link("$name §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") { - onClick(internalName) - if (KeyboardManager.isModifierKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) { - lastAttemptTime = SimpleTimeMark.now() - retrieveMaterials(internalName, itemName, itemsNeeded.toInt()) - } - }) + formatPrice(totalPrice, internalName, itemName, list, itemsNeeded, onClick) bigList.add(list) - - if (i == 10 + testOffset) break } - if (testOffset != 0) { - bigList.addAsSingletonList(Renderable.link("testOffset = $testOffset") { - ComposterOverlay.testOffset = 0 - update() - }) - } + return first + } - return first ?: error("First is empty!") + private fun formatPrice( + totalPrice: Double, + internalName: NEUInternalName, + itemName: String, + list: MutableList, + itemsNeeded: Double, + onClick: (NEUInternalName) -> Unit + ) { + val format = NumberUtil.format(totalPrice) + val selected = if (internalName == currentOrganicMatterItem || internalName == currentFuelItem) "§n" else "" + val rawItemName = itemName.removeColor() + val name = itemName.substring(0, 2) + selected + rawItemName + list.add(Renderable.link("$name §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") { + onClick(internalName) + if (KeyboardManager.isModifierKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) { + lastAttemptTime = SimpleTimeMark.now() + retrieveMaterials(internalName, itemName, itemsNeeded.toInt()) + } + }) } - private fun retrieveMaterials(internalName: String, itemName: String, itemsNeeded: Int) { - if (itemsNeeded == 0 || internalName == "BIOFUEL") return + private fun retrieveMaterials(internalName: NEUInternalName, itemName: String, itemsNeeded: Int) { + if (itemsNeeded == 0 || internalName.equals("BIOFUEL")) return if (config.retrieveFrom == ComposterConfig.RetrieveFromEntry.BAZAAR && !LorenzUtils.noTradeMode) { BazaarApi.searchForBazaarItem(itemName, itemsNeeded) return } - val having = InventoryUtils.countItemsInLowerInventory { it.getInternalName_old() == internalName } + val having = InventoryUtils.countItemsInLowerInventory { it.getInternalName() == internalName } if (having >= itemsNeeded) { LorenzUtils.chat("$itemName §8x${itemsNeeded} §ealready found in inventory!") return } - val sackItem = SackAPI.fetchSackItem(internalName.asInternalName()) + val sackItem = SackAPI.fetchSackItem(internalName) val amountInSacks = sackItem.amount val sackStatus = sackItem.getStatus() if (sackStatus == SackStatus.MISSING || sackStatus == SackStatus.OUTDATED) { if (sackStatus == SackStatus.OUTDATED) LorenzUtils.sendCommandToServer("gfs $internalName ${itemsNeeded - having}") // TODO Add sack type repo data - val sackType = if (internalName == "VOLTA" || internalName == "OIL_BARREL") "Mining" + val sackType = if (internalName.equals("VOLTA") || internalName.equals("OIL_BARREL")) "Mining" else "Enchanted Agronomy" LorenzUtils.clickableChat( "Sacks could not be loaded. Click here and open your §9$sackType Sack §eto update the data!", @@ -495,10 +520,10 @@ object ComposterOverlay { } } - private fun getPrice(internalName: String): Double { + private fun getPrice(internalName: NEUInternalName): Double { val useSellPrice = config.overlayPriceType == ComposterConfig.OverlayPriceTypeEntry.BUY_ORDER - val price = NEUItems.getPrice(internalName, useSellPrice) - if (internalName == "BIOFUEL" && price > 20_000) return 20_000.0 + val price = internalName.getPrice(useSellPrice) + if (internalName.equals("BIOFUEL") && price > 20_000) return 20_000.0 return price } @@ -525,28 +550,27 @@ object ComposterOverlay { } } - private fun updateOrganicMatterFactors(baseValues: Map): Map { - val map = mutableMapOf() + private fun updateOrganicMatterFactors(baseValues: Map): Map { + val map = mutableMapOf() for ((internalName, _) in NotEnoughUpdates.INSTANCE.manager.itemInformation) { - if (internalName == "POTION_AFFINITY_TALISMAN") continue - if (internalName == "CROPIE_TALISMAN") continue - if (internalName.endsWith("_BOOTS")) continue - if (internalName.endsWith("_HELMET")) continue - if (internalName.endsWith("_CHESTPLATE")) continue - if (internalName.endsWith("_LEGGINGS")) continue - if (internalName == "SPEED_TALISMAN") continue - if (internalName == "SIMPLE_CARROT_CANDY") continue - val (newId, amount) = NEUItems.getMultiplier(internalName) + if (internalName == "POTION_AFFINITY_TALISMAN" + || internalName == "CROPIE_TALISMAN" + || internalName.endsWith("_BOOTS") + || internalName.endsWith("_HELMET") + || internalName.endsWith("_CHESTPLATE") + || internalName.endsWith("_LEGGINGS") + || internalName == "SPEED_TALISMAN" + || internalName == "SIMPLE_CARROT_CANDY" + ) continue + + var (newId, amount) = NEUItems.getMultiplier(internalName) if (amount <= 9) continue - val finalAmount = - if (internalName == "ENCHANTED_HUGE_MUSHROOM_1" || internalName == "ENCHANTED_HUGE_MUSHROOM_2") { - // 160 * 8 * 4 is 5120 and not 5184, but hypixel made an error, so we have to copy the error - 5184 - } else amount - - baseValues[newId]?.let { - val d = it * finalAmount - map[internalName] = d + if (internalName == "ENCHANTED_HUGE_MUSHROOM_1" || internalName == "ENCHANTED_HUGE_MUSHROOM_2") { + // 160 * 8 * 4 is 5120 and not 5184, but hypixel made an error, so we have to copy the error + amount = 5184 + } + baseValues[newId.asInternalName()]?.let { + map[internalName.asInternalName()] = it * amount } } return map @@ -582,7 +606,6 @@ object ComposterOverlay { event.move(3, "garden.composterOverlayOrganicMatterPos", "garden.composters.overlayOrganicMatterPos") event.move(3, "garden.composterOverlayFuelExtrasPos", "garden.composters.overlayFuelExtrasPos") event.move(3, "garden.composterRoundDown", "garden.composters.roundDown") - event.transform(15, "garden.composters.overlayPriceType") { element -> ConfigUtils.migrateIntToEnum(element, OverlayPriceTypeEntry::class.java) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 6cc7fa03f9e1..5a563c254819 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -18,7 +18,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.ItemUtils.isVanilla @@ -232,7 +232,7 @@ class HideNotClickableItems { reverseColor = true - val internalName = stack.getInternalName_old() + val internalName = stack.getInternalName() if (internalName == ComposterOverlay.currentOrganicMatterItem) { return false } From 2fbd2295a7ab9efeb8f388daec10789c06a7f93c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:02:22 +0100 Subject: [PATCH 16/22] code cleanup --- .../features/garden/composter/ComposterOverlay.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index 04630838e3e9..dbddf3af5cda 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -140,10 +140,10 @@ object ComposterOverlay { if (!inComposterUpgrades) return update() for (upgrade in ComposterUpgrade.entries) { - event.itemStack.name?.let { + event.itemStack.name?.let { if (it.contains(upgrade.displayName)) { maxLevel = ComposterUpgrade.regex.matchMatcher(it) { - group("level")?.romanToDecimalIfNecessary() ?: 0 + group("level")?.romanToDecimalIfNecessary() ?: 0 } == 25 extraComposterUpgrade = upgrade update() @@ -179,8 +179,9 @@ object ComposterOverlay { ) return } - if (currentOrganicMatterItem.let { it !in organicMatterFactors.keys && it != NONE }) currentOrganicMatterItem = - NONE + if (currentOrganicMatterItem.let { it !in organicMatterFactors.keys && it != NONE }) { + currentOrganicMatterItem = NONE + } if (currentFuelItem.let { it !in fuelFactors.keys && it != NONE }) currentFuelItem = NONE if (inComposter) { @@ -336,7 +337,6 @@ object ComposterOverlay { if (currentTimeType == TimeType.COMPOST) "Compost multiplier" else "Composts per $timeText" newList.addAsSingletonList(" §7$compostPerTitle: §e${multiplier.round(2)}$compostPerTitlePreview") - val organicMatterPrice = getPrice(organicMatterItem) val organicMatterFactor = organicMatterFactors[organicMatterItem]!! @@ -364,7 +364,6 @@ object ComposterOverlay { " §7Material costs per $timeText: §6${NumberUtil.format(totalCost)}$materialCostFormatPreview" newList.addAsSingletonList(materialCostFormat) - val priceCompost = getPrice("COMPOST") val profit = ((priceCompost * multiDropFactor) - (fuelPricePer + organicMatterPricePer)) * timeMultiplier val profitPreview = @@ -463,7 +462,7 @@ object ComposterOverlay { val name = itemName.substring(0, 2) + selected + rawItemName list.add(Renderable.link("$name §8x${itemsNeeded.addSeparators()} §7(§6$format§7)") { onClick(internalName) - if (KeyboardManager.isModifierKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) { + if (KeyboardManager.isModifierKeyDown() && lastAttemptTime.passedSince() > 500.milliseconds) { lastAttemptTime = SimpleTimeMark.now() retrieveMaterials(internalName, itemName, itemsNeeded.toInt()) } From 626e4c822dd56e1c36f281220499fa19b83afdfc Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Thu, 21 Dec 2023 12:03:44 +0000 Subject: [PATCH 17/22] Remove getInternalName_old (#710) Remove getInternalName_old #710 --- src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 420f3decbfe5..38e1c40c07c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -124,10 +124,6 @@ object ItemUtils { return false } - // TODO remove - @Deprecated("Use NEUInternalName rather than String", ReplaceWith("getInternalName()")) - fun ItemStack.getInternalName_old() = getInternalName().asString() - fun ItemStack.getInternalName() = getInternalNameOrNull() ?: NEUInternalName.NONE fun ItemStack.getInternalNameOrNull() = getRawInternalName()?.asInternalName() From bda63cf7205c49a6e2b47409abcbe6d7023453c8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:40:48 +0100 Subject: [PATCH 18/22] Fixed gfs command in composter overlay. --- .../skyhanni/features/garden/composter/ComposterOverlay.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index dbddf3af5cda..0b695149b7d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -486,7 +486,7 @@ object ComposterOverlay { val sackStatus = sackItem.getStatus() if (sackStatus == SackStatus.MISSING || sackStatus == SackStatus.OUTDATED) { - if (sackStatus == SackStatus.OUTDATED) LorenzUtils.sendCommandToServer("gfs $internalName ${itemsNeeded - having}") + if (sackStatus == SackStatus.OUTDATED) LorenzUtils.sendCommandToServer("gfs ${internalName.asString()} ${itemsNeeded - having}") // TODO Add sack type repo data val sackType = if (internalName.equals("VOLTA") || internalName.equals("OIL_BARREL")) "Mining" else "Enchanted Agronomy" @@ -506,7 +506,7 @@ object ComposterOverlay { return } - LorenzUtils.sendCommandToServer("gfs $internalName ${itemsNeeded - having}") + LorenzUtils.sendCommandToServer("gfs ${internalName.asString()} ${itemsNeeded - having}") if (amountInSacks <= itemsNeeded - having) { if (LorenzUtils.noTradeMode) { LorenzUtils.chat("You're out of $itemName §ein your sacks!") From d6942265ddfc2f116c39387095b004d4c8ba870a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:24:56 +0100 Subject: [PATCH 19/22] Copy Underbid price supports setting stack size of more than one at once. --- .../features/misc/items/AuctionHouseCopyUnderbidPrice.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt index 11a51749ed05..23e5d4754077 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/AuctionHouseCopyUnderbidPrice.kt @@ -23,13 +23,14 @@ class AuctionHouseCopyUnderbidPrice { val internalName = item.getInternalName() if (internalName == NEUInternalName.NONE) return - val price = internalName.getPrice().toLong() - 1 + val price = internalName.getPrice().toLong() if (price <= 0) { OSUtils.copyToClipboard("") return } - OSUtils.copyToClipboard("$price") - LorenzUtils.chat("Set §e${price.addSeparators()} §eto clipboard. (Copy Underbid Price)") + val newPrice = price * item.stackSize - 1 + OSUtils.copyToClipboard("$newPrice") + LorenzUtils.chat("Set §e${newPrice.addSeparators()} §eto clipboard. (Copy Underbid Price)") } fun isEnabled() = LorenzUtils.inSkyBlock && config.copyUnderbidPrice From 31f4c69a17f1f935c7cca11d8c3331b6cc4d7897 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:53:37 +0100 Subject: [PATCH 20/22] code cleanup --- .../garden/inventory/SkyMartCopperPrice.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 e2b15c49ce97..a2e6a91c75b7 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 @@ -18,7 +18,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SkyMartCopperPrice { - private val pattern = "§c(?.*) Copper".toPattern() + private val copperPattern = "§c(?.*) Copper".toPattern() private var display = emptyList>() private val config get() = GardenAPI.config.skyMart @@ -38,20 +38,20 @@ class SkyMartCopperPrice { val internalName = stack.getInternalName() val lowestBin = internalName.getPriceOrNull() ?: continue - pattern.matchMatcher(line) { - val amount = group("amount").replace(",", "").toInt() - val factor = lowestBin / amount - val perFormat = NumberUtil.format(factor) - val priceFormat = NumberUtil.format(lowestBin) - val amountFormat = NumberUtil.format(amount) + val amount = copperPattern.matchMatcher(line) { + group("amount").replace(",", "").toInt() + } ?: continue + val factor = lowestBin / amount + val perFormat = NumberUtil.format(factor) + val priceFormat = NumberUtil.format(lowestBin) + val amountFormat = NumberUtil.format(amount) - val name = stack.nameWithEnchantment!! - val advancedStats = if (config.copperPriceAdvancedStats) { - " §7(§6$priceFormat §7/ §c$amountFormat Copper§7)" - } else "" - val pair = Pair("$name§f:", "§6§l$perFormat$advancedStats") - table[pair] = Pair(factor, internalName) - } + val name = stack.nameWithEnchantment!! + val advancedStats = if (config.copperPriceAdvancedStats) { + " §7(§6$priceFormat §7/ §c$amountFormat Copper§7)" + } else "" + val pair = Pair("$name§f:", "§6§l$perFormat$advancedStats") + table[pair] = Pair(factor, internalName) } } From 0102ddc4946b2e197024ef828c14f3b7b298dcd5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:30:32 +0100 Subject: [PATCH 21/22] Fixed SkyMart items showing wrong profit when having another items as cost. --- .../garden/inventory/SkyMartCopperPrice.kt | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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 a2e6a91c75b7..0aba4b861396 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 @@ -11,10 +11,13 @@ import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class SkyMartCopperPrice { @@ -26,6 +29,25 @@ class SkyMartCopperPrice { var inInventory = false } + private fun ItemStack.loreCosts(): MutableList { + var found = false + val list = mutableListOf() + for (lines in getLore()) { + if (lines == "§7Cost") { + found = true + continue + } + + if (!found) continue + if (lines.isEmpty()) return list + + NEUItems.getInternalNameOrNull(lines)?.let { + list.add(it) + } + } + return list + } + @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!isEnabled()) return @@ -34,16 +56,20 @@ class SkyMartCopperPrice { inInventory = true val table = mutableMapOf, Pair>() for (stack in event.inventoryItems.values) { - for (line in stack.getLore()) { + val lore = stack.getLore() + val otherItemsPrice = stack.loreCosts().sumOf { it.getPrice() } + + for (line in lore) { val internalName = stack.getInternalName() val lowestBin = internalName.getPriceOrNull() ?: continue + val profit = lowestBin - otherItemsPrice val amount = copperPattern.matchMatcher(line) { group("amount").replace(",", "").toInt() } ?: continue - val factor = lowestBin / amount + val factor = profit / amount val perFormat = NumberUtil.format(factor) - val priceFormat = NumberUtil.format(lowestBin) + val priceFormat = NumberUtil.format(profit) val amountFormat = NumberUtil.format(amount) val name = stack.nameWithEnchantment!! From acbc0df1de5e89a978b42d4dc4f123d52ddf0e82 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 22 Dec 2023 01:22:11 +0100 Subject: [PATCH 22/22] Hide "Not sprayed!" text while in barn or outside garden area. --- .../skyhanni/features/garden/pests/SprayDisplay.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt index c54e875ab6c5..fa48a0518831 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.currentSpray +import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBarn import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isSprayExpired import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.markExpiredSprayAsNotified import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name @@ -27,11 +28,12 @@ class SprayDisplay { if (!GardenAPI.inGarden() || !event.isMod(5)) return if (config.displayEnabled) { - val plot = GardenPlotAPI.getCurrentPlot() ?: return - display = plot.currentSpray?.let { - val timer = it.expiry.timeUntil() - "§eSprayed with §a${it.type.displayName} §7- ${timer.timerColor("§b")}${timer.format()}" - } ?: if (config.showNotSprayed) "§cNot sprayed!" else "" + display = GardenPlotAPI.getCurrentPlot()?.takeIf { !it.isBarn() }?.let { plot -> + plot.currentSpray?.let { + val timer = it.expiry.timeUntil() + "§eSprayed with §a${it.type.displayName} §7- ${timer.timerColor("§b")}${timer.format()}" + } ?: if (config.showNotSprayed) "§cNot sprayed!" else "" + } ?: "" } if (config.expiryNotification) {