From 68abc8ade546de62aee76e0b786993fc59fbc3cc Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Sat, 21 Oct 2023 07:31:19 +0100 Subject: Internal Change: Misc Refactoring (#551) Internal Change: Misc Refactoring #551 --- .../skyhanni/features/misc/BestiaryData.kt | 489 -------------------- .../hannibal2/skyhanni/features/misc/ChatPeek.kt | 30 -- .../hannibal2/skyhanni/features/misc/ChestValue.kt | 277 ------------ .../skyhanni/features/misc/ChickenHeadTimer.kt | 75 ---- .../skyhanni/features/misc/ChumBucketHider.kt | 83 ---- .../features/misc/CompactSplashPotionMessage.kt | 32 -- .../hannibal2/skyhanni/features/misc/EnderNode.kt | 33 -- .../skyhanni/features/misc/EnderNodeTracker.kt | 239 ---------- .../skyhanni/features/misc/FrozenTreasure.kt | 19 - .../features/misc/FrozenTreasureTracker.kt | 167 ------- .../skyhanni/features/misc/HarpFeatures.kt | 78 ---- .../skyhanni/features/misc/HideDamageSplash.kt | 28 -- .../features/misc/ThunderSparksHighlight.kt | 77 ---- .../features/misc/ghostcounter/GhostCounter.kt | 494 --------------------- .../features/misc/ghostcounter/GhostData.kt | 90 ---- .../features/misc/ghostcounter/GhostFormatting.kt | 182 -------- .../features/misc/ghostcounter/GhostUtil.kt | 144 ------ .../misc/powdertracker/PowderChestReward.kt | 148 ------ .../features/misc/powdertracker/PowderTracker.kt | 366 --------------- .../misc/tabcomplete/GetFromSacksTabComplete.kt | 45 -- .../features/misc/tabcomplete/PlayerTabComplete.kt | 86 ---- .../features/misc/tabcomplete/TabComplete.kt | 38 -- .../features/misc/tabcomplete/WarpTabComplete.kt | 26 -- .../skyhanni/features/misc/tiarelay/Relay.kt | 48 -- .../features/misc/tiarelay/TiaRelayHelper.kt | 146 ------ .../features/misc/tiarelay/TiaRelayWaypoints.kt | 63 --- 26 files changed, 3503 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/HideDamageSplash.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ThunderSparksHighlight.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostFormatting.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/powdertracker/PowderChestReward.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/powdertracker/PowderTracker.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/GetFromSacksTabComplete.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/PlayerTabComplete.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/TabComplete.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tabcomplete/WarpTabComplete.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/Relay.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayHelper.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/tiarelay/TiaRelayWaypoints.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt deleted file mode 100644 index 211641694..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BestiaryData.kt +++ /dev/null @@ -1,489 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.addButton -import at.hannibal2.skyhanni.utils.NumberUtil -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded -import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision -import at.hannibal2.skyhanni.utils.NumberUtil.toRoman -import at.hannibal2.skyhanni.utils.RenderUtils.highlight -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.renderables.Renderable -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - - -object BestiaryData { - - private val config get() = SkyHanniMod.feature.combat.bestiary - private var display = emptyList>() - private val mobList = mutableListOf() - private val stackList = mutableMapOf() - private val catList = mutableListOf() - private val progressPattern = "(?[0-9kKmMbB,.]+)/(?[0-9kKmMbB,.]+$)".toPattern() - private val titlePattern = "^(?:\\(\\d+/\\d+\\) )?(Bestiary|.+) ➜ (.+)$".toPattern() - private var inInventory = false - private var isCategory = false - private var indexes = listOf( - 10, 11, 12, 13, 14, 15, 16, - 19, 20, 21, 22, 23, 24, 25, - 28, 29, 30, 31, 32, 33, 34, - 37, 38, 39, 40, 41, 42, 43 - ) - - @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - if (!isEnabled()) return - if (inInventory) { - config.position.renderStringsAndItems( - display, - extraSpace = -1, - itemScale = 1.3, - posLabel = "Bestiary Data" - ) - } - } - - @SubscribeEvent - fun onRender(event: GuiContainerEvent.BackgroundDrawnEvent) { - if (!isEnabled()) return - if (inInventory) { - for (slot in InventoryUtils.getItemsInOpenChest()) { - val stack = slot.stack - val lore = stack.getLore() - if (lore.any { it == "§7Overall Progress: §b100% §7(§c§lMAX!§7)" || it == "§7Families Completed: §a100%" }) { - slot highlight LorenzColor.GREEN - } - } - } - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!isEnabled()) return - val inventoryName = event.inventoryName - val stack = event.inventoryItems[4] ?: return - if ((inventoryName == "Bestiary ➜ Fishing" || inventoryName == "Bestiary") || isBestiaryGui( - stack, - inventoryName - ) - ) { - isCategory = inventoryName == "Bestiary ➜ Fishing" || inventoryName == "Bestiary" - stackList.putAll(event.inventoryItems) - inInventory = true - update() - } - } - - @SubscribeEvent - fun onInventoryClose(event: InventoryCloseEvent) { - mobList.clear() - stackList.clear() - inInventory = false - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "misc.bestiaryData", "combat.bestiary") - } - - private fun update() { - display = drawDisplay() - } - - private fun init() { - mobList.clear() - catList.clear() - if (isCategory) { - inCategory() - } else { - notInCategory() - } - } - - private fun inCategory() { - for ((index, stack) in stackList) { - if (stack.displayName == " ") continue - if (!indexes.contains(index)) continue - inInventory = true - val name = stack.displayName - var familiesFound: Long = 0 - var totalFamilies: Long = 0 - var familiesCompleted: Long = 0 - for ((lineIndex, loreLine) in stack.getLore().withIndex()) { - val line = loreLine.removeColor() - if (!line.startsWith(" ")) continue - val previousLine = stack.getLore()[lineIndex - 1] - val progress = line.substring(line.lastIndexOf(' ') + 1) - if (previousLine.contains("Families Found")) { - progressPattern.matchMatcher(progress) { - familiesFound = group("current").formatNumber() - totalFamilies = group("needed").formatNumber() - } - } else if (previousLine.contains("Families Completed")) { - progressPattern.matchMatcher(progress) { - familiesCompleted = group("current").formatNumber() - } - } - } - catList.add(Category(name, familiesFound, totalFamilies, familiesCompleted)) - } - } - - private fun notInCategory() { - for ((index, stack) in stackList) { - if (stack.displayName == " ") continue - if (!indexes.contains(index)) continue - inInventory = true - val name = " [IVX0-9]+$".toPattern().matcher(stack.displayName).replaceFirst("") - val level = " ([IVX0-9]+$)".toRegex().find(stack.displayName)?.groupValues?.get(1) ?: "0" - var totalKillToMax: Long = 0 - var currentTotalKill: Long = 0 - var totalKillToTier: Long = 0 - var currentKillToTier: Long = 0 - var actualRealTotalKill: Long = 0 - for ((lineIndex, line) in stack.getLore().withIndex()) { - val loreLine = line.removeColor() - if (loreLine.startsWith("Kills: ")) { - actualRealTotalKill = - "([0-9,.]+)".toRegex().find(loreLine)?.groupValues?.get(1)?.formatNumber() - ?: 0 - } - if (!loreLine.startsWith(" ")) continue - val previousLine = stack.getLore()[lineIndex - 1] - val progress = loreLine.substring(loreLine.lastIndexOf(' ') + 1) - if (previousLine.contains("Progress to Tier")) { - progressPattern.matchMatcher(progress) { - totalKillToTier = group("needed").formatNumber() - currentKillToTier = group("current").formatNumber() - } - } else if (previousLine.contains("Overall Progress")) { - progressPattern.matchMatcher(progress) { - totalKillToMax = group("needed").formatNumber() - currentTotalKill = group("current").formatNumber() - } - } - } - mobList.add( - BestiaryMob( - name, - level, - totalKillToMax, - currentTotalKill, - totalKillToTier, - currentKillToTier, - actualRealTotalKill - ) - ) - } - } - - private fun drawDisplay(): List> { - val newDisplay = mutableListOf>() - init() - - addCategories(newDisplay) - - if (mobList.isEmpty()) return newDisplay - - addList(newDisplay) - - addButtons(newDisplay) - - return newDisplay - } - - private fun sortMobList(): MutableList { - val sortedMobList = when (config.displayType) { - 0 -> mobList.sortedBy { it.percentToMax() } - 1 -> mobList.sortedBy { it.percentToTier() } - 2 -> mobList.sortedBy { it.totalKills } - 3 -> mobList.sortedByDescending { it.totalKills } - 4 -> mobList.sortedBy { it.killNeededToMax() } - 5 -> mobList.sortedByDescending { it.killNeededToMax() } - 6 -> mobList.sortedBy { it.killNeededToNextLevel() } - 7 -> mobList.sortedByDescending { it.killNeededToNextLevel() } - else -> mobList.sortedBy { it.totalKills } - }.toMutableList() - return sortedMobList - } - - private fun addList(newDisplay: MutableList>) { - val sortedMobList = sortMobList() - - newDisplay.addAsSingletonList("§7Bestiary Data") - for (mob in sortedMobList) { - val isUnlocked = mob.totalKills != 0.toLong() - val isMaxed = mob.percentToMax() >= 1 - if (!isUnlocked) { - newDisplay.add(buildList { - add(" §7- ") - add("${mob.name}: §cNot unlocked!") - }) - continue - } - if (isMaxed && config.hideMaxed) continue - val text = getMobLine(mob, isMaxed) - val tips = getMobHover(mob) - newDisplay.addAsSingletonList(Renderable.hoverTips(text, tips) { true }) - } - } - - private fun getMobHover(mob: BestiaryMob) = listOf( - "§6Name: §b${mob.name}", - "§6Level: §b${mob.level} ${if (!config.replaceRoman) "§7(${mob.level.romanToDecimalIfNeeded()})" else ""}", - "§6Total Kills: §b${mob.actualRealTotalKill.formatNumber()}", - "§6Kills needed to max: §b${mob.killNeededToMax().formatNumber()}", - "§6Kills needed to next lvl: §b${mob.killNeededToNextLevel().formatNumber()}", - "§6Current kill to next level: §b${mob.currentKillToNextLevel.formatNumber()}", - "§6Kill needed for next level: §b${mob.killNeededForNextLevel.formatNumber()}", - "§6Current kill to max: §b${mob.killToMax.formatNumber()}", - "§6Percent to max: §b${mob.percentToMaxFormatted()}", - "§6Percent to tier: §b${mob.percentToTierFormatted()}", - "", - "§7More info thing" - ) - - private fun getMobLine( - mob: BestiaryMob, - isMaxed: Boolean - ): String { - val displayType = config.displayType - var text = "" - text += " §7- " - text += "${mob.name} ${mob.level.romanOrInt()} " - text += if (isMaxed) { - "§c§lMAXED! §7(§b${mob.actualRealTotalKill.formatNumber()}§7 kills)" - } else { - when (displayType) { - 0, 1 -> { - val currentKill = when (displayType) { - 0 -> mob.totalKills - 1 -> mob.currentKillToNextLevel - else -> 0 - } - val killNeeded = when (displayType) { - 0 -> mob.killToMax - 1 -> mob.killNeededForNextLevel - else -> 0 - } - "§7(§b${currentKill.formatNumber()}§7/§b${killNeeded.formatNumber()}§7) §a${ - ((currentKill.toDouble() / killNeeded) * 100).roundToPrecision( - 2 - ) - }§6% ${if (displayType == 1) "§ato level ${mob.getNextLevel()}" else ""}" - } - - 2, 3 -> { - - "§6${mob.totalKills.formatNumber()} §7total kills" - } - - 4, 5 -> { - "§6${mob.killNeededToMax().formatNumber()} §7kills needed" - } - - 6, 7 -> { - "§6${mob.killNeededToNextLevel().formatNumber()} §7kills needed" - } - - else -> "§cYou are not supposed to see this, please report it to @HiZe on discord!" - } - } - return text - } - - private fun addButtons(newDisplay: MutableList>) { - newDisplay.addButton( - prefix = "§7Number Format: ", - getName = FormatType.entries[config.numberFormat].type, - onChange = { - config.numberFormat = (config.numberFormat + 1) % 2 - update() - }) - - newDisplay.addButton( - prefix = "§7Display Type: ", - getName = DisplayType.entries[config.displayType].type, - onChange = { - config.displayType = (config.displayType + 1) % 8 - update() - }) - - newDisplay.addButton( - prefix = "§7Number Type: ", - getName = NumberType.entries[if (config.replaceRoman) 0 else 1].type, - onChange = { - config.replaceRoman = !config.replaceRoman - update() - } - ) - newDisplay.addButton( - prefix = "§7Hide Maxed: ", - getName = HideMaxed.entries[if (config.hideMaxed) 1 else 0].type, - onChange = { - config.hideMaxed = !config.hideMaxed - update() - } - ) - } - - private fun addCategories(newDisplay: MutableList>) { - if (catList.isNotEmpty()) { - newDisplay.addAsSingletonList("§7Category") - for (cat in catList) { - newDisplay.add(buildList { - add(" §7- ${cat.name}§7: ") - val element = when { - cat.familiesCompleted == cat.totalFamilies -> "§c§lCompleted!" - cat.familiesFound == cat.totalFamilies -> "§b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed" - cat.familiesFound < cat.totalFamilies -> - "§b${cat.familiesFound}§7/§b${cat.totalFamilies} §7found, §b${cat.familiesCompleted}§7/§b${cat.totalFamilies} §7completed" - - else -> continue - } - add(element) - }) - } - } - } - - private fun isBestiaryGui(stack: ItemStack?, name: String): Boolean { - if (stack == null) return false - val bestiaryGuiTitleMatcher = titlePattern.matcher(name) - if (bestiaryGuiTitleMatcher.matches()) { - if ("Bestiary" != bestiaryGuiTitleMatcher.group(1)) { - var loreContainsFamiliesFound = false - for (line in stack.getLore()) { - if (line.removeColor().startsWith("Families Found")) { - loreContainsFamiliesFound = true - break - } - } - if (!loreContainsFamiliesFound) { - return false - } - } - return true - } else if (name == "Search Results") { - val loreList = stack.getLore() - if (loreList.size >= 2 && loreList[0].startsWith("§7Query: §a") - && loreList[1].startsWith("§7Results: §a") - ) { - return true - } - } - return false - } - - enum class FormatType(val type: String) { - SHORT("Short"), - LONG("Long") - } - - enum class NumberType(val type: String) { - INT("Normal (1, 2, 3)"), - ROMAN("Roman (I, II, III") - } - - enum class DisplayType(val type: String) { - GLOBAL_MAX("Global display (to max)"), - GLOBAL_TIER("Global display (to next tier)"), - LOWEST_TOTAL("Lowest total kills"), - HIGHEST_TOTAL("Highest total kills"), - LOWEST_NEEDED_MAX("Lowest kills needed to max"), - HIGHEST_NEEDED_MAX("Highest kills needed to max"), - LOWEST_NEEDED_TIER("Lowest kills needed to next tier"), - HIGHEST_NEEDED_TIER("Highest kills needed to next tier"), - } - - enum class HideMaxed(val type: String) { - NO("Show"), - YES("Hide") - } - - private fun Long.formatNumber(): String = when (config.numberFormat) { - 0 -> NumberUtil.format(this) - 1 -> this.addSeparators() - else -> "0" - } - - data class Category( - val name: String, - val familiesFound: Long, - val totalFamilies: Long, - val familiesCompleted: Long - ) - - data class BestiaryMob( - var name: String, - var level: String, - var killToMax: Long, - var totalKills: Long, - var killNeededForNextLevel: Long, - var currentKillToNextLevel: Long, - var actualRealTotalKill: Long - ) { - - fun killNeededToMax(): Long { - return 0L.coerceAtLeast(killToMax - totalKills) - } - - fun killNeededToNextLevel(): Long { - return 0L.coerceAtLeast(killNeededForNextLevel - currentKillToNextLevel) - } - - fun percentToMax() = totalKills.toDouble() / killToMax - - fun percentToMaxFormatted() = LorenzUtils.formatPercentage(percentToMax()) - - fun percentToTier() = currentKillToNextLevel.toDouble() / killNeededForNextLevel - - fun percentToTierFormatted() = LorenzUtils.formatPercentage(percentToTier()) - - fun getNextLevel() = level.getNextLevel() - } - - - private fun String.romanOrInt() = romanToDecimalIfNeeded().let { - if (config.replaceRoman || it == 0) it.toString() else it.toRoman() - } - - fun Any.getNextLevel(): String { - return when (this) { - is Int -> { - (this + 1).toString().romanOrInt() - } - - is String -> { - if (this == "0") { - "I".romanOrInt() - } else { - val intValue = romanToDecimalIfNeeded() - (intValue + 1).toRoman().romanOrInt() - } - } - - else -> { - "Unsupported type: ${this::class.simpleName}" - } - } - } - - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt deleted file mode 100644 index b92375f10..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChatPeek.kt +++ /dev/null @@ -1,30 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI -import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui -import at.hannibal2.skyhanni.utils.NEUItems -import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.inventory.GuiEditSign -import org.lwjgl.input.Keyboard - - -object ChatPeek { - @JvmStatic - fun peek(): Boolean { - val key = SkyHanniMod.feature.chat.peekChat - - if (Minecraft.getMinecraft().thePlayer == null) return false - if (key <= Keyboard.KEY_NONE) return false - if (Minecraft.getMinecraft().currentScreen is GuiEditSign) return false - if (Minecraft.getMinecraft().currentScreen is GuiScreenElementWrapper) return false - - if (NEUItems.neuHasFocus()) return false - if (GuiEditManager.isInGui() || FFGuideGUI.isInGui() || VisualWordGui.isInGui()) return false - - return key.isKeyHeld() - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt deleted file mode 100644 index 82db5d451..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChestValue.kt +++ /dev/null @@ -1,277 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.addButton -import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull -import at.hannibal2.skyhanni.utils.NumberUtil -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.RenderUtils.highlight -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.SpecialColour -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.renderables.Renderable -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.inventory.GuiChest -import net.minecraft.init.Items -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color - -class ChestValue { - - private val config get() = SkyHanniMod.feature.inventory.chestValueConfig - private var display = emptyList>() - private val chestItems = mutableMapOf() - private val inInventory get() = isValidStorage() - - @SubscribeEvent - fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - if (!isEnabled()) return - if (InventoryUtils.openInventoryName() == "") return - if (inInventory) { - config.position.renderStringsAndItems( - display, - extraSpace = -1, - itemScale = 1.3, - posLabel = "Estimated Chest Value" - ) - } - } - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - if (event.isMod(5)) { - update() - } - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryOpenEvent) { - if (!isEnabled()) return - if (inInventory) { - update() - } - } - - @SubscribeEvent - fun onInventoryClose(event: InventoryCloseEvent) { - chestItems.clear() - Renderable.list.clear() - } - - @SubscribeEvent(priority = EventPriority.LOW) - fun onDrawBackground(event: GuiContainerEvent.BackgroundDrawnEvent) { - if (!isEnabled()) return - if (!config.enableHighlight) return - if (inInventory) { - for ((_, indexes) in Renderable.list) { - for (slot in InventoryUtils.getItemsInOpenChest()) { - if (indexes.contains(slot.slotIndex)) { - slot highlight Color(SpecialColour.specialToChromaRGB(config.highlightColor), true) - } - } - } - } - } - - private fun update() { - display = drawDisplay() - } - - private fun drawDisplay(): List> { - val newDisplay = mutableListOf>() - - init() - - if (chestItems.isEmpty()) return newDisplay - - addList(newDisplay) - addButton(newDisplay) - - return newDisplay - } - - private fun addList(newDisplay: MutableList>) { - val sortedList = sortedList() - var totalPrice = 0.0 - var rendered = 0 - val amountShowing = if (config.itemToShow > sortedList.size) sortedList.size else config.itemToShow - newDisplay.addAsSingletonList("§7Estimated Chest Value: §o(Showing $amountShowing of ${sortedList.size} items)") - for ((index, amount, stack, total, tips) in sortedList) { - totalPrice += total - if (rendered >= config.itemToShow) continue - if (total < config.hideBelow) continue - val textAmount = " §7x$amount:" - val width = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textAmount) - val name = "${stack.displayName.reduceStringLength((config.nameLength - width), ' ')} $textAmount" - val price = "§b${(total).formatPrice()}" - val text = if (config.alignedDisplay) - "$name $price" - else - "${stack.displayName} §7x$amount: §b${total.formatPrice()}" - newDisplay.add(buildList { - val renderable = Renderable.hoverTips( - text, - tips, - stack = stack, - indexes = index - ) - add(" §7- ") - if (config.showStacks) add(stack) - add(renderable) - }) - rendered++ - } - newDisplay.addAsSingletonList("§6Total value : §b${totalPrice.formatPrice()}") - } - - private fun sortedList(): MutableList { - return when (config.sortingType) { - 0 -> chestItems.values.sortedByDescending { it.total } - 1 -> chestItems.values.sortedBy { it.total } - else -> chestItems.values.sortedByDescending { it.total } - }.toMutableList() - } - - private fun addButton(newDisplay: MutableList>) { - newDisplay.addButton("§7Sorted By: ", - getName = SortType.entries[config.sortingType].longName, - onChange = { - config.sortingType = (config.sortingType + 1) % 2 - update() - }) - - newDisplay.addButton("§7Value format: ", - getName = FormatType.entries[config.formatType].type, - onChange = { - config.formatType = (config.formatType + 1) % 2 - update() - }) - - newDisplay.addButton("§7Display Type: ", - getName = DisplayType.entries[if (config.alignedDisplay) 1 else 0].type, - onChange = { - config.alignedDisplay = !config.alignedDisplay - update() - }) - } - - private fun init() { - if (inInventory) { - val isMinion = InventoryUtils.openInventoryName().contains(" Minion ") - val slots = InventoryUtils.getItemsInOpenChest().filter { - it.hasStack && it.inventory != Minecraft.getMinecraft().thePlayer.inventory && (!isMinion || it.slotNumber % 9 != 1) - } - val stacks = buildMap { - slots.forEach { - put(it.slotIndex, it.stack) - } - } - chestItems.clear() - for ((i, stack) in stacks) { - val internalName = stack.getInternalNameOrNull() ?: continue - if (internalName.getItemStackOrNull() == null) continue - val list = mutableListOf() - val pair = EstimatedItemValue.getEstimatedItemPrice(stack, list) - var (total, _) = pair - if (stack.item == Items.enchanted_book) - total /= 2 - list.add("§aTotal: §6§l${total.formatPrice()}") - if (total == 0.0) continue - val item = chestItems.getOrPut(internalName) { - Item(mutableListOf(), 0, stack, 0.0, list) - } - item.index.add(i) - item.amount += stack.stackSize - item.total += total * stack.stackSize - } - } - } - - private fun Double.formatPrice(): String { - return when (config.formatType) { - 0 -> if (this > 1_000_000_000) NumberUtil.format(this, true) else NumberUtil.format(this) - 1 -> this.addSeparators() - else -> "0" - } - } - - enum class SortType(val shortName: String, val longName: String) { - PRICE_DESC("Price D", "Price Descending"), - PRICE_ASC("Price A", "Price Ascending") - ; - } - - enum class FormatType(val type: String) { - SHORT("Formatted"), - LONG("Unformatted") - ; - } - - enum class DisplayType(val type: String) { - NORMAL("Normal"), - COMPACT("Aligned") - } - - private fun isValidStorage(): Boolean { - val name = InventoryUtils.openInventoryName().removeColor() - if (Minecraft.getMinecraft().currentScreen !is GuiChest) return false - - if ((name.contains("Backpack") && name.contains("Slot #") || name.startsWith("Ender Chest (")) && - !InventoryUtils.isNeuStorageEnabled.getValue() - ) { - return true - } - - val inMinion = name.contains("Minion") && !name.contains("Recipe") && - LorenzUtils.skyBlockIsland == IslandType.PRIVATE_ISLAND - return name == "Chest" || name == "Large Chest" || inMinion || name == "Personal Vault" - } - - private fun String.reduceStringLength(targetLength: Int, char: Char): String { - val mc = Minecraft.getMinecraft() - val spaceWidth = mc.fontRendererObj.getCharWidth(char) - - var currentString = this - var currentLength = mc.fontRendererObj.getStringWidth(currentString) - - while (currentLength > targetLength) { - currentString = currentString.dropLast(1) - currentLength = mc.fontRendererObj.getStringWidth(currentString) - } - - val difference = targetLength - currentLength - - if (difference > 0) { - val numSpacesToAdd = difference / spaceWidth - val spaces = " ".repeat(numSpacesToAdd) - return currentString + spaces - } - - return currentString - } - - data class Item( - val index: MutableList, - var amount: Int, - val stack: ItemStack, - var total: Double, - val tips: MutableList - ) - - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt deleted file mode 100644 index c43f1f623..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChickenHeadTimer.kt +++ /dev/null @@ -1,75 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.TimeUtils -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class ChickenHeadTimer { - private var hasChickenHead = false - private var lastTime = 0L - private val config get() = SkyHanniMod.feature.itemAbilities.chickenHead - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - if (!event.isMod(5)) return - - val itemStack = InventoryUtils.getArmor()[3] - val name = itemStack?.name ?: "" - hasChickenHead = name.contains("Chicken Head") - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - lastTime = System.currentTimeMillis() - } - - @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - if (!isEnabled()) return - if (!hasChickenHead) return - if (event.message == "§aYou laid an egg!") { - lastTime = System.currentTimeMillis() - if (config.hideChat) { - event.blockedReason = "chicken_head_timer" - } - } - } - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!isEnabled()) return - if (!hasChickenHead) return - - val sinceLastTime = System.currentTimeMillis() - lastTime - val cooldown = 5_000 - val remainingTime = cooldown - sinceLastTime - - val displayText = if (remainingTime < 0) { - "Chicken Head Timer: §aNow" - } else { - val formatDuration = TimeUtils.formatDuration(remainingTime) - "Chicken Head Timer: §b$formatDuration" - } - - config.position.renderString(displayText, posLabel = "Chicken Head Timer") - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "misc.chickenHeadTimerHideChat", "itemAbilities.chickenHead.hideChat") - event.move(2, "misc.chickenHeadTimerPosition", "itemAbilities.chickenHead.position") - event.move(2, "misc.chickenHeadTimerDisplay", "itemAbilities.chickenHead.displayTimer") - } - - fun isEnabled() = LorenzUtils.inSkyBlock && config.displayTimer -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt deleted file mode 100644 index 5a0b6fe86..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt +++ /dev/null @@ -1,83 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.ConfigLoadEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.entity.Entity -import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class ChumBucketHider { - private val config get() = SkyHanniMod.feature.fishing.chumBucketHider - private val titleEntity = mutableListOf() - private val hiddenEntities = mutableListOf() - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - reset() - } - - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!LorenzUtils.inSkyBlock) return - if (!config.enabled.get()) return - - val entity = event.entity - if (entity !is EntityArmorStand) return - - if (entity in hiddenEntities) { - event.isCanceled = true - return - } - - val name = entity.name - - // First text line - if (name.endsWith("'s Chum Bucket") || name.endsWith("'s Chumcap Bucket")) { - if (name.contains(LorenzUtils.getPlayerName()) && !config.hideOwn.get()) return - titleEntity.add(entity) - hiddenEntities.add(entity) - event.isCanceled = true - return - } - - // Second text line - if (name.contains("/10 §aChums")) { - val entityLocation = entity.getLorenzVec() - for (title in titleEntity) { - if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { - hiddenEntities.add(entity) - event.isCanceled = true - return - } - } - } - - // Chum Bucket - if (config.hideBucket.get() && entity.inventory.any { it != null && (it.name == "§fEmpty Chum Bucket" || it.name == "§aEmpty Chumcap Bucket") }) { - val entityLocation = entity.getLorenzVec() - for (title in titleEntity) { - if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { - hiddenEntities.add(entity) - event.isCanceled = true - return - } - } - } - } - - @SubscribeEvent - fun onConfigLoad(event: ConfigLoadEvent) { - onToggle(config.enabled, config.hideBucket, config.hideOwn) { reset() } - } - - private fun reset() { - titleEntity.clear() - hiddenEntities.clear() - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt deleted file mode 100644 index 932cdb1bf..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactSplashPotionMessage.kt +++ /dev/null @@ -1,32 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import net.minecraft.util.ChatComponentText -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class CompactSplashPotionMessage { - private val potionEffectPattern = - "§a§lBUFF! §fYou have gained §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() - private val potionEffectOthersPattern = - "§a§lBUFF! §fYou were splashed by (?.*) §fwith §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern() - - @SubscribeEvent - fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.inSkyBlock || !SkyHanniMod.feature.chat.compactPotionMessage) return - - potionEffectPattern.matchMatcher(event.message) { - val name = group("name") - event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$name") - } - - potionEffectOthersPattern.matchMatcher(event.message) { - val playerName = group("playerName").removeColor() - val effectName = group("effectName") - event.chatComponent = ChatComponentText("§a§lPotion Effect! §r$effectName by §b$playerName") - } - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt deleted file mode 100644 index 301dc65e2..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNode.kt +++ /dev/null @@ -1,33 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName - -enum class EnderNode( - val internalName: NEUInternalName, - val displayName: String, -) { - - ENCHANTED_ENDSTONE("ENCHANTED_ENDSTONE".asInternalName(), "§aEnchanted End Stone"), - ENCHANTED_OBSIDIAN("ENCHANTED_OBSIDIAN".asInternalName(), "§aEnchanted Obsidian"), - ENCHANTED_ENDER_PEARL("ENCHANTED_ENDER_PEARL".asInternalName(), "§aEnchanted Ender Pearl"), - GRAND_EXP_BOTTLE("GRAND_EXP_BOTTLE".asInternalName(), "§aGrand Experience Bottle"), - TITANIC_EXP_BOTTLE("TITANIC_EXP_BOTTLE".asInternalName(), "§9Titanic Experience Bottle"), - END_STONE_SHULKER("END_STONE_SHULKER".asInternalName(), "§9End Stone Shulker"), - ENDSTONE_GEODE("ENDSTONE_GEODE".asInternalName(), "§9End Stone Geode"), - MAGIC_RUNE("MAGIC_RUNE;1".asInternalName(), "§d◆ Magical Rune I"), - ENDER_GAUNTLET("ENDER_GAUNTLET".asInternalName(), "§5Ender Gauntlet"), - MITE_GEL("MITE_GEL".asInternalName(), "§5Mite Gel"), - SHRIMP_THE_FISH("SHRIMP_THE_FISH".asInternalName(), "§cShrimp the Fish"), - - END_HELMET("END_HELMET".asInternalName(), "§5Ender Helmet"), - END_CHESTPLATE("END_CHESTPLATE".asInternalName(), "§5Ender Chestplate"), - END_LEGGINGS("END_LEGGINGS".asInternalName(), "§5Ender Leggings"), - END_BOOTS("END_BOOTS".asInternalName(), "§5Ender Boots"), - ENDER_NECKLACE("ENDER_NECKLACE".asInternalName(), "§5Ender Necklace"), - COMMON_ENDERMAN_PET("ENDERMAN;0".asInternalName(), "§fEnderman"), - UNCOMMON_ENDERMAN_PET("ENDERMAN;1".asInternalName(), "§aEnderman"), - RARE_ENDERMAN_PET("ENDERMAN;2".asInternalName(), "§9Enderman"), - EPIC_ENDERMAN_PET("ENDERMAN;3".asInternalName(), "§5Enderman"), - LEGENDARY_ENDERMAN_PET("ENDERMAN;4".asInternalName(), "§6Enderman") -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt deleted file mode 100644 index d07ae0ef2..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EnderNodeTracker.kt +++ /dev/null @@ -1,239 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.Storage -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.ConfigLoadEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.IslandChangeEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent -import at.hannibal2.skyhanni.events.SackChangeEvent -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.LorenzUtils.afterChange -import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy -import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull -import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.format -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import io.github.moulberry.notenoughupdates.util.MinecraftExecutor -import net.minecraft.client.Minecraft -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class EnderNodeTracker { - private val config get() = SkyHanniMod.feature.combat.enderNodeTracker - private val storage get() = ProfileStorageData.profileSpecific?.enderNodeTracker - - private var totalEnderArmor = 0 - private var miteGelInInventory = 0 - private var display = emptyList>() - private var lootProfit = mapOf() - - private val enderNodeRegex = Regex("""ENDER NODE!.+You found (\d+x )?§r(.+)§r§f!""") - private val endermanRegex = Regex("""(RARE|PET) DROP! §r(.+) §r§b\(""") - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!config.enabled) return - if (!ProfileStorageData.loaded) return - if (!isInTheEnd()) return - - // don't call removeColor because we want to distinguish enderman pet rarity - val message = event.message.trim() - var item: String? = null - var amount = 1 - val storage = storage ?: return - - // check whether the loot is from an ender node or an enderman - enderNodeRegex.find(message)?.let { - storage.totalNodesMined++ - amount = it.groups[1]?.value?.substringBefore("x")?.toIntOrNull() ?: 1 - item = it.groups[2]?.value - } ?: endermanRegex.find(message)?.let { - amount = 1 - item = it.groups[2]?.value - } - - when { - item == null -> return - isEnderArmor(item) -> totalEnderArmor++ - item == "§cEndermite Nest" -> { - storage.totalEndermiteNests++ - } - } - - // increment the count of the specific item found - EnderNode.entries.find { it.displayName == item }?.let { - val old = storage.lootCount[it] ?: 0 - storage.lootCount = storage.lootCount.editCopy { - this[it] = old + amount - } - } - update() - } - - @SubscribeEvent - fun onIslandChange(event: IslandChangeEvent) { - if (!config.enabled) return - if (event.newIsland != IslandType.THE_END) return - miteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory - .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName } - .sumOf { it.stackSize } - } - - @SubscribeEvent - fun onSackChange(event: SackChangeEvent) { - if (!config.enabled) return - if (!ProfileStorageData.loaded) return - if (!isInTheEnd()) return - val storage = storage ?: return - - val change = event.sackChanges - .firstOrNull { it.internalName == EnderNode.MITE_GEL.internalName && it.delta > 0 } - ?: return - val old = storage.lootCount[EnderNode.MITE_GEL] ?: 0 - storage.lootCount = storage.lootCount.editCopy { - this[EnderNode.MITE_GEL] = old + change.delta - } - update() - } - - @SubscribeEvent - fun onInventoryUpdate(event: OwnInventoryItemUpdateEvent) { - if (!config.enabled) return - if (!isInTheEnd()) return - if (!ProfileStorageData.loaded) return - val storage = storage ?: return - - MinecraftExecutor.OnThread.execute { - val newMiteGelInInventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory - .filter { it?.getInternalNameOrNull() == EnderNode.MITE_GEL.internalName } - .sumOf { it.stackSize } - val change = newMiteGelInInventory - miteGelInInventory - if (change > 0) { - val old = storage.lootCount[EnderNode.MITE_GEL] ?: 0 - storage.lootCount = storage.lootCount.editCopy { - this[EnderNode.MITE_GEL] = old + change - } - update() - } - miteGelInInventory = newMiteGelInInventory - } - } - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.enabled) return - if (!isInTheEnd()) return - config.position.renderStringsAndItems(display, posLabel = "Ender Node Tracker") - } - - @SubscribeEvent - fun onConfigLoad(event: ConfigLoadEvent) { - config.textFormat.afterChange { - update() - } - val storage = storage ?: return - - totalEnderArmor = storage.lootCount.filter { isEnderArmor(it.key.displayName) } - .map { it.value } - .sum() - update() - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "misc.enderNodeTracker", "combat.enderNodeTracker") - } - - private fun calculateProfit(storage: Storage.ProfileSpecific.EnderNodeTracker): Map { - if (!ProfileStorageData.loaded) return emptyMap() - - val newProfit = mutableMapOf() - storage.lootCount.forEach { (item, amount) -> - val price = if (isEnderArmor(item.displayName)) { - 10_000.0 - } else { - (if (!LorenzUtils.noTradeMode) item.internalName.getPriceOrNull() else 0.0) - ?.coerceAtLeast(item.internalName.getNpcPriceOrNull() ?: 0.0) - ?.coerceAtLeast(georgePrice(item) ?: 0.0) - ?: 0.0 - } - newProfit[item] = price * amount - } - return newProfit - } - - private fun update() { - val storage = storage ?: return - lootProfit = calculateProfit(storage) - display = formatDisplay(drawDisplay(storage)) - } - - private fun isInTheEnd() = LorenzUtils.skyBlockArea == "The End" - - private fun isEnderArmor(displayName: String?) = when (displayName) { - EnderNode.END_HELMET.displayName, - EnderNode.END_CHESTPLATE.displayName, - EnderNode.END_LEGGINGS.displayName, - EnderNode.END_BOOTS.displayName, - EnderNode.ENDER_NECKLACE.displayName, - EnderNode.ENDER_GAUNTLET.displayName -> true - - else -> false - } - - private fun georgePrice(petRarity: EnderNode): Double? = when (petRarity) { - EnderNode.COMMON_ENDERMAN_PET -> 100.0 - EnderNode.UNCOMMON_ENDERMAN_PET -> 500.0 - EnderNode.RARE_ENDERMAN_PET -> 2_000.0 - EnderNode.EPIC_ENDERMAN_PET -> 10_000.0 - EnderNode.LEGENDARY_ENDERMAN_PET -> 1_000_000.0 - else -> null - } - - private fun drawDisplay(storage: Storage.ProfileSpecific.EnderNodeTracker) = buildList> { - if (!ProfileStorageData.loaded) return emptyList>() - - addAsSingletonList("§5§lEnder Node Tracker") - addAsSingletonList("§d${storage.totalNodesMined.addSeparators()} Ender Nodes mined") - addAsSingletonList("§6${format(lootProfit.values.sum())} Coins made") - addAsSingletonList(" ") - addAsSingletonList("§b${storage.totalEndermiteNests.addSeparators()} §cEndermite Nest") - - for (item in EnderNode.entries.subList(0, 11)) { - val count = (storage.lootCount[item] ?: 0).addSeparators() - val profit = format(lootProfit[item] ?: 0.0) - addAsSingletonList("§b$count ${item.displayName} §7(§6$profit§7)") - } - addAsSingletonList(" ") - addAsSingletonList( - "§b${totalEnderArmor.addSeparators()} §5Ender Armor " + - "§7(§6${format(totalEnderArmor * 10_000)}§7)" - ) - for (item in EnderNode.entries.subList(11, 16)) { - val count = (storage.lootCount[item] ?: 0).addSeparators() - val profit = format(lootProfit[item] ?: 0.0) - addAsSingletonList("§b$count ${item.displayName} §7(§6$profit§7)") - } - // enderman pet rarities - val (c, u, r, e, l) = EnderNode.entries.subList(16, 21).map { (storage.lootCount[it] ?: 0).addSeparators() } - val profit = format(EnderNode.entries.subList(16, 21).sumOf { lootProfit[it] ?: 0.0 }) - addAsSingletonList("§f$c§7-§a$u§7-§9$r§7-§5$e§7-§6$l §fEnderman Pet §7(§6$profit§7)") - } - - private fun formatDisplay(map: List>): List> { - if (!ProfileStorageData.loaded) return emptyList() - - val newList = mutableListOf>() - for (index in config.textFormat.get()) { - newList.add(map[index]) - } - return newList - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt deleted file mode 100644 index e2c70cedc..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasure.kt +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 21e28319d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt +++ /dev/null @@ -1,167 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.Storage -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -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.event.winter.frozenTreasureTracker - private var display = emptyList>() - private var estimatedIce = 0L - private var lastEstimatedIce = 0L - private var icePerSecond = mutableListOf() - private var icePerHour = 0 - private var stoppedChecks = 0 - private var compactPattern = "COMPACT! You found an Enchanted Ice!".toPattern() - - init { - fixedRateTimer(name = "skyhanni-frozen-treasure-tracker", period = 1000) { - if (!onJerryWorkshop()) return@fixedRateTimer - calculateIcePerHour() - } - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - icePerHour = 0 - stoppedChecks = 0 - icePerSecond = mutableListOf() - saveAndUpdate() - } - - private fun calculateIcePerHour() { - val difference = estimatedIce - lastEstimatedIce - lastEstimatedIce = estimatedIce - - if (difference == estimatedIce) return - - - if (difference == 0L) { - if (icePerSecond.isEmpty()) return - stoppedChecks += 1 - } else { - if (stoppedChecks > 60) { - stoppedChecks = 0 - icePerSecond.clear() - icePerHour = 0 - } - while (stoppedChecks > 0) { - stoppedChecks -= 1 - icePerSecond.add(0) - } - icePerSecond.add(difference) - val listCopy = icePerSecond - while (listCopy.size > 1200) listCopy.removeAt(0) - icePerSecond = listCopy - } - icePerHour = (icePerSecond.average() * 3600).toInt() - } - - private fun formatDisplay(map: List>): List> { - val newList = mutableListOf>() - 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() - val storage = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return - - compactPattern.matchMatcher(message) { - storage.compactProcs += 1 - saveAndUpdate() - if (config.hideMessages) event.blockedReason = "frozen treasure tracker" - } - - for (treasure in FrozenTreasure.entries) { - if ("FROZEN TREASURE! You found ${treasure.displayName.removeColor()}!".toRegex().matches(message)) { - storage.treasuresMined += 1 - val old = storage.treasureCount[treasure] ?: 0 - storage.treasureCount = storage.treasureCount.editCopy { this[treasure] = old + 1 } - saveAndUpdate() - if (config.hideMessages) event.blockedReason = "frozen treasure tracker" - } - } - } - - @SubscribeEvent - fun onPreProfileSwitch(event: PreProfileSwitchEvent) { - display = emptyList() - } - - private fun drawTreasureDisplay(storage: Storage.ProfileSpecific.FrozenTreasureTracker) = buildList> { - addAsSingletonList("§1§lFrozen Treasure Tracker") - addAsSingletonList("§6${formatNumber(storage.treasuresMined)} Treasures Mined") - addAsSingletonList("§3${formatNumber(estimatedIce)} Total Ice") - addAsSingletonList("§3${formatNumber(icePerHour)} Ice/hr") - addAsSingletonList("§8${formatNumber(storage.treasuresMined)} Compact Procs") - addAsSingletonList("") - - for (treasure in FrozenTreasure.entries) { - val count = (storage.treasureCount[treasure] ?: 0) * if (config.showAsDrops) treasure.defaultAmount else 1 - 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 storage = ProfileStorageData.profileSpecific?.frozenTreasureTracker ?: return - calculateIce(storage) - display = formatDisplay(drawTreasureDisplay(storage)) - } - - private fun calculateIce(storage: Storage.ProfileSpecific.FrozenTreasureTracker) { - estimatedIce = 0 - estimatedIce += storage.compactProcs * 160 - for (treasure in FrozenTreasure.entries) { - val amount = storage.treasureCount[treasure] ?: 0 - estimatedIce += amount * treasure.defaultAmount * treasure.iceMultiplier - } - } - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!config.enabled) return - if (!onJerryWorkshop()) return - if (config.onlyInCave && !inGlacialCave()) return - config.position.renderStringsAndItems(display, posLabel = "Frozen Treasure Tracker") - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "misc.frozenTreasureTracker", "event.winter.frozenTreasureTracker") - } - - private fun onJerryWorkshop() = LorenzUtils.inIsland(IslandType.WINTER) - - private fun inGlacialCave() = onJerryWorkshop() && ScoreboardData.sidebarLinesFormatted.contains(" §7⏣ §3Glacial Cave") -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt deleted file mode 100644 index e483aa980..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HarpFeatures.kt +++ /dev/null @@ -1,78 +0,0 @@ -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrato