From 16a5d2c65fb0d0dbba5eeae30efba3d00cb16790 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Mon, 19 Jun 2023 20:09:38 +1000 Subject: start of frozen treasure tracker --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 + .../hannibal2/skyhanni/config/features/Misc.java | 67 ++++++++++++++++++++++ .../features/misc/FrozenTreasureTracker.kt | 33 +++++++++++ .../skyhanni/features/misc/FrozenTreasures.kt | 14 +++++ 4 files changed, 115 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 4fbf8a619..082ff7f7c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -296,6 +296,7 @@ class SkyHanniMod { loadModule(RestorePieceOfWizardPortalLore()) loadModule(QuickModMenuSwitch) loadModule(ShowItemUuid()) + loadModule(FrozenTreasureTracker()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 258bc517a..f5a08521d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -6,6 +6,10 @@ import io.github.moulberry.moulconfig.annotations.*; import io.github.moulberry.moulconfig.observer.Property; import org.lwjgl.input.Keyboard; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + public class Misc { @Expose @@ -478,6 +482,69 @@ public class Misc { public Position pos = new Position(-178, 143, false, true); } + @Expose + @ConfigOption(name = "Frozen Treasure Tracker", desc = "") + @Accordion + public Misc.FrozenTreasureTracker frozenTreasureTracker = new Misc.FrozenTreasureTracker(); + + public static class FrozenTreasureTracker { + + @Expose + @ConfigOption( + name = "Enabled", + desc = "Tracks all of your drops from frozen treasure in the Glacial Caves\n" + + "§eIce calculations are an estimate but are relatively accurate" + ) + @ConfigEditorBoolean + public boolean enabled = true; + + @Expose + @ConfigOption( + name = "Text Format", + desc = "Drag text to change the appearance of the overlay." + ) + @ConfigEditorDraggableList( + exampleText = { // todo change colours + "§e§lFrozen Treasure Tracker", + "§e1,636 Treasures Mined", + "§e3.2 Total Ice", + "§e342,192 Ice/hr", + "§e31,002 Compact Procs", + " ", + "§b182 §fWhite Gift", + "§b94 §aGreen Gift", + "§b17 §9§cRed Gift", + "§b328 §fPacked Ice", + "§b80 §aEnchanted Ice", + "§b4 §9Enchanted Packed Ice", + "§b182 §aIce Bait", + "§b3 §aGlowy Chum Bait", + "§b36 §5Glacial Fragment", + "§b6 §fGlacial Talisman", + " ", + } + ) + public List textFormat = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 14, 15)); + + @Expose + @ConfigOption(name = "Count Compact", desc = "Adds compact drops from your pickaxe to the ice total.") + @ConfigEditorBoolean + public boolean countCompact = true; + + @Expose + @ConfigOption(name = "Only in Glacial Cave", desc = "Only shows the overlay while in the Glacial Cave.") + @ConfigEditorBoolean + public boolean onlyInCave = true; + + @Expose + @ConfigOption(name = "Hide Chat messages", desc = "Hides the chat messages from frozen treasures.") + @ConfigEditorBoolean + public boolean hideMessages = false; + + @Expose + public Position glacialDropPos = new Position(10, 80, false, true); + } + @Expose @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt new file mode 100644 index 000000000..fa947b022 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class FrozenTreasureTracker { + private val config get() = SkyHanniMod.feature.misc.frozenTreasureTracker + private var display = listOf>() + private var treasureMined = 0 + private var compactProcs = 0 + private var estimatedIce = 0 + private var icePerHour = 0 + + private var treasureCount = mapOf() + + private fun formatDisplay(map: List>): List> { + val newList = mutableListOf>() + for (index in config.textFormat) { + newList.add(map[index]) + } + return newList + } + + @SubscribeEvent + fun onPreProfileSwitch(event: PreProfileSwitchEvent) { + display = emptyList() + } + + + //FROZEN TREASURE! You found Enchanted Ice! + +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt new file mode 100644 index 000000000..b2ede31d7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.features.misc + +enum class FrozenTreasures (val internalName: String, val displayName: String, val defaultAmount: Int, val iceMultiplier: Int = 0){ + WHITE_GIFT("WHITE_GIFT", "§fWhite Gift", 1), + GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1), + RED_GIFT("RED_GIFT","§9§cRed Gift", 1), + PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9), + ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 16, 160), + ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600), + ICE_BAIT("ICE_BAIT","§aIce Bait", 16), + GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16), + GLACIAL_FRAGMENT("GLACIAL_FRAGMENT","§5Glacial Fragment", 1), + GLACIAL_TALISMAN("GLACIAL_TALISMAN", "§fGlacial Talisman",1) +} \ No newline at end of file -- cgit From 54cbf2fc5177ffc6b219a72be8032789ff3514b7 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Mon, 19 Jun 2023 21:37:22 +1000 Subject: done apart from testing --- .../java/at/hannibal2/skyhanni/config/Storage.java | 17 ++- .../hannibal2/skyhanni/config/features/Misc.java | 15 +-- .../java/at/hannibal2/skyhanni/data/IslandType.kt | 1 + .../features/misc/FrozenTreasureTracker.kt | 125 ++++++++++++++++++++- .../skyhanni/features/misc/FrozenTreasures.kt | 2 +- 5 files changed, 146 insertions(+), 14 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 0a63e5928..c0a003aad 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -5,7 +5,8 @@ import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.misc.GhostCounter.Option; +import at.hannibal2.skyhanni.features.misc.FrozenTreasures; +import at.hannibal2.skyhanni.features.misc.GhostCounter.Option; import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; import net.minecraft.item.ItemStack; @@ -229,6 +230,20 @@ public class Storage { } + @Expose + public FrozenTreasureTracker frozenTreasureTracker = new FrozenTreasureTracker(); + + public static class FrozenTreasureTracker { + @Expose + public int treasuresMined = 0; + + @Expose + public int compactProcs = 0; + + @Expose + public Map treasureCount = new HashMap<>(); + } + public long nextCityProjectParticipationTime = 0L; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index f0d5b7d7b..ebfe716fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -1,13 +1,10 @@ package at.hannibal2.skyhanni.config.features; -import at.hannibal2.skyhanni.config.core.config.*; -import com.google.gson.annotations.*; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.*; -import io.github.moulberry.moulconfig.observer.*; -import org.lwjgl.input.*; - -import java.util.ArrayList; -import java.util.List; +import io.github.moulberry.moulconfig.observer.Property; +import org.lwjgl.input.Keyboard; import java.util.ArrayList; import java.util.Arrays; @@ -510,9 +507,9 @@ public class Misc { exampleText = { // todo change colours "§e§lFrozen Treasure Tracker", "§e1,636 Treasures Mined", - "§e3.2 Total Ice", + "§e3.2m Total Ice", "§e342,192 Ice/hr", - "§e31,002 Compact Procs", + "§e1,002 Compact Procs", " ", "§b182 §fWhite Gift", "§b94 §aGreen Gift", diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 8b9c4dc3e..7935bf985 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -18,6 +18,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { GARDEN("Garden"), GARDEN_GUEST("Garden Guest"), SPIDER_DEN("Spider's Den"), + WINTER("Jerry's Workshop"), //todo confirm NONE(""), UNKNOWN("???"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index fa947b022..bdb6db48d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -1,19 +1,61 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PreProfileSwitchEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.concurrent.fixedRateTimer class FrozenTreasureTracker { private val config get() = SkyHanniMod.feature.misc.frozenTreasureTracker private var display = listOf>() - private var treasureMined = 0 + private var treasuresMined = 0 private var compactProcs = 0 - private var estimatedIce = 0 + private var estimatedIce = 0L + private var lastEstimatedIce = 0L + private val icePerMin = mutableListOf() private var icePerHour = 0 + private var missedMinutes = 0 + private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() private var treasureCount = mapOf() + init { + fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 60_000) { + if (!onJerryWorkshop()) return@fixedRateTimer + calculateIcePerHour() + } + } + + private fun calculateIcePerHour() { + val difference = estimatedIce - lastEstimatedIce + if (difference == 0L) { + missedMinutes += 1 + if (missedMinutes == 3) { + missedMinutes = 0 + icePerMin.clear() + icePerHour = 0 + } + return + } + missedMinutes = 0 + icePerMin.add(difference) + icePerHour = icePerMin.average().toInt() + } + private fun formatDisplay(map: List>): List> { val newList = mutableListOf>() for (index in config.textFormat) { @@ -22,12 +64,89 @@ class FrozenTreasureTracker { return newList } + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!ProfileStorageData.loaded) return + if (!onJerryWorkshop()) return + + val message = event.message.removeColor().trim() + + compactPattern.matchMatcher(message) { + compactProcs += 1 + saveAndUpdate() + if (config.hideMessages) event.isCanceled + } + + for (treasure in FrozenTreasures.values()) { + if ("FROZEN TREASURE! You found ${treasure.displayName}!".toRegex().matches(message)) { + val old = treasureCount[treasure] ?: 0 + treasureCount = treasureCount.editCopy { this[treasure] = old + 1 } + saveAndUpdate() + if (config.hideMessages) event.isCanceled + } + } + } + @SubscribeEvent fun onPreProfileSwitch(event: PreProfileSwitchEvent) { display = emptyList() } + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val hidden = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return + treasuresMined = hidden.treasuresMined + compactProcs = hidden.compactProcs + treasureCount = hidden.treasureCount + saveAndUpdate() + } + + private fun drawTreasureDisplay() = buildList> { + addAsSingletonList("§e§lFrozen Treasure Tracker") + addAsSingletonList("§e${formatNumber(treasuresMined)} Treasures Mined") + addAsSingletonList("§e${formatNumber(estimatedIce)} Total Ice") + addAsSingletonList("§e${formatNumber(icePerHour)} Ice/hr") + addAsSingletonList("§e${formatNumber(compactProcs)} Compact Procs") + addAsSingletonList("") + + for (treasure in FrozenTreasures.values()) { + val count = treasureCount[treasure] ?: 0 + addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}") + } + addAsSingletonList("") + } + + fun formatNumber(amount: Number): String { + if (amount is Int) return amount.addSeparators() + if (amount is Long) return NumberUtil.format(amount) + return "$amount" + } + private fun saveAndUpdate() { + val hidden = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return + hidden.treasuresMined = treasuresMined + hidden.compactProcs = compactProcs + hidden.treasureCount = treasureCount + calculateIce() + display = formatDisplay(drawTreasureDisplay()) + } - //FROZEN TREASURE! You found Enchanted Ice! + private fun calculateIce() { + estimatedIce = 0 + if (config.countCompact) estimatedIce += compactProcs * 160 + for (treasure in FrozenTreasures.values()) { + val amount = treasureCount[treasure] ?: 0 + estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!config.enabled) return + if (!onJerryWorkshop()) return + if (config.onlyInCave && !inGlacialCave()) return + config.glacialDropPos.renderStringsAndItems(display, posLabel = "Visitor Stats") + } + private fun onJerryWorkshop() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.WINTER + private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains("Glacial Cave") } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt index b2ede31d7..d9d936a31 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt @@ -5,7 +5,7 @@ enum class FrozenTreasures (val internalName: String, val displayName: String, v GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1), RED_GIFT("RED_GIFT","§9§cRed Gift", 1), PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9), - ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 16, 160), + ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9 ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600), ICE_BAIT("ICE_BAIT","§aIce Bait", 16), GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16), -- cgit From 4a12bbd0b780238557cdc2330cf6314015e0de07 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Mon, 19 Jun 2023 21:48:45 +1000 Subject: renaming --- src/main/java/at/hannibal2/skyhanni/config/Storage.java | 4 ++-- .../at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt | 14 ++++++++++++++ .../skyhanni/features/misc/FrozenTreasureTracker.kt | 8 ++++---- .../at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt | 14 -------------- 4 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 4a95871cb..ca852e482 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.misc.FrozenTreasures; +import at.hannibal2.skyhanni.features.misc.FrozenTreasure; import at.hannibal2.skyhanni.features.misc.GhostCounter.Option; import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; @@ -241,7 +241,7 @@ public class Storage { public int compactProcs = 0; @Expose - public Map treasureCount = new HashMap<>(); + public Map treasureCount = new HashMap<>(); } public long nextCityProjectParticipationTime = 0L; diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt new file mode 100644 index 000000000..d18b65983 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.features.misc + +enum class FrozenTreasure (val internalName: String, val displayName: String, val defaultAmount: Int, val iceMultiplier: Int = 0){ + WHITE_GIFT("WHITE_GIFT", "§fWhite Gift", 1), + GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1), + RED_GIFT("RED_GIFT","§9§cRed Gift", 1), + PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9), + ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9 + ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600), + ICE_BAIT("ICE_BAIT","§aIce Bait", 16), + GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16), + GLACIAL_FRAGMENT("GLACIAL_FRAGMENT","§5Glacial Fragment", 1), + GLACIAL_TALISMAN("GLACIAL_TALISMAN", "§fGlacial Talisman",1) +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index bdb6db48d..93bab63e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -31,7 +31,7 @@ class FrozenTreasureTracker { private var missedMinutes = 0 private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() - private var treasureCount = mapOf() + private var treasureCount = mapOf() init { fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 60_000) { @@ -77,7 +77,7 @@ class FrozenTreasureTracker { if (config.hideMessages) event.isCanceled } - for (treasure in FrozenTreasures.values()) { + for (treasure in FrozenTreasure.values()) { if ("FROZEN TREASURE! You found ${treasure.displayName}!".toRegex().matches(message)) { val old = treasureCount[treasure] ?: 0 treasureCount = treasureCount.editCopy { this[treasure] = old + 1 } @@ -109,7 +109,7 @@ class FrozenTreasureTracker { addAsSingletonList("§e${formatNumber(compactProcs)} Compact Procs") addAsSingletonList("") - for (treasure in FrozenTreasures.values()) { + for (treasure in FrozenTreasure.values()) { val count = treasureCount[treasure] ?: 0 addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}") } @@ -133,7 +133,7 @@ class FrozenTreasureTracker { private fun calculateIce() { estimatedIce = 0 if (config.countCompact) estimatedIce += compactProcs * 160 - for (treasure in FrozenTreasures.values()) { + for (treasure in FrozenTreasure.values()) { val amount = treasureCount[treasure] ?: 0 estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt deleted file mode 100644 index d9d936a31..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasures.kt +++ /dev/null @@ -1,14 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -enum class FrozenTreasures (val internalName: String, val displayName: String, val defaultAmount: Int, val iceMultiplier: Int = 0){ - WHITE_GIFT("WHITE_GIFT", "§fWhite Gift", 1), - GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1), - RED_GIFT("RED_GIFT","§9§cRed Gift", 1), - PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9), - ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9 - ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600), - ICE_BAIT("ICE_BAIT","§aIce Bait", 16), - GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16), - GLACIAL_FRAGMENT("GLACIAL_FRAGMENT","§5Glacial Fragment", 1), - GLACIAL_TALISMAN("GLACIAL_TALISMAN", "§fGlacial Talisman",1) -} \ No newline at end of file -- cgit From be16cc2145df374226bf0e83335ee500a7080f4d Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Tue, 20 Jun 2023 07:41:25 +1000 Subject: remove colour --- .../java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 93bab63e7..ea9583057 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -78,7 +78,7 @@ class FrozenTreasureTracker { } for (treasure in FrozenTreasure.values()) { - if ("FROZEN TREASURE! You found ${treasure.displayName}!".toRegex().matches(message)) { + if ("FROZEN TREASURE! You found ${treasure.displayName.removeColor()}!".toRegex().matches(message)) { val old = treasureCount[treasure] ?: 0 treasureCount = treasureCount.editCopy { this[treasure] = old + 1 } saveAndUpdate() -- cgit From 917170b1ca53b0718f59a0f922e028567e61c998 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Tue, 20 Jun 2023 09:21:58 +1000 Subject: maybe fixed error --- .../java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index ea9583057..264d16ae4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -42,6 +42,7 @@ class FrozenTreasureTracker { private fun calculateIcePerHour() { val difference = estimatedIce - lastEstimatedIce + lastEstimatedIce = estimatedIce if (difference == 0L) { missedMinutes += 1 if (missedMinutes == 3) { @@ -53,7 +54,7 @@ class FrozenTreasureTracker { } missedMinutes = 0 icePerMin.add(difference) - icePerHour = icePerMin.average().toInt() + if (difference != estimatedIce) icePerHour = icePerMin.average().toInt() } private fun formatDisplay(map: List>): List> { -- cgit From de47024ea3f4910bbca68a880491c8924fc5ecc6 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Tue, 20 Jun 2023 09:40:29 +1000 Subject: hours do have 60 minutes --- .../skyhanni/features/misc/FrozenTreasureTracker.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 264d16ae4..50c11d128 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -28,13 +28,13 @@ class FrozenTreasureTracker { private var lastEstimatedIce = 0L private val icePerMin = mutableListOf() private var icePerHour = 0 - private var missedMinutes = 0 + private var stoppedChecks = 0 private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() private var treasureCount = mapOf() init { - fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 60_000) { + fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 15_000) { if (!onJerryWorkshop()) return@fixedRateTimer calculateIcePerHour() } @@ -44,17 +44,17 @@ class FrozenTreasureTracker { val difference = estimatedIce - lastEstimatedIce lastEstimatedIce = estimatedIce if (difference == 0L) { - missedMinutes += 1 - if (missedMinutes == 3) { - missedMinutes = 0 + stoppedChecks += 1 + if (stoppedChecks == 12) { + stoppedChecks = 0 icePerMin.clear() icePerHour = 0 } return } - missedMinutes = 0 + stoppedChecks = 0 icePerMin.add(difference) - if (difference != estimatedIce) icePerHour = icePerMin.average().toInt() + if (difference != estimatedIce) icePerHour = icePerMin.average().toInt() * 240 } private fun formatDisplay(map: List>): List> { -- cgit From f88467675040a7351f56fcd9972382a2badab50d Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Tue, 20 Jun 2023 09:42:01 +1000 Subject: hours do have 60 minutes --- .../at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 50c11d128..30cd31e36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer @@ -40,6 +41,14 @@ class FrozenTreasureTracker { } } + @SubscribeEvent + fun onWorldLoad(event: WorldEvent.Load) { + icePerHour = 0 + stoppedChecks = 0 + icePerMin.clear() + saveAndUpdate() + } + private fun calculateIcePerHour() { val difference = estimatedIce - lastEstimatedIce lastEstimatedIce = estimatedIce -- cgit From a9fdc5c1cced1faa54c04cad93fe35249583fe89 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Tue, 20 Jun 2023 10:21:11 +1000 Subject: multiplying by default amount --- .../java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 30cd31e36..006916e4f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -120,7 +120,7 @@ class FrozenTreasureTracker { addAsSingletonList("") for (treasure in FrozenTreasure.values()) { - val count = treasureCount[treasure] ?: 0 + val count = (treasureCount[treasure] ?: 0) * treasure.defaultAmount // enchanted ice will be inaccurate addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}") } addAsSingletonList("") -- cgit From 617c4352fdb622b1b21769823c0af0235d539717 Mon Sep 17 00:00:00 2001 From: CalMWolfs Date: Fri, 23 Jun 2023 08:18:38 +1000 Subject: fixed up --- .../at/hannibal2/skyhanni/config/features/Misc.java | 21 +++++++++++---------- .../skyhanni/features/misc/FrozenTreasureTracker.kt | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index ebfe716fe..e9def2a1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -504,12 +504,12 @@ public class Misc { desc = "Drag text to change the appearance of the overlay." ) @ConfigEditorDraggableList( - exampleText = { // todo change colours - "§e§lFrozen Treasure Tracker", - "§e1,636 Treasures Mined", - "§e3.2m Total Ice", - "§e342,192 Ice/hr", - "§e1,002 Compact Procs", + exampleText = { + "§1§lFrozen Treasure Tracker", + "§61,636 Treasures Mined", + "§33.2m Total Ice", + "§3342,192 Ice/hr", + "§81,002 Compact Procs", " ", "§b182 §fWhite Gift", "§b94 §aGreen Gift", @@ -527,14 +527,15 @@ public class Misc { public List textFormat = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 14, 15)); @Expose - @ConfigOption(name = "Count Compact", desc = "Adds compact drops from your pickaxe to the ice total.") + @ConfigOption(name = "Only in Glacial Cave", desc = "Only shows the overlay while in the Glacial Cave.") @ConfigEditorBoolean - public boolean countCompact = true; + public boolean onlyInCave = true; @Expose - @ConfigOption(name = "Only in Glacial Cave", desc = "Only shows the overlay while in the Glacial Cave.") + @ConfigOption(name = "Show as drops", desc = "Multiplies the numbers on the display by the base drop. \n" + + "E.g. 3 Ice Bait -> 48 Ice Bait") @ConfigEditorBoolean - public boolean onlyInCave = true; + public boolean showAsDrops = false; @Expose @ConfigOption(name = "Hide Chat messages", desc = "Hides the chat messages from frozen treasures.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 006916e4f..2022713b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -84,15 +84,16 @@ class FrozenTreasureTracker { compactPattern.matchMatcher(message) { compactProcs += 1 saveAndUpdate() - if (config.hideMessages) event.isCanceled + if (config.hideMessages) event.blockedReason = "frozen treasure tracker" } for (treasure in FrozenTreasure.values()) { if ("FROZEN TREASURE! You found ${treasure.displayName.removeColor()}!".toRegex().matches(message)) { + treasuresMined += 1 val old = treasureCount[treasure] ?: 0 treasureCount = treasureCount.editCopy { this[treasure] = old + 1 } saveAndUpdate() - if (config.hideMessages) event.isCanceled + if (config.hideMessages) event.blockedReason = "frozen treasure tracker" } } } @@ -112,15 +113,15 @@ class FrozenTreasureTracker { } private fun drawTreasureDisplay() = buildList> { - addAsSingletonList("§e§lFrozen Treasure Tracker") - addAsSingletonList("§e${formatNumber(treasuresMined)} Treasures Mined") - addAsSingletonList("§e${formatNumber(estimatedIce)} Total Ice") - addAsSingletonList("§e${formatNumber(icePerHour)} Ice/hr") - addAsSingletonList("§e${formatNumber(compactProcs)} Compact Procs") + addAsSingletonList("§1§lFrozen Treasure Tracker") + addAsSingletonList("§6${formatNumber(treasuresMined)} Treasures Mined") + addAsSingletonList("§3${formatNumber(estimatedIce)} Total Ice") + addAsSingletonList("§3${formatNumber(icePerHour)} Ice/hr") + addAsSingletonList("§8${formatNumber(compactProcs)} Compact Procs") addAsSingletonList("") for (treasure in FrozenTreasure.values()) { - val count = (treasureCount[treasure] ?: 0) * treasure.defaultAmount // enchanted ice will be inaccurate + val count = (treasureCount[treasure] ?: 0) * if (config.showAsDrops) treasure.defaultAmount else 1 addAsSingletonList("§b${formatNumber(count)} ${treasure.displayName}") } addAsSingletonList("") @@ -142,7 +143,7 @@ class FrozenTreasureTracker { private fun calculateIce() { estimatedIce = 0 - if (config.countCompact) estimatedIce += compactProcs * 160 + estimatedIce += compactProcs * 160 for (treasure in FrozenTreasure.values()) { val amount = treasureCount[treasure] ?: 0 estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier @@ -158,5 +159,5 @@ class FrozenTreasureTracker { } private fun onJerryWorkshop() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.WINTER - private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains("Glacial Cave") + private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §3Glacial Cave") } \ No newline at end of file -- cgit From a1efe2d469bfe9e152ffcae4cd42dd9e98818c0f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 23 Jun 2023 00:49:38 +0200 Subject: formatting changes --- .../hannibal2/skyhanni/config/features/Misc.java | 2 +- .../skyhanni/features/misc/FrozenTreasure.kt | 25 +++++++++++++--------- .../features/misc/FrozenTreasureTracker.kt | 6 ++++-- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index e9def2a1c..8d15a46df 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -543,7 +543,7 @@ public class Misc { public boolean hideMessages = false; @Expose - public Position glacialDropPos = new Position(10, 80, false, true); + public Position position = new Position(10, 80, false, true); } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt index d18b65983..e2c70cedc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt @@ -1,14 +1,19 @@ package at.hannibal2.skyhanni.features.misc -enum class FrozenTreasure (val internalName: String, val displayName: String, val defaultAmount: Int, val iceMultiplier: Int = 0){ +enum class FrozenTreasure( + val internalName: String, + val displayName: String, + val defaultAmount: Int, + val iceMultiplier: Int = 0, +) { WHITE_GIFT("WHITE_GIFT", "§fWhite Gift", 1), - GREEN_GIFT("GREEN_GIFT", "§aGreen Gift",1), - RED_GIFT("RED_GIFT","§9§cRed Gift", 1), - PACKED_ICE("PACKED_ICE","§fPacked Ice", 32, 9), - ENCHANTED_ICE("ENCHANTED_ICE","§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9 - ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice",1, 25600), - ICE_BAIT("ICE_BAIT","§aIce Bait", 16), - GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait",16), - GLACIAL_FRAGMENT("GLACIAL_FRAGMENT","§5Glacial Fragment", 1), - GLACIAL_TALISMAN("GLACIAL_TALISMAN", "§fGlacial Talisman",1) + GREEN_GIFT("GREEN_GIFT", "§aGreen Gift", 1), + RED_GIFT("RED_GIFT", "§9§cRed Gift", 1), + PACKED_ICE("PACKED_ICE", "§fPacked Ice", 32, 9), + ENCHANTED_ICE("ENCHANTED_ICE", "§aEnchanted Ice", 9, 160), // wiki says 1-16 so assuming 9 + ENCHANTED_PACKED_ICE("ENCHANTED_PACKED_ICE", "§9Enchanted Packed Ice", 1, 25600), + ICE_BAIT("ICE_BAIT", "§aIce Bait", 16), + GLOWY_CHUM_BAIT("GLOWY_CHUM_BAIT", "§aGlowy Chum Bait", 16), + GLACIAL_FRAGMENT("GLACIAL_FRAGMENT", "§5Glacial Fragment", 1), + GLACIAL_TALISMAN("GLACIAL_TALISMAN", "§fGlacial Talisman", 1) } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt index 2022713b5..10c2f0bd6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -132,6 +132,7 @@ class FrozenTreasureTracker { if (amount is Long) return NumberUtil.format(amount) return "$amount" } + private fun saveAndUpdate() { val hidden = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return hidden.treasuresMined = treasuresMined @@ -155,9 +156,10 @@ class FrozenTreasureTracker { if (!config.enabled) return if (!onJerryWorkshop()) return if (config.onlyInCave && !inGlacialCave()) return - config.glacialDropPos.renderStringsAndItems(display, posLabel = "Visitor Stats") + config.position.renderStringsAndItems(display, posLabel = "Visitor Stats") } - private fun onJerryWorkshop() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.WINTER + private fun onJerryWorkshop() = LorenzUtils.inIsland(IslandType.WINTER) + private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §3Glacial Cave") } \ No newline at end of file -- cgit