diff options
Diffstat (limited to 'src/main')
6 files changed, 251 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 51d695899..5eb0eec1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -298,6 +298,7 @@ class SkyHanniMod { loadModule(QuickModMenuSwitch) loadModule(ArachneChatMessageHider()) loadModule(ShowItemUuid()) + loadModule(FrozenTreasureTracker()) loadModule(SlayerRngMeterDisplay()) loadModule(GhostCounter) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index ffac3b8ec..4a95871cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -5,6 +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.GhostCounter.Option; import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; @@ -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<FrozenTreasures, Integer> 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 ef99c5d90..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,12 +1,13 @@ 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 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 { @@ -482,6 +483,69 @@ public class Misc { } @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.2m Total Ice", + "§e342,192 Ice/hr", + "§e1,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<Integer> 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 public boolean hideExpBottles = false; 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 new file mode 100644 index 000000000..bdb6db48d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -0,0 +1,152 @@ +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<List<Any>>() + private var treasuresMined = 0 + private var compactProcs = 0 + private var estimatedIce = 0L + private var lastEstimatedIce = 0L + private val icePerMin = mutableListOf<Long>() + private var icePerHour = 0 + private var missedMinutes = 0 + private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() + + private var treasureCount = mapOf<FrozenTreasures, Int>() + + 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<Any>>): List<List<Any>> { + val newList = mutableListOf<List<Any>>() + for (index in config.textFormat) { + newList.add(map[index]) + } + 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<List<Any>> { + 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()) + } + + 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 new file mode 100644 index 000000000..d9d936a31 --- /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", 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 |