From 4a47f275f8ae544e2bc3d95f6ce7e88c5474934e Mon Sep 17 00:00:00 2001 From: Forrick <69301168+Forrick@users.noreply.github.com> Date: Fri, 13 Jan 2023 05:12:07 +0100 Subject: Updated to 0.14.1 and Bazaar stuff. (#8) --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 6 +-- .../at/hannibal2/skyhanni/config/Features.java | 5 +++ .../hannibal2/skyhanni/config/features/Bazaar.java | 10 +++++ .../hannibal2/skyhanni/events/BazaarUpdateEvent.kt | 5 +++ .../skyhanni/features/bazaar/BazaarData.kt | 2 +- .../skyhanni/features/bazaar/BazaarDataGrabber.kt | 6 ++- .../skyhanni/features/bazaar/BazaarUpdateTimer.kt | 45 ++++++++++++++++++++++ .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 14 ++++--- 8 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 71cde563c..8926c31c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -6,10 +6,7 @@ import at.hannibal2.skyhanni.config.commands.Commands; import at.hannibal2.skyhanni.data.*; import at.hannibal2.skyhanni.data.repo.RepoManager; import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper; -import at.hannibal2.skyhanni.features.bazaar.BazaarApi; -import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod; -import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard; -import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper; +import at.hannibal2.skyhanni.features.bazaar.*; import at.hannibal2.skyhanni.features.bingo.CompactBingoChat; import at.hannibal2.skyhanni.features.chat.ChatFilter; import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages; @@ -172,6 +169,7 @@ public class SkyHanniMod { loadModule(new CroesusUnopenedChestTracker()); loadModule(new CompactBingoChat()); loadModule(new BrewingStandOverlay()); + loadModule(new BazaarUpdateTimer()); Commands.INSTANCE.init(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 39d20d74b..0f3b52c2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -106,6 +106,11 @@ public class Features extends Config { editOverlay(activeConfigCategory, 200, 16, misc.nonGodPotEffectPos); return; } + + if (runnableId.equals("bazzarUpdateTimer")) { + editOverlay(activeConfigCategory, 200, 16, bazaar.updateTimerPos); + return; + } } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java b/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java index 890d21313..2e3ea2195 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java @@ -27,4 +27,14 @@ public class Bazaar { @ConfigOption(name = "Cancelled Buy Order Clipboard", desc = "Saves missing items from cancelled buy orders to clipboard for faster re-entry.") @ConfigEditorBoolean public boolean cancelledBuyOrderClipboard = true; + + @Expose + @ConfigOption(name = "Update Timer", desc = "A countdown timer for upcoming Bazzar data update.") + @ConfigEditorBoolean + public boolean updateTimer = false; + + @Expose + @ConfigOption(name = "Update timer Position", desc = "") + @ConfigEditorButton(runnableId = "bazzarUpdateTimer", buttonText = "Edit") + public Position updateTimerPos = new Position(10, 10, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt new file mode 100644 index 000000000..4d415d920 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import at.hannibal2.skyhanni.features.bazaar.BazaarData + +class BazaarUpdateEvent(val bazaarMap: MutableMap): LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt index b43cb1eb3..b4f00f248 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt @@ -1,3 +1,3 @@ package at.hannibal2.skyhanni.features.bazaar -data class BazaarData(val apiName: String, val itemName: String, val sellPrice: Double, val buyPrice: Double) \ No newline at end of file +data class BazaarData(val apiName: String, val itemName: String, val sellPrice: Double, val buyPrice: Double, val buyMovingWeek: Int, val sellMovingWeek: Int) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt index bcf1b3e48..c2f5fb5a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.bazaar +import at.hannibal2.skyhanni.events.BazaarUpdateEvent import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -97,6 +98,8 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap() + list.add("Next update in:") + list.add(format) + SkyHanniMod.feature.bazaar.updateTimerPos.renderStrings(list, center = true) + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.updateTimer + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index ff28c52ab..e3052874f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -424,7 +424,7 @@ object RenderUtils { return lastValue + (currentValue - lastValue) * multiplier } - fun Position.renderString(string: String?, offsetY: Int = 0) { + fun Position.renderString(string: String?, offsetY: Int = 0, center: Boolean = true) { val minecraft = Minecraft.getMinecraft() if (minecraft.gameSettings.keyBindPlayerList.isKeyDown) return @@ -437,7 +437,11 @@ object RenderUtils { val renderer = minecraft.renderManager.fontRenderer ?: return - val offsetX = (200 - renderer.getStringWidth(display.removeColor())) / 2 + val offsetX = if (center) { + (200 - renderer.getStringWidth(display.removeColor())) / 2 + } else { + 0 + } val x = getAbsX(resolution, 200) + offsetX val y = getAbsY(resolution, 16) + offsetY @@ -448,13 +452,13 @@ object RenderUtils { GlStateManager.popMatrix() } - fun Position.renderStrings(list: List) { + fun Position.renderStrings(list: List, extraSpace: Int = 0, center: Boolean = false) { if (list.isEmpty()) return var offsetY = 0 for (s in list) { - renderString(s, offsetY) - offsetY += 14 + renderString(s, offsetY, center = center) + offsetY += 10 + extraSpace } } -- cgit