From 35e13552257e07ef13ef0aaf059156a175f55340 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 12 Dec 2023 04:21:20 +0100 Subject: Not only Slayer, also Fishing and Diana items will now show in chat & title when over a custom defined price. --- .../config/features/misc/TrackerConfig.java | 34 ++++++++++++++++++++++ .../features/slayer/ItemProfitTrackerConfig.java | 23 --------------- .../features/slayer/SlayerProfitTracker.kt | 25 ++-------------- .../skyhanni/utils/tracker/SkyHanniItemTracker.kt | 12 ++++++-- 4 files changed, 46 insertions(+), 48 deletions(-) (limited to 'src/main/java/at/hannibal2') 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 d3a257dc3..0451bfb00 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 @@ -1,10 +1,13 @@ package at.hannibal2.skyhanni.config.features.misc; +import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.HasLegacyId; import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.Accordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; import io.github.moulberry.moulconfig.observer.Property; @@ -62,4 +65,35 @@ public class TrackerConfig { @ConfigOption(name = "Exclude Hidden", desc = "Exclude hidden items in the total price calculation.") @ConfigEditorBoolean public boolean excludeHiddenItemsInPrice = false; + + @Expose + @ConfigOption(name = "Item Warnings", desc = "Item Warnings") + @Accordion + public TrackerWarningConfig warnings = new TrackerWarningConfig(); + + public static class TrackerWarningConfig { + + @Expose + @ConfigOption(name = "Price in Chat", desc = "Show an extra chat message when you pick up an expensive item. " + + "(This contains name, amount and price)") + @ConfigEditorBoolean + @FeatureToggle + public boolean chat = false; + + @Expose + @ConfigOption(name = "Minimum Price", desc = "Items below this price will not show up in chat.") + @ConfigEditorSlider(minValue = 1, maxValue = 20_000_000, minStep = 1) + public int minimumChat = 5_000_000; + + @Expose + @ConfigOption(name = "Title Warning", desc = "Show a title for expensive item pickups.") + @ConfigEditorBoolean + @FeatureToggle + public boolean title = true; + + @Expose + @ConfigOption(name = "Title Price", desc = "Items above this price will show up as a title.") + @ConfigEditorSlider(minValue = 1, maxValue = 50_000_000, minStep = 1) + public int minimumTitle = 5_000_000; + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/ItemProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/ItemProfitTrackerConfig.java index 5fc67993b..424af991c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/slayer/ItemProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/slayer/ItemProfitTrackerConfig.java @@ -4,7 +4,6 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class ItemProfitTrackerConfig { @@ -19,26 +18,4 @@ public class ItemProfitTrackerConfig { @Expose public Position pos = new Position(20, 20, false, true); - @Expose - @ConfigOption(name = "Price in Chat", desc = "Show an extra chat message when you pick up an item. " + - "(This contains name, amount and price)") - @ConfigEditorBoolean - @FeatureToggle - public boolean priceInChat = false; - - @Expose - @ConfigOption(name = "Minimum Price", desc = "Items below this price will not show up in chat.") - @ConfigEditorSlider(minValue = 1, maxValue = 5_000_000, minStep = 1) - public int minimumPrice = 100_000; - - @Expose - @ConfigOption(name = "Title Warning", desc = "Show a title for expensive item pickups.") - @ConfigEditorBoolean - @FeatureToggle - public boolean titleWarning = false; - - @Expose - @ConfigOption(name = "Title Price", desc = "Items above this price will show up as a title.") - @ConfigEditorSlider(minValue = 1, maxValue = 20_000_000, minStep = 1) - public int minimumPriceWarning = 500_000; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index 1f6631a3a..78391a069 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent -import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName @@ -26,14 +25,12 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration.Companion.seconds object SlayerProfitTracker { private val config get() = SkyHanniMod.feature.slayer.itemProfitTracker private var itemLogCategory = "" private var baseSlayerType = "" - private val logger = LorenzLogger("slayer/profit_tracker") private val trackers = mutableMapOf>() class Data : ItemTrackerData() { @@ -89,11 +86,9 @@ object SlayerProfitTracker { if (!isEnabled()) return val coins = event.coins if (event.reason == PurseChangeCause.GAIN_MOB_KILL && SlayerAPI.isInCorrectArea) { - logger.log("Coins gained for killing mobs: ${coins.addSeparators()}") - addMobKillCoins(coins.toInt()) + getTracker()?.addCoins(coins.toInt()) } if (event.reason == PurseChangeCause.LOSE_SLAYER_QUEST_STARTED) { - logger.log("Coins paid for starting slayer quest: ${coins.addSeparators()}") addSlayerCosts(coins.toInt()) } } @@ -106,14 +101,6 @@ object SlayerProfitTracker { getTracker()?.update() } - private fun addMobKillCoins(coins: Int) { - getTracker()?.addCoins(coins) - } - - private fun addItemPickup(internalName: NEUInternalName, stackSize: Int) { - getTracker()?.addItem(internalName, stackSize) - } - private fun getTracker(): SkyHanniItemTracker? { if (itemLogCategory == "") return null @@ -148,15 +135,7 @@ object SlayerProfitTracker { return } - val (itemName, price) = SlayerAPI.getItemNameAndPrice(internalName, amount) - addItemPickup(internalName, amount) - logger.log("Coins gained for picking up an item ($itemName) ${price.addSeparators()}") - if (config.priceInChat && price > config.minimumPrice) { - LorenzUtils.chat("§a+Slayer Drop§7: §r$itemName") - } - if (config.titleWarning && price > config.minimumPriceWarning) { - LorenzUtils.sendTitle("§a+ $itemName", 5.seconds) - } + getTracker()?.addItem(internalName, amount) } private fun isAllowedItem(internalName: NEUInternalName): Boolean { 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 6812476df..60d094dbe 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils.tracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry +import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.test.PriceSource import at.hannibal2.skyhanni.utils.ItemUtils.getNameWithEnchantment import at.hannibal2.skyhanni.utils.KeyboardManager @@ -35,15 +36,22 @@ class SkyHanniItemTracker( addItem(SKYBLOCK_COIN, coins) } - fun addItem(internalName: NEUInternalName, stackSize: Int) { + fun addItem(internalName: NEUInternalName, amount: Int) { modify { - it.additem(internalName, stackSize) + it.additem(internalName, amount) } getSharedTracker()?.let { val hidden = it.get(DisplayMode.TOTAL).items[internalName]!!.hidden it.get(DisplayMode.SESSION).items[internalName]!!.hidden = hidden } + val (itemName, price) = SlayerAPI.getItemNameAndPrice(internalName, amount) + if (config.warnings.chat && price >= config.warnings.minimumChat) { + LorenzUtils.chat("§a+Tracker Drop§7: §r$itemName") + } + if (config.warnings.title && price >= config.warnings.minimumTitle) { + LorenzUtils.sendTitle("§a+ $itemName", 5.seconds) + } } fun addPriceFromButton(lists: MutableList>) { -- cgit