diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-09-23 19:01:06 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-23 11:01:06 +0200 |
commit | 0e056d210d4cf46c1c82310c01adc99f8ab1853e (patch) | |
tree | 917eddd3e50aec16d989527ab4f3628adec7de97 /src | |
parent | 8df9bd41947f91d2014156f345f8f21bd382682a (diff) | |
download | skyhanni-0e056d210d4cf46c1c82310c01adc99f8ab1853e.tar.gz skyhanni-0e056d210d4cf46c1c82310c01adc99f8ab1853e.tar.bz2 skyhanni-0e056d210d4cf46c1c82310c01adc99f8ab1853e.zip |
Trevor stuff and small frozen treasure tracker stuff #422
* accept quest hotkey and more prevention for false detects
* saving to fix other thing
* basic data tracker done and fix ice tracker/hr
* colour change and elusive horse thx fycron
* Merge branch 'hannibal002:beta' into trevor_changes
* Merge remote-tracking branch 'origin/trevor_changes' into trevor_changes
* Merge branch 'beta' into trevor_changes
* fix
* update display each second
* Merge branch 'beta' into trevor_changes
* Merge branch 'hannibal002:beta' into trevor_changes
* i prob did this right
* okay this might be better
* Merge branch 'beta' into trevor_changes
* nea change
* think this is what nea meant
* fix toctou?
* Merge branch 'beta' into trevor_changes
Diffstat (limited to 'src')
8 files changed, 306 insertions, 40 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 70d50a536..4fbc113e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -67,6 +67,7 @@ import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayHelper import at.hannibal2.skyhanni.features.misc.tiarelay.TiaRelayWaypoints import at.hannibal2.skyhanni.features.misc.trevor.TrevorFeatures import at.hannibal2.skyhanni.features.misc.trevor.TrevorSolver +import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.mobs.AreaMiniBossFeatures import at.hannibal2.skyhanni.features.mobs.AshfangMinisNametagHider @@ -330,8 +331,9 @@ class SkyHanniMod { loadModule(MovementSpeedDisplay()) loadModule(ChumBucketHider()) loadModule(InquisitorWaypointShare) - loadModule(TrevorFeatures()) + loadModule(TrevorFeatures) loadModule(TrevorSolver) + loadModule(TrevorTracker) loadModule(BingoCardTips()) loadModule(GardenVisitorDropStatistics) loadModule(CaptureFarmingGear()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index da3ccd8f4..3c3d0d130 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import at.hannibal2.skyhanni.features.misc.EnderNode; import at.hannibal2.skyhanni.features.misc.FrozenTreasure; import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData; +import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.misc.powdertracker.PowderChestReward; import at.hannibal2.skyhanni.features.rift.area.westvillage.KloonTerminal; import at.hannibal2.skyhanni.utils.LorenzVec; @@ -407,5 +408,26 @@ public class Storage { @Expose public List<String> kingsTalkedTo = new ArrayList<>(); } + + @Expose + public TrapperData trapperData = new TrapperData(); + + public static class TrapperData { + + @Expose + public int questsDone; + + @Expose + public int peltsGained; + + @Expose + public int killedAnimals; + + @Expose + public int selfKillingAnimals; + + @Expose + public Map<TrevorTracker.TrapperMobRarity, Integer> animalRarities= new HashMap<>(); + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index f50d95dca..da816457e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -7,6 +7,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 MiscConfig { @Expose @@ -281,6 +285,51 @@ public class MiscConfig { public static class TrevorTheTrapper { @Expose + @ConfigOption( + name = "Enable Data Tracker", + desc = "Tracks all of your data from doing Trevor Quests.\n" + + "Shows based on the setting below" + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean dataTracker = true; + + @Expose + @ConfigOption( + name = "Show Between Quests", + desc = "Shows the tracker during and between quests otherwise it will only show during them." + + "Will show in the Trapper's Den regardless. Global toggle above" + ) + @ConfigEditorBoolean + public boolean displayType = true; + + @Expose + @ConfigOption( + name = "Text Format", + desc = "Drag text to change the appearance of the overlay." + ) + @ConfigEditorDraggableList( + exampleText = { + "§b§lTrevor Data Tracker", + "§b1,428 §9Quests Started", + "§b11,281 §5Total Pelts Gained", + "§b2,448 §5Pelts Per Hour", + "", + "§b850 §cKilled Animals", + "§b153 §cSelf Killing Animals", + "§b788 §fTrackable Animals", + "§b239 §aUntrackable Animals", + "§b115 §9Undetected Animals", + "§b73 §5Endangered Animals", + "§b12 §6Elusive Animals" + } + ) + public List<Integer> textFormat = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11)); + + @Expose + public Position position = new Position(10, 80, false, true); + + @Expose @ConfigOption(name = "Trapper Solver", desc = "Assists you in finding Trevor's mobs. §eNote: May not always work as expected. " + "§cWill not help you to find rabbits or sheep in the Oasis!") @ConfigEditorBoolean @@ -299,10 +348,18 @@ public class MiscConfig { public boolean warpToTrapper = false; @Expose - @ConfigOption(name = "Warp Hotkey", desc = "Press this key to warp to Trevor's Den.") + @ConfigOption(name = "Accept Trapper Quest", desc = "Click this key after the chat prompt to accept Trevor's quest.") + @ConfigEditorBoolean + @FeatureToggle + public boolean acceptQuest = false; + + @Expose + @ConfigOption(name = "Trapper Hotkey", desc = "Press this key to warp to Trevor's Den and to accept the quest." + + "§eRequires the relevant above settings to be toggled") @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) public int keyBindWarpTrapper = Keyboard.KEY_NONE; + @Expose @ConfigOption(name = "Trapper Cooldown", desc = "Change the color of Trevor and adds a cooldown over his head.") @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 index e80c5b15b..6a77f9fe9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt @@ -26,13 +26,13 @@ class FrozenTreasureTracker { private var display = emptyList<List<Any>>() private var estimatedIce = 0L private var lastEstimatedIce = 0L - private val icePerMin = mutableListOf<Long>() + private var icePerSecond = mutableListOf<Long>() private var icePerHour = 0 private var stoppedChecks = 0 private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() init { - fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 1000) { + fixedRateTimer(name = "skyhanni-frozen-treasure-tracker", period = 1000) { if (!onJerryWorkshop()) return@fixedRateTimer calculateIcePerHour() } @@ -42,7 +42,7 @@ class FrozenTreasureTracker { fun onWorldChange(event: LorenzWorldChangeEvent) { icePerHour = 0 stoppedChecks = 0 - icePerMin.clear() + icePerSecond = mutableListOf() saveAndUpdate() } @@ -50,23 +50,28 @@ class FrozenTreasureTracker { val difference = estimatedIce - lastEstimatedIce lastEstimatedIce = estimatedIce - if (difference == estimatedIce) { - return - } + if (difference == estimatedIce) return - icePerHour = icePerMin.average().toInt() * 3600 - icePerMin.add(difference) if (difference == 0L) { + if (icePerSecond.isEmpty()) return stoppedChecks += 1 - if (stoppedChecks == 60) { + } else { + if (stoppedChecks > 60) { stoppedChecks = 0 - icePerMin.clear() + icePerSecond.clear() icePerHour = 0 } - return + while (stoppedChecks > 0) { + stoppedChecks -= 1 + icePerSecond.add(0) + } + icePerSecond.add(difference) + val listCopy = icePerSecond + while (listCopy.size > 1200) listCopy.removeAt(0) + icePerSecond = listCopy } - stoppedChecks = 0 + icePerHour = (icePerSecond.average() * 3600).toInt() } private fun formatDisplay(map: List<List<Any>>): List<List<Any>> { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt index fcc083bc7..f8a7f7c4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt @@ -9,6 +9,6 @@ enum class CurrentMobArea(val location: String, val coordinates: LorenzVec) { SETTLEMENT("Desert Settlement", LorenzVec(184.0, 86.0, -384.0)), GLOWING("Glowing Mushroom Cave", LorenzVec(199.0, 50.0, -512.0)), MOUNTAIN("Desert Mountain", LorenzVec(255.0, 148.0, -518.0)), - FOUND("Mob Location", LorenzVec(0.0, 0.0, 0.0)), + FOUND(" ", LorenzVec(0.0, 0.0, 0.0)), NONE(" ", LorenzVec(0.0, 0.0, 0.0)), }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 7b0482efd..7dd67a549 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -30,7 +30,7 @@ import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.seconds -class TrevorFeatures { +object TrevorFeatures { private val trapperPattern = "\\[NPC] Trevor: You can find your (?<rarity>.*) animal near the (?<location>.*).".toPattern() private val talbotPatternAbove = @@ -45,6 +45,12 @@ class TrevorFeatures { private var trapperID: Int = 56 private var backupTrapperID: Int = 17 private var timeLastWarped: Long = 0 + private var lastChatPrompt = "" + private var lastChatPromptTime = -1L + private var teleportBlock = -1L + + var questActive = false + var inBetweenQuests = false private val config get() = SkyHanniMod.feature.misc.trevorTheTrapper @@ -55,7 +61,9 @@ class TrevorFeatures { if (config.trapperSolver) { if (onFarmingIsland()) { updateTrapper() - TrevorSolver.findMob() + TrevorTracker.saveAndUpdate() + TrevorTracker.calculatePeltsPerHour() + if (questActive) TrevorSolver.findMob() } } } catch (error: Throwable) { @@ -92,6 +100,9 @@ class TrevorFeatures { currentStatus = TrapperStatus.ACTIVE currentLabel = "§cActive Quest" trapperReady = false + TrevorTracker.startQuest(matcher) + updateTrapper() + lastChatPromptTime = -1L } matcher = talbotPatternAbove.matcher(event.message.removeColor()) @@ -105,6 +116,24 @@ class TrevorFeatures { val height = matcher.group("height").toInt() TrevorSolver.findMobHeight(height, false) } + + if (event.message.removeColor() == "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task.") { + teleportBlock = System.currentTimeMillis() + } + + if (event.message.contains("§r§7Click an option: §r§a§l[YES]§r§7 - §r§c§l[NO]")) { + + val siblings = event.chatComponent.siblings + + for (sibling in siblings) { + if (sibling.chatStyle.chatClickEvent != null) { + if (sibling.chatStyle.chatClickEvent.value.contains("YES")) { + lastChatPromptTime = System.currentTimeMillis() + lastChatPrompt = sibling.chatStyle.chatClickEvent.value.drop(1) + } + } + } + } } @SubscribeEvent(priority = EventPriority.LOWEST) @@ -165,10 +194,13 @@ class TrevorFeatures { if (!found) TrevorSolver.mobLocation = CurrentMobArea.NONE if (!active) { trapperReady = true + } else { + inBetweenQuests = true } if (TrevorSolver.mobCoordinates != LorenzVec(0.0, 0.0, 0.0) && active) { TrevorSolver.mobLocation = previousLocation } + questActive = active } @SubscribeEvent @@ -196,9 +228,10 @@ class TrevorFeatures { location = LorenzVec(location.x, TrevorSolver.averageHeight, location.z) } if (TrevorSolver.mobLocation == CurrentMobArea.FOUND) { + val displayName = if (TrevorSolver.currentMob == null) "Mob Location" else TrevorSolver.currentMob!!.mobName location = TrevorSolver.mobCoordinates event.drawWaypointFilled(location.add(0, -2, 0), LorenzColor.GREEN.toColor(), true, true) - event.drawDynamicText(location.add(0, 1, 0), TrevorSolver.mobLocation.location, 1.5) + event.drawDynamicText(location.add(0, 1, 0), displayName, 1.5) } else { event.drawWaypointFilled(location, LorenzColor.GOLD.toColor(), true, true) event.drawDynamicText(location.add(0, 1, 0), TrevorSolver.mobLocation.location, 1.5) @@ -208,20 +241,30 @@ class TrevorFeatures { @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (!config.warpToTrapper) return if (!onFarmingIsland()) return if (!Keyboard.getEventKeyState()) return - val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() - if (config.keyBindWarpTrapper != key) return Minecraft.getMinecraft().currentScreen?.let { if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return } if (NEUItems.neuHasFocus()) return - - if (System.currentTimeMillis() - timeLastWarped < 3000) return - LorenzUtils.sendCommandToServer("warp trapper") - timeLastWarped = System.currentTimeMillis() + val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() + if (config.keyBindWarpTrapper == key) { + if (lastChatPromptTime != -1L && config.acceptQuest && !questActive) { + if (System.currentTimeMillis() - 200 > lastChatPromptTime && System.currentTimeMillis() < lastChatPromptTime + 5000) { + lastChatPromptTime = -1L + LorenzUtils.sendCommandToServer(lastChatPrompt) + lastChatPrompt = "" + timeLastWarped = System.currentTimeMillis() + return + } + } + if (System.currentTimeMillis() - timeLastWarped > 3000 && config.warpToTrapper) { + if (System.currentTimeMillis() < teleportBlock + 5000) return + LorenzUtils.sendCommandToServer("warp trapper") + timeLastWarped = System.currentTimeMillis() + } + } } @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -241,6 +284,8 @@ class TrevorFeatures { TrevorSolver.resetLocation() currentStatus = TrapperStatus.READY currentLabel = "§2Ready" + questActive = false + inBetweenQuests = false } enum class TrapperStatus(baseColor: LorenzColor) { @@ -253,8 +298,8 @@ class TrevorFeatures { val colorCode = baseColor.getChatColor() } - private fun onFarmingIsland() = + fun onFarmingIsland() = LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.THE_FARMING_ISLANDS - private fun inTrapperDen() = ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §bTrapper's Den") + fun inTrapperDen() = ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §bTrapper's Den") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt index 475a9fda1..f5d87d5e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.misc.trevor import at.hannibal2.skyhanni.data.TitleUtils import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth @@ -13,13 +12,12 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.entity.passive.EntityChicken import kotlin.time.Duration.Companion.seconds object TrevorSolver { - private val animalHealths = intArrayOf(100, 200, 400, 500, 1000, 2000, 5000, 10000, 20000) //future proofing for Derpy :) + private val animalHealths = intArrayOf(100, 200, 500, 1000, 2000, 5000, 10000, 30000) - private var currentMob: TrevorMobs? = null + var currentMob: TrevorMobs? = null private var maxHeight: Double = 0.0 private var minHeight: Double = 0.0 private var foundID = -1 @@ -55,14 +53,6 @@ object TrevorSolver { val name = entity.name val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth.derpy() else 0 currentMob = TrevorMobs.entries.firstOrNull { it.mobName.contains(name) } - if (currentMob == TrevorMobs.CHICKEN) { - if (entity is EntityChicken) { - if (entity.hasMaxHealth(20_000)) { - // raider of the sea - currentMob = null - } - } - } if (animalHealths.any { it == entityHealth }) { if (currentMob != null) { if (foundID == entity.entityId) { @@ -80,7 +70,7 @@ object TrevorSolver { } if (canSee) { if (mobLocation != CurrentMobArea.FOUND) { - TitleUtils.sendTitle("§2Saw Mob!", 3.seconds) + TitleUtils.sendTitle("§2Saw ${currentMob!!.mobName}!", 3.seconds) } mobLocation = CurrentMobArea.FOUND mobCoordinates = entity.position.toLorenzVec() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt new file mode 100644 index 000000000..53f3d2482 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt @@ -0,0 +1,145 @@ +package at.hannibal2.skyhanni.features.misc.trevor + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.Storage +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Matcher + +object TrevorTracker { + private val config get() = SkyHanniMod.feature.misc.trevorTheTrapper + private var display = emptyList<List<Any>>() + + private val selfKillMobPattern = "§aYour mob died randomly, you are rewarded §r§5(?<pelts>.*) pelts§r§a.".toPattern() + private val killMobPattern = "§aKilling the animal rewarded you §r§5(?<pelts>.*) pelts§r§a.".toPattern() + + private val peltsPerSecond = mutableListOf<Int>() + private var peltsPerHour = 0 + private var stoppedChecks = 0 + private var lastPelts = 0 + + fun calculatePeltsPerHour() { + val storage = ProfileStorageData.profileSpecific?.trapperData ?: return + val difference = storage.peltsGained - lastPelts + lastPelts = storage.peltsGained + println("last: $lastPelts stopped: $stoppedChecks difference: $difference length: ${peltsPerSecond.size}") + + if (difference == storage.peltsGained) return + + if (difference == 0) { + if (peltsPerSecond.isEmpty()) return + stoppedChecks += 1 + } else { + if (stoppedChecks > 150) { + peltsPerSecond.clear() + peltsPerHour = 0 + stoppedChecks = 0 + } + while (stoppedChecks > 0) { + stoppedChecks -= 1 + peltsPerSecond.add(0) + } + peltsPerSecond.add(difference) + } + + peltsPerHour = (peltsPerSecond.average() * 3600).toInt() + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + peltsPerSecond.clear() + peltsPerHour = 0 + stoppedChecks = 0 + saveAndUpdate() + } + + 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 (!TrevorFeatures.onFarmingIsland()) return + val storage = ProfileStorageData.profileSpecific?.trapperData ?: return + + var matcher = selfKillMobPattern.matcher(event.message) + if (matcher.matches()) { + val pelts = matcher.group("pelts").toInt() + storage.peltsGained += pelts + storage.selfKillingAnimals += 1 + saveAndUpdate() + } + matcher = killMobPattern.matcher(event.message) + if (matcher.matches()) { + val pelts = matcher.group("pelts").toInt() + storage.peltsGained += pelts + storage.killedAnimals += 1 + saveAndUpdate() + } + } + + fun startQuest(matcher: Matcher) { + val storage = ProfileStorageData.profileSpecific?.trapperData ?: return + storage.questsDone += 1 + val rarity = matcher.group("rarity") + val foundRarity = TrapperMobRarity.values().firstOrNull { it.formattedName == rarity } ?: return + val old = storage.animalRarities[foundRarity] ?: 0 + storage.animalRarities = storage.animalRarities.editCopy { this[foundRarity] = old + 1 } + saveAndUpdate() + } + + fun saveAndUpdate() { + val storage = ProfileStorageData.profileSpecific?.trapperData ?: return + display = formatDisplay(drawTrapperDisplay(storage)) + } + + private fun drawTrapperDisplay(storage: Storage.ProfileSpecific.TrapperData) = buildList<List<Any>> { + addAsSingletonList("§b§lTrevor Data Tracker") + addAsSingletonList("§b${storage.questsDone.addSeparators()} §9Quests Started") + addAsSingletonList("§b${storage.peltsGained.addSeparators()} §5Total Pelts Gained") + addAsSingletonList("§b${peltsPerHour.addSeparators()} §5Pelts Per Hour") + addAsSingletonList("") + addAsSingletonList("§b${storage.killedAnimals.addSeparators()} §cKilled Animals") + addAsSingletonList("§b${storage.selfKillingAnimals.addSeparators()} §cSelf Killing Animals") + addAsSingletonList("§b${(storage.animalRarities[TrapperMobRarity.TRACKABLE] ?: 0).addSeparators()} §fTrackable Animals") + addAsSingletonList("§b${(storage.animalRarities[TrapperMobRarity.UNTRACKABLE] ?: 0).addSeparators()} §aUntrackable Animals") + addAsSingletonList("§b${(storage.animalRarities[TrapperMobRarity.UNDETECTED] ?: 0).addSeparators()} §9Undetected Animals") + addAsSingletonList("§b${(storage.animalRarities[TrapperMobRarity.ENDANGERED] ?: 0).addSeparators()} §5Endangered Animals") + addAsSingletonList("§b${(storage.animalRarities[TrapperMobRarity.ELUSIVE] ?: 0).addSeparators()} §6Elusive Animals") + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { + if (!shouldDisplay()) return + config.position.renderStringsAndItems(display, posLabel = "Frozen Treasure Tracker") + } + + private fun shouldDisplay(): Boolean { + if (!config.dataTracker) return false + if (!TrevorFeatures.onFarmingIsland()) return false + if (TrevorFeatures.inTrapperDen()) return true + return when (config.displayType) { + true -> (TrevorFeatures.inBetweenQuests || TrevorFeatures.questActive) + else -> TrevorFeatures.questActive + } + } + + enum class TrapperMobRarity(val formattedName: String) { + TRACKABLE("TRACKABLE"), + UNTRACKABLE("UNTRACKABLE"), + UNDETECTED("UNDETECTED"), + ENDANGERED("ENDANGERED"), + ELUSIVE("ELUSIVE") + } +}
\ No newline at end of file |