From 3cd21195a7d9ecd84cd5d0136ad5318ab0f54fee Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 19 Dec 2024 01:47:41 +0100 Subject: [PATCH 01/93] code cleanup --- .../at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 8f8f6cdf348c..fa37f375b890 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -498,8 +498,7 @@ object SkyHanniDebugsAndTests { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - @Suppress("ConstantConditionIf") - if (false) { + @Suppress("ConstantConditionIf") if (false) { itemRenderDebug() } @@ -534,8 +533,7 @@ object SkyHanniDebugsAndTests { @SubscribeEvent fun onGuiRenderChestGuiOverlayRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - @Suppress("ConstantConditionIf") - if (false) { + @Suppress("ConstantConditionIf") if (false) { dragAbleTest() } } From e904b915f440727444674d8cf6006462fa3c6031 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:25:43 +0100 Subject: [PATCH 02/93] Revert "code cleanup" This reverts commit 3cd21195a7d9ecd84cd5d0136ad5318ab0f54fee. --- .../at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index fa37f375b890..8f8f6cdf348c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -498,7 +498,8 @@ object SkyHanniDebugsAndTests { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - @Suppress("ConstantConditionIf") if (false) { + @Suppress("ConstantConditionIf") + if (false) { itemRenderDebug() } @@ -533,7 +534,8 @@ object SkyHanniDebugsAndTests { @SubscribeEvent fun onGuiRenderChestGuiOverlayRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - @Suppress("ConstantConditionIf") if (false) { + @Suppress("ConstantConditionIf") + if (false) { dragAbleTest() } } From 0c74cbb31877f75724812b2b2082b7f6c5b93df2 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:40:07 +0100 Subject: [PATCH 03/93] Revert "Revert "code cleanup"" This reverts commit e904b915f440727444674d8cf6006462fa3c6031. --- .../at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 8f8f6cdf348c..fa37f375b890 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -498,8 +498,7 @@ object SkyHanniDebugsAndTests { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - @Suppress("ConstantConditionIf") - if (false) { + @Suppress("ConstantConditionIf") if (false) { itemRenderDebug() } @@ -534,8 +533,7 @@ object SkyHanniDebugsAndTests { @SubscribeEvent fun onGuiRenderChestGuiOverlayRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - @Suppress("ConstantConditionIf") - if (false) { + @Suppress("ConstantConditionIf") if (false) { dragAbleTest() } } From b8456f31b78b3d1862db2a2850bd486d71a3a1be Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:47:55 -0500 Subject: [PATCH 04/93] Fix: Revert Failures (#3087) --- .../at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index fa37f375b890..8bc25033843a 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -495,10 +495,11 @@ object SkyHanniDebugsAndTests { } @SubscribeEvent + @Suppress("ConstantConditionIf") fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return - @Suppress("ConstantConditionIf") if (false) { + if (false) { itemRenderDebug() } @@ -532,8 +533,9 @@ object SkyHanniDebugsAndTests { } @SubscribeEvent + @Suppress("ConstantConditionIf") fun onGuiRenderChestGuiOverlayRender(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - @Suppress("ConstantConditionIf") if (false) { + if (false) { dragAbleTest() } } From b0b3605f699210d6f98511844501801bce748ec1 Mon Sep 17 00:00:00 2001 From: Mikecraft1224 <85994411+Mikecraft1224@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:20:51 +0100 Subject: [PATCH 05/93] Fix: replace roman numeral v2 (#3003) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/misc/ReplaceRomanNumerals.kt | 76 +++++++++++++------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt index a25cc348577d..be1fcd7994de 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -4,38 +4,51 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.events.ChatHoverEvent -import at.hannibal2.skyhanni.events.LorenzToolTipEvent -import at.hannibal2.skyhanni.features.inventory.patternGroup +import at.hannibal2.skyhanni.events.item.ItemHoverEvent import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible import at.hannibal2.skyhanni.utils.StringUtils.isRoman import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ReplaceRomanNumerals { - // Using toRegex here since toPattern doesn't seem to provide the necessary functionality - private val splitRegex = "((§\\w)|(\\s+)|(\\W))+|(\\w*)".toRegex() + private val patternGroup = RepoPattern.group("replace.roman") - // /** - * REGEX-TEST: §eSelect an option: §r§a[§aOk, then what?§a] + * REGEX-TEST: §9Dedication IV + * REGEX-FAIL: §cD§6y§ee§as */ - private val isSelectOptionPattern by patternGroup.pattern( - "string.isselectoption", - "§eSelect an option: .*" + private val findRomanNumeralPattern by patternGroup.pattern( + "findroman", + "[ ➜](?=[MDCLXVI])(?M*(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3}))(?.?)" ) - // TODO: Remove after pr 1717 is ready and switch to ItemHoverEvent - @SubscribeEvent(priority = EventPriority.LOWEST) - fun onTooltip(event: LorenzToolTipEvent) { + /** + * REGEX-TEST: K + */ + private val isWordPattern by patternGroup.pattern( + "findword", + "^[\\w-']" + ) + + /** + * REGEX-TEST: ➜ + */ + private val allowedCharactersAfter by patternGroup.pattern( + "allowedcharactersafter", + "[➜):]?" + ) + + @HandleEvent(priority = HandleEvent.LOWEST) + fun onTooltip(event: ItemHoverEvent) { if (!isEnabled()) return event.toolTip.replaceAll { it.transformLine() } @@ -57,23 +70,38 @@ object ReplaceRomanNumerals { @HandleEvent fun onSystemMessage(event: SystemMessageEvent) { - if (!isEnabled() || event.message.isSelectOption()) return + if (!isEnabled()) return event.applyIfPossible { it.transformLine() } } - private fun String.isSelectOption(): Boolean = isSelectOptionPattern.matches(this) + /** + * Transforms a line with a roman numeral to a line with a decimal numeral. + * Override block one is to be used for tablist or other places where there is no need to check for normal text containing + * the word "I". + * + * Currently not replaced: + * - "§7Bonzo I Reward:" in the collection rewards when hovering on the collection + */ + private fun String.transformLine(overrideBlockOne: Boolean = false): String { + val (romanNumeral, rest) = findRomanNumeralPattern.findMatcher(this.removeFormatting()) { + group("roman") to group("extra") + } ?: return this - private fun String.transformLine() = splitRegex.findAll(this).map { it.value }.joinToString("") { - it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() != 2000 }?.coloredRomanToDecimal() ?: it - } + if (romanNumeral.isNullOrEmpty() || !romanNumeral.isRoman() || isWordPattern.matches(rest)) { + return recursiveSplit(romanNumeral) + } - private fun String.removeFormatting() = removeColor().replace(",", "") + val parsedRomanNumeral = romanNumeral.romanToDecimal() + + return takeIf { parsedRomanNumeral != 1 || overrideBlockOne || rest.isEmpty() || allowedCharactersAfter.matches(rest) } + ?.replaceFirst(romanNumeral, parsedRomanNumeral.toString())?.transformLine() + ?: recursiveSplit(romanNumeral) + } - private fun String.isValidRomanNumeral() = removeFormatting() - .let { it.isRoman() && it.isNotEmpty() } + private fun String.recursiveSplit(romanNumeral: String) = + this.split(romanNumeral, limit = 2).let { it[0] + romanNumeral + it[1].transformLine() } - private fun String.coloredRomanToDecimal() = removeFormatting() - .let { replace(it, it.romanToDecimal().toString()) } + private fun String.removeFormatting() = removeColor().replace(",", "") private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.replaceRomanNumerals } From 9b56006af21f3503d29d37fb677fca1025296af3 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:21:17 +0100 Subject: [PATCH 06/93] Fix: Vacuum Bag Item Stack after 1k Pests (#3088) --- .../skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index d40d99f7253e..c517bef7e131 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -78,10 +78,11 @@ object ItemDisplayOverlayFeatures { /** * REGEX-TEST: §7Vacuum Bag: §21 Pest * REGEX-TEST: §7Vacuum Bag: §2444 Pests + * REGEX-TEST: §7Vacuum Bag: §21,652 Pests */ private val gardenVacuumPattern by patternGroup.pattern( "vacuum", - "§7Vacuum Bag: §2(?\\d*) Pests?", + "§7Vacuum Bag: §2(?[\\d.,]*) Pests?", ) private val harvestPattern by patternGroup.pattern( "harvest", From 72103bee9e9246c93ad9363c5b34bc9dadaf7648 Mon Sep 17 00:00:00 2001 From: martimavocado <39881008+martimavocado@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:22:31 +0000 Subject: [PATCH 07/93] Fix: shtrackcollection not counting Youngite and Obsolite when tracking timite (#3082) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/misc/CollectionTracker.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt index a05d9a695082..b788a5fca689 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CollectionTracker.kt @@ -41,6 +41,12 @@ object CollectionTracker { private var recentGain = 0 private var lastGainTime = -1L + private val CACTUS = "CACTUS".toInternalName() + private val CACTUS_GREEN = "INK_SACK-2".toInternalName() + private val YOUNGITE = "YOUNGITE".toInternalName() + private val OBSOLITE = "OBSOLITE".toInternalName() + private val TIMITE = "TIMITE".toInternalName() + fun command(args: Array) { if (args.isEmpty()) { if (internalName == null) { @@ -167,17 +173,18 @@ object CollectionTracker { ) } - private fun countCurrentlyInInventory(): Int { - val cactus = "CACTUS".toInternalName() - val cactusGreen = "INK_SACK-2".toInternalName() - return InventoryUtils.countItemsInLowerInventory { - if (internalName == cactus && it.getInternalName() == cactusGreen) { - return@countItemsInLowerInventory true - } - it.getInternalName() == internalName + private fun countCurrentlyInInventory(): Int = InventoryUtils.countItemsInLowerInventory { + val name = it.getInternalName() + if (internalName == CACTUS && name == CACTUS_GREEN) { + return@countItemsInLowerInventory true } + if (internalName == TIMITE && (name == YOUNGITE || name == OBSOLITE)) { + return@countItemsInLowerInventory true + } + name == internalName } + fun handleTabComplete(command: String): List? { if (command != "shtrackcollection") return null From 5761c02958c87bd8c6754dcac30f6ef78663fe05 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:23:20 -0500 Subject: [PATCH 08/93] Fix: Hoppity Call Warning on World Change (#3086) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/event/hoppity/HoppityCallWarning.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCallWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCallWarning.kt index 0b05c76f34fe..ed73e817f362 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCallWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCallWarning.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.PurseAPI import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.minecraft.KeyPressEvent @@ -33,6 +34,7 @@ import kotlin.time.Duration.Companion.seconds @SkyHanniModule object HoppityCallWarning { + // /** * Test messages (and the real ones from Hypixel) have a space at the end of * them that the IDE kills. So it's "§r§e ✆ " @@ -63,6 +65,7 @@ object HoppityCallWarning { "hoppity.call.pickup", "§e\\[NPC] §aHoppity§f: §b✆ §f§rWhat's up, .*§f\\?", ) + // private val config get() = HoppityEggsManager.config.hoppityCallWarning private var warningSound = SoundUtils.createSound("note.pling", 1f) @@ -152,6 +155,12 @@ object HoppityCallWarning { ) } + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + acceptUUID = null + stopWarningUser() + } + private fun readPickupUuid(event: LorenzChatEvent) { val siblings = event.chatComponent.siblings.takeIf { it.size >= 3 } ?: return val clickEvent = siblings[2]?.chatStyle?.chatClickEvent ?: return From dc9931661b861d92b701cf14fa9bf66410d29eff Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:30:21 +0100 Subject: [PATCH 09/93] Improvement: Graph Navigation performance boost (#3083) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 957d1e837820..b814f0a40af2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -103,7 +103,6 @@ object IslandGraphs { private var pathfindClosestNode: GraphNode? = null var closestNode: GraphNode? = null - private var secondClosestNode: GraphNode? = null private var currentTarget: LorenzVec? = null private var currentTargetNode: GraphNode? = null @@ -251,13 +250,11 @@ object IslandGraphs { } val graph = currentIslandGraph ?: return - val sortedNodes = graph.sortedBy { it.position.distanceSqToPlayer() } - val newClosest = sortedNodes.first() + val newClosest = graph.minBy { it.position.distanceSqToPlayer() } if (pathfindClosestNode == newClosest) return val newPath = !onCurrentPath() closestNode = newClosest - secondClosestNode = sortedNodes.getOrNull(1) onNewNode() if (newClosest == prevClosest) return if (newPath) { @@ -277,9 +274,6 @@ object IslandGraphs { val newNodes = path.drop(index) val newGraph = Graph(newNodes) fastestPath = skipIfCloser(newGraph) - newNodes.getOrNull(1)?.let { - secondClosestNode = it - } setFastestPath(newGraph to newGraph.totalLenght(), setPath = false) return true } From c94c87e42707c46bac0c1a14928322a5a02b68e6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:30:27 +0100 Subject: [PATCH 10/93] Fix: Skill overflow edge case (#3084) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 3f18be7dab58..0d3f811180fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -353,7 +353,11 @@ object SkillAPI { private fun handleSkillPatternMultiplier(matcher: Matcher, skillType: SkillType, skillInfo: SkillInfo) { val currentXp = matcher.group("current").formatLong() val maxXp = matcher.group("needed").formatLong() - val level = getLevelExact(maxXp) - 1 + + // when at overflow, we dont need to subtract one level in the logic below + val minus = if (maxXp == 0L) 0 else 1 + val level = getLevelExact(maxXp) - minus + val levelXp = calculateLevelXp(level - 1).toLong() + currentXp val (currentLevel, currentOverflow, currentMaxOverflow, totalOverflow) = calculateSkillLevel(levelXp, defaultSkillCap[skillType.lowercaseName] ?: 60) From 6c3360491deb5c8ee61489e4252d9a7241fbf483 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:30:34 +0100 Subject: [PATCH 11/93] Backend: Added /shtestactionbar and more debug (#3085) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/data/ActionBarData.kt | 46 ++++++++++++++++++- .../skyhanni/test/SkyBlockIslandTest.kt | 17 +++++++ .../at/hannibal2/skyhanni/test/TestBingo.kt | 16 +++++++ .../hannibal2/skyhanni/utils/TabListData.kt | 26 +++++++++-- 4 files changed, 100 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt index 2aacf4d2bdea..a6b9a8bf21e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt @@ -1,18 +1,62 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.commands.CommandCategory +import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.events.ActionBarUpdateEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.stripHypixelMessage +import kotlinx.coroutines.launch import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ActionBarData { private var actionBar = "" + private var debugActionBar: String? = null fun getActionBar() = actionBar + @HandleEvent + fun onCommandRegistration(event: CommandRegistrationEvent) { + event.register("shtestactionbar") { + description = "Set your clipboard as a fake action bar." + category = CommandCategory.DEVELOPER_TEST + callback { debugCommand() } + } + } + + private fun debugCommand() { + SkyHanniMod.coroutineScope.launch { + val clipboard = OSUtils.readFromClipboard() + if (debugActionBar == clipboard) { + debugActionBar = null + ChatUtils.chat("Disabled action bar test!") + } else { + debugActionBar = clipboard + ChatUtils.chat("Set action bar test to '$clipboard'") + } + } + } + + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Action Bar") + debugActionBar?.let { + event.addData { + add("debug active!") + add("line: '$it'") + } + } ?: run { + event.addIrrelevant("not active.") + } + } + @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { actionBar = "" @@ -27,7 +71,7 @@ object ActionBarData { //#endif val original = event.message - val message = original.formattedText.stripHypixelMessage() + val message = debugActionBar ?: original.formattedText.stripHypixelMessage() actionBar = message val actionBarEvent = ActionBarUpdateEvent(actionBar, event.message) actionBarEvent.post() diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyBlockIslandTest.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyBlockIslandTest.kt index 31609eddf77e..faeb14521201 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyBlockIslandTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyBlockIslandTest.kt @@ -1,8 +1,12 @@ package at.hannibal2.skyhanni.test +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +@SkyHanniModule object SkyBlockIslandTest { var testIsland: IslandType? = null @@ -33,6 +37,19 @@ object SkyBlockIslandTest { } + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Island Test") + testIsland?.let { + event.addData { + add("debug active!") + add("island: '$it'") + } + } ?: run { + event.addIrrelevant("not active.") + } + } + private fun find(search: String): IslandType? { for (type in IslandType.entries) { if (type.name.equals(search, ignoreCase = true)) return type diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestBingo.kt b/src/main/java/at/hannibal2/skyhanni/test/TestBingo.kt index 99418c607b2f..2c13b4a84c4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestBingo.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestBingo.kt @@ -1,7 +1,11 @@ package at.hannibal2.skyhanni.test +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +@SkyHanniModule object TestBingo { var testBingo = false @@ -10,4 +14,16 @@ object TestBingo { testBingo = !testBingo ChatUtils.chat("Test Bingo " + (if (testBingo) "enabled" else "disabled")) } + + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Bingo Test") + if (testBingo) { + event.addData { + add("debug active!") + } + } else { + event.addIrrelevant("not active.") + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt index accc7168fcf8..599b5a80eb12 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt @@ -1,8 +1,10 @@ package at.hannibal2.skyhanni.utils +//#if MC<1.12 import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.model.TabWidget +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.TablistFooterUpdateEvent @@ -20,12 +22,12 @@ import kotlinx.coroutines.launch import net.minecraft.client.Minecraft import net.minecraft.client.network.NetworkPlayerInfo import net.minecraft.network.play.server.S38PacketPlayerListItem +import net.minecraft.world.WorldSettings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly import kotlin.time.Duration.Companion.seconds -//#if MC<1.12 -import net.minecraft.world.WorldSettings + //#else //$$ import net.minecraft.world.GameType //#endif @@ -46,6 +48,22 @@ object TabListData { fun getHeader() = header fun getFooter() = footer + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Tab List") + debugCache?.let { + event.addData { + add("debug active!") + add("lines: (${it.size})") + for (line in it) { + add(" '$line'") + } + } + } ?: run { + event.addIrrelevant("not active.") + } + } + fun toggleDebug() { if (debugCache != null) { ChatUtils.chat("Disabled tab list debug.") @@ -64,7 +82,7 @@ object TabListData { ChatUtils.clickableChat( "Tab list debug is enabled!", onClick = { toggleDebug() }, - "§eClick to disable!" + "§eClick to disable!", ) return } @@ -99,7 +117,7 @@ object TabListData { return ComparisonChain.start().compareTrueFirst( //#if MC<1.12 o1.gameType != WorldSettings.GameType.SPECTATOR, - o2.gameType != WorldSettings.GameType.SPECTATOR + o2.gameType != WorldSettings.GameType.SPECTATOR, //#else //$$ o1.gameType != GameType.SPECTATOR, //$$ o2.gameType != GameType.SPECTATOR From cc73310b7170d698dfd8ae0822215f9b3ac2ecf9 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:51:08 +0100 Subject: [PATCH 12/93] Backend: Commands to Guide, move Party Commands (#3040) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- CONTRIBUTING.md | 1 + .../skyhanni/config/commands/Commands.kt | 40 -------------- .../features/commands/PartyCommands.kt | 55 ++++++++++++++++--- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b7405ffd552..53226d5d7049 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -153,6 +153,7 @@ for more information and usages. the main thread. - When updating a config option variable, use the `ConfigUpdaterMigrator.ConfigFixEvent` with event.move() when moving a value, and event.transform() when updating a value. [For Example](https://github.com/hannibal002/SkyHanni/blob/e88f416c48f9659f89b7047d7629cd9a1d1535bc/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt#L276). - Use American English spelling conventions (e.g., "color" not "colour"). +- When creating/updating a command, move it out of the `Commands.kt` class, if it isn't already, into the class that it belongs to. - Avoid direct function imports. Always access functions or members through their respective namespaces or parent classes to improve readability and maintain encapsulation. ## Additional Useful Development Tools diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index cea7f1080408..e1c8244cec08 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.features.chat.ColorFormattingHelper import at.hannibal2.skyhanni.features.chat.translation.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.commands.PartyChatCommands -import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.WikiManager import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker import at.hannibal2.skyhanni.features.dungeon.floor7.TerminalInfo @@ -114,7 +113,6 @@ object Commands { devTest(event) devDebug(event) internalCommands(event) - shortenedCommands(event) } private fun usersMain(event: CommandRegistrationEvent) { @@ -762,42 +760,4 @@ object Commands { callback { ChatClickActionManager.onCommand(it) } } } - - private fun shortenedCommands(event: CommandRegistrationEvent) { - event.register("pko") { - description = "Kicks offline party members" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.kickOffline() } - } - event.register("pw") { - description = "Warps your party" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.warp() } - } - event.register("pk") { - description = "Kick a specific party member" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.kick(it) } - } - event.register("pt") { - description = "Transfer the party to another party member" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.transfer(it) } - } - event.register("pp") { - description = "Promote a specific party member" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.promote(it) } - } - event.register("pd") { - description = "Disbands the party" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.disband() } - } - event.register("rpt") { - description = "Reverse transfer party to the previous leader" - category = CommandCategory.SHORTENED_COMMANDS - callback { PartyCommands.reverseTransfer() } - } - } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt index 0010718e8455..720a676dea78 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt @@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.commands.CommandCategory +import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.data.PartyAPI.partyLeader import at.hannibal2.skyhanni.data.PartyAPI.transferVoluntaryPattern @@ -24,25 +26,25 @@ object PartyCommands { private val config get() = SkyHanniMod.feature.misc.commands - fun kickOffline() { + private fun kickOffline() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return HypixelCommands.partyKickOffline() } - fun disband() { + private fun disband() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return HypixelCommands.partyDisband() } - fun warp() { + private fun warp() { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return HypixelCommands.partyWarp() } - fun kick(args: Array) { + private fun kick(args: Array) { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return if (args.isEmpty()) return @@ -54,7 +56,7 @@ object PartyCommands { HypixelCommands.partyKick(kickedPlayer) } - fun transfer(args: Array) { + private fun transfer(args: Array) { if (args.isEmpty()) { if (LimboTimeTracker.inLimbo) { LimboTimeTracker.printStats(true) @@ -68,14 +70,14 @@ object PartyCommands { HypixelCommands.partyTransfer(args[0]) } - fun promote(args: Array) { + private fun promote(args: Array) { if (!config.shortCommands) return if (PartyAPI.partyMembers.isEmpty()) return if (args.isEmpty()) return HypixelCommands.partyPromote(args[0]) } - fun reverseTransfer() { + private fun reverseTransfer() { if (!config.reversePT.command) return if (PartyAPI.partyMembers.isEmpty()) return val prevPartyLeader = PartyAPI.prevPartyLeader ?: return @@ -139,4 +141,43 @@ object PartyCommands { prefix = false, ) } + + @HandleEvent + fun onCommandRegistration(event: CommandRegistrationEvent) { + event.register("pko") { + description = "Kicks offline party members" + category = CommandCategory.SHORTENED_COMMANDS + callback { kickOffline() } + } + event.register("pw") { + description = "Warps your party" + category = CommandCategory.SHORTENED_COMMANDS + callback { warp() } + } + event.register("pk") { + description = "Kick a specific party member" + category = CommandCategory.SHORTENED_COMMANDS + callback { kick(it) } + } + event.register("pt") { + description = "Transfer the party to another party member" + category = CommandCategory.SHORTENED_COMMANDS + callback { transfer(it) } + } + event.register("pp") { + description = "Promote a specific party member" + category = CommandCategory.SHORTENED_COMMANDS + callback { promote(it) } + } + event.register("pd") { + description = "Disbands the party" + category = CommandCategory.SHORTENED_COMMANDS + callback { disband() } + } + event.register("rpt") { + description = "Reverse transfer party to the previous leader" + category = CommandCategory.SHORTENED_COMMANDS + callback { reverseTransfer() } + } + } } From 0d09339db76bc94555dacd6472225296bb929d13 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Fri, 20 Dec 2024 01:52:04 +0100 Subject: [PATCH 13/93] Backend: Move Next Jacobs Contest, Best Crop Milestone & Jyrre Timer to Renderable (#3004) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: Cal --- .../features/event/winter/JyrreTimer.kt | 41 ++--- .../skyhanni/features/garden/GardenAPI.kt | 12 +- .../features/garden/GardenNextJacobContest.kt | 152 +++++++++--------- .../garden/farming/GardenBestCropTime.kt | 139 ++++++++-------- .../farming/GardenCropMilestoneDisplay.kt | 26 +-- .../skyhanni/utils/CollectionUtils.kt | 8 +- .../hannibal2/skyhanni/utils/RenderUtils.kt | 24 --- versions/1.8.9/detekt/baseline.xml | 5 +- 8 files changed, 192 insertions(+), 215 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt index 513753f2c383..8403f5336d45 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt @@ -7,13 +7,15 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RegexUtils.matches -import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes @@ -25,9 +27,9 @@ object JyrreTimer { private val config get() = SkyHanniMod.feature.event.winter.jyrreTimer private val drankBottlePattern by RepoPattern.pattern( "event.winter.drank.jyrre", - "§aYou drank a §r§6Refined Bottle of Jyrre §r§aand gained §r§b\\+300✎ Intelligence §r§afor §r§b60 minutes§r§a!" + "§aYou drank a §r§6Refined Bottle of Jyrre §r§aand gained §r§b\\+300✎ Intelligence §r§afor §r§b60 minutes§r§a!", ) - private var display = emptyList() + private var display: Renderable? = null private var duration = 0.seconds @HandleEvent @@ -36,8 +38,8 @@ object JyrreTimer { } private fun resetDisplay() { - if (display.isEmpty()) return - display = if (config.showInactive) drawDisplay() else emptyList() + if (display == null) return + display = if (config.showInactive) drawDisplay() else null duration = 0.seconds } @@ -50,14 +52,14 @@ object JyrreTimer { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - config.pos.renderSingleLineWithItems(display, posLabel = "Refined Jyrre Timer") + config.pos.renderRenderable(display, posLabel = "Refined Jyrre Timer") } @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (display.isNotEmpty() && !config.showInactive && duration <= 0.seconds) { + if (display != null && !config.showInactive && duration <= 0.seconds) { resetDisplay() return } @@ -67,20 +69,21 @@ object JyrreTimer { private val displayIcon by lazy { "REFINED_BOTTLE_OF_JYRRE".toInternalName().getItemStack() } - fun drawDisplay(): MutableList { + fun drawDisplay(): Renderable { duration -= 1.seconds - return mutableListOf().apply { - addItemIcon(displayIcon) - add("§aJyrre Boost: ") + return Renderable.horizontalContainer( + buildList { + addItemStack(displayIcon) + addString("§aJyrre Boost: ") - if (duration <= 0.seconds && config.showInactive) { - add("§cInactive!") - } else { - val format = duration.format() - add("§b$format") - } - } + if (duration <= 0.seconds && config.showInactive) { + addString("§cInactive!") + } else { + addString("§b${duration.format()}") + } + }, + ) } private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 2753c95616d5..04f720a2c2a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -41,7 +41,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.RenderUtils.addItemIcon import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getCultivatingCounter import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHoeCounter import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -172,16 +171,7 @@ object GardenAPI { fun readCounter(itemStack: ItemStack): Long = itemStack.getHoeCounter() ?: itemStack.getCultivatingCounter() ?: -1L - @Deprecated("use renderable list instead", ReplaceWith("")) - fun MutableList.addCropIcon( - crop: CropType, - scale: Double = NEUItems.itemFontSize, - highlight: Boolean = false, - ) = - addItemIcon(crop.icon.copy(), highlight, scale = scale) - - // TODO rename to addCropIcon - fun MutableList.addCropIconRenderable( + fun MutableList.addCropIcon( crop: CropType, scale: Double = NEUItems.itemFontSize, highlight: Boolean = false, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index ebbdd8907c75..10457768d1fa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -18,13 +18,14 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtils import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark @@ -34,6 +35,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.json.toJsonArray +import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.Gson import com.google.gson.JsonPrimitive @@ -59,15 +61,20 @@ import kotlin.time.Duration.Companion.seconds object GardenNextJacobContest { private val dispatcher = Dispatchers.IO - private var display = emptyList() + private var display: Renderable? = null private var simpleDisplay = emptyList() var contests = mutableMapOf() private var inCalendar = false private val patternGroup = RepoPattern.group("garden.nextcontest") + + /** + * REGEX-TEST: Day 1 + * REGEX-TEST: Day 31 + */ val dayPattern by patternGroup.pattern( "day", - "§aDay (?.*)" + "§aDay (?.*)", ) /** @@ -77,11 +84,17 @@ object GardenNextJacobContest { */ val monthPattern by patternGroup.pattern( "month", - "(?(?:\\w+ )?(?:Summer|Spring|Winter|Autumn)), Year (?\\d+)" + "(?(?:\\w+ )?(?:Summer|Spring|Winter|Autumn)), Year (?\\d+)", ) + + /** + * REGEX-TEST: §e○ §7Cactus + * REGEX-TEST: §6☘ §7Carrot + * REGEX-TEST: §e○ §7Melon + */ private val cropPattern by patternGroup.pattern( "crop", - "§(?:e○|6☘) §7(?.*)" + "§(?:e○|6☘) §7(?.*)", ) private const val CLOSE_TO_NEW_YEAR_TEXT = "§7Close to new SB year!" @@ -111,7 +124,7 @@ object GardenNextJacobContest { add("Current time: ${SimpleTimeMark.now()}") add("") - val display = display.filterIsInstance().joinToString("") + // TODO Renderable.toString() add("Display: '$display'") add("") @@ -254,7 +267,7 @@ object GardenNextJacobContest { "§2Click here to submit this year's farming contests. Thank you for helping everyone out!", onClick = { shareContests() }, "§eClick to submit!", - oneTimeClick = true + oneTimeClick = true, ) } } @@ -310,7 +323,7 @@ object GardenNextJacobContest { ChatUtils.chat("§2Enabled automatic sharing of future contests!") }, "§eClick to enable autosharing!", - oneTimeClick = true + oneTimeClick = true, ) } } @@ -328,82 +341,76 @@ object GardenNextJacobContest { } display = if (isFetchingContests) { - listOf("§cFetching this years jacob contests...") + Renderable.string("§cFetching this years jacob contests...") } else { fetchContestsIfAble() // Will only run when needed/enabled drawDisplay() } } - private fun drawDisplay(): List { - val list = mutableListOf() + private fun drawDisplay() = Renderable.horizontalContainer( + buildList { + if (inCalendar) { + val size = contests.size + val percentage = size.toDouble() / MAX_CONTESTS_PER_YEAR + val formatted = LorenzUtils.formatPercentage(percentage) + addString("§eDetected $formatted of farming contests this year") + return@buildList + } + + if (contests.isEmpty()) { + if (isCloseToNewYear()) { + addString(CLOSE_TO_NEW_YEAR_TEXT) + } else { + addString("§cOpen calendar to read Jacob contest times!") + } + return@buildList + } - if (inCalendar) { - val size = contests.size - val percentage = size.toDouble() / MAX_CONTESTS_PER_YEAR - val formatted = LorenzUtils.formatPercentage(percentage) - list.add("§eDetected $formatted of farming contests this year") + val nextContest = contests.values.filterNot { it.endTime.isInPast() }.minByOrNull { it.endTime } - return list - } + // Show next contest + if (nextContest != null) { + addAll(drawNextContest(nextContest)) + return@buildList + } - if (contests.isEmpty()) { if (isCloseToNewYear()) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) + addString(CLOSE_TO_NEW_YEAR_TEXT) } else { - list.add("§cOpen calendar to read Jacob contest times!") + addString("§cOpen calendar to read Jacob contest times!") } - return list - } - - val nextContest = - contests.filter { !it.value.endTime.isInPast() }.toSortedMap() - .firstNotNullOfOrNull { it.value } - // Show next contest - if (nextContest != null) return drawNextContest(nextContest, list) - if (isCloseToNewYear()) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) - } else { - list.add("§cOpen calendar to read Jacob contest times!") - } + fetchedFromElite = false + contests.clear() + }, + ) - fetchedFromElite = false - contests.clear() - return list - } - - private fun drawNextContest( - nextContest: FarmingContest, - list: MutableList, - ): MutableList { + private fun drawNextContest(nextContest: FarmingContest) = buildList { var duration = nextContest.endTime.timeUntil() if (duration > 4.days) { - list.add(CLOSE_TO_NEW_YEAR_TEXT) - return list + addString(CLOSE_TO_NEW_YEAR_TEXT) + return@buildList } val boostedCrop = calculateBoostedCrop(nextContest) val activeContest = duration < contestDuration if (activeContest) { - list.add("§aActive: ") + addString("§aActive: ") } else { - list.add("§eNext: ") + addString("§eNext: ") duration -= contestDuration } for (crop in nextContest.crops) { - list.addCropIcon(crop, 1.0, highlight = (crop == boostedCrop)) + addCropIcon(crop, 1.0, highlight = (crop == boostedCrop)) nextContestCrops.add(crop) } if (!activeContest) { warn(duration, nextContest.crops, boostedCrop) } - val format = duration.format() - list.add("§7(§b$format§7)") - - return list + addString("§7(§b${duration.format()}§7)") } private fun calculateBoostedCrop(nextContest: FarmingContest): CropType? { @@ -439,10 +446,7 @@ object GardenNextJacobContest { } if (config.warnPopup && !Display.isActive()) { SkyHanniMod.coroutineScope.launch { - openPopupWindow( - "Farming Contest soon!
" + - "Crops: $cropTextNoColor" - ) + openPopupWindow("Farming Contest soon!
Crops: $cropTextNoColor") } } } @@ -456,7 +460,7 @@ object GardenNextJacobContest { } catch (e: java.lang.Exception) { ErrorManager.logErrorWithData( e, "Failed to open a popup window", - "message" to message + "message" to message, ) } @@ -468,11 +472,13 @@ object GardenNextJacobContest { val buttons = mutableListOf() val close = JButton("Ok") - close.addMouseListener(object : MouseAdapter() { - override fun mouseClicked(event: MouseEvent) { - frame.isVisible = false - } - }) + close.addMouseListener( + object : MouseAdapter() { + override fun mouseClicked(event: MouseEvent) { + frame.isVisible = false + } + }, + ) buttons.add(close) val allOptions = buttons.toTypedArray() @@ -484,7 +490,7 @@ object GardenNextJacobContest { JOptionPane.INFORMATION_MESSAGE, null, allOptions, - allOptions[0] + allOptions[0], ) } @@ -494,10 +500,10 @@ object GardenNextJacobContest { fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - if (display.isEmpty()) { + if (display == null) { config.pos.renderStrings(simpleDisplay, posLabel = "Next Jacob Contest") } else { - config.pos.renderSingleLineWithItems(display, posLabel = "Next Jacob Contest") + config.pos.renderRenderable(display, posLabel = "Next Jacob Contest") } } @@ -506,10 +512,10 @@ object GardenNextJacobContest { if (!config.display) return if (!inCalendar) return - if (display.isNotEmpty()) { - SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems( + if (display != null) { + SkyHanniMod.feature.misc.inventoryLoadPos.renderRenderable( display, - posLabel = "Load SkyBlock Calendar" + posLabel = "Load SkyBlock Calendar", ) } } @@ -567,12 +573,12 @@ object GardenNextJacobContest { } else { ChatUtils.chat( "This year's contests aren't available to fetch automatically yet, " + - "please load them from your calendar or wait 10 minutes." + "please load them from your calendar or wait 10 minutes.", ) ChatUtils.clickableChat( "Click here to open your calendar!", onClick = { HypixelCommands.calendar() }, - "§eClick to run /calendar!" + "§eClick to run /calendar!", ) } @@ -589,7 +595,7 @@ object GardenNextJacobContest { } catch (e: Exception) { ErrorManager.logErrorWithData( e, - "Failed to fetch upcoming contests. Please report this error if it continues to occur" + "Failed to fetch upcoming contests. Please report this error if it continues to occur", ) } @@ -625,13 +631,13 @@ object GardenNextJacobContest { } else { ErrorManager.logErrorStateWithData( "Something went wrong submitting upcoming contests!", - "submitContestsToElite not successful" + "submitContestsToElite not successful", ) } } catch (e: Exception) { ErrorManager.logErrorWithData( e, "Failed to submit upcoming contests. Please report this error if it continues to occur.", - "contests" to contests + "contests" to contests, ) null } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index d441fab1015e..8c008df43065 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -13,17 +13,18 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable import kotlin.time.Duration.Companion.milliseconds @SkyHanniModule object GardenBestCropTime { - var display = emptyList>() + var display: Renderable? = null private val config get() = GardenAPI.config.cropMilestones val timeTillNextCrop = mutableMapOf() @@ -56,82 +57,86 @@ object GardenBestCropTime { } } - fun drawBestDisplay(currentCrop: CropType?): List> { - val newList = mutableListOf>() - if (timeTillNextCrop.size < CropType.entries.size) { - updateTimeTillNextCrop() - } - - val gardenExp = config.next.bestType == NextConfig.BestTypeEntry.GARDEN_EXP - val useOverflow = config.overflow.bestCropTime - val sorted = if (gardenExp) { - val helpMap = mutableMapOf() - for ((crop, time) in timeTillNextCrop) { - if (crop.isMaxed(useOverflow)) continue - val currentTier = - GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) - val gardenExpForTier = getGardenExpForTier(currentTier + 1) - val fakeTime = time / gardenExpForTier - helpMap[crop] = fakeTime + fun drawBestDisplay(currentCrop: CropType?) = Renderable.verticalContainer( + buildList { + if (timeTillNextCrop.size < CropType.entries.size) { + updateTimeTillNextCrop() } - helpMap.sorted() - } else { - timeTillNextCrop.sorted() - } - - if (!config.next.bestHideTitle) { - val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" - if (config.next.bestCompact) { - newList.addAsSingletonList("§eBest Crop Time") + val gardenExp = config.next.bestType == NextConfig.BestTypeEntry.GARDEN_EXP + val useOverflow = config.overflow.bestCropTime + val sorted = if (gardenExp) { + val helpMap = mutableMapOf() + for ((crop, time) in timeTillNextCrop) { + if (crop.isMaxed(useOverflow)) continue + val currentTier = + GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) + val gardenExpForTier = getGardenExpForTier(currentTier + 1) + val fakeTime = time / gardenExpForTier + helpMap[crop] = fakeTime + } + helpMap.sorted() } else { - newList.addAsSingletonList("§eBest Crop Time §7($title§7)") + timeTillNextCrop.sorted() } - } - - if (!config.progress) { - newList.addAsSingletonList("§cCrop Milestone Progress Display is disabled!") - return newList - } - if (sorted.isEmpty()) { - newList.addAsSingletonList("§cFarm crops to add them to this list!") - return newList - } - var number = 0 - for (crop in sorted.keys) { - if (crop.isMaxed(useOverflow)) continue - val millis = timeTillNextCrop[crop]?.milliseconds ?: continue - // TODO, change functionality to use enum rather than ordinals - val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] - val duration = millis.format(biggestUnit, maxUnits = 2) - val isCurrent = crop == currentCrop - number++ - if (number > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) continue - - val list = mutableListOf() - if (!config.next.bestCompact) { - list.add("§7$number# ") + if (!config.next.bestHideTitle) { + val title = if (gardenExp) "§2Garden Experience" else "§bSkyBlock Level" + if (config.next.bestCompact) { + addString("§eBest Crop Time") + } else { + addString("§eBest Crop Time §7($title§7)") + } } - list.addCropIcon(crop) - val color = if (isCurrent) "§e" else "§7" - val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" - val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) - val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + if (!config.progress) { + addString("§cCrop Milestone Progress Display is disabled!") + return@buildList + } - val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" - val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" - list.add("$color$contestFormat$cropName$tier§b$duration") + if (sorted.isEmpty()) { + addString("§cFarm crops to add them to this list!") + return@buildList + } - if (gardenExp && !config.next.bestCompact) { - val gardenExpForTier = getGardenExpForTier(nextTier) - list.add(" §7(§2$gardenExpForTier §7Exp)") + sorted.keys.withIndex().forEach { (index, crop) -> + createCropEntry(crop, index + 1, useOverflow, gardenExp, currentCrop)?.let(::add) } - newList.add(list) - } - return newList + }, + ) + + private fun createCropEntry(crop: CropType, index: Int, useOverflow: Boolean, gardenExp: Boolean, currentCrop: CropType?): Renderable? { + if (crop.isMaxed(useOverflow)) return null + val millis = timeTillNextCrop[crop]?.milliseconds ?: return null + // TODO, change functionality to use enum rather than ordinals + val biggestUnit = TimeUnit.entries[config.highestTimeFormat.get().ordinal] + val duration = millis.format(biggestUnit, maxUnits = 2) + val isCurrent = crop == currentCrop + if (index > config.next.showOnlyBest && (!config.next.showCurrent || !isCurrent)) return null + + return Renderable.horizontalContainer( + buildList { + if (!config.next.bestCompact) { + addString("§7$index# ") + } + addCropIcon(crop) + + val color = if (isCurrent) "§e" else "§7" + val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" + val currentTier = GardenCropMilestones.getTierForCropCount(crop.getCounter(), crop, allowOverflow = true) + val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + + val cropName = if (!config.next.bestCompact) crop.cropName + " " else "" + val tier = if (!config.next.bestCompact) "$currentTier➜$nextTier§r " else "" + addString("$color$contestFormat$cropName$tier§b$duration") + + if (gardenExp && !config.next.bestCompact) { + val gardenExpForTier = getGardenExpForTier(nextTier) + addString(" §7(§2$gardenExpForTier §7Exp)") + } + }, + ) } private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index fbf9a4cf18dd..81c4b340f5a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -18,7 +18,7 @@ import at.hannibal2.skyhanni.events.garden.farming.CropMilestoneUpdateEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable +import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -29,8 +29,8 @@ import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.roundTo +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUnit @@ -76,17 +76,17 @@ object GardenCropMilestoneDisplay { if (GardenAPI.hideExtraGuis()) return config.progressDisplayPos.renderRenderables( - progressDisplay, posLabel = "Crop Milestone Progress" + progressDisplay, posLabel = "Crop Milestone Progress", ) if (config.mushroomPetPerk.enabled) { config.mushroomPetPerk.pos.renderRenderables( - mushroomCowPerkDisplay, posLabel = "Mushroom Cow Perk" + mushroomCowPerkDisplay, posLabel = "Mushroom Cow Perk", ) } if (config.next.bestDisplay) { - config.next.displayPos.renderStringsAndItems(GardenBestCropTime.display, posLabel = "Best Crop Time") + config.next.displayPos.renderRenderable(GardenBestCropTime.display, posLabel = "Best Crop Time") } } @@ -131,7 +131,7 @@ object GardenCropMilestoneDisplay { fun update() { progressDisplay = emptyList() mushroomCowPerkDisplay = emptyList() - GardenBestCropTime.display = emptyList() + GardenBestCropTime.display = null val currentCrop = GardenAPI.getCurrentlyFarmedCrop() currentCrop?.let { progressDisplay = drawProgressDisplay(it) @@ -158,13 +158,13 @@ object GardenCropMilestoneDisplay { lineMap[MilestoneTextEntry.MILESTONE_TIER] = Renderable.horizontalContainer( buildList { - addCropIconRenderable(crop) + addCropIcon(crop) if (crop.isMaxed(overflowDisplay) && !overflowDisplay) { addString("§7" + crop.cropName + " §eMAXED") } else { addString("§7" + crop.cropName + " §8$currentTier➜§3$nextTier") } - } + }, ) val allowOverflowOrCustom = overflowDisplay || useCustomGoal @@ -306,9 +306,9 @@ object GardenCropMilestoneDisplay { lineMap[MushroomTextEntry.TITLE] = Renderable.string("§6Mooshroom Cow Perk") lineMap[MushroomTextEntry.MUSHROOM_TIER] = Renderable.horizontalContainer( buildList { - addCropIconRenderable(mushroom) + addCropIcon(mushroom) addString("§7Mushroom Milestone $nextTier") - } + }, ) lineMap[MushroomTextEntry.NUMBER_OUT_OF_TOTAL] = Renderable.string("§e$haveFormat§8/§e$needFormat") @@ -356,21 +356,21 @@ object GardenCropMilestoneDisplay { event.move( 11, "garden.cropMilestones.highestTimeFormat", - "garden.cropMilestones.highestTimeFormat" + "garden.cropMilestones.highestTimeFormat", ) { element -> ConfigUtils.migrateIntToEnum(element, TimeFormatEntry::class.java) } event.move( 11, "garden.cropMilestones.text", - "garden.cropMilestones.text" + "garden.cropMilestones.text", ) { element -> ConfigUtils.migrateIntArrayListToEnumArrayList(element, MilestoneTextEntry::class.java) } event.move( 11, "garden.cropMilestones.mushroomPetPerk.text", - "garden.cropMilestones.mushroomPetPerk.text" + "garden.cropMilestones.mushroomPetPerk.text", ) { element -> ConfigUtils.migrateIntArrayListToEnumArrayList(element, MushroomTextEntry::class.java) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index 3e3b6e394a06..18bc0b7f670f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -312,15 +312,15 @@ object CollectionUtils { add(Renderable.itemStack(itemStack, scale = scale)) } + fun MutableList.addItemStack(internalName: NEUInternalName) { + addItemStack(internalName.getItemStack()) + } + fun takeColumn(start: Int, end: Int, startColumn: Int, endColumn: Int, rowSize: Int = 9) = generateSequence(start) { it + 1 }.map { (it / (endColumn - startColumn)) * rowSize + (it % (endColumn - startColumn)) + startColumn }.takeWhile { it <= end } - fun MutableList.addItemStack(internalName: NEUInternalName) { - addItemStack(internalName.getItemStack()) - } - // TODO move to RenderableUtils inline fun > MutableList.addSelector( prefix: String, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index a6f92fb10932..3a3a2daaca77 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -13,12 +13,10 @@ import at.hannibal2.skyhanni.features.misc.PatcherFixes import at.hannibal2.skyhanni.features.misc.RoundedRectangleOutlineShader import at.hannibal2.skyhanni.features.misc.RoundedRectangleShader import at.hannibal2.skyhanni.features.misc.RoundedTextureShader -import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.zipWithNext3 import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.getCorners -import at.hannibal2.skyhanni.utils.compat.EnchantmentsCompat import at.hannibal2.skyhanni.utils.compat.GuiScreenUtils import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned @@ -36,7 +34,6 @@ import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.entity.Entity import net.minecraft.inventory.Slot -import net.minecraft.item.ItemStack import net.minecraft.util.AxisAlignedBB import net.minecraft.util.MathHelper import net.minecraft.util.ResourceLocation @@ -686,27 +683,6 @@ object RenderUtils { return offsetX } - @Deprecated("use renderable item list", ReplaceWith("")) - fun MutableList.addItemIcon( - item: ItemStack, - highlight: Boolean = false, - scale: Double = NEUItems.itemFontSize, - ) { - try { - if (highlight) { - // Hack to add enchant glint, like Hypixel does it - item.addEnchantment(EnchantmentsCompat.PROTECTION.enchantment, 0) - } - add(Renderable.itemStack(item, scale)) - } catch (e: NullPointerException) { - ErrorManager.logErrorWithData( - e, - "Add item icon to renderable list", - "item" to item, - ) - } - } - // totally not modified Autumn Client's TargetStrafe fun drawCircle(entity: Entity, partialTicks: Float, rad: Double, color: Color) { GlStateManager.pushMatrix() diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index c9ef245f4622..e9400d2a9066 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -15,7 +15,6 @@ CyclomaticComplexMethod:CropMoneyDisplay.kt$CropMoneyDisplay$private fun drawDisplay(): List<List<Any>> CyclomaticComplexMethod:DamageIndicatorManager.kt$DamageIndicatorManager$private fun checkThorn(realHealth: Long, realMaxHealth: Long): String? CyclomaticComplexMethod:EstimatedItemValueCalculator.kt$EstimatedItemValueCalculator$private fun addEnchantments(stack: ItemStack, list: MutableList<String>): Double - CyclomaticComplexMethod:GardenBestCropTime.kt$GardenBestCropTime$fun drawBestDisplay(currentCrop: CropType?): List<List<Any>> CyclomaticComplexMethod:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$private fun drawProgressDisplay(crop: CropType): List<Renderable> CyclomaticComplexMethod:GardenVisitorFeatures.kt$GardenVisitorFeatures$private fun readToolTip(visitor: VisitorAPI.Visitor, itemStack: ItemStack?, toolTip: MutableList<String>) CyclomaticComplexMethod:GraphEditor.kt$GraphEditor$private fun input() @@ -168,8 +167,7 @@ RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.name", "Garden (?:Desk|Level (?<currentLevel>.*))" ) RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.nextxp", ".* §e(?<nextLevelExp>.*)§6/.*" ) RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.overflow", ".*§r §6(?<overflow>.*)" ) - RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "crop", "§(?:e○|6☘) §7(?<crop>.*)" ) - RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "day", "§aDay (?<day>.*)" ) + RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "day", "§aDay (?<day>.*)", ) RepoPatternRegexTest:GardenPlotAPI.kt$GardenPlotAPI$by patternGroup.pattern( "spray.target", "§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b(?<plot>.*) §r§7with §r§a(?<spray>.*)§r§7!" ) RepoPatternRegexTest:GlacitePowderFeatures.kt$GlacitePowderFeatures$by patternGroup.pattern( "glacitepowder", "Glacite Powder x(?<amount>.*)" ) RepoPatternRegexTest:HighlightPlaceableNpcs.kt$HighlightPlaceableNpcs$by patternGroup.pattern( "location", "§7Location: §f\\[§e\\d+§f, §e\\d+§f, §e\\d+§f]", ) @@ -417,7 +415,6 @@ UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$lastParticlePoint2?.distance(particlePoint!!)!! UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$particlePoint!! UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$particlePoint?.let { it - lastParticlePoint2!! }!! - UnsafeCallOnNullableType:SummoningSoulsName.kt$SummoningSoulsName$mobsName.getOrNull(nearestMob)!! UnsafeCallOnNullableType:SuperpairsClicksAlert.kt$SuperpairsClicksAlert$match.groups[1]!! UnsafeCallOnNullableType:TiaRelayWaypoints.kt$TiaRelayWaypoints$waypointName!! UnsafeCallOnNullableType:Translator.kt$Translator$messageContentRegex.find(message)!! From 92ebf2a9d3593edbe09c54891dea3432c7c3c7a4 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:21:41 +0100 Subject: [PATCH 14/93] Improvement: CF Shop non purhcaseable (#3095) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../inventory/chocolatefactory/ChocolateShopPrice.kt | 12 ++++++++++-- .../java/at/hannibal2/skyhanni/utils/StringUtils.kt | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index 6901f8df66a5..40a30d70d5b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables +import at.hannibal2.skyhanni.utils.StringUtils.addStrikethorugh import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -107,8 +108,9 @@ object ChocolateShopPrice { val internalName = item.getInternalName() val itemPrice = internalName.getPriceOrNull() ?: continue val otherItemsPrice = item.loreCosts().sumOf { it.getPrice() }.takeIf { it != 0.0 } + val canBeBought = lore.any { it == "§eClick to trade!" } - newProducts.add(Product(slot, item.itemName, internalName, chocolate, itemPrice, otherItemsPrice)) + newProducts.add(Product(slot, item.itemName, internalName, chocolate, itemPrice, otherItemsPrice, canBeBought)) } products = newProducts } @@ -141,10 +143,15 @@ object ChocolateShopPrice { add("") val formattedTimeUntilGoal = ChocolateAmount.CURRENT.formattedTimeUntilGoal(product.chocolate) add("§7Time until affordable: §6$formattedTimeUntilGoal ") + + if (!product.canBeBought) { + add("") + add("§cCannot be bought!") + } } table.add( DisplayTableEntry( - "${product.name}§f:", + product.name.addStrikethorugh(!product.canBeBought), "§6§l$perFormat", factor, product.item, @@ -205,5 +212,6 @@ object ChocolateShopPrice { val chocolate: Long, val itemPrice: Double, val otherItemPrice: Double?, + val canBeBought: Boolean, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index e596c316eb0b..8e30c6672e3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorChatComponentText +import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode import at.hannibal2.skyhanni.utils.GuiRenderUtils.darkenColor import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RegexUtils.findAll @@ -525,4 +526,12 @@ object StringUtils { if (string.isEmpty()) return "" return if (string[0] in "aeiou") "an" else "a" } + + fun String.addStrikethorugh(strikethorugh: Boolean = true): String { + if (!strikethorugh) return this + + val firstColor = getFirstColorCode() + val clean = removeColor() + return "§$firstColor§m$clean" + } } From a638e646449a28b6888bcec5eb2f61069a7af19b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:53:14 +0100 Subject: [PATCH 15/93] Improvement: More Reminder checks (#2028) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../hannibal2/skyhanni/features/fame/ReminderUtils.kt | 10 +++++++++- .../hannibal2/skyhanni/features/misc/NoBitsWarning.kt | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt index 821ac7774d76..542d34ba96d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt @@ -9,7 +9,15 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland object ReminderUtils { - // TODO: add arachne fight, add slayer boss spawned, add dragon fight + /** + * TODO: + * add arachne fight + * add slayer boss spawned + * add dragon fight + * add experimentation solver + * add matriach lair + * add server restart + */ fun isBusy(ignoreFarmingContest: Boolean = false): Boolean = (DungeonAPI.inDungeon() && !DungeonAPI.completed) || LorenzUtils.inKuudraFight || (FarmingContestAPI.inContest && !ignoreFarmingContest) || diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt index 888373c3f483..68d3c51f2b9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt @@ -28,6 +28,7 @@ object NoBitsWarning { HypixelCommands.bazaar("booster cookie") }, "§eClick to run /bz booster cookie!" ) + // TODO use reminder utils LorenzUtils.sendTitle("§bNo Bits Available", 5.seconds) if (config.notificationSound) SoundUtils.repeatSound(100, 10, createSound("note.pling", 0.6f)) } From 82060fcef495af013c5a46de4dd0a47821fa4be8 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:45:58 +0100 Subject: [PATCH 16/93] Feature: Carrolyn (#3096) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/garden/GardenConfig.java | 8 ++ .../skyhanni/events/ItemClickEvent.kt | 1 + .../features/fishing/trophy/OdgerWaypoint.kt | 6 +- .../garden/inventory/CarrolynHelper.kt | 76 +++++++++++++++++++ 4 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/inventory/CarrolynHelper.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java index b2b3f19aeaa1..04ee9f610e2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java @@ -15,6 +15,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.annotations.SearchTag; public class GardenConfig { @Expose @@ -241,4 +242,11 @@ public class GardenConfig { @Expose @ConfigLink(owner = GardenConfig.class, field = "showLogBookStats") public Position logBookStatsPos = new Position(427, 92, false, true); + + @Expose + @ConfigOption(name = "Carrolyn Fetch Helper", desc = "Helps to fetch items to Carrolyn for permanent buffs.") + @SearchTag("Expired Pumpkin, Exportable Carrots, Supreme Chocolate Bar, Fine Flour") + @ConfigEditorBoolean + @FeatureToggle + public boolean helpCarrolyn = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt index e0a96d7e5db6..d5f0e1155958 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt @@ -3,4 +3,5 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.ClickType import net.minecraft.item.ItemStack +// Left or right click into the world, with the item in hand class ItemClickEvent(itemInHand: ItemStack?, clickType: ClickType) : WorldClickEvent(itemInHand, clickType) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt index 3d56036eea70..1fbe3995cae6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt @@ -22,7 +22,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object OdgerWaypoint { private val config get() = SkyHanniMod.feature.fishing.trophyFishing - private val location = LorenzVec(-373, 207, -808) + private val odgerLocation = LorenzVec(-373, 207, -808) private var trophyFishInInventory = false @@ -39,8 +39,8 @@ object OdgerWaypoint { if (FishingAPI.holdingLavaRod) return if (!trophyFishInInventory) return - event.drawWaypointFilled(location, LorenzColor.WHITE.toColor()) - event.drawDynamicText(location, "Odger", 1.5) + event.drawWaypointFilled(odgerLocation, LorenzColor.WHITE.toColor()) + event.drawDynamicText(odgerLocation, "Odger", 1.5) } @HandleEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/CarrolynHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/CarrolynHelper.kt new file mode 100644 index 000000000000..215659f475cb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/CarrolynHelper.kt @@ -0,0 +1,76 @@ +package at.hannibal2.skyhanni.features.garden.inventory + +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.EntityMovementData +import at.hannibal2.skyhanni.data.IslandGraphs +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.ItemClickEvent +import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.item.ItemStack + +@SkyHanniModule +object CarrolynHelper { + private val config get() = GardenAPI.config + + private val carrolynLocation = LorenzVec(0.5, 103.1, -803.7) + + private val patternGroup = RepoPattern.group("garden.carrolyn") + + /** + * REGEX-TEST: §7Bring §63,000 §7of these to §5Carrolyn §7in + */ + private val lorePattern by patternGroup.pattern( + "lore", + "§7Bring §63,000 §7of these to §5Carrolyn §7in", + ) + + @HandleEvent(priority = HandleEvent.LOWEST) + fun onTooltip(event: ItemHoverEvent) { + if (!isEnabled()) return + + if (!event.itemStack.isCarrolynItem()) return + + event.toolTip.add("") + event.toolTip.add("§eClick to navigate to Carrolyn!") + } + + private fun ItemStack?.isCarrolynItem() = this?.getLore()?.any { lorePattern.matches(it) } ?: false + + @HandleEvent(onlyOnSkyblock = true) + fun onItemClick(event: ItemClickEvent) { + if (!isEnabled()) return + + if (!event.itemInHand.isCarrolynItem()) return + + if (LorenzUtils.skyBlockIsland == IslandType.CRIMSON_ISLE) { + startPathfind() + } else { + ChatUtils.clickableChat( + "Carrolyn is on the Crimson Isle. Click here to warp there!", + onClick = { + HypixelCommands.warp("crimson") + EntityMovementData.onNextTeleport(IslandType.CRIMSON_ISLE) { + startPathfind() + } + }, + replaceSameMessage = true, + ) + } + } + + private fun startPathfind() { + IslandGraphs.pathFind(carrolynLocation, "§5Carrolyn", condition = { isEnabled() }) + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.helpCarrolyn + +} From 742306de2f6e484e26bd8c0c7f79059c589301b9 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:46:08 +0100 Subject: [PATCH 17/93] Fix: Reforge Helper NPE (#3093) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/inventory/ReforgeHelper.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ReforgeHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ReforgeHelper.kt index 1bad6e6f1151..6a9ffebe38cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ReforgeHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ReforgeHelper.kt @@ -417,8 +417,8 @@ object ReforgeHelper { if (slot != null) { slot highlight color } else { - inventory[HEX_REFORGE_NEXT_DOWN_BUTTON]?.takeIf { it.stack.item == Items.skull }?.highlight(color) - inventory[HEX_REFORGE_NEXT_UP_BUTTON]?.takeIf { it.stack.item == Items.skull }?.highlight(color) + inventory[HEX_REFORGE_NEXT_DOWN_BUTTON]?.takeIf { it.stack?.item == Items.skull }?.highlight(color) + inventory[HEX_REFORGE_NEXT_UP_BUTTON]?.takeIf { it.stack?.item == Items.skull }?.highlight(color) } } From a83029bd9783352ffffdeb474f154a283cdf614e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:47:02 +0100 Subject: [PATCH 18/93] Improvement: Gemstone unlock material name (#3089) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../items/EstimatedItemValueCalculator.kt | 140 +++++++++--------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index 9a7256d12039..c8fc7aed0c17 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.SKYBLOCK_COIN import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NEUItems.removePrefix @@ -230,8 +231,8 @@ object EstimatedItemValueCalculator { val applyCost = reforge.costs?.let { getReforgeStoneApplyCost(stack, it, internalName) } ?: return 0.0 list.add("§7Reforge: §9${reforge.name}") - list.add(" §7Stone: $reforgeStoneName §7(§6" + reforgeStonePrice.shortFormat() + "§7)") - list.add(" §7Apply cost: (§6" + applyCost.shortFormat() + "§7)") + list.add(" §7Stone: $reforgeStoneName §7(§6" + reforgeStonePrice.shortFormat() + "§7)") + list.add(" §7Apply cost: (§6" + applyCost.shortFormat() + "§7)") return reforgeStonePrice + applyCost } @@ -461,13 +462,9 @@ object EstimatedItemValueCalculator { } for ((materialInternalName, amount) in price.itemPrice) { - val itemPrice = materialInternalName.getPriceOrNull(config.priceSource.get())?.let { it * amount } - if (itemPrice != null) { - map[" §8${amount.addSeparators()}x ${materialInternalName.itemName} §7(§6${itemPrice.shortFormat()}§7)"] = itemPrice - } else { - map[" §8${amount.addSeparators()}x ${materialInternalName.itemName}"] = 0.0 - } - totalPrice += itemPrice ?: 0.0 + val itemPrice = materialInternalName.getPrice() + map[materialInternalName.getPriceName(amount)] = itemPrice + totalPrice += itemPrice } list.add("§7Stars: §e$havingStars§7/§e$maxStars §7(§6" + totalPrice.shortFormat() + "§7)") @@ -578,16 +575,15 @@ object EstimatedItemValueCalculator { private fun addDrillUpgrades(stack: ItemStack, list: MutableList): Double { val drillUpgrades = stack.getDrillUpgrades() ?: return 0.0 - var totalPrice = 0.0 val map = mutableMapOf() for (internalName in drillUpgrades) { val name = internalName.itemName val price = internalName.getPriceOrNull(config.priceSource.get()) ?: continue - totalPrice += price val format = price.shortFormat() map[" $name §7(§6$format§7)"] = price } + val totalPrice = map.values.sum() if (map.isNotEmpty()) { list.add("§7Drill upgrades: §6" + totalPrice.shortFormat()) list += map.sortedDesc().keys @@ -655,16 +651,15 @@ object EstimatedItemValueCalculator { private fun addAbilityScrolls(stack: ItemStack, list: MutableList): Double { val abilityScrolls = stack.getAbilityScrolls() ?: return 0.0 - var totalPrice = 0.0 val map = mutableMapOf() for (internalName in abilityScrolls) { val name = internalName.itemName val price = internalName.getPriceOrNull(config.priceSource.get()) ?: continue - totalPrice += price val format = price.shortFormat() map[" $name §7(§6$format§7)"] = price } + val totalPrice = map.values.sum() if (map.isNotEmpty()) { list.add("§7Ability Scrolls: §6" + totalPrice.shortFormat()) list += map.sortedDesc().keys @@ -730,7 +725,6 @@ object EstimatedItemValueCalculator { private fun addEnchantments(stack: ItemStack, list: MutableList): Double { val enchantments = stack.getEnchantments() ?: return 0.0 - var totalPrice = 0.0 val map = mutableMapOf() // todo use repo @@ -787,30 +781,28 @@ object EstimatedItemValueCalculator { val singlePrice = enchantmentName.getPriceOrNull(config.priceSource.get()) ?: continue var name = itemStack.getLore()[0] + // TODO find a way to use this here "".toInternalName().getPriceName(multiplier) if (multiplier > 1) { name = "§8${multiplier}x $name" } val price = singlePrice * multiplier - - totalPrice += price val format = price.shortFormat() - map[" $name §7(§6$format§7)"] = price } val enchantmentsCap: Int = config.enchantmentsCap.get() - if (map.isNotEmpty()) { - list.add("§7Enchantments: §6" + totalPrice.shortFormat()) - var i = 0 - for (entry in map.sortedDesc().keys) { - if (i == enchantmentsCap) { - val missing = map.size - enchantmentsCap - list.add(" §7§o$missing more enchantments..") - break - } - list.add(entry) - i++ + if (map.isEmpty()) return 0.0 + val totalPrice = map.values.sum() + list.add("§7Enchantments: §6" + totalPrice.shortFormat()) + var i = 0 + for (entry in map.sortedDesc().keys) { + if (i == enchantmentsCap) { + val missing = map.size - enchantmentsCap + list.add(" §7§o$missing more enchantments..") + break } + list.add(entry) + i++ } return totalPrice } @@ -818,7 +810,6 @@ object EstimatedItemValueCalculator { private fun addGemstones(stack: ItemStack, list: MutableList): Double { val gemstones = stack.getGemstones() ?: return 0.0 - var totalPrice = 0.0 val counterMap = mutableMapOf() for (gemstone in gemstones) { val internalName = gemstone.getInternalName() @@ -828,23 +819,12 @@ object EstimatedItemValueCalculator { val priceMap = mutableMapOf() for ((internalName, amount) in counterMap) { - - val name = internalName.itemName - val price = internalName.getPrice() * amount - - totalPrice += price - val format = price.shortFormat() - - val text = if (amount == 1) { - " $name §7(§6$format§7)" - } else { - " §8${amount}x $name §7(§6$format§7)" - } - priceMap[text] = price + val text = internalName.getPriceName(amount) + priceMap[text] = internalName.getPrice() * amount } - + val totalPrice = priceMap.values.sum() if (priceMap.isNotEmpty()) { - list.add("§7Gemstones: §6" + totalPrice.shortFormat()) + list.add("§7Gemstones Applied: §6" + totalPrice.shortFormat()) list += priceMap.sortedDesc().keys } return totalPrice @@ -853,64 +833,84 @@ object EstimatedItemValueCalculator { private fun ItemStack.readNbtDump() = tagCompound?.getReadableNBTDump(includeLore = true)?.joinToString("\n") ?: "no tag compound" - private fun addGemstoneSlotUnlockCost(stack: ItemStack, list: MutableList): Double { - val internalName = stack.getInternalName() - + private fun ItemStack.readUnlockedSlots(): String? { // item have to contains gems.unlocked_slots NBT array for unlocked slot detection - val unlockedSlots = stack.getExtraAttributes()?.getCompoundTag("gems")?.getTag("unlocked_slots")?.toString() ?: return 0.0 + val unlockedSlots = getExtraAttributes()?.getCompoundTag("gems")?.getTag("unlocked_slots")?.toString() ?: return null // TODO detection for old items which doesn't have gems.unlocked_slots NBT array // if (unlockedSlots == "null") return 0.0 - val priceMap = mutableMapOf() - if (EstimatedItemValue.gemstoneUnlockCosts.isEmpty()) return 0.0 + if (EstimatedItemValue.gemstoneUnlockCosts.isEmpty()) return null + val internalName = getInternalName() if (internalName !in EstimatedItemValue.gemstoneUnlockCosts) { ErrorManager.logErrorStateWithData( - "Could not find gemstone slot price for ${stack.name}", + "Could not find gemstone slot price for $name", "EstimatedItemValue has no gemstoneUnlockCosts for $internalName", "internal name" to internalName, "gemstoneUnlockCosts" to EstimatedItemValue.gemstoneUnlockCosts, - "item name" to stack.name, - "item nbt" to stack.readNbtDump(), + "item name" to name, + "item nbt" to readNbtDump(), ) - return 0.0 + return null } - var totalPrice = 0.0 - val slots = EstimatedItemValue.gemstoneUnlockCosts[internalName] ?: return 0.0 - for (slot in slots) { - if (!unlockedSlots.contains(slot.key)) continue + return unlockedSlots + } - val previousTotal = totalPrice - for (ingredients in slot.value) { - val ingredient = PrimitiveIngredient(ingredients) + private fun addGemstoneSlotUnlockCost(stack: ItemStack, list: MutableList): Double { + val unlockedSlots = stack.readUnlockedSlots() ?: return 0.0 - totalPrice += if (ingredient.isCoin()) { - ingredient.count - } else { - ingredient.internalName.getPrice() * ingredient.count - } + val materials = mutableMapOf() + val slots = EstimatedItemValue.gemstoneUnlockCosts[stack.getInternalName()] ?: return 0.0 + val slotNames = mutableListOf() + for ((key, value) in slots) { + if (!unlockedSlots.contains(key)) continue + + for (ingredients in value) { + val ingredient = PrimitiveIngredient(ingredients) + val amount = ingredient.count.toInt() + materials.addOrPut(ingredient.internalName, amount) } - val splitSlot = slot.key.split("_") // eg. SAPPHIRE_1 + val splitSlot = key.split("_") // eg. SAPPHIRE_1 val colorCode = SkyBlockItemModifierUtils.GemstoneSlotType.getColorCode(splitSlot[0]) - val formattedPrice = (totalPrice - previousTotal).shortFormat() // eg. SAPPHIRE_1 -> Sapphire Slot 2 val displayName = splitSlot[0].lowercase(Locale.ENGLISH).replaceFirstChar(Char::uppercase) + " Slot" + // If the slot index is 0, we don't need to specify if (splitSlot[1] != "0") " " + (splitSlot[1].toInt() + 1) else "" - priceMap[" §$colorCode $displayName §7(§6$formattedPrice§7)"] = totalPrice - previousTotal + slotNames.add("§$colorCode$displayName") } + if (slotNames.isEmpty()) return 0.0 + + val priceMap = mutableMapOf() + for ((material, amount) in materials) { + val price = material.getPrice() * amount + priceMap[material.getPriceName(amount)] = price + } + val totalPrice = priceMap.values.sum() list.add("§7Gemstone Slot Unlock Cost: §6" + totalPrice.shortFormat()) + list += priceMap.sortedDesc().keys + + // TODO add toggle that is default enabled "show unlocked gemstone slot name + list.add(" §7Unlocked slots: " + slotNames.joinToString("§7, ")) + return totalPrice } - private fun NEUInternalName.getPrice(): Double = getPriceOrNull(config.priceSource.get()) ?: -1.0 + private fun NEUInternalName.getPriceName(amount: Int): String { + val price = getPrice() * amount + if (this == SKYBLOCK_COIN) return " §6${price.shortFormat()} coins" + + val prefix = if (amount == 1) "" else "§8${amount.addSeparators()}x " + return " $prefix§r$itemName §7(§6${price.shortFormat()}§7)" + } + + private fun NEUInternalName.getPrice(): Double = getPriceOrNull(config.priceSource.get()) ?: 0.0 fun Pair.getAttributeName(): String { val name = first.fixMending().allLettersFirstUppercase() From b750029c3c92d3a73124bcb66b4ba157cf078a1b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:47:10 +0100 Subject: [PATCH 19/93] Improvement: opt in persistent search (#3090) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/misc/MiscConfig.java | 5 +++ .../skyhanni/data/model/TextInput.kt | 8 +++- .../skyhanni/features/misc/IslandAreas.kt | 4 +- .../misc/update/GuiOptionEditorUpdateCheck.kt | 4 +- .../skyhanni/test/graph/GraphNodeEditor.kt | 4 +- .../utils/renderables/SearchTextInput.kt | 38 +++++++++++++++++++ .../skyhanni/utils/renderables/Searchable.kt | 16 ++++---- .../skyhanni/utils/tracker/SkyHanniTracker.kt | 4 +- 8 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/renderables/SearchTextInput.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index cc5b0302be52..1e3f393a9a1d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -124,6 +124,11 @@ public class MiscConfig { @Accordion public LastServersConfig lastServers = new LastServersConfig(); + @Expose + @ConfigOption(name = "Reset Search on Close", desc = "Reset the search in GUIs after closing the inventory.") + @ConfigEditorBoolean + public boolean resetSearchGuiOnClose = true; + @Expose @ConfigOption(name = "Show Outside SkyBlock", desc = "Show these features outside of SkyBlock.") @ConfigEditorDraggableList diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt index 3299759157fc..c820b25aae5e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt @@ -13,7 +13,7 @@ import org.lwjgl.input.Keyboard import org.spongepowered.asm.mixin.injection.callback.CallbackInfo import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable -class TextInput { +open class TextInput { var textBox: String = "" private var carriage: Int? = null @@ -46,6 +46,10 @@ class TextInput { private val updateEvents = mutableMapOf Unit>() + protected fun update() { + updateEvents.forEach { (_, it) -> it(this) } + } + fun registerToEvent(key: Int, event: (TextInput) -> Unit) { updateEvents[key] = event } @@ -102,7 +106,7 @@ class TextInput { private fun updated() { with(activeInstance) { if (this == null) return - this.updateEvents.forEach { (_, it) -> it(this) } + update() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt index c4bc07d5fefe..7c993717a756 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/IslandAreas.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.data.IslandGraphs.pathFind import at.hannibal2.skyhanni.data.model.Graph import at.hannibal2.skyhanni.data.model.GraphNode import at.hannibal2.skyhanni.data.model.GraphNodeTag -import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -28,6 +27,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.SearchTextInput import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.renderables.buildSearchBox import at.hannibal2.skyhanni.utils.renderables.toSearchable @@ -45,7 +45,7 @@ object IslandAreas { var display: Renderable? = null private var targetNode: GraphNode? = null var currentAreaName = "" - private val textInput = TextInput() + private val textInput = SearchTextInput() @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt index e3cdac76d5a9..5eee15d4d941 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt @@ -13,7 +13,7 @@ import org.lwjgl.input.Mouse class GuiOptionEditorUpdateCheck(option: ProcessedOption) : GuiOptionEditor(option) { - val button = GuiElementButton("", -1) { } + val button = GuiElementButton("", -1) {} override fun render(x: Int, y: Int, width: Int) { val fr = Minecraft.getMinecraft().fontRendererObj @@ -55,7 +55,7 @@ class GuiOptionEditorUpdateCheck(option: ProcessedOption) : GuiOptionEditor(opti 10F, true, widthRemaining / 2, - -1 + -1, ) GlStateManager.popMatrix() diff --git a/src/main/java/at/hannibal2/skyhanni/test/graph/GraphNodeEditor.kt b/src/main/java/at/hannibal2/skyhanni/test/graph/GraphNodeEditor.kt index 780d3fc0dec6..54edd6a74f27 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/graph/GraphNodeEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/graph/GraphNodeEditor.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.test.graph import at.hannibal2.skyhanni.data.model.GraphNodeTag -import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.graph.GraphEditor.distanceSqToPlayer @@ -14,6 +13,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.renderables.ScrollValue +import at.hannibal2.skyhanni.utils.renderables.SearchTextInput import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.renderables.buildSearchableScrollable import at.hannibal2.skyhanni.utils.renderables.toSearchable @@ -27,7 +27,7 @@ object GraphNodeEditor { private val scrollValueNodes = ScrollValue() private val scrollValueTags = ScrollValue() - private val textInput = TextInput() + private val textInput = SearchTextInput() private var nodesDisplay = emptyList() private var lastUpdate = SimpleTimeMark.farPast() private val tagsToShow: MutableList = GraphNodeTag.entries.toMutableList() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/SearchTextInput.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/SearchTextInput.kt new file mode 100644 index 000000000000..18c5dbdab767 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/SearchTextInput.kt @@ -0,0 +1,38 @@ +package at.hannibal2.skyhanni.utils.renderables + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.model.TextInput +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class SearchTextInput : TextInput() { + + init { + searchTextInputs.add(this) + } + + @SkyHanniModule + companion object { + + private val config get() = SkyHanniMod.feature.misc + + val searchTextInputs = mutableListOf() + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + if (!isEnabled()) return + + for (input in searchTextInputs) { + if (input.textBox != "") { + input.textBox = "" + input.update() + } + } + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.resetSearchGuiOnClose + } + +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt index d2191462f40a..dbc76705f6a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Searchable.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.utils.renderables -import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.utils.StringUtils.removeColor class Searchable(val renderable: Renderable, val string: String?) @@ -10,14 +9,15 @@ fun Searchable.toRenderable() = renderable fun List.toRenderable() = map { it.toRenderable() } fun List.toMap() = associate { it.renderable to it.string } const val SEARCH_PREFIX = "§eSearch: §7" + fun List.buildSearchBox( - textInput: TextInput, + textInput: SearchTextInput, ): Renderable { val key = 0 return Renderable.searchBox( Renderable.verticalSearchableContainer(toMap(), textInput = textInput, key = key + 1), SEARCH_PREFIX, - onUpdateSize = { println("onUpdateSize") }, + onUpdateSize = {}, textInput = textInput, key = key, ) @@ -25,7 +25,7 @@ fun List.buildSearchBox( fun List.buildSearchableScrollable( height: Int, - textInput: TextInput, + textInput: SearchTextInput, scrollValue: ScrollValue = ScrollValue(), velocity: Double = 2.0, ): Renderable { @@ -40,19 +40,21 @@ fun List.buildSearchableScrollable( velocity = velocity, ), SEARCH_PREFIX, - onUpdateSize = { println("onUpdateSize") }, + onUpdateSize = {}, textInput = textInput, key = key, ) } +// TODO remove this function entirely, sack display should use a SearchTextInput object per sack name +@Deprecated("remove this function, instead use a fix SearchTextInput object") fun Map, String?>.buildSearchableTable(): Renderable { - val textInput = TextInput() + val textInput = SearchTextInput() val key = 0 return Renderable.searchBox( Renderable.searchableTable(toMap(), textInput = textInput, key = key + 1), SEARCH_PREFIX, - onUpdateSize = { println("onUpdateSize") }, + onUpdateSize = {}, textInput = textInput, key = key, ) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index 18c4075c13f9..15ddd26e1ff0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.TrackerManager -import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils @@ -15,6 +14,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.SearchTextInput import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.renderables.buildSearchBox import at.hannibal2.skyhanni.utils.renderables.toRenderable @@ -39,7 +39,7 @@ open class SkyHanniTracker( private var sessionResetTime = SimpleTimeMark.farPast() private var wasSearchEnabled = config.trackerSearchEnabled.get() private var dirty = false - private val textInput = TextInput() + private val textInput = SearchTextInput() companion object { From 2862774ccfd3c8f18ed315d329a3b202483f22bf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:47:26 +0100 Subject: [PATCH 20/93] Backend: Discord RCP /shdebug (#3092) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../misc/discordrpc/DiscordRPCManager.kt | 65 ++++++++++++++----- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index 20ae7c37a96e..6b7a6ad125df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -4,7 +4,6 @@ package at.hannibal2.skyhanni.features.misc.discordrpc import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature -import at.hannibal2.skyhanni.SkyHanniMod.Companion.logger import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.DiscordRPCConfig.LineEntry @@ -13,6 +12,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.jsonobjects.repo.StackingEnchantData import at.hannibal2.skyhanni.data.jsonobjects.repo.StackingEnchantsJson import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent @@ -51,17 +51,22 @@ object DiscordRPCManager : IPCListener { var stackingEnchants: Map = emptyMap() + private var debugError = false + private var debugStatusMessage = "nothing" + fun start(fromCommand: Boolean = false) { coroutineScope.launch { try { if (isConnected()) return@launch - logger.info("Starting Discord RPC...") + updateDebugStatus("Starting...") startTimestamp = System.currentTimeMillis() client = IPCClient(APPLICATION_ID) client?.setup(fromCommand) - } catch (ex: Throwable) { - logger.warn("Discord RPC has thrown an unexpected error while trying to start...", ex) + } catch (e: Throwable) { + updateDebugStatus("Unexpected error: ${e.message}", error = true) + ErrorManager.logErrorWithData(e, "Discord RPC has thrown an unexpected error while trying to start") + } } } @@ -69,6 +74,7 @@ object DiscordRPCManager : IPCListener { private fun stop() { coroutineScope.launch { if (isConnected()) { + updateDebugStatus("Stopped") client?.close() started = false } @@ -84,14 +90,16 @@ object DiscordRPCManager : IPCListener { // confirm that /shrpcstart worked ChatUtils.chat("Successfully started Rich Presence!", prefixColor = "§a") - } catch (ex: Exception) { - logger.warn("Failed to connect to RPC!", ex) + updateDebugStatus("Successfully started") + status + } catch (e: Exception) { + updateDebugStatus("Failed to connect: ${e.message} (discord not started yet?)", error = true) ChatUtils.clickableChat( "Discord Rich Presence was unable to start! " + "This usually happens when you join SkyBlock when Discord is not started. " + "Please run /shrpcstart to retry once you have launched Discord.", onClick = { startCommand() }, - "§eClick to run /shrpcstart!" + "§eClick to run /shrpcstart!", ) } } @@ -131,16 +139,16 @@ object DiscordRPCManager : IPCListener { addButton( RichPresenceButton( "https://sky.shiiyu.moe/stats/${LorenzUtils.getPlayerName()}/${HypixelData.profileName}", - "Open SkyCrypt" - ) + "Open SkyCrypt", + ), ) } - }.build() + }.build(), ) } override fun onReady(client: IPCClient) { - logger.info("Discord RPC Ready.") + updateDebugStatus("Discord RPC Ready.") } @SubscribeEvent @@ -152,17 +160,18 @@ object DiscordRPCManager : IPCListener { } override fun onClose(client: IPCClient, json: JsonObject?) { - logger.info("Discord RPC closed.") + updateDebugStatus("Discord RPC closed.") this.client = null } override fun onDisconnect(client: IPCClient?, t: Throwable?) { - logger.info("Discord RPC disconnected.") + updateDebugStatus("Discord RPC disconnected.") this.client = null } - private fun getStatusByConfigId(entry: LineEntry) = - DiscordStatus.entries.getOrElse(entry.ordinal) { DiscordStatus.NONE } + private fun getStatusByConfigId(entry: LineEntry): DiscordStatus { + return DiscordStatus.entries.getOrElse(entry.ordinal) { DiscordStatus.NONE } + } private fun isEnabled() = config.enabled.get() @@ -207,14 +216,38 @@ object DiscordRPCManager : IPCListener { ChatUtils.chat("Attempting to start Discord Rich Presence...") try { start(true) + updateDebugStatus("Successfully started") } catch (e: Exception) { + updateDebugStatus("Unable to start: ${e.message}", error = true) ErrorManager.logErrorWithData( e, - "Unable to start Discord Rich Presence! Please report this on Discord and ping @netheriteminer." + "Unable to start Discord Rich Presence! Please report this on Discord and ping @netheriteminer.", ) } } + private fun updateDebugStatus(message: String, error: Boolean = false) { + debugStatusMessage = message + debugError = error + } + + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Discord RCP") + + if (debugError) { + event.addData { + add("Error detected!") + add(debugStatusMessage) + } + } else { + event.addIrrelevant { + add("no error detected.") + add("status: $debugStatusMessage") + } + } + } + // Events that change things in DiscordStatus @HandleEvent fun onKeyPress(event: KeyPressEvent) { From ef14bc11b65eb8bbc11ac0e8b9f5edb9f105c5e6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:48:02 +0100 Subject: [PATCH 21/93] Improvement + Fix: Craftable Item list (#3094) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: calwolfson --- .../features/inventory/InventoryConfig.java | 2 +- .../at/hannibal2/skyhanni/data/SackAPI.kt | 3 +- .../inventory/craft/CraftableItemList.kt | 55 ++++++++++++------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 7a0aa9c7a36f..c5f17354f6dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -70,7 +70,7 @@ public class InventoryConfig { public ItemPickupLogConfig itemPickupLogConfig = new ItemPickupLogConfig(); @Expose - @Category(name = "Craftable Item List", desc = "") + @Category(name = "Craftable Item List", desc = "Helps to find items to §e/craft.") @Accordion public CraftableItemListConfig craftableItemList = new CraftableItemListConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 9db3f0ff1ac7..da619fd9eb61 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -236,7 +236,8 @@ object SackAPI { if (savingSacks) saveSackData() } - private var sackData = mapOf() + var sackData = mapOf() + private set data class SackChange(val delta: Int, val internalName: NEUInternalName, val sacks: List) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt index 60ce4cf91b17..6a5328fa9401 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt @@ -1,13 +1,15 @@ package at.hannibal2.skyhanni.features.inventory.craft import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacks +import at.hannibal2.skyhanni.data.SackAPI +import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc +import at.hannibal2.skyhanni.utils.CollectionUtils.toSingletonListOrEmpty import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice @@ -25,6 +27,9 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.Searchable +import at.hannibal2.skyhanni.utils.renderables.buildSearchableScrollable +import at.hannibal2.skyhanni.utils.renderables.toSearchable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.floor @@ -35,6 +40,7 @@ object CraftableItemList { private var display = listOf() private var inInventory = false + private val textInput = TextInput() private val craftItemPattern by RepoPattern.pattern( "craftableitemlist.craftitem", "Craft Item", @@ -47,23 +53,30 @@ object CraftableItemList { inInventory = true val pricePer = mutableMapOf() - val lines = mutableMapOf() + val lines = mutableMapOf() loadItems(pricePer, lines) display = if (lines.isEmpty()) { - listOf(Renderable.string("§7No Items to craft")) + Renderable.hoverTips( + "§7No Items to craft", + tips = listOf( + "§7No items found in your Inventory", + "or sacks that can be used as", + "material in crafting recipes.", + ), + ).toSingletonListOrEmpty() } else { - val items = pricePer.sortedDesc().keys.map { lines[it] ?: error("impossible") } - listOf( - Renderable.string("§eCraftable items (${items.size})"), - Renderable.scrollList(items, height = 250, velocity = 20.0), - ) + buildList { + val items = pricePer.sortedDesc().keys.map { lines[it] ?: error("impossible") } + add(Renderable.string("§e§lCraftable Items §7(${items.size})")) + add(items.buildSearchableScrollable(height = 250, textInput, velocity = 20.0)) + } } } private fun loadItems( pricePer: MutableMap, - lines: MutableMap, + lines: MutableMap, ) { val availableMaterial = readItems() for (internalName in NEUItems.allInternalNames) { @@ -83,7 +96,7 @@ object CraftableItemList { availableMaterial: Map, pricePer: MutableMap, internalName: NEUInternalName, - ): Renderable? { + ): Searchable? { val neededItems = ItemUtils.neededItems(recipe) // Just a fail save, should not happen normally if (neededItems.isEmpty()) return null @@ -94,8 +107,9 @@ object CraftableItemList { val amountFormat = canCraftAmount.addSeparators() val totalPrice = pricePer(neededItems) pricePer[internalName] = totalPrice - val tooltip = buildList { - add(internalName.itemName) + val itemName = internalName.itemName + val tooltip = buildList { + add(itemName) add("") add("§7Craft cost: §6${totalPrice.shortFormat()}") for ((item, amount) in neededItems) { @@ -106,17 +120,17 @@ object CraftableItemList { add("") add("§7You have enough materials") val timeName = StringUtils.pluralize(canCraftAmount, "time", "times") - add("§7to craft this item $amountFormat $timeName!") + add("§7to craft this item §e$amountFormat §7$timeName!") add("") add("§eClick to craft!") } return Renderable.clickAndHover( - "§8x$amountFormat ${internalName.itemName}", + "§8x$amountFormat $itemName", tips = tooltip, onClick = { HypixelCommands.viewRecipe(internalName.asString()) }, - ) + ).toSearchable(itemName) } @SubscribeEvent @@ -134,9 +148,7 @@ object CraftableItemList { ): Int { val canCraftTotal = mutableListOf() for ((name, neededAmount) in need) { - val inventory = available[name] ?: 0 - val sacks = if (config.includeSacks) name.getAmountInSacks() else 0 - val having = inventory + sacks + val having = available[name] ?: 0 val canCraft = floor(having.toDouble() / neededAmount).toInt() canCraftTotal.add(canCraft) } @@ -149,6 +161,11 @@ object CraftableItemList { val item = stack.toPrimitiveStackOrNull() ?: continue materials.addOrPut(item.internalName, item.amount.toLong()) } + if (config.includeSacks) { + for ((internalName, item) in SackAPI.sackData) { + materials.addOrPut(internalName, item.amount.toLong()) + } + } return materials } @@ -157,7 +174,7 @@ object CraftableItemList { if (!isEnabled()) return if (!inInventory) return - config.position.renderRenderables(display, posLabel = "Craft Materials From Bazaar") + config.position.renderRenderables(display, posLabel = "Craftable Item List") } fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled From 99f1135216ed0f556d1fbfa79580cf07d7064196 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 21 Dec 2024 00:56:20 +0100 Subject: [PATCH 22/93] fix merge conflict --- .../skyhanni/features/inventory/craft/CraftableItemList.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt index 6a5328fa9401..6b2dd71785cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/craft/CraftableItemList.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.inventory.craft import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.SackAPI -import at.hannibal2.skyhanni.data.model.TextInput import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent @@ -27,6 +26,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.SearchTextInput import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.renderables.buildSearchableScrollable import at.hannibal2.skyhanni.utils.renderables.toSearchable @@ -40,7 +40,7 @@ object CraftableItemList { private var display = listOf() private var inInventory = false - private val textInput = TextInput() + private val textInput = SearchTextInput() private val craftItemPattern by RepoPattern.pattern( "craftableitemlist.craftitem", "Craft Item", From 084790f71defe4c179af43954261c7b0f277e361 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 21 Dec 2024 01:03:25 +0100 Subject: [PATCH 23/93] Fix: Special Zealot Highlight (#3099) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/combat/mobs/MobHighlight.kt | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt index e4daec51015f..8584d2d9ea65 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth -import at.hannibal2.skyhanni.utils.LorenzUtils.ignoreDerpy import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.entity.EntityOtherPlayerMP @@ -70,27 +69,24 @@ object MobHighlight { val isZealot = maxHealth == 13_000 || maxHealth == 13_000 * 4 // runic val isBruiser = maxHealth == 65_000 || maxHealth == 65_000 * 4 // runic + if (!(isZealot || isBruiser)) return + if (config.zealotBruiserHighlighter) { - if (isZealot || isBruiser) { - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - entity, - LorenzColor.DARK_AQUA.toColor().addAlpha(127), - ) { config.zealotBruiserHighlighter } - } + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.DARK_AQUA.toColor().addAlpha(127), + ) { config.zealotBruiserHighlighter } } - if (config.chestZealotHighlighter) { - val isHoldingChest = entity.getBlockInHand()?.block == Blocks.ender_chest - if ((isZealot || isBruiser) && isHoldingChest) { - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - entity, - LorenzColor.GREEN.toColor().addAlpha(127), - ) { config.chestZealotHighlighter } - } + val heldItem = entity.getBlockInHand()?.block + if (config.chestZealotHighlighter && heldItem == Blocks.ender_chest) { + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + entity, + LorenzColor.GREEN.toColor().addAlpha(127), + ) { config.chestZealotHighlighter } } - // Special Zealots are not impacted by derpy - if (config.specialZealotHighlighter && maxHealth.ignoreDerpy() == 2_000) { + if (config.specialZealotHighlighter && heldItem == Blocks.end_portal_frame) { RenderLivingEntityHelper.setEntityColorWithNoHurtTime( entity, LorenzColor.DARK_RED.toColor().addAlpha(50), From a1d120bc4af0c9488011ea7701472838b0cbb90d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 21 Dec 2024 02:11:57 +0100 Subject: [PATCH 24/93] Version 0.28 Beta 21 --- docs/CHANGELOG.md | 23 +++++++++++++++++++++++ docs/FEATURES.md | 1 + root.gradle.kts | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 20a5cf4e027e..c290ef7aefb6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -78,6 +78,10 @@ + Added chat solvers for Primal Fears. - Helium9 (https://github.com/hannibal002/SkyHanni/pull/2771) + Added solvers for Math and Public Speaking Primal Fears. +#### Garden Features + ++ Added Carrolyn Fetch Helper to fetch items for permanent farming buffs. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3096) + ### Improvements #### Inventory Improvements @@ -96,6 +100,11 @@ + Improved the UI for the Cake Tracker. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2939) + Made the Cake Tracker scrollable instead of having a fixed size. + Cakes you claim from the baker will now be added to the Cake Tracker automatically. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3008) ++ Made the Craftable Item List searchable. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3094) ++ Added an option to reset search on close. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3090) + + Reset search terms in GUIs after closing inventory (Profit Trackers, Area Navigation list, etc.). + + Enabled by default to reduce confusion caused by the search feature. ++ The Estimated Item Value now displays material names used to unlock gemstone slots. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3089) #### Chat and Command Improvements @@ -150,6 +159,7 @@ + Added more granular control over when the Hoppity Live Display is shown. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2919) + The Hoppity Unclaimed Eggs display is now more accurate at the end of events. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2986) + Added option to display Date/Time on Hoppity Event Live Display. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2973) ++ Marked non-purchasable items in CF Shop. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3095) #### Great Spook Improvements @@ -197,6 +207,7 @@ + Added the Minecraft version to the mod file name. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2941) + Added a warning for empty messages left behind by Stash Compact. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3009) + Added option to hide seconds in the Real Time GUI. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2979) ++ Improved graph navigation performance. - hannibal2 & Thunderblade (https://github.com/hannibal002/SkyHanni/pull/3083) ### Fixes @@ -235,6 +246,10 @@ + Fixed edge case causing error when acquiring a power-up on first click in SuperPairs. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3080) + Fixed Experiments Profit Tracker not counting exp bottles splashed after using the Experimentation Table. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3066) + Fixed items from the previous menu leaking into the SkyHanni User Luck stat breakdown submenu. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/3057) ++ Fixed hover text being off by one in the Craftable Item List. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3094) ++ Fixed a rare error with Reforge Helper. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3093) ++ Fixed skill overflow detection for values slightly above the maximum. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3084) ++ Fixed /shtrackcollection not tracking Youngite and Obsolite. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/3082) #### Combat Fixes @@ -244,6 +259,7 @@ + Fixed Millennia-Aged Blaze not being highlighted by the Area Boss Highlight feature. - jani (https://github.com/hannibal002/SkyHanni/pull/2707) + Fixed a small typo in Bestiary Display. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2748) + Fixed `Line to Slayer Miniboss` not checking for walls. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2788) ++ Fixed Special Zealots not highlighted after a recent Hypixel update. - Luna (https://github.com/hannibal002/SkyHanni/pull/3099) #### Custom Scoreboard Fixes @@ -279,6 +295,7 @@ + Fixed issue with Stampede/Golden Click not counting in Stray Tracker. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3013) + Fixed stray timer not activating from Hitman Eggs outside of Hoppity's Hunt. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3015) + Fixed Hitman Full Time calculation. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3075) ++ Fixed edge case where Hoppity Call warning wouldn't disappear. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3086) #### Garden Fixes @@ -307,6 +324,7 @@ + Specified in visitor config that Maeve's dialogue is not hidden in the "Hide Chat" option. - Chissl (https://github.com/hannibal002/SkyHanni/pull/3002) + Fixed the next visitor timer not decreasing on pest kills. - Chissl (https://github.com/hannibal002/SkyHanni/pull/3027) + Fixed chat error spam from Garden Composter Overlay. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3037) ++ Fixed Vacuum Item Stack Size not showing with over 1k Pests. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3088) #### Crimson Isle Fixes @@ -405,6 +423,7 @@ + Fixed intermittent NEU rendering issues. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/3053) + Fixed collection tracker to recognize the current collection. - nopo (https://github.com/hannibal002/SkyHanni/pull/3049) + Fixed skill level. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3068) ++ Fixed Replace Roman Numerals replacing random letters. - Mikecraft1224 (https://github.com/hannibal002/SkyHanni/pull/3003) ### Technical Details @@ -519,6 +538,10 @@ + Cleaned up code in ChocolateFactoryStats. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3056) + Added support for removing items with ReplaceItemEvent. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/3057) + Converted additional `LorenzEvents` to `SkyHanniEvents`. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/3058) ++ Discord RPC now shows in /shdebug when there's an issue or current status. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3092) ++ Moved Next Jacobs Contest, Best Crop Milestone & Jyrre Timer to Renderable. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3004) ++ Added /shtestactionbar command: set your clipboard as a fake Action Bar. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3085) ++ Added /shdebug support for SkyBlock island, Bingo, and Tab List data tests. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3085) ### Removed Features diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 9d8f309dcb24..df3a0b3a6750 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -773,6 +773,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Removed the chat message "There are no Pests on your Garden!". + Added No Pests Title. - saga (https://github.com/hannibal002/SkyHanni/pull/1957) + Shows a title when you use the Pest Tracker without any pests to clear. ++ Added Carrolyn Fetch Helper to fetch items for permanent farming buffs. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3096)
diff --git a/root.gradle.kts b/root.gradle.kts index d2e7d3daa8a0..3cef4a498e48 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.20" + version = "0.28.Beta.21" repositories { mavenCentral() mavenLocal() From 74ed3742a64fe1888844585367a35e660cb86508 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 22 Dec 2024 01:22:50 +0100 Subject: [PATCH 25/93] Backend: Better formatting settings (#3104) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .editorconfig | 7 +++++++ detekt/detekt.yml | 2 -- src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index d781e8ef4800..54e4945de5a2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -25,6 +25,7 @@ ij_java_names_count_to_use_import_on_demand = 2147483647 ij_java_class_count_to_use_import_on_demand = 2147483647 ij_java_packages_to_use_import_on_demand = 2147483647 +# Kotlin Files [*.kt] ktlint_code_style = intellij_idea @@ -59,3 +60,9 @@ ktlint_standard_final-newline = disabled ktlint_standard_no-wildcard-imports = enabled ktlint_standard_function-expression-body = disabled + +# Additional Kotlin-specific formatting for conditions and continuation +ij_kotlin_continuation_indent_size = 8 +ij_kotlin_binary_expression_wrap = if_long +ij_kotlin_keep_line_breaks = true +ij_kotlin_annotations_new_line_after_suppress = true diff --git a/detekt/detekt.yml b/detekt/detekt.yml index 038f970410ab..374d87e691bd 100644 --- a/detekt/detekt.yml +++ b/detekt/detekt.yml @@ -1,4 +1,3 @@ - config: validation: true @@ -24,7 +23,6 @@ ImportRules: CustomImportOrdering: active: true - style: MagicNumber: # I, Linnea Gräf, of sound mind and body, disagree with disabling this rule active: false diff --git a/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt b/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt index 288c3cf50932..b59d5f49fbc8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt @@ -25,11 +25,12 @@ object BossbarData { bossbar = null } - @SubscribeEvent //#if MC < 1.12 + @SubscribeEvent fun onTick(event: LorenzTickEvent) { val bossbarLine = BossStatus.bossName ?: return //#else + //$$ @SubscribeEvent //$$ fun onRenderGameOverlay(event: RenderGameOverlayEvent.BossInfo) { //$$ val bossbarLine = event.bossInfo.name.formattedText //#endif From e1e0deb10821f1f007f39798b3bb9956dea176a5 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 22 Dec 2024 11:26:17 -0500 Subject: [PATCH 26/93] Backend: Remove Unused Config Option (#3103) --- .../chocolatefactory/ChocolateFactoryConfig.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index a6c6847671ec..6446114232b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -211,15 +211,6 @@ public class ChocolateFactoryConfig { @ConfigLink(owner = ChocolateFactoryConfig.class, field = "strayRabbitTracker") public Position strayRabbitTrackerPosition = new Position(300, 300, false, true); - @Expose - @ConfigOption( - name = "Hitman Slot Rabbit", - desc = "Show the last rabbit found in hitman slots that are on cooldown." - ) - @ConfigEditorBoolean - @FeatureToggle - public boolean hitmanSlotInfo = false; - @Expose @ConfigOption(name = "Hitman Costs", desc = "Show the sum cost of remaining hitman slots.") @ConfigEditorBoolean From 0fe7bc903aa544a01f53103e33083c79fc5a411c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 24 Dec 2024 11:42:16 +0100 Subject: [PATCH 27/93] added comments --- .../skyhanni/features/event/hoppity/NucleusBarriersBox.kt | 1 + src/main/java/at/hannibal2/skyhanni/utils/CircularList.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt index 7f769a505751..3d3fed53c8dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt @@ -14,6 +14,7 @@ import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +// TODO move into mining category and package @SkyHanniModule object NucleusBarriersBox { private val config get() = SkyHanniMod.feature.mining.crystalHighlighter diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CircularList.kt b/src/main/java/at/hannibal2/skyhanni/utils/CircularList.kt index cd7e966706de..adb6e6359368 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CircularList.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CircularList.kt @@ -1,5 +1,13 @@ package at.hannibal2.skyhanni.utils +/** + * A generic, immutable circular list that cycles through its elements infinitely. + * + * @param T The type of elements in the circular list. + * @property items A list of elements to be accessed in a circular manner. + * @constructor Creates a CircularList with the given elements. + * @throws IllegalArgumentException if the list is empty. + */ class CircularList(private val items: List) { constructor(vararg elements: T) : this(elements.asList()) From 5f70fa220bc3a5faab52baee1b0287b051322e7b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 24 Dec 2024 16:55:56 +0100 Subject: [PATCH 28/93] Backend: More crop reading error data (#3114) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/garden/contest/FarmingContestAPI.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 5bdcffa31a69..13745c840d54 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.garden.farming.FarmingContestEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -98,7 +99,19 @@ object FarmingContestAPI { private fun readCurrentCrop(): CropType? { val line = ScoreboardData.sidebarLinesFormatted.nextAfter("§eJacob's Contest") ?: return null return sidebarCropPattern.matchMatcher(line) { - CropType.getByName(group("crop")) + val cropName = group("crop") + try { + CropType.getByName(cropName) + } catch (e: IllegalStateException) { + ScoreboardData.sidebarLinesFormatted + ErrorManager.logErrorWithData( + e, "Farming contest read current crop failed", + "cropName" to cropName, + "line" to line, + "sidebarLinesFormatted" to ScoreboardData.sidebarLinesFormatted, + ) + null + } } } From c4750c0bd893a253bf7e6203ee5ef9a4341af439 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Tue, 24 Dec 2024 17:19:03 -0500 Subject: [PATCH 29/93] Backend: Bump changelog builder (#3120) --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index f44fde571dbf..0c8f3fc78e50 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -13,5 +13,5 @@ repositories { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib") - implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.0.2") + implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.0.3") } From 8347d2a3e44f59de1f1598ce96560b037bf90d15 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:03:59 +0100 Subject: [PATCH 30/93] Fix: Skill progress NumberFormatException (#3105) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/skillprogress/SkillProgress.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index 658cac0120c7..e46d7ab8841a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -463,20 +463,28 @@ object SkillProgress { } if (config.showActionLeft.get() && percent != 100f) { - append(" - ") - val gain = skill.lastGain.formatDouble() - val actionLeft = (ceil(currentXpMax.toDouble() - currentXp) / gain).toLong().plus(1).addSeparators() - if (skill.lastGain != "" && !actionLeft.contains("-")) { - append("§6$actionLeft Left") - } else { - append("§6∞ Left") - } + append(" - " + addActionsLeft(skill, currentXpMax, currentXp)) } }, ), ) } + private fun addActionsLeft( + skill: SkillAPI.SkillInfo, + currentXpMax: Long, + currentXp: Long, + ): String { + if (skill.lastGain != "") { + val gain = skill.lastGain.formatDouble() + val actionLeft = (ceil(currentXpMax.toDouble() - currentXp) / gain).toLong().plus(1).addSeparators() + if (skill.lastGain != "" && !actionLeft.contains("-")) { + return "§6$actionLeft Left" + } + } + return "§6∞ Left" + } + private fun updateSkillInfo() { val activeSkill = activeSkill ?: return val xpInfo = skillXPInfoMap.getOrPut(activeSkill) { SkillAPI.SkillXPInfo() } From 960621e2905b4f140d0d02eddf2e7e2cd8c43782 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:04:14 +0100 Subject: [PATCH 31/93] Backend: Contributor Rabbit Name (#3109) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../ChocolateFactoryConfig.java | 5 ++ .../event/hoppity/HoppityCollectionData.kt | 2 +- .../hoppity/ReplaceHoppityWithContributor.kt | 82 +++++++++++++++++++ .../features/misc/ContributorManager.kt | 9 +- 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/hoppity/ReplaceHoppityWithContributor.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 6446114232b8..7f424b66eb20 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -91,6 +91,11 @@ public class ChocolateFactoryConfig { @ConfigEditorBoolean public boolean showStackSizes = true; + @Expose + @ConfigOption(name = "Contributor Rabbit Name", desc = "Replaces the rabbit names in the rabbit collection menu with SkyHanni contributor names.") + @ConfigEditorBoolean + public boolean contributorRabbitName = false; + @Expose @ConfigOption(name = "Highlight Upgrades", desc = "Highlight any upgrades that you can afford.\n" + "The upgrade with a star is the most optimal and the lightest color of green is the most optimal you can afford.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt index b6056451dd66..11b3d305309b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @SkyHanniModule object HoppityCollectionData { - private val rabbitRarities = mutableMapOf() + val rabbitRarities = mutableMapOf() private val rarityBonuses = mutableMapOf() private val specialBonuses = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/ReplaceHoppityWithContributor.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/ReplaceHoppityWithContributor.kt new file mode 100644 index 000000000000..cf4584f90691 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/ReplaceHoppityWithContributor.kt @@ -0,0 +1,82 @@ +package at.hannibal2.skyhanni.features.event.hoppity + +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.features.misc.ContributorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.CircularList +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object ReplaceHoppityWithContributor { + + private val config get() = ChocolateFactoryAPI.config + + private val replaceMap = mutableMapOf() + + @HandleEvent(priority = 5) + fun onNeuRepoReload(event: NeuRepositoryReloadEvent) { + update() + } + + @SubscribeEvent(priority = EventPriority.LOW) + fun onRepoReload(event: RepositoryReloadEvent) { + update() + } + + fun update() { + replaceMap.clear() + + val contributors = ContributorManager.contributorNames + val rabbits = HoppityCollectionData.rabbitRarities + + if (contributors.isEmpty()) return + if (rabbits.isEmpty()) return + + val newNames = CircularList(contributors.toList()) + for (internalName in rabbits.map { it.key }.shuffled()) { + val realName = internalName.allLettersFirstUppercase() + val newName = newNames.next() + replaceMap[realName] = newName + } + } + + @HandleEvent(priority = HandleEvent.LOWEST) + fun onTooltip(event: ItemHoverEvent) { + if (!isEnabled()) return + if (!HoppityCollectionStats.inInventory) return + + val itemStack = event.itemStack + val lore = itemStack.getLore() + val last = lore.lastOrNull() ?: return + if (!last.endsWith(" RABBIT")) return + + val realName = itemStack.name + val cleanName = realName.removeColor() + val fakeName = replaceMap[cleanName] ?: return + + val newName = event.toolTip[0].replace(cleanName, fakeName) + event.toolTip[0] = newName + + event.toolTip.add(" ") + event.toolTip.add("§8§oSome might say this rabbit is also known as $realName") + + // TODO find a way to handle non containing entries in a kotlin nullable way instead of checking for -1 + val index = event.toolTip.indexOfFirst { it.contains(" a duplicate") } + if (index == -1) return + val oldLine = event.toolTip[index] + val newLine = oldLine.replace(cleanName, fakeName) + event.toolTip[index] = newLine + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.contributorRabbitName +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt index ff5bdcacb66c..e4f2e54547a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt @@ -16,11 +16,18 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ContributorManager { private val config get() = SkyHanniMod.feature.dev + // Key is the lowercase contributor name private var contributors: Map = emptyMap() + // Just the names of the contributors including their proper case + var contributorNames = emptyList() + private set + @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - contributors = event.getConstant("Contributors").contributors.mapKeys { it.key.lowercase() } + val map = event.getConstant("Contributors").contributors + contributors = map.mapKeys { it.key.lowercase() } + contributorNames = map.map { it.key } } @HandleEvent From a3d2e182d124dea595aa2b3776829c14e75a6653 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:04:36 +0100 Subject: [PATCH 32/93] Backend: Added /shdebugvisualwords (#3112) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../misc/visualwords/ModifyVisualWords.kt | 47 ++++++++++++++++--- .../misc/visualwords/VisualWordGui.kt | 9 ++-- .../hannibal2/skyhanni/utils/LorenzUtils.kt | 16 ++----- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt index ecf57e3f3314..02fb21755da8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt @@ -3,9 +3,11 @@ package at.hannibal2.skyhanni.features.misc.visualwords import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigFileType +import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.convertToFormatted import at.hannibal2.skyhanni.utils.TimeLimitedCache @@ -15,11 +17,36 @@ import kotlin.time.Duration.Companion.minutes object ModifyVisualWords { private val config get() = SkyHanniMod.feature.gui.modifyWords - var textCache = TimeLimitedCache(5.minutes) + private val textCache = TimeLimitedCache(5.minutes) - var modifiedWords = mutableListOf() + // Replacements the user added manually via /shwords + var userModifiedWords = mutableListOf() - val reverseRegex = "(§.|^|[\\s:()+-])([^§\\s:()+-]*)".toRegex() + // Replacements the mod added automatically for some features, april jokes, etc + var modModifiedWords = mutableListOf() + private var finalWordsList = listOf() + private var debug = false + + fun update() { + finalWordsList = modModifiedWords + userModifiedWords + textCache.clear() + } + + @HandleEvent + fun onCommandRegistration(event: CommandRegistrationEvent) { + event.register("shdebugvisualwords") { + description = "Prints in the console all replaced words by /shwords" + callback { toggleDebug() } + } + } + + private fun toggleDebug() { + debug = !debug + ChatUtils.chat("Visual Words debug ${if (debug) "enabled" else "disabled"}") + if (debug) { + update() + } + } fun modifyText(originalText: String?): String? { var modifiedText = originalText ?: return null @@ -27,23 +54,29 @@ object ModifyVisualWords { if (!config.enabled) return originalText if (!LorenzUtils.inSkyBlock && !OutsideSbFeature.MODIFY_VISUAL_WORDS.isSelected()) return originalText - if (modifiedWords.isEmpty()) { - modifiedWords.addAll(SkyHanniMod.visualWordsData.modifiedWords) + if (userModifiedWords.isEmpty()) { + userModifiedWords.addAll(SkyHanniMod.visualWordsData.modifiedWords) + update() } return textCache.getOrPut(originalText) { if (originalText.startsWith("§§")) { modifiedText = modifiedText.removePrefix("§§") } else { - for (modifiedWord in modifiedWords) { + for (modifiedWord in finalWordsList) { if (!modifiedWord.enabled) continue val phrase = modifiedWord.phrase.convertToFormatted() if (phrase.isEmpty()) continue + val original = modifiedText + val replacement = modifiedWord.replacement.convertToFormatted() modifiedText = modifiedText.replace( - phrase, modifiedWord.replacement.convertToFormatted(), modifiedWord.isCaseSensitive() + phrase, replacement, modifiedWord.isCaseSensitive(), ) + if (debug && original != modifiedText) { + println("Visual words Change debug: '$original' -> `$modifiedText` (`$phrase` -> `$replacement`)") + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt index 077332e634f8..babcfdd83ed6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/VisualWordGui.kt @@ -246,7 +246,7 @@ open class VisualWordGui : GuiScreen() { } if (modifiedWords.size < 1) { - modifiedWords = ModifyVisualWords.modifiedWords + modifiedWords = ModifyVisualWords.userModifiedWords } if (toRemove != null) { @@ -568,9 +568,8 @@ open class VisualWordGui : GuiScreen() { } private fun saveChanges() { - ModifyVisualWords.modifiedWords = modifiedWords - ModifyVisualWords.textCache.clear() - SkyHanniMod.visualWordsData.modifiedWords = modifiedWords + ModifyVisualWords.userModifiedWords = modifiedWords + ModifyVisualWords.update() SkyHanniMod.configManager.saveConfig(ConfigFileType.VISUAL_WORDS, "Updated visual words") } @@ -600,7 +599,7 @@ open class VisualWordGui : GuiScreen() { } if (importedWords > 0 || skippedWords > 0) { chat( - "§aSuccessfully imported §e$importedWords §aand skipped §e$skippedWords §aVisualWords from SkyBlockExtras !" + "§aSuccessfully imported §e$importedWords §aand skipped §e$skippedWords §aVisualWords from SkyBlockExtras !", ) SkyHanniMod.feature.storage.visualWordsImported = true drawImport = false diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index b76f5dc8a35f..12322964a83b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -76,7 +76,7 @@ object LorenzUtils { val never = SkyHanniMod.feature.dev.debug.neverFunnyTime val result = (!never && (always || itsTime)) if (previousApril != result) { - ModifyVisualWords.textCache.clear() + ModifyVisualWords.update() } previousApril = result return result @@ -261,12 +261,8 @@ object LorenzUtils { fun GuiEditSign.isRancherSign(): Boolean { if (this !is AccessorGuiEditSign) return false - val tileSign = (this as AccessorGuiEditSign).tileSign - return ( - tileSign.signText[1].unformattedText.removeColor() == "^^^^^^" && - tileSign.signText[2].unformattedText.removeColor() == "Set your" && - tileSign.signText[3].unformattedText.removeColor() == "speed cap!" - ) + val signText = (this as AccessorGuiEditSign).tileSign.signText.map { it.unformattedText.removeColor() } + return signText[1] == "^^^^^^" && signText[2] == "Set your" && signText[3] == "speed cap!" } fun IslandType.isInIsland() = inSkyBlock && skyBlockIsland == this @@ -304,8 +300,7 @@ object LorenzUtils { } inline fun > enumValueOf(name: String) = - enumValueOfOrNull(name) - ?: error("Unknown enum constant for ${enumValues().first().name.javaClass.simpleName}: '$name'") + enumValueOfOrNull(name) ?: error("Unknown enum constant for ${enumValues().first().name.javaClass.simpleName}: '$name'") inline fun > enumJoinToPattern(noinline transform: (T) -> CharSequence = { it.name }) = enumValues().joinToString("|", transform = transform) @@ -319,8 +314,7 @@ object LorenzUtils { FMLCommonHandler.instance().handleExit(-1) } - fun inMiningIsland() = IslandType.GOLD_MINES.isInIsland() || - IslandType.DEEP_CAVERNS.isInIsland() || MiningAPI.inAdvancedMiningIsland() + fun inMiningIsland() = IslandType.GOLD_MINES.isInIsland() || IslandType.DEEP_CAVERNS.isInIsland() || MiningAPI.inAdvancedMiningIsland() fun isBetaVersion() = UpdateManager.isCurrentlyBeta() From 9f69b0adf2380e540d5e55dcc2358c66ac96b263 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Wed, 25 Dec 2024 12:09:00 +1100 Subject: [PATCH 33/93] Fix up the installation guide (#3111) --- docs/INSTALLING.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/INSTALLING.md b/docs/INSTALLING.md index 3dc059a428ac..2c0efdb7f459 100644 --- a/docs/INSTALLING.md +++ b/docs/INSTALLING.md @@ -30,8 +30,8 @@ Double-click the file to install it. Forge is the system that loads your mods into the game. You need Java to run Forge. -Download [Forge for 1.8.9](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.8.9.html). -Click installer, when you double-click the file, install as client. +Download [Forge for 1.8.9](https://maven.minecraftforge.net/net/minecraftforge/forge/1.8.9-11.15.1.2318-1.8.9/forge-1.8.9-11.15.1.2318-1.8.9-installer.jar). +When you double-click the file, install as client. If Forge does not open with Java, download [Jarfix](https://johann.loefflmann.net/en/software/jarfix/index.html), double click it, then try running Forge again. @@ -43,7 +43,7 @@ double click it, then try running Forge again. Neu is NotEnoughUpdates, another Forge mod that contains files that SkyHanni depends on to function. You can install it from [Moulberry's Bush Discord Server](https://discord.gg/moulberry) in the -channel [#🧪neu-alphas](https://discord.com/channels/516977525906341928/1028896920346841118) or +channel [#🚀neu-download](https://discord.com/channels/516977525906341928/693586404256645231) or from [SkyHanni Discord](https://discord.com/invite/skyhanni-997079228510117908) in the channel [#neu-updates](https://discord.com/channels/997079228510117908/1123201092193366027) @@ -70,8 +70,9 @@ has new features earlier, but also may contain more bugs. 6. Find .minecraft Once you have downloaded both NEU and SkyHanni, you need to navigate to your `.minecraft` folder. -On Windows, open file explorer, in the file location bar at the top type in `%appdata%` and open `.minecraft`. -On Mac, go to `~/Library/Application Support/minecraft`. +- On Windows, open file explorer, in the file location bar at the top type in `%appdata%` and open `.minecraft`. +- On Mac, open finder, click on "Go" at the top of your screen and then "Go to Folder" and type in `~/Library/Application Support/Minecraft`. +- On Linux, `.minecraft` is located in your home folder. `~/.minecraft`
@@ -101,10 +102,9 @@ To allocate ram, go to installation, press the 3 dots next to the installation y click edit, press more options. In JVM arguments, look for something that says -Xmx2G or some other number followed by G. That number is the amount you have allocated for Minecraft to use. -If you have 2G of ram on your computer, you might struggle to play Minecraft. -Try to allocate 1G. If you have 4G, allocate 2G. If you -have 8 or more G, allocate 4G. -You should never need more than 4G, unless you have more mods, than you know what to do. +If you have 4GB, allocate 2GB. If you +have 8 or more GB, allocate 4GB. +You should never need more than 4GB, unless you have more mods, than you know what to do. From a58bd09eba415c66ffd7416add8472c416f1af0c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:55:10 +0100 Subject: [PATCH 34/93] additional fine tuning and changing the format from github to discord in INSTALLING.md --- docs/INSTALLING.md | 196 ++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 126 deletions(-) diff --git a/docs/INSTALLING.md b/docs/INSTALLING.md index 2c0efdb7f459..dd600a866f1c 100644 --- a/docs/INSTALLING.md +++ b/docs/INSTALLING.md @@ -1,134 +1,78 @@ # Download and Install SkyHanni SkyHanni is a Forge mod for **Minecraft 1.8.9 only**. -Trying to run this on Badlion, Lunar, Feather, or newer versions of Minecraft is **not supported**. +Running SkyHanni on Badlion, Lunar, Feather, or newer versions of Minecraft is **not supported**. Follow this guide to install SkyHanni in regular Minecraft Forge. If you already have Forge mods, you can skip to step 4. Otherwise, start from step 1. If you already have the latest alpha version from NEU, you can skip to step 5. -
-1. Run vanilla 1.8.9 - -Run Minecraft 1.8.9, unmodded, for 10 seconds, then close it. - -
- - -
-2. Install Java - -To play with mods, you need Java. -Install [Java 8](https://www.java.com/download/ie_manual.jsp). -Double-click the file to install it. - -
- - -
-3. Install Forge - -Forge is the system that loads your mods into the game. -You need Java to run Forge. -Download [Forge for 1.8.9](https://maven.minecraftforge.net/net/minecraftforge/forge/1.8.9-11.15.1.2318-1.8.9/forge-1.8.9-11.15.1.2318-1.8.9-installer.jar). -When you double-click the file, install as client. -If Forge does not open with Java, download [Jarfix](https://johann.loefflmann.net/en/software/jarfix/index.html), -double click it, then try running Forge again. - -
- - -
-4. Download NEU - -Neu is NotEnoughUpdates, another Forge mod that contains files that SkyHanni depends on to function. -You can install it from [Moulberry's Bush Discord Server](https://discord.gg/moulberry) in the -channel [#🚀neu-download](https://discord.com/channels/516977525906341928/693586404256645231) or -from [SkyHanni Discord](https://discord.com/invite/skyhanni-997079228510117908) in the -channel [#neu-updates](https://discord.com/channels/997079228510117908/1123201092193366027) - -
- - -
-5. Download SkyHanni - -SkyHanni has two different update circles: [Full Release](https://github.com/hannibal002/SkyHanni/releases/latest) -and [Beta](https://github.com/hannibal002/SkyHanni/releases). - -In general, it is recommended to use the **Full Release**. -It updates every 3–4 weeks and should run very stable. -If you find bugs or miss features in the full version, they might be fixed/implemented already in a beta version. - -The **Beta Version**, on the other hand, gets updated multiple times a week, -has new features earlier, but also may contain more bugs. - -
- - -
-6. Find .minecraft - -Once you have downloaded both NEU and SkyHanni, you need to navigate to your `.minecraft` folder. -- On Windows, open file explorer, in the file location bar at the top type in `%appdata%` and open `.minecraft`. -- On Mac, open finder, click on "Go" at the top of your screen and then "Go to Folder" and type in `~/Library/Application Support/Minecraft`. -- On Linux, `.minecraft` is located in your home folder. `~/.minecraft` - -
- - -
- -7. Move mods into mods folder - -If there is a "mods" folder, great! Open it. -Otherwise, create one and name it exactly "mods". - -Move both your downloaded NEU file and SkyHanni file into the folder. -(If you have already an older version of NEU or SkyHanni in that folder, delete it.) - -*Note: if you have a problem, people may ask to see your mod folder - that is this folder.* - -
- - -
-8. Setup RAM - -If you're running mods, you also need to set up your allocated ram. -If you don't know how much ram your computer has, -follow [this guide](https://www.howtogeek.com/435644/how-to-see-how-much-ram-is-in-your-pc-and-its-speed/). -To allocate ram, go to installation, press the 3 dots next to the installation you are using, -click edit, press more options. -In JVM arguments, look for something that says -Xmx2G or some other number followed by G. -That number is the amount you have allocated for Minecraft to use. -If you have 4GB, allocate 2GB. If you -have 8 or more GB, allocate 4GB. -You should never need more than 4GB, unless you have more mods, than you know what to do. - -
- - -
-9. Launch the Forge profile in the launcher - -Installing Minecraft Forge should have set the profile for you, but if it didn't, go to installations, -select new installation, under version you need to find Forge for 1.8.9 (most likely at the top or bottom) - -
- - -
-10. Recommended additional mods (optional) - -[OptiFine](https://optifine.net/adloadx?f=preview_OptiFine_1.8.9_HD_U_M6_pre2.jar) -and either [Sk1erLLC's Patcher](https://sk1er.club/mods/patcher) or [Polyfrost's PolyPatcher]() (a fork of Patcher with OneConfig, slightly different features, and bug fixes, including fixed cactus hitboxes) - -Those two mods help you get more FPS in game and let you change many more performance -settings. - -*Ask on discord if you need help with those.* - -
- -

And finally, don't forget to never run a file that is sent to you in dms

+> **1: Run vanilla 1.8.9** +> Run Minecraft 1.8.9, unmodded, for 10 seconds, then close it. + +> **2: Install Java** +> To play with mods, you need Java 8. +> Install [Java 8](). +> Double-click the file to install it. + +> **3: Install Forge** +> Forge is the system that loads your mods into the game. +> You need Java to run Forge. +> Download [Forge for 1.8.9](). +> When you double-click the file, install as client. +> If Forge does not open with Java, download [Jarfix](), double-click it, then try running Forge again. + +> **4: Download NEU** +> NEU is NotEnoughUpdates, another Forge mod that contains files that SkyHanni depends on to function. +> You can install it from any of those spots: +> - [Modrinth]() +> - [Moulberry's Bush Discord Server]() in the channel [#neu-download]() +> - [SkyHanni Discord]() in the channel #neu-updates. + +> **5: Download SkyHanni** +> SkyHanni has two different update circles: [Full Release]() and [Beta](). +> It is recommended to use the **Full Release**. +> It updates every 3–4 weeks and should run very stable. +> If you find bugs or miss features in the full version, they might be fixed/implemented already in a beta version. +> The **Beta Version**, on the other hand, gets updated multiple times a week, has new features earlier, but may also contain more bugs. + +> **6: Find .minecraft** +> Once you have downloaded both NEU and SkyHanni, you need to navigate to your `.minecraft` folder. +> - On Windows, open File Explorer, in the file location bar at the top type in `%appdata%` and open `.minecraft`. +> - On Mac, open Finder, click on "Go" at the top of your screen and then "Go to Folder" and type in `~/Library/Application Support/Minecraft`. +> - On Linux, `.minecraft` is located in your home folder. `~/.minecraft` + +> **7: Move mods into mods folder** +> If there is a `mods` folder, great! Open it. +> Otherwise, create a new folder and name it exactly `mods`. +> Move the NEU and SkyHanni files you downloaded into the folder. +> Remove older versions of NEU or SkyHanni in that folder before adding the new files. +> *Note: If you encounter a problem, support may ask for a screenshot of your mods folder: this is the folder you just set up.* + +> **8: Setup RAM** +> If you're running mods, you also need to set up your RAM. +> If you don't know how much RAM your computer has, follow [this guide](). +> To allocate RAM, go to Installations, press the 3 dots next to the installation you are using, click edit, and press the `More Options` button. +> In JVM arguments, look for something that says `-Xmx2G` or some other number followed by `G`. +> - If you have 4GB, allocate 2GB. +> - If you have 8GB or more, allocate 4GB. +> You generally don't need more than 4GB unless you are using an extensive number of mods. + +> **9: Launch the Forge profile in the launcher** +> Installing Minecraft Forge should have set the profile for you, but if it didn't, go to installations, select new installation, and under version, find Forge for 1.8.9 (most likely at the top or bottom). + +> **10: Recommended additional mods (optional)** +> [OptiFine]() and either [Sk1erLLC's Patcher]() or [Polyfrost's PolyPatcher]() (a fork of Patcher with OneConfig, slightly different features, and bug fixes, including fixed cactus hitboxes). +> Those two mods help you get more FPS in-game and let you change many more performance settings. + +*Ask in #support if you need help with a step during installation. +If you have any other questions about the mod, please read our #faq before asking in #support for help.* + +> **Important note** +> Never run files sent to you via Discord or other messaging apps. + +> **Quick Download Links** +> Full Release: #releases +> Beta: #beta + +*This guide was last updated on December 24th, 2024.* From 52c078a656d37432078e16f3d0a0b53eeb5d9b61 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Wed, 25 Dec 2024 13:04:12 +1100 Subject: [PATCH 35/93] Fix: shwords causing blank messages in chat (#3110) --- .../misc/visualwords/ModifyVisualWords.kt | 8 -------- .../gui/MixinGuiUtilRenderComponents.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiUtilRenderComponents.java diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt index 02fb21755da8..83305d223dae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt @@ -80,14 +80,6 @@ object ModifyVisualWords { } } - // Disabled, as it's only a novelty for 30 seconds and will annoy after that everyone. - /* - if (LorenzUtils.isAprilFoolsDay && !FontRendererHook.cameFromChat && Random.nextDouble() < 0.02) { - modifiedText = modifiedText.replace(reverseRegex) { - it.groupValues[1] + it.groupValues[2].reversed() - } - } - */ modifiedText } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiUtilRenderComponents.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiUtilRenderComponents.java new file mode 100644 index 000000000000..df4530b5fbfc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiUtilRenderComponents.java @@ -0,0 +1,17 @@ +package at.hannibal2.skyhanni.mixins.transformers.gui; + +import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords; +import net.minecraft.client.gui.GuiUtilRenderComponents; +import net.minecraft.util.IChatComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(GuiUtilRenderComponents.class) +public class MixinGuiUtilRenderComponents { + + @Redirect(method = "splitText", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/IChatComponent;getUnformattedTextForChat()Ljava/lang/String;")) + private static String onSplitText(IChatComponent instance) { + return ModifyVisualWords.INSTANCE.modifyText(instance.getUnformattedTextForChat()); + } +} From e5b04fe3fc6d112e335bbb9e0bcc19ef621b8c59 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:04:58 +0100 Subject: [PATCH 36/93] Fix: Kuudra Lines in CS (#3118) --- .../features/gui/customscoreboard/CustomScoreboard.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt index aa5b443f3571..001537ced2d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt @@ -201,7 +201,13 @@ object CustomScoreboard { @HandleEvent fun onIslandChange(event: IslandChangeEvent) { - if (event.newIsland != IslandType.NONE) updateIslandEntries() + if (event.newIsland != IslandType.NONE) { + updateIslandEntries() + + runDelayed(3.seconds) { + updateIslandEntries() + } + } } private fun updateIslandEntries() { From ea9d839bef511114aa1f05222fd203a847de45f6 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 24 Dec 2024 21:06:34 -0500 Subject: [PATCH 37/93] Fix: Class Cast Error in Stray Warning (#3108) Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> --- .../chocolatefactory/ChocolateFactoryStrayWarning.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayWarning.kt index b3eb15168ce8..72c33110e2c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayWarning.kt @@ -95,8 +95,11 @@ object ChocolateFactoryStrayWarning { else event.strayHighlight() } + private fun GuiContainerEvent.getEventChest(): ContainerChest? = + gui.inventorySlots as? ContainerChest + private fun GuiContainerEvent.BackgroundDrawnEvent.partyModeHighlight() { - val eventChest = (gui.inventorySlots as ContainerChest) + val eventChest = getEventChest() ?: return eventChest.getUpperItems().keys.forEach { it highlight CHROMA_COLOR_ALT.toSpecialColor() } eventChest.inventorySlots.filter { it.slotNumber != it.slotIndex @@ -106,7 +109,8 @@ object ChocolateFactoryStrayWarning { } private fun GuiContainerEvent.BackgroundDrawnEvent.strayHighlight() { - (gui.inventorySlots as ContainerChest).getUpperItems().keys.filter { + val eventChest = getEventChest() ?: return + eventChest.getUpperItems().keys.filter { it.slotNumber in activeStraySlots }.forEach { it highlight warningConfig.inventoryHighlightColor.toSpecialColor() From d4510fa75a26cdadb9cdeedfd29c89201f0b8fce Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:32:35 +0100 Subject: [PATCH 38/93] Improvement + Backend: Roman Allow List (#3113) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/misc/MiscConfig.java | 2 +- .../elements/ScoreboardElementSlayer.kt | 3 +- .../features/misc/ReplaceRomanNumerals.kt | 133 +++++++++++------- .../items/EstimatedItemValueCalculator.kt | 4 +- .../misc/items/enchants/EnchantParser.kt | 25 ++-- .../features/slayer/SlayerProfitTracker.kt | 31 ++-- .../features/slayer/SlayerRngMeterDisplay.kt | 2 - .../at/hannibal2/skyhanni/utils/ItemUtils.kt | 19 ++- 8 files changed, 132 insertions(+), 87 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 1e3f393a9a1d..cf75a3411bc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -305,7 +305,7 @@ public class MiscConfig { @ConfigOption(name = "Replace Roman Numerals", desc = "Replace Roman Numerals with Arabic Numerals on any item.") @ConfigEditorBoolean @FeatureToggle - public boolean replaceRomanNumerals = false; + public Property replaceRomanNumerals = Property.of(false); @Expose @ConfigOption(name = "Thunder Bottle", desc = "Show a notification when your Thunder Bottle is fully charged.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt index b2f10b412494..de101f453594 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementSlayer.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals // internal // scoreboard update event @@ -9,7 +10,7 @@ object ScoreboardElementSlayer : ScoreboardElement() { override fun getDisplay() = buildList { if (!SlayerAPI.hasActiveSlayerQuest()) return@buildList add("Slayer Quest") - add(SlayerAPI.latestSlayerCategory) + add(ReplaceRomanNumerals.replaceLine(SlayerAPI.latestSlayerCategory)) add(SlayerAPI.latestSlayerProgress) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt index be1fcd7994de..8f59492a758f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -4,54 +4,65 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.events.ChatHoverEvent -import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal -import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher +import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible import at.hannibal2.skyhanni.utils.StringUtils.isRoman import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TimeLimitedCache import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object ReplaceRomanNumerals { - private val patternGroup = RepoPattern.group("replace.roman") - - /** - * REGEX-TEST: §9Dedication IV - * REGEX-FAIL: §cD§6y§ee§as - */ - private val findRomanNumeralPattern by patternGroup.pattern( - "findroman", - "[ ➜](?=[MDCLXVI])(?M*(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3}))(?.?)" - ) - - /** - * REGEX-TEST: K - */ - private val isWordPattern by patternGroup.pattern( - "findword", - "^[\\w-']" + // Using toRegex here since toPattern doesn't seem to provide the necessary functionality + private val splitRegex = "((§\\w)|(\\s+)|(\\W))+|(\\w*)".toRegex() + private val cachedStrings = TimeLimitedCache(5.seconds) + + private val patternGroup = RepoPattern.group("replace.roman.numerals") + + @Suppress("MaxLineLength") + private val allowedPatterns by patternGroup.list( + "allowed.patterns", + "§o§a(?:Combat|Farming|Fishing|Mining|Foraging|Enchanting|Alchemy|Carpentry|Runecrafting|Taming|Social|)( Level)? (?[IVXLCDM]+)§r", + "(?:§5§o)?§7Progress to (?:Collection|Level|Tier|Floor|Milestone|Chocolate Factory) (?[IVXLCDM]+): §.(?:.*)%", + "§5§o §e(?:\\w+) (?[IVXLCDM]+)", + "(?:§.)*Abiphone (?[IVXLCDM]+) .*", + "§o§a§a(?:§c§lMM§c )?The Catacombs §8- §eFloor (?[IVXLCDM]+)§r", + ".*Extra Farming Fortune (?[IVXLCDM]+)", + ".*(?:Collection|Level|Tier|Floor|Milestone) (?[IVXLCDM]+)(?: ?§(?:7|r).*)?", + "(?:§5§o§a ✔|§5§o§c ✖) §.* (?[IVXLCDM]+)", + "§o§a✔ §.* (?[IVXLCDM]+)§r", + "§5§o§7Purchase §a.* (?[IVXLCDM]+) §7.*", + "§5§o(?:§7)§.(?[IVXLCDM]+).*", + ".*Heart of the Mountain (?[IVXLCDM]+) ?.*" ) /** - * REGEX-TEST: ➜ + * REGEX-TEST: §eSelect an option: §r§a[§aOk, then what?§a] */ - private val allowedCharactersAfter by patternGroup.pattern( - "allowedcharactersafter", - "[➜):]?" + private val isSelectOptionPattern by patternGroup.pattern( + "string.isselectoption", + "§eSelect an option: .*", ) - @HandleEvent(priority = HandleEvent.LOWEST) - fun onTooltip(event: ItemHoverEvent) { + // TODO: Remove after pr 1717 is ready and switch to ItemHoverEvent + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return - event.toolTip.replaceAll { it.transformLine() } + event.toolTip.replaceAll { it.tryReplace() } } @HandleEvent(priority = HandleEvent.LOWEST) @@ -60,7 +71,7 @@ object ReplaceRomanNumerals { if (!isEnabled()) return val lore = event.getHoverEvent().value.formattedText.split("\n").toMutableList() - lore.replaceAll { it.transformLine() } + lore.replaceAll { it.tryReplace() } val chatComponentText = ChatComponentText(lore.joinToString("\n")) val hoverEvent = HoverEvent(event.component.chatStyle.chatHoverEvent?.action, chatComponentText) @@ -70,38 +81,58 @@ object ReplaceRomanNumerals { @HandleEvent fun onSystemMessage(event: SystemMessageEvent) { - if (!isEnabled()) return - event.applyIfPossible { it.transformLine() } + if (!isEnabled() || event.message.isSelectOption()) return + event.applyIfPossible { it.tryReplace() } } - /** - * Transforms a line with a roman numeral to a line with a decimal numeral. - * Override block one is to be used for tablist or other places where there is no need to check for normal text containing - * the word "I". - * - * Currently not replaced: - * - "§7Bonzo I Reward:" in the collection rewards when hovering on the collection - */ - private fun String.transformLine(overrideBlockOne: Boolean = false): String { - val (romanNumeral, rest) = findRomanNumeralPattern.findMatcher(this.removeFormatting()) { - group("roman") to group("extra") - } ?: return this + @SubscribeEvent(priority = EventPriority.LOW) + fun onRepoReload(event: RepositoryReloadEvent) { + cachedStrings.clear() + } - if (romanNumeral.isNullOrEmpty() || !romanNumeral.isRoman() || isWordPattern.matches(rest)) { - return recursiveSplit(romanNumeral) - } + private fun String.isSelectOption(): Boolean = isSelectOptionPattern.matches(this) - val parsedRomanNumeral = romanNumeral.romanToDecimal() + private fun String.tryReplace(): String = cachedStrings.getOrPut(this) { + if (allowedPatterns.matches(this)) replace() else this + } + + fun replaceLine(line: String): String { + if (!isEnabled()) return line - return takeIf { parsedRomanNumeral != 1 || overrideBlockOne || rest.isEmpty() || allowedCharactersAfter.matches(rest) } - ?.replaceFirst(romanNumeral, parsedRomanNumeral.toString())?.transformLine() - ?: recursiveSplit(romanNumeral) + return cachedStrings.getOrPut(line) { + line.replace() + } } - private fun String.recursiveSplit(romanNumeral: String) = - this.split(romanNumeral, limit = 2).let { it[0] + romanNumeral + it[1].transformLine() } + private fun String.replace() = splitRegex.findAll(this).map { it.value }.joinToString("") { + it.takeIf { it.isValidRomanNumeral() && it.removeFormatting().romanToDecimal() != 2000 }?.coloredRomanToDecimal() ?: it + } private fun String.removeFormatting() = removeColor().replace(",", "") - private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.replaceRomanNumerals + private fun String.isValidRomanNumeral() = removeFormatting().let { it.isRoman() && it.isNotEmpty() } + + private fun String.coloredRomanToDecimal() = removeFormatting().let { replace(it, it.romanToDecimal().toString()) } + + private fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.misc.replaceRomanNumerals.get() + + init { + RecalculatingValue + } + + @HandleEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Replace Roman Numerals") + event.addIrrelevant { + val map = cachedStrings.toMap() + add("cachedStrings: (${map.size})") + for ((original, changed) in map) { + if (original == changed) { + add("unchanged: '$original'") + } else { + add("'$original' -> '$changed'") + } + } + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index c8fc7aed0c17..c49e56d7e990 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -19,7 +19,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getAttributeFromShard import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.getReadableNBTDump import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -777,10 +776,9 @@ object EstimatedItemValueCalculator { if (rawName in tieredEnchants) level = 1 val enchantmentName = "$rawName;$level".uppercase().toInternalName() - val itemStack = enchantmentName.getItemStackOrNull() ?: continue val singlePrice = enchantmentName.getPriceOrNull(config.priceSource.get()) ?: continue - var name = itemStack.getLore()[0] + var name = enchantmentName.itemName // TODO find a way to use this here "".toInternalName().getPriceName(multiplier) if (multiplier > 1) { name = "§8${multiplier}x $name" diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt index 8c1661739348..6d028f6ecd8b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getExtraAttributes import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -53,6 +53,7 @@ object EnchantParser { "exclusive", "^(?:(?:§.)+[A-Za-z][A-Za-z '-]+ (?:[IVXLCDM]+|[0-9]+)(?:(?:§r)?§9, |\$| §8\\d{1,3}(?:[,.]\\d{1,3})*)[kKmMbB]?)+\$", ) + // Above regex tests apply to this pattern also @Suppress("MaxLineLength") val enchantmentPattern by patternGroup.pattern( @@ -213,7 +214,7 @@ object EnchantParser { "Item has enchants in nbt but none were found?", "item" to currentItem, "loreList" to loreList, - "nbt" to currentItem?.getExtraAttributes() + "nbt" to currentItem?.getExtraAttributes(), ) return } catch (e: ConcurrentModificationException) { @@ -222,7 +223,7 @@ object EnchantParser { "ConcurrentModificationException whilst formatting enchants", "loreList" to loreList, "format" to config.format.get(), - "orderedEnchants" to orderedEnchants.toString() + "orderedEnchants" to orderedEnchants.toString(), ) } @@ -271,22 +272,18 @@ object EnchantParser { private fun orderEnchants(loreList: MutableList) { var lastEnchant: FormattedEnchant? = null + val isRoman = !SkyHanniMod.feature.misc.replaceRomanNumerals.get() + val regex = "[\\d,.kKmMbB]+\$".toRegex() for (i in startEnchant..endEnchant) { val matcher = enchantmentPattern.matcher(loreList[i]) var containsEnchant = false var enchantsOnThisLine = 0 - var isRoman = true while (matcher.find()) { // Pull enchant, enchant level and stacking amount if applicable val enchant = this.enchants.getFromLore(matcher.group("enchant")) - val level = try { - // If one enchant is not a roman numeral we assume all are not roman numerals (idk a situation where this wouldn't be the case) - matcher.group("levelNumeral").toInt().also { isRoman = false } - } catch (e: NumberFormatException) { - matcher.group("levelNumeral").romanToDecimal() - } - val stacking = if (matcher.group("stacking").trimStart().removeColor().matches("[\\d,.kKmMbB]+\$".toRegex())) { + val level = matcher.group("levelNumeral").romanToDecimalIfNecessary() + val stacking = if (matcher.group("stacking").trimStart().removeColor().matches(regex)) { shouldBeSingleColumn = true matcher.group("stacking") } else "empty" @@ -295,9 +292,9 @@ object EnchantParser { lastEnchant = FormattedEnchant(enchant, level, stacking, isRoman) if (!orderedEnchants.add(lastEnchant)) { - for (e: FormattedEnchant in orderedEnchants) { - if (lastEnchant?.let { e.compareTo(it) } == 0) { - lastEnchant = e + for (formattedEnchant: FormattedEnchant in orderedEnchants) { + if (lastEnchant?.let { formattedEnchant.compareTo(it) } == 0) { + lastEnchant = formattedEnchant break } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index 446b927deea9..0bb83f270d7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString @@ -41,7 +42,8 @@ object SlayerProfitTracker { private val config get() = SkyHanniMod.feature.slayer.itemProfitTracker - private var itemLogCategory = "" + private var category = "" + private val categoryName get() = ReplaceRomanNumerals.replaceLine(category) private var baseSlayerType = "" private val trackers = mutableMapOf>() @@ -126,21 +128,21 @@ object SlayerProfitTracker { @HandleEvent fun onSlayerChange(event: SlayerChangeEvent) { val newSlayer = event.newSlayer - itemLogCategory = newSlayer.removeColor() - baseSlayerType = itemLogCategory.substringBeforeLast(" ") + category = newSlayer.removeColor() + baseSlayerType = category.substringBeforeLast(" ") getTracker()?.update() } private fun getTracker(): SkyHanniItemTracker? { - if (itemLogCategory == "") return null + if (category == "") return null - return trackers.getOrPut(itemLogCategory) { + return trackers.getOrPut(category) { val getStorage: (ProfileSpecificStorage) -> Data = { it.slayerProfitData.getOrPut( - itemLogCategory, + category, ) { Data() } } - SkyHanniItemTracker("$itemLogCategory Profit Tracker", { Data() }, getStorage) { drawDisplay(it) } + SkyHanniItemTracker("$categoryName Profit Tracker", { Data() }, getStorage) { drawDisplay(it) } } } @@ -162,7 +164,7 @@ object SlayerProfitTracker { private fun tryAddItem(internalName: NEUInternalName, amount: Int, command: Boolean) { if (!isAllowedItem(internalName) && internalName != NEUInternalName.SKYBLOCK_COIN) { - ChatUtils.debug("Ignored non-slayer item pickup: '$internalName' '$itemLogCategory'") + ChatUtils.debug("Ignored non-slayer item pickup: '$internalName' '$category'") return } @@ -176,7 +178,7 @@ object SlayerProfitTracker { private fun drawDisplay(data: Data) = buildList { val tracker = getTracker() ?: return@buildList - addSearchString("§e§l$itemLogCategory Profit Tracker") + addSearchString("§e§l$categoryName Profit Tracker") var profit = tracker.drawItems(data, { true }, this) val slayerSpawnCost = data.slayerSpawnCost @@ -191,11 +193,14 @@ object SlayerProfitTracker { profit += slayerSpawnCost } - val slayerCompletedCount = data.slayerCompletedCount + val slayerCompletedCount = data.slayerCompletedCount.addSeparators() add( Renderable.hoverTips( - "§7Bosses killed: §e${slayerCompletedCount.addSeparators()}", - listOf("§7You killed the $itemLogCategory boss", "§e${slayerCompletedCount.addSeparators()} §7times."), + "§7Bosses killed: §e$slayerCompletedCount", + listOf( + "§7You killed the $categoryName boss", + "§e$slayerCompletedCount §7times.", + ), ).toSearchable(), ) @@ -248,7 +253,7 @@ object SlayerProfitTracker { fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled fun resetCommand() { - if (itemLogCategory == "") { + if (category == "") { ChatUtils.userError( "No current slayer data found! " + "§eGo to a slayer area and start the specific slayer type you want to reset the data of.", diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 5427013c9506..45a29e60d6d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -222,8 +222,6 @@ object SlayerRngMeterDisplay { ) { return "" } - val latestSlayerCategory = SlayerAPI.latestSlayerCategory - latestSlayerCategory.endsWith(" I") with(storage) { if (itemGoal == "?") return "§cOpen RNG Meter Inventory!" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 4bb28c0f2dd8..cf0672a09b07 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -1,10 +1,13 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.NotificationManager import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.SkyHanniNotification +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator.getAttributeName import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager @@ -46,6 +49,13 @@ object ItemUtils { private val missingRepoItems = mutableSetOf() private var lastRepoWarning = SimpleTimeMark.farPast() + @HandleEvent + fun onConfigLoad(event: ConfigLoadEvent) { + ConditionalUtils.onToggle(SkyHanniMod.feature.misc.replaceRomanNumerals) { + itemNameCache.clear() + } + } + private val SKYBLOCK_MENU by lazy { "SKYBLOCK_MENU".toInternalName() } fun ItemStack.cleanName() = this.displayName.removeColor() @@ -500,10 +510,10 @@ object ItemUtils { // show enchanted book name if (itemStack.getItemCategoryOrNull() == ItemCategory.ENCHANTED_BOOK) { - return itemStack.getLore()[0] + return ReplaceRomanNumerals.replaceLine(itemStack.getLore()[0]) } if (name.endsWith("Enchanted Book Bundle")) { - return name.replace("Enchanted Book", itemStack.getLore()[0].removeColor()) + return name.replace("Enchanted Book", ReplaceRomanNumerals.replaceLine(itemStack.getLore()[0]).removeColor()) } // obfuscated trophy fish @@ -511,6 +521,11 @@ object ItemUtils { return name.replace("§kObfuscated", "Obfuscated") } + // remove roman runic tier + if (isRune()) { + return ReplaceRomanNumerals.replaceLine(name) + } + // hide pet level PetAPI.getCleanName(name)?.let { return "$it Pet" From ffc6d1d0a0f2ecd4374f5110b720ce547d3c52aa Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:44:19 +0100 Subject: [PATCH 39/93] Improvement: Estimated Item Value Mithril Infusion (#2990) Co-authored-by: Empa Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../jsonobjects/repo/neu/NeuReforgeJson.kt | 4 +- .../items/EstimatedItemValueCalculator.kt | 92 +++++++++++-------- .../skyhanni/utils/NEUInternalName.kt | 3 + .../utils/SkyBlockItemModifierUtils.kt | 2 + 4 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeJson.kt index c56098d553a6..a53e89ab00f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeJson.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo.neu import at.hannibal2.skyhanni.data.model.SkyblockStatList import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalNames import at.hannibal2.skyhanni.utils.NEUItems import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName @@ -52,7 +52,7 @@ data class NeuReforgeJson( is Map<*, *> -> { val type = "SPECIAL_ITEMS" val map = any as? Map> ?: return type to emptyList() - val internalNames = map["internalName"]?.map { it.toInternalName() }.orEmpty() + val internalNames = map["internalName"]?.toInternalNames().orEmpty() val itemType = map["itemid"]?.map { NEUItems.getInternalNamesForItemId(Item.getByNameOrId(it) ?: return@map emptyList()) }?.flatten().orEmpty() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index c49e56d7e990..4cdc96e86019 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -50,6 +50,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getGemstones import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHelmetSkin import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getHotPotatoCount import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getManaDisintegrators +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMithrilInfusion import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPolarvoidBookCount import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPowerScroll import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName @@ -70,7 +71,7 @@ import io.github.notenoughupdates.moulconfig.observer.Property import net.minecraft.item.ItemStack import java.util.Locale -// TODO split into smaler sub classes +// TODO split into smaller sub classes @Suppress("LargeClass") object EstimatedItemValueCalculator { @@ -94,6 +95,7 @@ object EstimatedItemValueCalculator { ::addStatsBook, ::addEnrichment, ::addDivanPowderCoating, + ::addMithrilInfusion, // counted ::addStars, // crimson, dungeon @@ -120,23 +122,33 @@ object EstimatedItemValueCalculator { ::addEnchantments, ) - val farmingForDummies = "FARMING_FOR_DUMMIES".toInternalName() - val etherwarpConduit = "ETHERWARP_CONDUIT".toInternalName() - val etherwarpMerger = "ETHERWARP_MERGER".toInternalName() - val fumingPotatoBook = "FUMING_POTATO_BOOK".toInternalName() - val hotPotatoBook = "HOT_POTATO_BOOK".toInternalName() - val silex = "SIL_EX".toInternalName() - val transmissionTuner = "TRANSMISSION_TUNER".toInternalName() - val manaDisintegrator = "MANA_DISINTEGRATOR".toInternalName() - - val kuudraUpgradeTiers = listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_") - - fun getTotalPrice(stack: ItemStack): Double = EstimatedItemValueCalculator.calculate(stack, mutableListOf()).first + private val FARMING_FOR_DUMMIES = "FARMING_FOR_DUMMIES".toInternalName() + private val ETHERWARP_CONDUIT = "ETHERWARP_CONDUIT".toInternalName() + private val ETHERWARP_MERGER = "ETHERWARP_MERGER".toInternalName() + private val FUMING_POTATO_BOOK = "FUMING_POTATO_BOOK".toInternalName() + private val HOT_POTATO_BOOK = "HOT_POTATO_BOOK".toInternalName() + private val SILEX = "SIL_EX".toInternalName() + private val TRANSMISSION_TUNER = "TRANSMISSION_TUNER".toInternalName() + private val MANA_DISINTEGRATOR = "MANA_DISINTEGRATOR".toInternalName() + private val RECOMBOBULATOR_3000 = "RECOMBOBULATOR_3000".toInternalName() + private val JALAPENO_BOOK = "JALAPENO_BOOK".toInternalName() + private val WOOD_SINGULARITY = "WOOD_SINGULARITY".toInternalName() + private val DIVAN_POWDER_COATING = "DIVAN_POWDER_COATING".toInternalName() + private val ART_OF_WAR = "THE_ART_OF_WAR".toInternalName() + private val BOOK_OF_STATS = "BOOK_OF_STATS".toInternalName() + private val ART_OF_PEACE = "THE_ART_OF_PEACE".toInternalName() + private val POLARVOID_BOOK = "POLARVOID_BOOK".toInternalName() + private val POCKET_SACK_IN_A_SACK = "POCKET_SACK_IN_A_SACK".toInternalName() + private val BOOKWORM_BOOK = "BOOKWORM_BOOK".toInternalName() + private val STONK_PICKAXE = "STONK_PICKAXE".toInternalName() + private val MITHRIL_INFUSION = "MITHRIL_INFUSION".toInternalName() + + fun getTotalPrice(stack: ItemStack): Double = calculate(stack, mutableListOf()).first fun calculate(stack: ItemStack, list: MutableList): Pair { val basePrice = addBaseItem(stack, list) val totalPrice = additionalCostFunctions.fold(basePrice) { total, function -> total + function(stack, list) } - return Pair(totalPrice, basePrice) + return totalPrice to basePrice } private fun addAttributeCost(stack: ItemStack, list: MutableList): Double { @@ -281,7 +293,7 @@ object EstimatedItemValueCalculator { private fun addRecombobulator(stack: ItemStack, list: MutableList): Double { if (!stack.isRecombobulated()) return 0.0 - val price = "RECOMBOBULATOR_3000".toInternalName().getPrice() + val price = RECOMBOBULATOR_3000.getPrice() list.add("§7Recombobulated: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -289,7 +301,7 @@ object EstimatedItemValueCalculator { private fun addJalapenoBook(stack: ItemStack, list: MutableList): Double { if (!stack.hasJalapenoBook()) return 0.0 - val price = "JALAPENO_BOOK".toInternalName().getPrice() + val price = JALAPENO_BOOK.getPrice() list.add("§7Jalapeno Book: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -297,7 +309,7 @@ object EstimatedItemValueCalculator { private fun addEtherwarp(stack: ItemStack, list: MutableList): Double { if (!stack.hasEtherwarp()) return 0.0 - val price = etherwarpConduit.getPrice() + etherwarpMerger.getPrice() + val price = ETHERWARP_CONDUIT.getPrice() + ETHERWARP_MERGER.getPrice() list.add("§7Etherwarp: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -305,7 +317,7 @@ object EstimatedItemValueCalculator { private fun addWoodSingularity(stack: ItemStack, list: MutableList): Double { if (!stack.hasWoodSingularity()) return 0.0 - val price = "WOOD_SINGULARITY".toInternalName().getPrice() + val price = WOOD_SINGULARITY.getPrice() list.add("§7Wood Singularity: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -313,15 +325,22 @@ object EstimatedItemValueCalculator { private fun addDivanPowderCoating(stack: ItemStack, list: MutableList): Double { if (!stack.hasDivanPowderCoating()) return 0.0 - val price = "DIVAN_POWDER_COATING".toInternalName().getPrice() + val price = DIVAN_POWDER_COATING.getPrice() list.add("§7Divan Powder Coating: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } + private fun addMithrilInfusion(stack: ItemStack, list: MutableList): Double { + if (!stack.getMithrilInfusion()) return 0.0 + val price = MITHRIL_INFUSION.getPrice() + list.add("§7Mithril Infusion: §a§l✔ §7(§6${price.shortFormat()}§7)") + return price + } + private fun addArtOfWar(stack: ItemStack, list: MutableList): Double { if (!stack.hasArtOfWar()) return 0.0 - val price = "THE_ART_OF_WAR".toInternalName().getPrice() + val price = ART_OF_WAR.getPrice() list.add("§7The Art of War: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -329,7 +348,7 @@ object EstimatedItemValueCalculator { private fun addStatsBook(stack: ItemStack, list: MutableList): Double { if (!stack.hasBookOfStats()) return 0.0 - val price = "BOOK_OF_STATS".toInternalName().getPrice() + val price = BOOK_OF_STATS.getPrice() list.add("§7Book of Stats: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -338,7 +357,7 @@ object EstimatedItemValueCalculator { private fun addArtOfPeace(stack: ItemStack, list: MutableList): Double { if (!stack.hasArtOfPeace()) return 0.0 - val price = "THE_ART_OF_PEACE".toInternalName().getPrice() + val price = ART_OF_PEACE.getPrice() list.add("§7The Art Of Peace: §a§l✔ §7(§6" + price.shortFormat() + "§7)") return price } @@ -358,12 +377,12 @@ object EstimatedItemValueCalculator { var totalPrice = 0.0 - val hpbPrice = hotPotatoBook.getPrice() * hpb + val hpbPrice = HOT_POTATO_BOOK.getPrice() * hpb list.add("§7HPB's: §e$hpb§7/§e10 §7(§6" + hpbPrice.shortFormat() + "§7)") totalPrice += hpbPrice if (fuming > 0) { - val fumingPrice = fumingPotatoBook.getPrice() * fuming + val fumingPrice = FUMING_POTATO_BOOK.getPrice() * fuming list.add("§7Fuming: §e$fuming§7/§e5 §7(§6" + fumingPrice.shortFormat() + "§7)") totalPrice += fumingPrice } @@ -374,7 +393,7 @@ object EstimatedItemValueCalculator { private fun addFarmingForDummies(stack: ItemStack, list: MutableList): Double { val count = stack.getFarmingForDummiesCount() ?: return 0.0 - val price = farmingForDummies.getPrice() * count + val price = FARMING_FOR_DUMMIES.getPrice() * count list.add("§7Farming for Dummies: §e$count§7/§e5 §7(§6" + price.shortFormat() + "§7)") return price } @@ -382,8 +401,7 @@ object EstimatedItemValueCalculator { private fun addPolarvoidBook(stack: ItemStack, list: MutableList): Double { val count = stack.getPolarvoidBookCount() ?: return 0.0 - val polarvoidBook = "POLARVOID_BOOK".toInternalName() - val price = polarvoidBook.getPrice() * count + val price = POLARVOID_BOOK.getPrice() * count list.add("§7Polarvoid: §e$count§7/§e5 §7(§6" + price.shortFormat() + "§7)") return price } @@ -391,8 +409,7 @@ object EstimatedItemValueCalculator { private fun addPocketSackInASack(stack: ItemStack, list: MutableList): Double { val count = stack.getAppliedPocketSackInASack() ?: return 0.0 - val pocketSackInASack = "POCKET_SACK_IN_A_SACK".toInternalName() - val price = pocketSackInASack.getPrice() * count + val price = POCKET_SACK_IN_A_SACK.getPrice() * count list.add("§7Pocket Sack-in-a-Sack: §e$count§7/§e3 §7(§6" + price.shortFormat() + "§7)") return price } @@ -400,8 +417,7 @@ object EstimatedItemValueCalculator { private fun addBookwormBook(stack: ItemStack, list: MutableList): Double { val count = stack.getBookwormBookCount() ?: return 0.0 - val bookwormBook = "BOOKWORM_BOOK".toInternalName() - val price = bookwormBook.getPrice() * count + val price = BOOKWORM_BOOK.getPrice() * count list.add("§7Bookworm's Favorite Book: §e$count§7/§e5 §7(§6" + price.shortFormat() + "§7)") return price } @@ -410,9 +426,9 @@ object EstimatedItemValueCalculator { val tier = stack.getSilexCount() ?: return 0.0 val internalName = stack.getInternalName() - val maxTier = if (internalName == "STONK_PICKAXE".toInternalName()) 4 else 5 + val maxTier = if (internalName == STONK_PICKAXE) 4 else 5 - val price = silex.getPrice() * tier + val price = SILEX.getPrice() * tier list.add("§7Silex: §e$tier§7/§e$maxTier §7(§6" + price.shortFormat() + "§7)") return price } @@ -420,7 +436,7 @@ object EstimatedItemValueCalculator { private fun addTransmissionTuners(stack: ItemStack, list: MutableList): Double { val count = stack.getTransmissionTunerCount() ?: return 0.0 - val price = transmissionTuner.getPrice() * count + val price = TRANSMISSION_TUNER.getPrice() * count list.add("§7Transmission Tuners: §e$count§7/§e4 §7(§6" + price.shortFormat() + "§7)") return price } @@ -428,7 +444,7 @@ object EstimatedItemValueCalculator { private fun addManaDisintegrators(stack: ItemStack, list: MutableList): Double { val count = stack.getManaDisintegrators() ?: return 0.0 - val price = manaDisintegrator.getPrice() * count + val price = MANA_DISINTEGRATOR.getPrice() * count list.add("§7Mana Disintegrators: §e$count§7/§e10 §7(§6" + price.shortFormat() + "§7)") return price } @@ -718,7 +734,7 @@ object EstimatedItemValueCalculator { private val hasAlwaysReplenish = listOf( "ADVANCED_GARDENING_HOE".toInternalName(), - "ADVANCED_GARDENING_AXE".toInternalName(), + "ADVANCED_GARDENING_AXE".toInternalName() ) private fun addEnchantments(stack: ItemStack, list: MutableList): Double { @@ -775,7 +791,7 @@ object EstimatedItemValueCalculator { } if (rawName in tieredEnchants) level = 1 - val enchantmentName = "$rawName;$level".uppercase().toInternalName() + val enchantmentName = "$rawName;$level".toInternalName() val singlePrice = enchantmentName.getPriceOrNull(config.priceSource.get()) ?: continue var name = enchantmentName.itemName @@ -915,7 +931,7 @@ object EstimatedItemValueCalculator { return "§b$name $second Shard" } - fun Pair.getAttributePrice(): Double? = EstimatedItemValueCalculator.getPriceOrCompositePriceForAttribute( + fun Pair.getAttributePrice(): Double? = getPriceOrCompositePriceForAttribute( "ATTRIBUTE_SHARD+ATTRIBUTE_$first", second, ) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt index 920b76894457..9ad4a0506b39 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt @@ -23,6 +23,9 @@ class NEUInternalName private constructor(private val internalName: String) { internalNameMap.getOrPut(it) { NEUInternalName(it) } } + fun Set.toInternalNames(): Set = mapTo(mutableSetOf()) { it.toInternalName() } + fun List.toInternalNames(): List = mapTo(mutableListOf()) { it.toInternalName() } + private val itemNameCache = mutableMapOf() fun fromItemNameOrNull(itemName: String): NEUInternalName? = itemNameCache.getOrPut(itemName) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index d3b9bb6dc8b4..093b5a45b1f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -35,6 +35,8 @@ object SkyBlockItemModifierUtils { it - 5 - getBaseSilexCount() }?.takeIf { it > 0 } + fun ItemStack.getMithrilInfusion(): Boolean = getAttributeByte("mithril_infusion") == 1.toByte() + private fun ItemStack.getBaseSilexCount() = when (getInternalName().asString()) { "STONK_PICKAXE" -> 1 "PROMISING_SPADE" -> 5 From 582882062cfc75bd90c026ab339e68eba8c71e4b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:44:52 +0100 Subject: [PATCH 40/93] code cleanup --- .../features/misc/items/EstimatedItemValueCalculator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index 4cdc96e86019..a4f0caaf9fed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -195,7 +195,7 @@ object EstimatedItemValueCalculator { list.add( " $nameColor${ displayName.allLettersFirstUppercase() - } ${attr.second}§7: $priceColor${if (price != null) price.shortFormat() else "Unknown"}", + } ${attr.second}§7: $priceColor${price?.shortFormat() ?: "Unknown"}", ) } // Adding 0.1 so that we always show the estimated item value overlay @@ -931,7 +931,7 @@ object EstimatedItemValueCalculator { return "§b$name $second Shard" } - fun Pair.getAttributePrice(): Double? = getPriceOrCompositePriceForAttribute( + private fun Pair.getAttributePrice(): Double? = getPriceOrCompositePriceForAttribute( "ATTRIBUTE_SHARD+ATTRIBUTE_$first", second, ) From 41d7bf47d654431b6da3f3498ba5acf0efd0e861 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:45:54 +0100 Subject: [PATCH 41/93] Fix: Farming Skill XP (#3121) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .editorconfig | 2 +- src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 54e4945de5a2..1880229305e3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -62,7 +62,7 @@ ktlint_standard_no-wildcard-imports = enabled ktlint_standard_function-expression-body = disabled # Additional Kotlin-specific formatting for conditions and continuation -ij_kotlin_continuation_indent_size = 8 +ij_kotlin_continuation_indent_size = 4 ij_kotlin_binary_expression_wrap = if_long ij_kotlin_keep_line_breaks = true ij_kotlin_annotations_new_line_after_suppress = true diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 0d3f811180fc..63230a194c9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getSkillInfo import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.xpRequiredForLevel import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -154,7 +155,11 @@ object SkillAPI { levelArray = data.levelingXp levelingMap = levelArray.withIndex().associate { (index, xp) -> (index + 1) to xp } exactLevelingMap = levelArray.withIndex().associate { (index, xp) -> xp to (index + 1) } - defaultSkillCap = data.levelingCaps + defaultSkillCap = data.levelingCaps.editCopy { + if (this["farming"] == 50) { + this["farming"] = 60 + } + } } @SubscribeEvent From fefb0a6dc75bad458473f29591452bb96b67c97a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Wed, 25 Dec 2024 11:46:07 +0100 Subject: [PATCH 42/93] Improvement: Profit per Anita Medal (#3122) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/garden/AnitaMedalProfit.kt | 131 ++++++++++++------ .../skyhanni/utils/CollectionUtils.kt | 4 + 2 files changed, 92 insertions(+), 43 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index f9a0a16ed48e..7587e1faef3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.CollectionUtils.add import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -20,7 +21,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -71,20 +71,21 @@ object AnitaMedalProfit { } val newList = mutableListOf() - newList.add(Renderable.string("§eMedal Profit")) + newList.add(Renderable.string("§eProfit per Bronze Medal")) newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = 0.7)) display = newList } private fun readItem(slot: Int, item: ItemStack, table: MutableList) { val itemName = getItemName(item) - if (itemName == " ") return - if (itemName == "§cClose") return - if (itemName == "§eUnique Gold Medals") return - if (itemName == "§aMedal Trades") return + if (isInvalidItemName(itemName)) return - val fullCost = getFullCost(getRequiredItems(item)) - if (fullCost < 0) return + val requiredItems = getRequiredItems(item) + val additionalMaterials = getAdditionalMaterials(requiredItems) + val additionalCost = getAdditionalCost(additionalMaterials) + + // Ignore items without medal cost, e.g. InfiniDirt Wand + val bronzeCost = getBronzeCost(requiredItems) ?: return val (name, amount) = ItemUtils.readItemAmount(itemName) ?: return @@ -96,23 +97,34 @@ object AnitaMedalProfit { val itemPrice = internalName.getPrice() * amount if (itemPrice < 0) return - val profit = itemPrice - fullCost - val profitFormat = profit.shortFormat() - val color = if (profit > 0) "§6" else "§c" + val profitPerSell = itemPrice - additionalCost + + // profit per bronze + val profitPerBronze = profitPerSell / bronzeCost + + val profitPerSellFormat = profitPerSell.shortFormat() + val profitPerBronzeFormat = profitPerBronze.shortFormat() + val color = if (profitPerBronze > 0) "§6" else "§c" + + val hover = buildList { + add(itemName) + add("") + add("§7Sell price: §6${itemPrice.shortFormat()}") - val hover = listOf( - itemName, - "", - "§7Item price: §6${itemPrice.shortFormat()} ", // TODO add more exact material cost breakdown - "§7Material cost: §6${fullCost.shortFormat()} ", - "§7Final profit: §6$profitFormat ", - ) + add("§7Additional cost: §6${additionalCost.shortFormat()}") + addAdditionalMaterials(additionalMaterials) + + add("§7Profit per sell: §6$profitPerSellFormat") + add("") + add("§7Bronze medals required: §c$bronzeCost") + add("§7Profit per bronze medal: §6$profitPerBronzeFormat") + } table.add( DisplayTableEntry( itemName, - "$color$profitFormat", - profit, + "$color$profitPerBronzeFormat", + profitPerBronze, internalName, hover, highlightsOnHoverSlots = listOf(slot), @@ -120,6 +132,23 @@ object AnitaMedalProfit { ) } + private fun MutableList.addAdditionalMaterials(additionalMaterials: Map) { + for ((internalName, amount) in additionalMaterials) { + val pricePer = internalName.getPrice() * amount + add(" " + internalName.itemName + " §8${amount}x §7(§6${pricePer.shortFormat()}§7)") + } + } + + private fun isInvalidItemName(itemName: String): Boolean = when (itemName) { + " ", + "§cClose", + "§eUnique Gold Medals", + "§aMedal Trades", + -> true + + else -> false + } + private fun getItemName(item: ItemStack): String { val name = item.name val isEnchantedBook = item.getItemCategoryOrNull() == ItemCategory.ENCHANTED_BOOK @@ -128,35 +157,39 @@ object AnitaMedalProfit { } else name } - private fun getFullCost(requiredItems: MutableList): Double { - val jacobTicketPrice = "JACOBS_TICKET".toInternalName().getPrice() - var otherItemsPrice = 0.0 - for (rawItemName in requiredItems) { - val pair = ItemUtils.readItemAmount(rawItemName) - if (pair == null) { - ErrorManager.logErrorStateWithData( - "Error in Anita Medal Contest", "Could not read item amount", - "rawItemName" to rawItemName, - ) - continue - } - - val (name, amount) = pair + private fun getAdditionalMaterials(requiredItems: Map): Map { + val additionalMaterials = mutableMapOf() + for ((name, amount) in requiredItems) { val medal = getMedal(name) - otherItemsPrice += if (medal != null) { - val bronze = medal.factorBronze * amount - bronze * jacobTicketPrice - } else { - NEUInternalName.fromItemName(name).getPrice() * amount + if (medal == null) { + additionalMaterials[NEUInternalName.fromItemName(name)] = amount } } + return additionalMaterials + } + + private fun getAdditionalCost(requiredItems: Map): Double { + var otherItemsPrice = 0.0 + for ((name, amount) in requiredItems) { + otherItemsPrice += name.getPrice() * amount + } return otherItemsPrice } - private fun getRequiredItems(item: ItemStack): MutableList { - val items = mutableListOf() + private fun getBronzeCost(requiredItems: Map): Int? { + for ((name, amount) in requiredItems) { + getMedal(name)?.let { + return it.factorBronze * amount + } + } + return null + } + + private fun getRequiredItems(item: ItemStack): MutableMap { + val items = mutableMapOf() var next = false - for (line in item.getLore()) { + val lore = item.getLore() + for (line in lore) { if (line == "§7Cost") { next = true continue @@ -167,7 +200,19 @@ object AnitaMedalProfit { continue } - items.add(line.replace("§8 ", " §8")) + val rawItemName = line.replace("§8 ", " §8") + + val pair = ItemUtils.readItemAmount(rawItemName) + if (pair == null) { + ErrorManager.logErrorStateWithData( + "Error in Anita Medal Contest", "Could not read item amount", + "rawItemName" to rawItemName, + "name" to item.name, + "lore" to lore, + ) + continue + } + items.add(pair) } } return items diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index 18bc0b7f670f..23c7b7266e90 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -489,4 +489,8 @@ object CollectionUtils { fun MutableList.addOrInsert(index: Int, element: E) { if (index < size) add(index, element) else add(element) } + + fun MutableMap.add(pair: Pair) { + this[pair.first] = pair.second + } } From c55e7ffab4a431fc56cce6bbbcee0cb623b913e7 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Wed, 25 Dec 2024 07:26:16 -0500 Subject: [PATCH 43/93] Backend: Add more error logging to trevor solver (#3107) --- .../features/misc/trevor/TrevorFeatures.kt | 4 +--- .../features/misc/trevor/TrevorSolver.kt | 17 ++++++++++++----- versions/1.8.9/detekt/baseline.xml | 7 ------- 3 files changed, 13 insertions(+), 15 deletions(-) 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 c1cf24cd3d64..9645052e1c72 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 @@ -290,9 +290,7 @@ object TrevorFeatures { location = LorenzVec(location.x, TrevorSolver.averageHeight, location.z) } if (TrevorSolver.mobLocation == TrapperMobArea.FOUND) { - val displayName = if (TrevorSolver.currentMob == null) "Mob Location" else { - TrevorSolver.currentMob!!.mobName - } + val displayName = TrevorSolver.currentMob?.mobName ?: "Mob Location" location = TrevorSolver.mobCoordinates event.drawWaypointFilled(location.down(2), LorenzColor.GREEN.toColor(), true, true) event.drawDynamicText(location.up(), displayName, 1.5) 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 94fefbdf8042..62af3e1ce4cf 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,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.trevor import at.hannibal2.skyhanni.data.mob.Mob import at.hannibal2.skyhanni.data.mob.MobData +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen import at.hannibal2.skyhanni.utils.LocationUtils @@ -11,7 +12,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.derpy import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.toLorenzVec -import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.EntityLivingBase import kotlin.time.Duration.Companion.seconds @@ -49,7 +49,6 @@ object TrevorSolver { } fun findMob() { - Minecraft.getMinecraft().theWorld ?: return for (entity in EntityUtils.getAllEntities()) { if (entity is EntityOtherPlayerMP) continue val name = entity.name @@ -57,14 +56,23 @@ object TrevorSolver { val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth.derpy() else 0 currentMob = TrevorMob.entries.firstOrNull { it.mobName.contains(name) } if ((animalHealths.any { it == entityHealth } && currentMob != null) || isTrevor) { + + val currentMob = currentMob ?: run { + ErrorManager.skyHanniError( + "Found trevor mob but current mob is null", + "entity" to entity, + "mobDataMob" to MobData.entityToMob[entity] + ) + } + if (foundID == entity.entityId) { val dist = entity.position.toLorenzVec().distanceToPlayer() val isOasisMob = currentMob == TrevorMob.RABBIT || currentMob == TrevorMob.SHEEP if (isOasisMob && mobLocation == TrapperMobArea.OASIS && !isTrevor) return - val canSee = entity.canBeSeen() && dist < currentMob!!.renderDistance + val canSee = entity.canBeSeen() && dist < currentMob.renderDistance if (canSee) { if (mobLocation != TrapperMobArea.FOUND) { - LorenzUtils.sendTitle("§2Saw ${currentMob!!.mobName}!", 3.seconds) + LorenzUtils.sendTitle("§2Saw ${currentMob.mobName}!", 3.seconds) } mobLocation = TrapperMobArea.FOUND mobCoordinates = entity.position.toLorenzVec() @@ -92,4 +100,3 @@ object TrevorSolver { mobCoordinates = LorenzVec(0.0, 0.0, 0.0) } } - diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index e9400d2a9066..11754ba60de3 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -231,10 +231,6 @@ RepoPatternRegexTest:ScoreboardPattern.kt$ScoreboardPattern$by dungeonSb.pattern( "keys", "Keys: §.■ §.[✗✓] §.■ §a.x", ) RepoPatternRegexTest:ScoreboardPattern.kt$ScoreboardPattern$by dungeonSb.pattern( "teammates", "(?:§.)*(?<classAbbv>\\[\\w]) (?:§.)*(?<username>\\w{2,16}) (?:(?:§.)*(?<classLevel>\\[Lvl?(?<level>[\\w,.]+)?]?)|(?:§.)*(?<health>[\\w,.]+)(?:§.)*.?)", ) RepoPatternRegexTest:ShowMotesNpcSellPrice.kt$ShowMotesNpcSellPrice$by RepoPattern.pattern( "rift.everywhere.burger", ".*(?:§\\w)+You have (?:§\\w)+(?<amount>\\d) Grubber Stacks.*" ) - RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill", "\\+(?<gained>[\\d.,]+) (?<skillName>\\w+) \\((?<current>[\\d.,]+)/(?<needed>[\\d.,]+)\\)", ) - RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill.multiplier", "\\+(?<gained>[\\d.,]+) (?<skillName>.+) \\((?<current>[\\d.,]+)/(?<needed>[\\d,.]+[kmb])\\)", ) - RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill.percent", "\\+(?<gained>[\\d.,]+) (?<skillName>.+) \\((?<progress>[\\d.]+)%\\)", ) - RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill.tab", " (?<type>\\w+)(?: (?<level>\\d+))?: §r§a(?<progress>[0-9.]+)%", ) RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill.tab.max", " (?<type>\\w+) (?<level>\\d+): §r§c§lMAX", ) RepoPatternRegexTest:SkillAPI.kt$SkillAPI$by patternGroup.pattern( "skill.tab.nopercent", " §r§a(?<type>\\w+)(?: (?<level>\\d+))?: §r§e(?<current>[0-9,.]+)§r§6/§r§e(?<needed>[0-9kmb]+)", ) RepoPatternRegexTest:SkillExperience.kt$SkillExperience$by patternGroup.pattern( "actionbar", ".*§3\\+.* (?<skill>.*) \\((?<overflow>.*)/(?<needed>.*)\\).*" ) @@ -276,7 +272,6 @@ RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "string.playerchat", "(?<important>.*?)(?:§[f7r])*: .*", ) RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "time.amount", "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?", ) RepoPatternRegexTest:VisitorListener.kt$VisitorListener$by RepoPattern.pattern( "garden.visitor.offersaccepted", "§7Offers Accepted: §a(?<offersAccepted>\\d+)", ) - ReturnCount:AnitaMedalProfit.kt$AnitaMedalProfit$private fun readItem(slot: Int, item: ItemStack, table: MutableList<DisplayTableEntry>) ReturnCount:ArachneChatMessageHider.kt$ArachneChatMessageHider$private fun shouldHide(message: String): Boolean ReturnCount:BingoNextStepHelper.kt$BingoNextStepHelper$private fun readDescription(description: String): NextStep? ReturnCount:BroodmotherFeatures.kt$BroodmotherFeatures$private fun onStageUpdate() @@ -418,8 +413,6 @@ UnsafeCallOnNullableType:SuperpairsClicksAlert.kt$SuperpairsClicksAlert$match.groups[1]!! UnsafeCallOnNullableType:TiaRelayWaypoints.kt$TiaRelayWaypoints$waypointName!! UnsafeCallOnNullableType:Translator.kt$Translator$messageContentRegex.find(message)!! - UnsafeCallOnNullableType:TrevorFeatures.kt$TrevorFeatures$TrevorSolver.currentMob!! - UnsafeCallOnNullableType:TrevorSolver.kt$TrevorSolver$currentMob!! UnsafeCallOnNullableType:TunnelsMaps.kt$TunnelsMaps$campfire.name!! UnsafeCallOnNullableType:UpdateManager.kt$UpdateManager$potentialUpdate!! UnsafeCallOnNullableType:VisitorRewardWarning.kt$VisitorRewardWarning$visitor.totalPrice!! From dc3ebeaf9ba0724152b2d4180d87fdfcfc4c4458 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 25 Dec 2024 14:19:14 +0100 Subject: [PATCH 44/93] Version 0.28 Beta 22 --- docs/CHANGELOG.md | 18 ++++++++++++++++++ root.gradle.kts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c290ef7aefb6..37553f2eeb5e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -105,6 +105,7 @@ + Reset search terms in GUIs after closing inventory (Profit Trackers, Area Navigation list, etc.). + Enabled by default to reduce confusion caused by the search feature. + The Estimated Item Value now displays material names used to unlock gemstone slots. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3089) ++ Added Mithril Infusion to Estimated Item Value. - Empa (https://github.com/hannibal002/SkyHanni/pull/2990) #### Chat and Command Improvements @@ -185,6 +186,7 @@ + Added an option to send the optimal speed warning even when not wearing Rancher's Boots. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2859) + Added a Pest Traps tab widget to the Tab Widget Display. - Luna (https://github.com/hannibal002/SkyHanni/pull/2984) + Updated Pest chat and GUI to indicate Pests Widget is disabled when displaying pests. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3022) ++ Changed Anita medal profit display to show profit per copper medal and sort by this value. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3122) #### Event Improvements @@ -208,6 +210,7 @@ + Added a warning for empty messages left behind by Stash Compact. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3009) + Added option to hide seconds in the Real Time GUI. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2979) + Improved graph navigation performance. - hannibal2 & Thunderblade (https://github.com/hannibal002/SkyHanni/pull/3083) ++ Added Roman numeral support to slayer names in trackers, Profit Tracker Items, and Scoreboard. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3113) ### Fixes @@ -260,6 +263,7 @@ + Fixed a small typo in Bestiary Display. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2748) + Fixed `Line to Slayer Miniboss` not checking for walls. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2788) + Fixed Special Zealots not highlighted after a recent Hypixel update. - Luna (https://github.com/hannibal002/SkyHanni/pull/3099) ++ Fixed Kuudra Lines sometimes not displaying in Custom Scoreboard. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3118) #### Custom Scoreboard Fixes @@ -358,6 +362,7 @@ + Fixed Time Tower warnings showing up on new profiles (e.g. Bingo). - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3012) + You can open `/cf` once to make the message disappear without changing settings if a new profile was created before applying the fix for the first time. + Fixed stray flash overlaying other Chocolate Factory information. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3054) ++ Fixed error when opening Choc Factory via NEU buttons. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3108) #### Event Fixes @@ -392,6 +397,7 @@ + Fixed the color of material messages. + Fixed overly liberal player message detection in Enable Chat Formatting. - !nea (https://github.com/hannibal002/SkyHanni/pull/2871) + This should fix many formatting issues related to `[SomethingHere] Something Else: Something Even More`. ++ Fixed /shwords causing blank messages in chat. - nopo (https://github.com/hannibal002/SkyHanni/pull/3110) #### Misc Fixes @@ -424,6 +430,10 @@ + Fixed collection tracker to recognize the current collection. - nopo (https://github.com/hannibal002/SkyHanni/pull/3049) + Fixed skill level. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3068) + Fixed Replace Roman Numerals replacing random letters. - Mikecraft1224 (https://github.com/hannibal002/SkyHanni/pull/3003) ++ Fixed most incorrect farming skill XP cases. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3121) + + Calculation errors when reaching a skill cap below 60 are not fixed yet. ++ Fixed distortion of regular words due to incorrect Roman numeral replacement. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3113) ++ Fixed rare error message in skill progress display. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3105) ### Technical Details @@ -542,6 +552,14 @@ + Moved Next Jacobs Contest, Best Crop Milestone & Jyrre Timer to Renderable. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3004) + Added /shtestactionbar command: set your clipboard as a fake Action Bar. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3085) + Added /shdebug support for SkyBlock island, Bingo, and Tab List data tests. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3085) ++ Added error logging to trevor solver. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/3107) ++ Added allowlist for Roman numeral replacement. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3113) ++ Added debug command /shdebugvisualwords. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3112) + + Added console logging of all words replaced by /shword. ++ Added contributor rabbit names. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3109) + + Replaced rabbit names in the rabbit collection menu with SkyHanni contributor names. ++ Added debug data for crop reading errors. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3114) ++ Improved Detekt and .editorconfig rules. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3104) ### Removed Features diff --git a/root.gradle.kts b/root.gradle.kts index 3cef4a498e48..0b962be5ed7d 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.21" + version = "0.28.Beta.22" repositories { mavenCentral() mavenLocal() From 6ef8ae3db3ab2aa023f2f66d35c5fa4693fa3894 Mon Sep 17 00:00:00 2001 From: Luna Date: Fri, 27 Dec 2024 21:14:09 +0100 Subject: [PATCH 45/93] Fix: Force zero price for glitched Gemstone Collection item (#3124) --- src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt | 1 + src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt index d8b9cbd6cbf0..022c29b4d121 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt @@ -25,6 +25,7 @@ object ItemPriceUtils { pastRecipes: List = emptyList(), ): Double? { when (this) { + NEUInternalName.GEMSTONE_COLLECTION -> return 0.0 NEUInternalName.JASPER_CRYSTAL -> return 0.0 NEUInternalName.RUBY_CRYSTAL -> return 0.0 NEUInternalName.SKYBLOCK_COIN -> return 1.0 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt index 9ad4a0506b39..f573a1883a8e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt @@ -11,6 +11,7 @@ class NEUInternalName private constructor(private val internalName: String) { val NONE = "NONE".toInternalName() val MISSING_ITEM = "MISSING_ITEM".toInternalName() + val GEMSTONE_COLLECTION = "GEMSTONE_COLLECTION".toInternalName() val JASPER_CRYSTAL = "JASPER_CRYSTAL".toInternalName() val RUBY_CRYSTAL = "RUBY_CRYSTAL".toInternalName() val SKYBLOCK_COIN = "SKYBLOCK_COIN".toInternalName() From 3bb825ac1b6e3fec2431b972459a632a06612eab Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 29 Dec 2024 19:37:42 -0500 Subject: [PATCH 46/93] Backend: Bump NEU depend to 2.5.0 (#3130) --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0716bc2ce77a..59268da5a9ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -191,9 +191,9 @@ dependencies { exclude(module = "unspecified") isTransitive = false } - // October 3, 2024, 11:43 PM AEST - // https://github.com/NotEnoughUpdates/NotEnoughUpdates/tree/2.4.0 - devenvMod("com.github.NotEnoughUpdates:NotEnoughUpdates:2.4.0:all") { + // December 29, 2024, 07:30 PM EST + // https://github.com/NotEnoughUpdates/NotEnoughUpdates/tree/2.5.0 + devenvMod("com.github.NotEnoughUpdates:NotEnoughUpdates:2.5.0:all") { exclude(module = "unspecified") isTransitive = false } From 184ca236727581d26fca6ee981e7ec0f6af314a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <142994683+Cedric-Ab@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:22:32 +0100 Subject: [PATCH 47/93] Update README.md (#3134) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c7721cfb176..6f48de4f9a41 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Give feedback or just chat with others on our community Discord! * **Bug Reports:** Use the `#bug-reports` channel when you find broken features (please check out `#faq` and `#known-bugs`). * **Quick Help** Ask in `#support` for questions and problems with the mod or Minecraft in general. -* **Feature Suggestions:** Feel fre to tell your ideas in `#suggestions` channel for new features and improvements to the mod. (Don't copy from existing mods or break Hypixel rules). +* **Feature Suggestions:** Feel free to tell your ideas in `#suggestions` channel for new features and improvements to the mod. (Don't copy from existing mods or break Hypixel rules). * **General Chat:** Chat with other SkyHanni users in `#skyblock-general` channel about the game. **[Join the Discord!](https://discord.gg/skyhanni-997079228510117908)** From 3269fe7eb2ab89fa1c2839249184d5766059bd04 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:57:05 +0100 Subject: [PATCH 48/93] Improvement: Default Custom Scoreboard Config (#3126) --- .../gui/customscoreboard/DisplayConfig.java | 2 +- .../gui/customscoreboard/EventsConfig.java | 2 +- .../ScoreboardConfigElement.kt | 25 ++++++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java index d91dbeb9f103..e250d0e2b90f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java @@ -138,7 +138,7 @@ public String toString() { @Expose @ConfigOption(name = "SkyBlock Time Exact Minutes", desc = "Display the exact minutes in the SkyBlock time, rather than only 10 minute increments.") @ConfigEditorBoolean - public boolean skyblockTimeExactMinutes = true; + public boolean skyblockTimeExactMinutes = false; @Expose @ConfigOption(name = "Date in Lobby Code", desc = "Show the current date infront of the server name, like Hypixel does.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/EventsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/EventsConfig.java index b091c8e90fee..26b4d5a5d33a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/EventsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/EventsConfig.java @@ -33,6 +33,6 @@ public class EventsConfig { @Expose @ConfigOption(name = "Show all active events", desc = "Show all active events in the scoreboard instead of the one with the highest priority.") @ConfigEditorBoolean - public boolean showAllActiveEvents = false; + public boolean showAllActiveEvents = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt index 9d9dcb378617..dced35b612c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt @@ -87,28 +87,29 @@ enum class ScoreboardConfigElement(val element: ScoreboardElement) { @JvmField val defaultOptions = listOf( TITLE, + LOBBY_CODE, + EMPTY_LINE, + DATE, + TIME, + ISLAND, + PLAYER_AMOUNT, + LOCATION, + VISITING, PROFILE, + EMPTY_LINE2, PURSE, - BANK, MOTES, + BANK, BITS, COPPER, GEMS, - NORTH_STARS, HEAT, COLD, - EMPTY_LINE, - ISLAND, - LOCATION, - LOBBY_CODE, - PLAYER_AMOUNT, - VISITING, - EMPTY_LINE2, - DATE, - TIME, + NORTH_STARS, + SOULFLOW, + EMPTY_LINE3, EVENTS, COOKIE, - EMPTY_LINE3, QUIVER, POWER, TUNING, From c1cbf398653893c573bad69061add5518c73a3e9 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:07:36 -0500 Subject: [PATCH 49/93] Fix: Stray Timer not Rendering When not Hoppity's (#3129) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../inventory/chocolatefactory/ChocolateFactoryStrayTimer.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTimer.kt index a4373133592b..27e9b5960c3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTimer.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.hoppity.EggFoundEvent -import at.hannibal2.skyhanni.features.event.hoppity.HoppityAPI import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.Companion.resettingEntries import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -64,7 +63,7 @@ object ChocolateFactoryStrayTimer { @SubscribeEvent fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { - if (!HoppityAPI.isHoppityEvent() || !ChocolateFactoryAPI.inChocolateFactory) return + if (!ChocolateFactoryAPI.inChocolateFactory) return if (!eventConfig.enabled || timer <= Duration.ZERO) return eventConfig.strayTimerPosition.renderRenderable(getTimerRenderable(), posLabel = "Stray Timer") } From 67e11391354a258c0505166d0d67fa966344f4ec Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:21:06 +0100 Subject: [PATCH 50/93] reset wrong quest data from config --- .../nether/reputationhelper/dailyquest/QuestLoader.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index 0b351f888f5f..39062319055f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -198,6 +198,12 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { val state = QuestState.valueOf(split[1]) val needAmount = split[2].toInt() val quest = addQuest(name, state, needAmount) + if (quest is UnknownQuest) { + dailyQuestHelper.quests.clear() + storage.quests.clear() + println("Reset crimson isle quest data from the config because the config was invalid!") + return + } if (quest is ProgressQuest && split.size == 4) { try { val haveAmount = split[3].toInt() From 7d521d99430d1820b75a76cf48427001efc6601d Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:26:43 -0500 Subject: [PATCH 51/93] Fix: Moby Highlighted by Trapper Highlight (#3127) --- .../hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt | 3 +++ 1 file changed, 3 insertions(+) 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 9645052e1c72..dd8f47deadb8 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 @@ -26,6 +26,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.MobUtils.mob import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -273,6 +274,8 @@ object TrevorFeatures { var entityTrapper = EntityUtils.getEntityByID(TRAPPER_ID) if (entityTrapper !is EntityLivingBase) entityTrapper = EntityUtils.getEntityByID(BACKUP_TRAPPER_ID) if (entityTrapper is EntityLivingBase && config.trapperTalkCooldown) { + // Solve for the fact that Moby also has the same ID as the Trapper + if (entityTrapper.mob?.name == "Moby") return RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entityTrapper, currentStatus.color) { config.trapperTalkCooldown } From 8e296e6d7fe3dc43fe41e7c0d45951e3dc6be75b Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:28:14 -0500 Subject: [PATCH 52/93] Fix: Stray Tracker Staying in Party Mode (#3128) --- .../chocolatefactory/ChocolateFactoryStrayTracker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt index 9137a955250b..d025a7555cc1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc +import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getSingleLineLore @@ -347,6 +349,11 @@ object ChocolateFactoryStrayTracker { } } + @HandleEvent + fun onConfigLoad(event: ConfigLoadEvent) { + config.partyMode.onToggle(tracker::update) + } + fun resetCommand() { tracker.resetCommand() } From ebc5171cc166d85932f1c6181de6b44ee86aa9e2 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:31:25 -0500 Subject: [PATCH 53/93] Fix: SkyblockStat parse error (#3133) --- .../skyhanni/data/model/SkyblockStat.kt | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt b/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt index 999d21c10a30..55e104a15e8c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/SkyblockStat.kt @@ -27,64 +27,64 @@ enum class SkyblockStat( @Language("RegExp") menuPatternS: String, ) { DAMAGE("§c❁", "", ""), // Weapon only - HEALTH("§c❤", " Health: §r§c❤(?.*)", " §c❤ Health §f(?.*)"), // TODO get from action bar - DEFENSE("§a❈", " Defense: §r§a❈(?.*)", " §a❈ Defense §f(?.*)"), // TODO get from action bar - STRENGTH("§c❁", " Strength: §r§c❁(?.*)", " §c❁ Strength §f(?.*)"), - INTELLIGENCE("§b✎", " Intelligence: §r§b✎(?.*)", " §b✎ Intelligence §f(?.*)"), // TODO get from action bar - CRIT_DAMAGE("§9☠", " Crit Damage: §r§9☠(?.*)", " §9☠ Crit Damage §f(?.*)"), - CRIT_CHANCE("§9☣", " Crit Chance: §r§9☣(?.*)", " §9☣ Crit Chance §f(?.*)"), - FEROCITY("§c⫽", " Ferocity: §r§c⫽(?.*)", " §c⫽ Ferocity §f(?.*)"), - BONUS_ATTACK_SPEED("§e⚔", " Attack Speed: §r§e⚔(?.*)", " §e⚔ Bonus Attack Speed §f(?.*)"), - ABILITY_DAMAGE("§c๑", " Ability Damage: §r§c๑(?.*)", " §c๑ Ability Damage §f(?.*)"), - HEALTH_REGEN("§c❣", " Health Regen: §r§c❣(?.*)", " §c❣ Health Regen §f(?.*)"), - VITALITY("§4♨", " Vitality: §r§4♨(?.*)", " §4♨ Vitality §f(?.*)"), - MENDING("§a☄", " Mending: §r§a☄(?.*)", " §a☄ Mending §f(?.*)"), - TRUE_DEFENSE("§7❂", " True Defense: §r§f❂(?.*)", " §f❂ True Defense §f(?.*)"), - SWING_RANGE("§eⓈ", " Swing Range: §r§eⓈ(?.*)", " §eⓈ Swing Range §f(?.*)"), - SPEED("§f✦", " Speed: §r§f✦(?.*)", " §f✦ Speed §f(?.*)"), // TODO add the way sba did get it (be careful with 500+ Speed) - SEA_CREATURE_CHANCE("§3α", " Sea Creature Chance: §r§3α(?.*)", " §3α Sea Creature Chance §f(?.*)"), - MAGIC_FIND("§b✯", " Magic Find: §r§b✯(?.*)", " §b✯ Magic Find §f(?.*)"), - PET_LUCK("§d♣", " Pet Luck: §r§d♣(?.*)", " §d♣ Pet Luck §f(?.*)"), - FISHING_SPEED("§b☂", " Fishing Speed: §r§b☂(?.*)", " §b☂ Fishing Speed §f(?.*)"), - DOUBLE_HOOK_CHANCE("§9⚓", " Double Hook Chance: §r§9⚓(?.*)", ""), - BONUS_PEST_CHANCE("§2ൠ", " (?:§r§7§m)?Bonus Pest Chance: (?:§r§2)?ൠ(?.*)", " (?:§7§m|§2)ൠ Bonus Pest Chance (?:§f)?(?.*)"), - COMBAT_WISDOM("§3☯", " Combat Wisdom: §r§3☯(?.*)", " §3☯ Combat Wisdom §f(?.*)"), - MINING_WISDOM("§3☯", " Mining Wisdom: §r§3☯(?.*)", " §3☯ Mining Wisdom §f(?.*)"), - FARMING_WISDOM("§3☯", " Farming Wisdom: §r§3☯(?.*)", " §3☯ Farming Wisdom §f(?.*)"), - FORAGING_WISDOM("§3☯", " Foraging Wisdom: §r§3☯(?.*)", " §3☯ Foraging Wisdom §f(?.*)"), - FISHING_WISDOM("§3☯", " Fishing Wisdom: §r§3☯(?.*)", " §3☯ Fishing Wisdom §f(?.*)"), - ENCHANTING_WISDOM("§3☯", " Enchanting Wisdom: §r§3☯(?.*)", " §3☯ Enchanting Wisdom §f(?.*)"), - ALCHEMY_WISDOM("§3☯", " Alchemy Wisdom: §r§3☯(?.*)", " §3☯ Alchemy Wisdom §f(?.*)"), - CARPENTRY_WISDOM("§3☯", " Carpentry Wisdom: §r§3☯(?.*)", " §3☯ Carpentry Wisdom §f(?.*)"), - RUNECRAFTING_WISDOM("§3☯", " Runecrafting Wisdom: §r§3☯(?.*)", " §3☯ Runecrafting Wisdom §f(?.*)"), - SOCIAL_WISDOM("§3☯", " Social Wisdom: §r§3☯(?.*)", " §3☯ Social Wisdom §f(?.*)"), - TAMING_WISDOM("§3☯", " Taming Wisdom: §r§3☯(?.*)", " §3☯ Taming Wisdom §f(?.*)"), - MINING_SPEED("§6⸕", " Mining Speed: §r§6⸕(?.*)", " §6⸕ Mining Speed §f(?.*)"), - BREAKING_POWER("§2Ⓟ", "", " §2Ⓟ Breaking Power §f(?.*)"), - PRISTINE("§5✧", " Pristine: §r§5✧(?.*)", " §5✧ Pristine §f(?.*)"), - FORAGING_FORTUNE("§☘", " Foraging Fortune: §r§6☘(?.*)", " §6☘ Foraging Fortune §f(?.*)"), - FARMING_FORTUNE("§6☘", " (?:§r§7§m)?Farming Fortune: (?:§r§6)?☘(?.*)", " (?:§7§m|§6)☘ Farming Fortune (?:§f)?(?.*)"), - MINING_FORTUNE("§6☘", " Mining Fortune: §r§6☘(?.*)", " §6☘ Mining Fortune §f(?.*)"), - FEAR("§5☠", " Fear: §r§5☠(?.*)", " §5☠ Fear §f(?.*)"), - COLD_RESISTANCE("§b❄", " Cold Resistance: §r§b❄(?.*)", ""), - WHEAT_FORTUNE("§7☘", "", " §7(?:§m)☘ Wheat Fortune (?.*)"), - CARROT_FORTUNE("§7☘", "", " §7(?:§m)☘ Carrot Fortune (?.*)"), - POTATO_FORTUNE("§7☘", "", " §7(?:§m)☘ Potato Fortune (?.*)"), - PUMPKIN_FORTUNE("§7☘", "", " §7(?:§m)☘ Pumpkin Fortune (?.*)"), - MELON_FORTUNE("§7☘", "", " §7(?:§m)☘ Melon Fortune (?.*)"), - MUSHROOM_FORTUNE("§7☘", "", " §7(?:§m)☘ Mushroom Fortune (?.*)"), - CACTUS_FORTUNE("§7☘", "", " §7(?:§m)☘ Cactus Fortune (?.*)"), - NETHER_WART_FORTUNE("§7☘", "", " §7(?:§m)☘ Nether Wart Fortune (?.*)"), - COCOA_BEANS_FORTUNE("§7☘", "", " §7(?:§m)☘ Cocoa Beans Fortune (?.*)"), - SUGAR_CANE_FORTUNE("§7☘", "", " §7(?:§m)☘ Sugar Cane Fortune (?.*)"), - - MINING_SPREAD("§e▚", " (§r§7§m)?Mining Spread: (§r§e)?▚(?.*)", " (§7§m|§e)▚ Mining Spread (§f)?(?.*)"), - GEMSTONE_SPREAD("§e▚", " (§r§7§m)?Mining Spread: (§r§e)?▚(?.*)", " (§7§m|§e)▚ Gemstone Spread (§f)?(?.*)"), - ORE_FORTUNE("§6☘", " Ore Fortune: §r§6☘(?.*)", " §6☘ Ore Fortune §f103"), - DWARVEN_METAL_FORTUNE("§6☘", " Dwarven Metal Fortune: §r§6☘(?.*)", " §6☘ Dwarven Metal Fortune §f(?.*)"), - BLOCK_FORTUNE("§6☘", " Block Fortune: §r§6☘(?.*)", " §6☘ Block Fortune §f(?.*)"), - GEMSTONE_FORTUNE("§6☘", " Gemstone Fortune: §r§6☘(?.*)", " §6☘ Gemstone Fortune §f(?.*)"), - HEAT_RESISTANCE("§c♨", " Heat Resistance: §r§c♨(?.*)", " §c♨ Heat Resistance §f(?.*)"), + HEALTH("§c❤", " Health: §r§c❤(?\\d+)(?: .*)?", " §c❤ Health §f(?\\d+)(?: .*)?"), // TODO get from action bar + DEFENSE("§a❈", " Defense: §r§a❈(?\\d+)(?: .*)?", " §a❈ Defense §f(?\\d+)(?: .*)?"), // TODO get from action bar + STRENGTH("§c❁", " Strength: §r§c❁(?\\d+)(?: .*)?", " §c❁ Strength §f(?\\d+)(?: .*)?"), + INTELLIGENCE("§b✎", " Intelligence: §r§b✎(?\\d+)(?: .*)?", " §b✎ Intelligence §f(?\\d+)(?: .*)?"), // TODO get from action bar + CRIT_DAMAGE("§9☠", " Crit Damage: §r§9☠(?\\d+)(?: .*)?", " §9☠ Crit Damage §f(?\\d+)(?: .*)?"), + CRIT_CHANCE("§9☣", " Crit Chance: §r§9☣(?\\d+)(?: .*)?", " §9☣ Crit Chance §f(?\\d+)(?: .*)?"), + FEROCITY("§c⫽", " Ferocity: §r§c⫽(?\\d+)(?: .*)?", " §c⫽ Ferocity §f(?\\d+)(?: .*)?"), + BONUS_ATTACK_SPEED("§e⚔", " Attack Speed: §r§e⚔(?\\d+)(?: .*)?", " §e⚔ Bonus Attack Speed §f(?\\d+)(?: .*)?"), + ABILITY_DAMAGE("§c๑", " Ability Damage: §r§c๑(?\\d+)(?: .*)?", " §c๑ Ability Damage §f(?\\d+)(?: .*)?"), + HEALTH_REGEN("§c❣", " Health Regen: §r§c❣(?\\d+)(?: .*)?", " §c❣ Health Regen §f(?\\d+)(?: .*)?"), + VITALITY("§4♨", " Vitality: §r§4♨(?\\d+)(?: .*)?", " §4♨ Vitality §f(?\\d+)(?: .*)?"), + MENDING("§a☄", " Mending: §r§a☄(?\\d+)(?: .*)?", " §a☄ Mending §f(?\\d+)(?: .*)?"), + TRUE_DEFENSE("§7❂", " True Defense: §r§f❂(?\\d+)(?: .*)?", " §f❂ True Defense §f(?\\d+)(?: .*)?"), + SWING_RANGE("§eⓈ", " Swing Range: §r§eⓈ(?\\d+)(?: .*)?", " §eⓈ Swing Range §f(?\\d+)(?: .*)?"), + SPEED("§f✦", " Speed: §r§f✦(?\\d+)(?: .*)?", " §f✦ Speed §f(?\\d+)(?: .*)?"), // TODO add the way sba did get it (be careful with 500+ Speed) + SEA_CREATURE_CHANCE("§3α", " Sea Creature Chance: §r§3α(?\\d+)(?: .*)?", " §3α Sea Creature Chance §f(?\\d+)(?: .*)?"), + MAGIC_FIND("§b✯", " Magic Find: §r§b✯(?\\d+)(?: .*)?", " §b✯ Magic Find §f(?\\d+)(?: .*)?"), + PET_LUCK("§d♣", " Pet Luck: §r§d♣(?\\d+)(?: .*)?", " §d♣ Pet Luck §f(?\\d+)(?: .*)?"), + FISHING_SPEED("§b☂", " Fishing Speed: §r§b☂(?\\d+)(?: .*)?", " §b☂ Fishing Speed §f(?\\d+)(?: .*)?"), + DOUBLE_HOOK_CHANCE("§9⚓", " Double Hook Chance: §r§9⚓(?\\d+)(?: .*)?", ""), + BONUS_PEST_CHANCE("§2ൠ", " (?:§r§7§m)?Bonus Pest Chance: (?:§r§2)?ൠ(?\\d+)(?: .*)?", " (?:§7§m|§2)ൠ Bonus Pest Chance (?:§f)?(?\\d+)(?: .*)?"), + COMBAT_WISDOM("§3☯", " Combat Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Combat Wisdom §f(?\\d+)(?: .*)?"), + MINING_WISDOM("§3☯", " Mining Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Mining Wisdom §f(?\\d+)(?: .*)?"), + FARMING_WISDOM("§3☯", " Farming Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Farming Wisdom §f(?\\d+)(?: .*)?"), + FORAGING_WISDOM("§3☯", " Foraging Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Foraging Wisdom §f(?\\d+)(?: .*)?"), + FISHING_WISDOM("§3☯", " Fishing Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Fishing Wisdom §f(?\\d+)(?: .*)?"), + ENCHANTING_WISDOM("§3☯", " Enchanting Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Enchanting Wisdom §f(?\\d+)(?: .*)?"), + ALCHEMY_WISDOM("§3☯", " Alchemy Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Alchemy Wisdom §f(?\\d+)(?: .*)?"), + CARPENTRY_WISDOM("§3☯", " Carpentry Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Carpentry Wisdom §f(?\\d+)(?: .*)?"), + RUNECRAFTING_WISDOM("§3☯", " Runecrafting Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Runecrafting Wisdom §f(?\\d+)(?: .*)?"), + SOCIAL_WISDOM("§3☯", " Social Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Social Wisdom §f(?\\d+)(?: .*)?"), + TAMING_WISDOM("§3☯", " Taming Wisdom: §r§3☯(?\\d+)(?: .*)?", " §3☯ Taming Wisdom §f(?\\d+)(?: .*)?"), + MINING_SPEED("§6⸕", " Mining Speed: §r§6⸕(?\\d+)(?: .*)?", " §6⸕ Mining Speed §f(?\\d+)(?: .*)?"), + BREAKING_POWER("§2Ⓟ", "", " §2Ⓟ Breaking Power §f(?\\d+)(?: .*)?"), + PRISTINE("§5✧", " Pristine: §r§5✧(?\\d+)(?: .*)?", " §5✧ Pristine §f(?\\d+)(?: .*)?"), + FORAGING_FORTUNE("§☘", " Foraging Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Foraging Fortune §f(?\\d+)(?: .*)?"), + FARMING_FORTUNE("§6☘", " (?:§r§7§m)?Farming Fortune: (?:§r§6)?☘(?\\d+)(?: .*)?", " (?:§7§m|§6)☘ Farming Fortune (?:§f)?(?\\d+)(?: .*)?"), + MINING_FORTUNE("§6☘", " Mining Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Mining Fortune §f(?\\d+)(?: .*)?"), + FEAR("§5☠", " Fear: §r§5☠(?\\d+)(?: .*)?", " §5☠ Fear §f(?\\d+)(?: .*)?"), + COLD_RESISTANCE("§b❄", " Cold Resistance: §r§b❄(?\\d+)(?: .*)?", ""), + WHEAT_FORTUNE("§7☘", "", " §7§m☘ Wheat Fortune (?\\d+)(?: .*)?"), + CARROT_FORTUNE("§7☘", "", " §7§m☘ Carrot Fortune (?\\d+)(?: .*)?"), + POTATO_FORTUNE("§7☘", "", " §7§m☘ Potato Fortune (?\\d+)(?: .*)?"), + PUMPKIN_FORTUNE("§7☘", "", " §7§m☘ Pumpkin Fortune (?\\d+)(?: .*)?"), + MELON_FORTUNE("§7☘", "", " §7§m☘ Melon Fortune (?\\d+)(?: .*)?"), + MUSHROOM_FORTUNE("§7☘", "", " §7§m☘ Mushroom Fortune (?\\d+)(?: .*)?"), + CACTUS_FORTUNE("§7☘", "", " §7§m☘ Cactus Fortune (?\\d+)(?: .*)?"), + NETHER_WART_FORTUNE("§7☘", "", " §7§m☘ Nether Wart Fortune (?\\d+)(?: .*)?"), + COCOA_BEANS_FORTUNE("§7☘", "", " §7§m☘ Cocoa Beans Fortune (?\\d+)(?: .*)?"), + SUGAR_CANE_FORTUNE("§7☘", "", " §7§m☘ Sugar Cane Fortune (?\\d+)(?: .*)?"), + + MINING_SPREAD("§e▚", " (§r§7§m)?Mining Spread: (§r§e)?▚(?\\d+)(?: .*)?", " (§7§m|§e)▚ Mining Spread (§f)?(?\\d+)(?: .*)?"), + GEMSTONE_SPREAD("§e▚", " (§r§7§m)?Mining Spread: (§r§e)?▚(?\\d+)(?: .*)?", " (§7§m|§e)▚ Gemstone Spread (§f)?(?\\d+)(?: .*)?"), + ORE_FORTUNE("§6☘", " Ore Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Ore Fortune §f103"), + DWARVEN_METAL_FORTUNE("§6☘", " Dwarven Metal Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Dwarven Metal Fortune §f(?\\d+)(?: .*)?"), + BLOCK_FORTUNE("§6☘", " Block Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Block Fortune §f(?\\d+)(?: .*)?"), + GEMSTONE_FORTUNE("§6☘", " Gemstone Fortune: §r§6☘(?\\d+)(?: .*)?", " §6☘ Gemstone Fortune §f(?\\d+)(?: .*)?"), + HEAT_RESISTANCE("§c♨", " Heat Resistance: §r§c♨(?\\d+)(?: .*)?", " §c♨ Heat Resistance §f(?\\d+)(?: .*)?"), UNKNOWN("§c?", "", "") ; @@ -97,11 +97,11 @@ enum class SkyblockStat( var lastSource: StatSourceType = StatSourceType.UNKNOWN - val capitalizedName = name.lowercase().allLettersFirstUppercase() + private val capitalizedName = name.lowercase().allLettersFirstUppercase() val iconWithName = "$icon $capitalizedName" - val keyName = name.lowercase().replace('_', '.') + private val keyName = name.lowercase().replace('_', '.') val displayValue get() = lastKnownValue?.let { icon + it.roundToInt() } From 4e55b9aec34ef5d01f5604ba7d486bbd9352ea27 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:31:39 -0500 Subject: [PATCH 54/93] Fix: Heat "null" on Custom Scoreboard (#3131) --- .../features/gui/customscoreboard/CustomScoreboardUtils.kt | 2 +- .../gui/customscoreboard/elements/ScoreboardElementHeat.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt index 8010208a305f..e3a8a2a51124 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt @@ -66,7 +66,7 @@ object CustomScoreboardUtils { internal fun getGems() = TabWidget.GEMS.matchMatcherFirstLine { group("gems") } ?: "0" - internal fun getHeat() = getGroup(ScoreboardPattern.heatPattern, getSbLines(), "heat") + internal fun getHeat() = getGroup(ScoreboardPattern.heatPattern, getSbLines(), "heat") ?: "§c♨ 0" internal fun getNorthStars() = getGroup(ScoreboardPattern.northstarsPattern, getSbLines(), "northStars") ?: "0" diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt index 8469e75fcb23..24f5ea4252ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt @@ -9,8 +9,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils // scoreboard update event object ScoreboardElementHeat : ScoreboardElement() { override fun getDisplay(): String? { - val heat = getHeat() ?: return null - + val heat = getHeat() return when { informationFilteringConfig.hideEmptyLines && heat == "§c♨ 0" -> null displayConfig.displayNumbersFirst -> "$heat Heat" From fcc3c0905677f9b1fa2185946becb9510c8c7442 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:34:42 +0100 Subject: [PATCH 55/93] only warn on unknown line after 10 seconds --- .../features/gui/customscoreboard/UnknownLinesHandler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt index b114b398ae13..9a99025ccc13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt @@ -242,9 +242,9 @@ object UnknownLinesHandler { unknownLine.lastFound = SimpleTimeMark.now() val firstFoundSince = unknownLine.firstFound.passedSince() val lastWarnedSince = unknownLine.lastWarned.passedSince() - if (firstFoundSince > 3.seconds && lastWarnedSince > 30.minutes) { + if (firstFoundSince > 10.seconds && lastWarnedSince > 30.minutes) { unknownLine.lastWarned = SimpleTimeMark.now() - warn(line, "same line active for 3 seconds") + warn(line, "same line active for 10 seconds") continue } } From f790f48fe0354d38ab4aef879d5d2d125778f8e5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:10:11 +0100 Subject: [PATCH 56/93] Fix: page scrolling in neu storage (#3135) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/inventory/PageScrolling.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/PageScrolling.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/PageScrolling.kt index 023fe057717f..11af24be608c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/PageScrolling.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/PageScrolling.kt @@ -54,6 +54,7 @@ object PageScrolling { @SubscribeEvent fun onLorenzTick(event: LorenzTickEvent) { if (!isEnabled()) return + if (InventoryUtils.inStorage() && InventoryUtils.isNeuStorageEnabled) return if (cooldown.isInFuture()) return if (!scroll.isMouseEventValid()) return From 83d200513089c73f428e0c65312a1f59eb8ca3f7 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:33:00 +0100 Subject: [PATCH 57/93] fix github --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c9ba173ee32..18fa6a95b710 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,6 +38,7 @@ jobs: path: versions/1.8.9/build/reports/tests/test/ preprocess: + if: ${{ false }} # Fix github runs-on: ubuntu-latest name: "Build multi version" steps: From 298219b45c60234482992e588aa9b809cc0c605d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:40:08 +0100 Subject: [PATCH 58/93] fix heat (#3138) Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/gui/customscoreboard/ChunkedStatsLine.kt | 2 +- .../features/gui/customscoreboard/CustomScoreboardUtils.kt | 2 +- .../gui/customscoreboard/elements/ScoreboardElementHeat.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLine.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLine.kt index 57000be68b86..4d0aef2ab152 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLine.kt @@ -69,7 +69,7 @@ enum class ChunkedStatsLine( configLine = "§aGems", ), HEAT( - displayPair = { "§c${getHeat()}" }, + displayPair = { "§c${getHeat() ?: "§c♨ 0"}" }, showWhen = { !(hideEmptyLines && getHeat() == "§c♨ 0") && ScoreboardElementHeat.showWhen() }, showIsland = { ScoreboardElementHeat.showIsland() }, configLine = "§cHeat", diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt index e3a8a2a51124..8010208a305f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt @@ -66,7 +66,7 @@ object CustomScoreboardUtils { internal fun getGems() = TabWidget.GEMS.matchMatcherFirstLine { group("gems") } ?: "0" - internal fun getHeat() = getGroup(ScoreboardPattern.heatPattern, getSbLines(), "heat") ?: "§c♨ 0" + internal fun getHeat() = getGroup(ScoreboardPattern.heatPattern, getSbLines(), "heat") internal fun getNorthStars() = getGroup(ScoreboardPattern.northstarsPattern, getSbLines(), "northStars") ?: "0" diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt index 24f5ea4252ee..cc1063a22323 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementHeat.kt @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils // scoreboard update event object ScoreboardElementHeat : ScoreboardElement() { override fun getDisplay(): String? { - val heat = getHeat() + val heat = getHeat() ?: return null return when { informationFilteringConfig.hideEmptyLines && heat == "§c♨ 0" -> null displayConfig.displayNumbersFirst -> "$heat Heat" From cbe631e8b8f5bbc3e9bd03344aa1bcd7bfc2e575 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:48:20 +0100 Subject: [PATCH 59/93] Improvement: HEDGEHOG in /ff (#3136) Co-authored-by: Luna Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/garden/fortuneguide/CaptureFarmingGear.kt | 6 ++++++ .../skyhanni/features/garden/fortuneguide/FFInfos.kt | 1 + .../skyhanni/features/garden/fortuneguide/FFStats.kt | 1 + .../skyhanni/features/garden/fortuneguide/FarmingItems.kt | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 03a5bb0ec160..34e1f9faffdb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -300,6 +300,7 @@ object CaptureFarmingGear { var highestRabbitRarity = (FarmingItems.RABBIT.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 var highestBeeRarity = (FarmingItems.BEE.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 var highestSlugRarity = (FarmingItems.SLUG.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 + var highestHedgehogRarity = (FarmingItems.HEDGEHOG.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 for ((_, item) in items) { if (item.getItemCategoryOrNull() != ItemCategory.PET) continue @@ -329,6 +330,11 @@ object CaptureFarmingGear { outdatedItems[FarmingItems.SLUG] = false highestSlugRarity = rarity.toInt() } + if (name == "HEDGEHOG" && rarity.toInt() > highestHedgehogRarity) { + FarmingItems.HEDGEHOG.setItem(item) + outdatedItems[FarmingItems.HEDGEHOG] = false + highestHedgehogRarity = rarity.toInt() + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt index 078f3489c3f7..61a12dbd963e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt @@ -84,6 +84,7 @@ internal enum class FFInfos( FarmingItems.MOOSHROOM_COW -> 158 FarmingItems.BEE -> 30 FarmingItems.SLUG -> 100 + FarmingItems.HEDGEHOG -> 45 else -> 0 } }, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index 77862b74daf5..53eaae443785 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -189,6 +189,7 @@ object FFStats { rawInternalName.contains("BEE;2") -> 0.2 * petLevel rawInternalName.contains("BEE;3") || rawInternalName.contains("BEE;4") -> 0.3 * petLevel rawInternalName.contains("SLUG;4") -> 1.0 * petLevel + rawInternalName.contains("HEDGEHOG;4") -> 0.45 * petLevel else -> 0.0 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt index bdfe98abfff2..c6f419a1111a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt @@ -36,6 +36,7 @@ enum class FarmingItems( RABBIT(ItemCategory.PET, FFStats::getPetFFData), BEE(ItemCategory.PET, FFStats::getPetFFData), SLUG(ItemCategory.PET, FFStats::getPetFFData), + HEDGEHOG(ItemCategory.PET, FFStats::getPetFFData), ; var selectedState = false @@ -138,7 +139,7 @@ enum class FarmingItems( val armor = listOf(HELMET, CHESTPLATE, LEGGINGS, BOOTS) val equip = listOf(NECKLACE, CLOAK, BELT, BRACELET) - val pets = listOf(ELEPHANT, MOOSHROOM_COW, RABBIT, BEE, SLUG) + val pets = listOf(ELEPHANT, MOOSHROOM_COW, RABBIT, BEE, SLUG, HEDGEHOG) fun getArmorDisplay(clickEnabled: Boolean = false): List = armor.map { it.getDisplay(clickEnabled) } From 61107904b891e14c6dab9bac825c291a861c1f6d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:48:30 +0100 Subject: [PATCH 60/93] Improvement: load trophy fish data by talking with odger (#3137) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../fishing/trophy/TrophyFishDisplay.kt | 26 +++--- .../fishing/trophy/TrophyFishManager.kt | 80 ++++++++++++++++++- .../fishing/trophy/TrophyFishMessages.kt | 4 +- 3 files changed, 96 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt index f9e729bd2131..090056778c5a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt @@ -93,7 +93,6 @@ object TrophyFishDisplay { } } - fun update() { if (!isEnabled()) return val list = mutableListOf() @@ -106,16 +105,23 @@ object TrophyFishDisplay { private fun createTable(): List> { val trophyFishes = TrophyFishManager.fish ?: return emptyList() val table = mutableListOf>() + + if (trophyFishes.isEmpty()) { + table.addSingleString("§cNo Trophy data found!") + table.addSingleString("§eTalk to Odger to load the data!") + return table + } + for ((rawName, data) in getOrder(trophyFishes)) { addRow(rawName, data, table) } - if (table.isEmpty()) { - get(config.onlyShowMissing.get())?.let { rarity -> - val name = rarity.formattedString - table.addSingleString("§eYou caught all $name Trophy Fishes") - if (rarity != TrophyRarity.DIAMOND) { - table.addSingleString("§cChange §eOnly Show Missing §cin the config to show more.") - } + if (table.isNotEmpty()) return table + + get(config.onlyShowMissing.get())?.let { rarity -> + val name = rarity.formattedString + table.addSingleString("§eYou caught all $name Trophy Fishes") + if (rarity != TrophyRarity.DIAMOND) { + table.addSingleString("§cChange §eOnly Show Missing §cin the config to show more.") } } return table @@ -233,7 +239,7 @@ object TrophyFishDisplay { ErrorManager.skyHanniError( "No Trophy Fishing name found", - "name" to name + "name" to name, ) } @@ -262,7 +268,7 @@ object TrophyFishDisplay { config.position.renderRenderables( display, extraSpace = config.extraSpace.get(), - posLabel = "Trophy Fishing Display" + posLabel = "Trophy Fishing Display", ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt index 584312c4f7b7..3a8500741671 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt @@ -5,10 +5,18 @@ import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.TrophyFishInfo import at.hannibal2.skyhanni.data.jsonobjects.repo.TrophyFishJson +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.NeuProfileDataLoadedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishMessages.getInternalName import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.event.HoverEvent import net.minecraft.util.ChatComponentText import net.minecraft.util.ChatStyle @@ -18,6 +26,24 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object TrophyFishManager { private val config get() = SkyHanniMod.feature.fishing.trophyFishing + private val patternGroup = RepoPattern.group("fishing.trophyfish") + + /** + * REGEX-TEST: §6Gold §a✔§7 (1) + */ + private val odgerRankPattern by patternGroup.pattern( + "odger.rank", + "§.(?.*) §a✔§7 \\((?.*)\\)", + ) + + /** + * REGEX-TEST: §bDiamond §c✖ + */ + private val odgerRankEmptyPattern by patternGroup.pattern( + "odger.rank.empty", + "§.(?.*) §c✖", + ) + @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("TrophyFish") @@ -55,15 +81,63 @@ object TrophyFishManager { } if (changed) { ChatUtils.clickableChat( - "Click here to load Trophy Fishing data from NEU PV!", onClick = { + "Click here to load Trophy Fishing data from NEU PV!", + onClick = { updateFromNeuPv(savedFishes, neuData) }, "§eClick to load!", - oneTimeClick = true + oneTimeClick = true, ) } } + // Fetch when talking with Odger + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (event.inventoryName != "Trophy Fishing") return + + val savedFishes = fish ?: return + var updatedFishes = 0 + for (stack in event.inventoryItems.values) { + val internalName = getInternalName(stack.name.replace("§k", "")) + + fun getRarity(rawRarity: String, line: String): TrophyRarity = + TrophyRarity.getByName(rawRarity) ?: ErrorManager.skyHanniError( + "unknown trophy fish rarity in odger inventory", + "rawRarity" to rawRarity, + "line" to line, + "stack.name" to stack.name, + "internalName" to internalName, + ) + + var updated = false + for (line in stack.getLore()) { + val (rarity, amount) = odgerRankPattern.matchMatcher(line) { + val rarity = getRarity(group("rarity"), line) + val amount = group("amount").formatInt() + rarity to amount + } ?: odgerRankEmptyPattern.matchMatcher(line) { + val rarity = getRarity(group("rarity"), line) + rarity to 0 + } ?: continue + + val stored = savedFishes[internalName]?.get(rarity) ?: -1 + if (amount != stored) { + updated = true + savedFishes.getOrPut(internalName) { mutableMapOf() }[rarity] = amount + } + } + if (updated) { + updatedFishes++ + } + } + + if (updatedFishes > 0) { + ChatUtils.chat("Updated $updatedFishes Trophy Fishes from Odger.") + TrophyFishDisplay.update() + } + } + private fun updateFromNeuPv( savedFishes: Map>, neuData: List>, @@ -94,7 +168,7 @@ object TrophyFishManager { fun getTooltip(internalName: String): ChatStyle? { val display = TrophyFishAPI.hoverInfo(internalName) ?: return null return ChatStyle().setChatHoverEvent( - HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(display)) + HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText(display)), ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt index bcac56c1c2b5..49fe60b423bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt @@ -101,9 +101,11 @@ object TrophyFishMessages { LorenzUtils.sendTitle(text, 3.seconds, 2.8, 7f) } + val regex = "[- ]".toRegex() + fun getInternalName(displayName: String): String { return displayName.replace("Obfuscated", "Obfuscated Fish") - .replace("[- ]".toRegex(), "").lowercase().removeColor() + .replace(regex, "").lowercase().removeColor() } private fun shouldBlockTrophyFish(rarity: TrophyRarity, amount: Int) = From 4048a803eb8787629f06f448a23f69050e5cb3ea Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:48:37 +0100 Subject: [PATCH 61/93] Improvement: Damage Indicator forever (#3139) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/dev/DevConfig.java | 5 +++ .../damageindicator/DamageIndicatorManager.kt | 37 ++++++++++--------- .../features/fishing/SeaCreatureFeatures.kt | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java index ab7d9b83cf26..fbdc91be8fc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java @@ -125,6 +125,11 @@ public class DevConfig { @ConfigEditorBoolean public boolean numberFormatOverride = false; + @Expose + @ConfigOption(name = "Damage Indicator", desc = "Enable the backend of the Damage Indicator. §cOnly disable when you know what you are doing!") + @ConfigEditorBoolean + public boolean damageIndicatorBackend = true; + @Expose @ConfigOption( name = "NTP Server", diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 19c5933f9f1a..89d5f781a0e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -79,8 +79,6 @@ object DamageIndicatorManager { private var data = mapOf() private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() - fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } - fun isDamageSplash(entity: EntityLivingBase): Boolean { if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false if (!entity.hasCustomName()) return false @@ -130,6 +128,9 @@ object DamageIndicatorManager { fun onWorldRender(event: LorenzRenderWorldEvent) { if (!isEnabled()) return + // only render when actually enabled + if (!config.enabled) return + GlStateManager.disableDepth() GlStateManager.disableCull() @@ -277,22 +278,21 @@ object DamageIndicatorManager { private fun EntityData.isConfigEnabled() = bossType.bossTypeToggle in config.bossesToShow - private fun noDeathDisplay(bossType: BossType): Boolean { - return when (bossType) { - BossType.SLAYER_BLAZE_TYPHOEUS_1, - BossType.SLAYER_BLAZE_TYPHOEUS_2, - BossType.SLAYER_BLAZE_TYPHOEUS_3, - BossType.SLAYER_BLAZE_TYPHOEUS_4, - BossType.SLAYER_BLAZE_QUAZII_1, - BossType.SLAYER_BLAZE_QUAZII_2, - BossType.SLAYER_BLAZE_QUAZII_3, - BossType.SLAYER_BLAZE_QUAZII_4, + @Suppress("Indentation") + private fun noDeathDisplay(bossType: BossType): Boolean = when (bossType) { + BossType.SLAYER_BLAZE_TYPHOEUS_1, + BossType.SLAYER_BLAZE_TYPHOEUS_2, + BossType.SLAYER_BLAZE_TYPHOEUS_3, + BossType.SLAYER_BLAZE_TYPHOEUS_4, + BossType.SLAYER_BLAZE_QUAZII_1, + BossType.SLAYER_BLAZE_QUAZII_2, + BossType.SLAYER_BLAZE_QUAZII_3, + BossType.SLAYER_BLAZE_QUAZII_4, // TODO f3/m3 4 guardians, f2/m2 4 boss room fighters - -> true + -> true - else -> false - } + else -> false } private fun tickDamage(damageCounter: DamageCounter) { @@ -392,6 +392,7 @@ object DamageIndicatorManager { } } + @Suppress("ReturnCount") private fun getCustomHealth( entityData: EntityData, health: Long, @@ -738,6 +739,7 @@ object DamageIndicatorManager { return "" } + @Suppress("CyclomaticComplexMethod", "ReturnCount") private fun checkThorn(realHealth: Long, realMaxHealth: Long): String? { val maxHealth: Int val health = if (DungeonAPI.isOneOf("F4")) { @@ -864,6 +866,7 @@ object DamageIndicatorManager { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { + if (!isEnabled()) return val entity = event.entity val entityData = data.values.find { @@ -887,7 +890,7 @@ object DamageIndicatorManager { } } } else { - if (entityData != null && isEnabled() && config.hideVanillaNametag && entityData.isConfigEnabled()) { + if (entityData != null && config.hideVanillaNametag && entityData.isConfigEnabled()) { val name = entity.name if (name.contains("Plasmaflux")) return if (name.contains("Overflux")) return @@ -932,5 +935,5 @@ object DamageIndicatorManager { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled + fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.dev.damageIndicatorBackend } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt index 24059bd4ef55..92245ac8ae67 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt @@ -50,7 +50,7 @@ object SeaCreatureFeatures { rareSeaCreatures.add(mob) var shouldHighlight = config.highlight - if (damageIndicatorConfig.enabled && DamageIndicatorConfig.BossCategory.SEA_CREATURES in damageIndicatorConfig.bossesToShow) { + if (DamageIndicatorConfig.BossCategory.SEA_CREATURES in damageIndicatorConfig.bossesToShow) { val seaCreaturesBosses = BossType.entries.filter { it.bossTypeToggle == DamageIndicatorConfig.BossCategory.SEA_CREATURES } if (seaCreaturesBosses.any { it.fullName.removeColor() == mob.name }) { From ee3aea60ed854193f84b26900117730cdc313485 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:48:54 +0100 Subject: [PATCH 62/93] Fix: End Portal Fumes (#3140) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 5279bbc356d4..ebc2d48c3cab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -60,7 +60,7 @@ object NonGodPotEffectDisplay { REV("§cZombie Brain Mixin", true), TARA("§6Spider Egg Mixin", true), SVEN("§bWolf Fur Mixin", true), - VOID("§6Ender Portal Fumes", true), + VOID("§6End Portal Fumes", true), BLAZE("§fGabagoey", true), GLOWING_MUSH("§2Glowing Mush Mixin", true), HOT_CHOCOLATE("§6Hot Chocolate Mixin", true), From daf6ebc1495989b2aac5cb94fc56fc0d5e94ca3b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 1 Jan 2025 03:18:11 +0100 Subject: [PATCH 63/93] Version 0.28 Beta 23 --- docs/CHANGELOG.md | 12 ++++++++++++ root.gradle.kts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 37553f2eeb5e..736cdd7b9da4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -129,6 +129,7 @@ + Improved Slayer Miniboss features. - Empa (https://github.com/hannibal002/SkyHanni/pull/2081) + Added the ability to remove people from the Carry Tracker. - Empa (https://github.com/hannibal002/SkyHanni/pull/2829) + Added Venom Shot attacks to the Arachne chat filter. - BearySuperior (https://github.com/hannibal002/SkyHanni/pull/3032) ++ Fixed Blaze Slayer features requiring Damage Indicator to be enabled. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3139) #### Mining Improvements @@ -149,6 +150,7 @@ + Added an option to always display the Barn Fishing Timer anywhere. - NeoNyaa (https://github.com/hannibal002/SkyHanni/pull/2735) + Improved the Golden Fish Timer to account for server lag. - Empa (https://github.com/hannibal002/SkyHanni/pull/2823) ++ Added loading of Trophy Fish data by talking with Odger. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3137) #### Hoppity Improvements @@ -173,6 +175,7 @@ + Added an option to display the profile type instead of the name in the Custom Scoreboard. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2810) + Improved performance when checking the Scoreboard. - Empa (https://github.com/hannibal002/SkyHanni/pull/2765) + Added a dropdown menu to select the Lobby Code date format. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2890) ++ Updated the Custom Scoreboard default config. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3126) #### Dungeon Improvements @@ -187,6 +190,7 @@ + Added a Pest Traps tab widget to the Tab Widget Display. - Luna (https://github.com/hannibal002/SkyHanni/pull/2984) + Updated Pest chat and GUI to indicate Pests Widget is disabled when displaying pests. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3022) + Changed Anita medal profit display to show profit per copper medal and sort by this value. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3122) ++ Added Hedgehog to /ff guide. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3136) #### Event Improvements @@ -253,6 +257,7 @@ + Fixed a rare error with Reforge Helper. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3093) + Fixed skill overflow detection for values slightly above the maximum. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3084) + Fixed /shtrackcollection not tracking Youngite and Obsolite. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/3082) ++ Disabled the Page Scrolling feature while using NEU Storage Overlay. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3135) #### Combat Fixes @@ -279,6 +284,7 @@ + Fixed a Custom Scoreboard error while waiting for the Mineshaft Queue. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3036) + Fixed Custom Scoreboard errors from the new Rift update. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3046) + Fixed Custom Scoreboard's player count to exclude offline players in co-ops and guest islands. - Chissl (https://github.com/hannibal002/SkyHanni/pull/3026) ++ Fixed heat showing as `null` in Custom Scoreboard. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3131) #### Hoppity Fixes @@ -300,6 +306,7 @@ + Fixed stray timer not activating from Hitman Eggs outside of Hoppity's Hunt. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3015) + Fixed Hitman Full Time calculation. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3075) + Fixed edge case where Hoppity Call warning wouldn't disappear. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3086) ++ Fixed stray timer not rendering if Hoppity's Hunt is inactive. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3129) #### Garden Fixes @@ -329,6 +336,7 @@ + Fixed the next visitor timer not decreasing on pest kills. - Chissl (https://github.com/hannibal002/SkyHanni/pull/3027) + Fixed chat error spam from Garden Composter Overlay. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3037) + Fixed Vacuum Item Stack Size not showing with over 1k Pests. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/3088) ++ Fixed Gemstone Powder showing as being worth billions of coins in Garden visitor rewards. - Luna (https://github.com/hannibal002/SkyHanni/pull/3124) #### Crimson Isle Fixes @@ -363,6 +371,7 @@ + You can open `/cf` once to make the message disappear without changing settings if a new profile was created before applying the fix for the first time. + Fixed stray flash overlaying other Chocolate Factory information. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3054) + Fixed error when opening Choc Factory via NEU buttons. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3108) ++ Fixed stray tracker partying a bit too much. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3128) #### Event Fixes @@ -434,6 +443,9 @@ + Calculation errors when reaching a skill cap below 60 are not fixed yet. + Fixed distortion of regular words due to incorrect Roman numeral replacement. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3113) + Fixed rare error message in skill progress display. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3105) ++ Fixed End Portal Fumes not being detected in Non-God Pot Display. - hannibal2 & The_Deerman (https://github.com/hannibal002/SkyHanni/pull/3140) ++ Fixed a rare case where stats could fail to parse. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3133) ++ Fixed Moby being highlighted by Trapper Highlight. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3127) ### Technical Details diff --git a/root.gradle.kts b/root.gradle.kts index 0b962be5ed7d..6df94648dc09 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.22" + version = "0.28.Beta.23" repositories { mavenCentral() mavenLocal() From 24da87d538c2130161cae1b31472758d9b16e960 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:20:28 -0500 Subject: [PATCH 64/93] 1.0.0 (#3123) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- build.gradle.kts | 8 ++--- buildSrc/build.gradle.kts | 2 +- root.gradle.kts | 10 +++++- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 10 +++++- .../skyhanni/config/ConfigManager.kt | 2 +- ...oErrorData.kt => ChangedChatErrorsJson.kt} | 13 ++++---- .../features/misc/update/UpdateManager.kt | 8 ++--- .../skyhanni/test/command/ErrorManager.kt | 11 +++---- .../hannibal2/skyhanni/utils/LorenzUtils.kt | 3 -- .../skyhanni/utils/json/BaseGsonBuilder.kt | 3 +- .../utils/json/SkyHanniTypeAdapters.kt | 6 ++++ .../skyhanni/utils/system/ModVersion.kt | 33 +++++++++++++++++++ 12 files changed, 77 insertions(+), 32 deletions(-) rename src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/{RepoErrorData.kt => ChangedChatErrorsJson.kt} (54%) create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt diff --git a/build.gradle.kts b/build.gradle.kts index 59268da5a9ef..0f74e479a720 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,4 @@ -import at.skyhanni.sharedvariables.MinecraftVersion -import at.skyhanni.sharedvariables.MultiVersionStage -import at.skyhanni.sharedvariables.ProjectTarget -import at.skyhanni.sharedvariables.SHVersionInfo -import at.skyhanni.sharedvariables.versionString +import at.skyhanni.sharedvariables.* import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask import moe.nea.shot.ShotParser @@ -312,7 +308,7 @@ tasks.withType(JavaCompile::class) { tasks.withType(org.gradle.jvm.tasks.Jar::class) { archiveBaseName.set("SkyHanni") - archiveAppendix.set("mc${target.minecraftVersion.versionName}") + archiveVersion.set("$version-mc${target.minecraftVersion.versionName}") duplicatesStrategy = DuplicatesStrategy.EXCLUDE // Why do we have this here? This only *hides* errors. manifest.attributes.run { this["Main-Class"] = "SkyHanniInstallerFrame" diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0c8f3fc78e50..61f1bb702403 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -13,5 +13,5 @@ repositories { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib") - implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.0.3") + implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.1.0") } diff --git a/root.gradle.kts b/root.gradle.kts index 6df94648dc09..4a1014034073 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,15 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.23" + + /** + * The version of the project. + * Major version + * Minor version + * Beta version + */ + version = "1.0.0" + repositories { mavenCentral() mavenLocal() diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2c14076a93ba..2777b94f7d81 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.test.hotswap.HotswapSupport import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded +import at.hannibal2.skyhanni.utils.system.ModVersion import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -108,9 +109,16 @@ class SkyHanniMod { const val MODID = "skyhanni" + val modVersion: ModVersion by lazy { + ModVersion.fromString(Loader.instance().indexedModList[MODID]!!.version) + } + @JvmStatic val version: String - get() = Loader.instance().indexedModList[MODID]!!.version + get() = modVersion.asString + + val isBetaVersion: Boolean + get() = modVersion.isBeta @JvmField var feature: Features = Features() diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index a534eac89193..dfb6285e78cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -43,7 +43,7 @@ import kotlin.concurrent.fixedRateTimer import kotlin.reflect.KMutableProperty0 private fun GsonBuilder.registerIfBeta(create: TypeAdapterFactory): GsonBuilder { - return if (LorenzUtils.isBetaVersion()) { + return if (SkyHanniMod.isBetaVersion) { registerTypeAdapterFactory(create) } else this } diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt similarity index 54% rename from src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt rename to src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt index 5ba59c148231..fd4a9a2ff1ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt @@ -1,18 +1,19 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo +import at.hannibal2.skyhanni.utils.system.ModVersion import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName -data class RepoErrorJson( +data class ChangedChatErrorsJson( @Expose @SerializedName("changed_error_messages") val changedErrorMessages: List, ) data class RepoErrorData( - @Expose @SerializedName("message_exact") private var rawMessageExact: List?, - @Expose @SerializedName("message_starts_with") private var rawMessageStartsWith: List?, - @Expose @SerializedName("replace_message") var replaceMessage: String?, - @Expose @SerializedName("custom_message") var customMessage: String?, - @Expose @SerializedName("affected_versions") var affectedVersions: List = listOf(), + @Expose @SerializedName("message_exact") private val rawMessageExact: List?, + @Expose @SerializedName("message_starts_with") private val rawMessageStartsWith: List?, + @Expose @SerializedName("replace_message") val replaceMessage: String?, + @Expose @SerializedName("custom_message") val customMessage: String?, + @Expose @SerializedName("fixed_in") val fixedIn: ModVersion?, ) { val messageExact get() = rawMessageExact.orEmpty() val messageStartsWith get() = rawMessageStartsWith.orEmpty() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index e22395aebf09..9bf25e4fd53a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -65,10 +65,6 @@ object UpdateManager { } } - fun isCurrentlyBeta(): Boolean { - return SkyHanniMod.version.contains("beta", ignoreCase = true) - } - private val config get() = SkyHanniMod.feature.about fun reset() { @@ -86,7 +82,7 @@ object UpdateManager { } logger.log("Starting update check") val currentStream = config.updateStream.get() - if (currentStream != UpdateStream.BETA && (updateStream == UpdateStream.BETA || isCurrentlyBeta())) { + if (currentStream != UpdateStream.BETA && (updateStream == UpdateStream.BETA || SkyHanniMod.isBetaVersion)) { config.updateStream = Property.of(UpdateStream.BETA) updateStream = UpdateStream.BETA } @@ -184,7 +180,7 @@ object UpdateManager { else -> currentStream } - val switchingToBeta = updateStream == UpdateStream.BETA && (currentStream != UpdateStream.BETA || !UpdateManager.isCurrentlyBeta()) + val switchingToBeta = updateStream == UpdateStream.BETA && (currentStream != UpdateStream.BETA || !SkyHanniMod.isBetaVersion) if (switchingToBeta) { ChatUtils.clickableChat( "Are you sure you want to switch to beta? These versions may be less stable.", diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index 97cfb5358bc6..cb71f7d2a6a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -1,13 +1,12 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.jsonobjects.repo.ChangedChatErrorsJson import at.hannibal2.skyhanni.data.jsonobjects.repo.RepoErrorData -import at.hannibal2.skyhanni.data.jsonobjects.repo.RepoErrorJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.KeyboardManager -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -129,7 +128,7 @@ object ErrorManager { betaOnly: Boolean = false, condition: () -> Boolean = { true }, ) { - if (betaOnly && !LorenzUtils.isBetaVersion()) return + if (betaOnly && !SkyHanniMod.isBetaVersion) return if (!ignoreErrorCache) { val pair = if (throwable.stackTrace.isNotEmpty()) { throwable.stackTrace[0].let { (it.fileName ?: "") to it.lineNumber } @@ -206,10 +205,10 @@ object ErrorManager { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant("ChangedChatErrors") - val version = SkyHanniMod.version + val data = event.getConstant("ChangedChatErrors") + val version = SkyHanniMod.modVersion - repoErrors = data.changedErrorMessages.filter { version in it.affectedVersions } + repoErrors = data.changedErrorMessages.filter { it.fixedIn == null || version < it.fixedIn } } private fun buildExtraDataString(extraData: Array>): String { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 12322964a83b..2bd6b9c88352 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -7,7 +7,6 @@ import at.hannibal2.skyhanni.data.MiningAPI import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign @@ -316,8 +315,6 @@ object LorenzUtils { fun inMiningIsland() = IslandType.GOLD_MINES.isInIsland() || IslandType.DEEP_CAVERNS.isInIsland() || MiningAPI.inAdvancedMiningIsland() - fun isBetaVersion() = UpdateManager.isCurrentlyBeta() - private var lastGuiTime = SimpleTimeMark.farPast() fun isAnyGuiActive(): Boolean { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt index 4784e87cb0d1..b34a6ba9d5b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.json.SkyHanniTypeAdapters.registerTypeAdapter +import at.hannibal2.skyhanni.utils.system.ModVersion import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import com.google.gson.GsonBuilder import io.github.notenoughupdates.moulconfig.observer.PropertyTypeAdapterFactory @@ -29,6 +29,7 @@ object BaseGsonBuilder { .registerTypeAdapter(NEUInternalName::class.java, SkyHanniTypeAdapters.INTERNAL_NAME.nullSafe()) .registerTypeAdapter(LorenzRarity::class.java, SkyHanniTypeAdapters.RARITY.nullSafe()) .registerTypeAdapter(IslandType::class.java, SkyHanniTypeAdapters.ISLAND_TYPE.nullSafe()) + .registerTypeAdapter(ModVersion::class.java, SkyHanniTypeAdapters.MOD_VERSION.nullSafe()) .registerTypeAdapter( SkyHanniTracker.DefaultDisplayMode::class.java, SkyHanniTypeAdapters.TRACKER_DISPLAY_MODE.nullSafe(), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt index 68c1d6888ac3..fa98d0587f82 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark +import at.hannibal2.skyhanni.utils.system.ModVersion import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import com.google.gson.GsonBuilder import com.google.gson.TypeAdapter @@ -82,6 +83,11 @@ object SkyHanniTypeAdapters { { SkyblockStat.getValue(this.uppercase()) }, ) + val MOD_VERSION: TypeAdapter = SimpleStringTypeAdapter( + { asString }, + { ModVersion.fromString(this) }, + ) + val TRACKER_DISPLAY_MODE = SimpleStringTypeAdapter.forEnum() val ISLAND_TYPE = SimpleStringTypeAdapter.forEnum() val RARITY = SimpleStringTypeAdapter.forEnum() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt new file mode 100644 index 000000000000..722f869da873 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.utils.system + +data class ModVersion(val major: Int, val minor: Int, val beta: Int) { + + companion object { + fun fromString(version: String): ModVersion { + + val parts = version.split('.') + return ModVersion( + parts.getOrNull(0)?.toIntOrNull() ?: 0, + parts.getOrNull(1)?.toIntOrNull() ?: 0, + parts.getOrNull(2)?.toIntOrNull() ?: 0, + ) + } + } + + val isBeta = beta != 0 + + val asString: String + get() = toString() + + override fun toString(): String { + return "$major.$minor.$beta" + } + + operator fun compareTo(other: ModVersion): Int { + return when { + major != other.major -> major.compareTo(other.major) + minor != other.minor -> minor.compareTo(other.minor) + else -> beta.compareTo(other.beta) + } + } +} From ec9184b28660ead7128a6ab20684929ba96d6704 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:23:14 +0100 Subject: [PATCH 65/93] fixed contributor names --- docs/CHANGELOG.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 736cdd7b9da4..2a756d837362 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -239,7 +239,7 @@ + Fixed the debug feature that allows you to add/remove stars being enabled by default. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2715) + Fixed displaying the Guardian warning text in the Experimentation Table even when using a Guardian Pet. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2718) + Fixed locked Ultimate enchantments being hidden by Enchant Parsing. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/2732) -+ Fixed Chest Value Display on Carpentry Chests. - fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2743) ++ Fixed Chest Value Display on Carpentry Chests. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2743) + Fixed Compact Item Stars. - Empa, Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2741) + Fixed an Estimated Item Value issue where +10 stars were accidentally added to certain items and unstarred items were not showing stars. - Fazfoxy and Empa (https://github.com/hannibal002/SkyHanni/pull/2758) + Fixed an issue with Estimated Item Value erroring when multiple mods affect the same item. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2787) @@ -399,12 +399,12 @@ #### Chat Fixes + Fixed item stash messages not being compacted correctly. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2781) -+ Fixed own player messages not being reformatted by chat formatting. - !nea (https://github.com/hannibal002/SkyHanni/pull/2806) ++ Fixed own player messages not being reformatted by chat formatting. - nea (https://github.com/hannibal002/SkyHanni/pull/2806) + Also fixed ranks losing their "+" colors. + Fixed compact stash messages. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2821) + Fixed compact item stash messages not being detected correctly. + Fixed the color of material messages. -+ Fixed overly liberal player message detection in Enable Chat Formatting. - !nea (https://github.com/hannibal002/SkyHanni/pull/2871) ++ Fixed overly liberal player message detection in Enable Chat Formatting. - nea (https://github.com/hannibal002/SkyHanni/pull/2871) + This should fix many formatting issues related to `[SomethingHere] Something Else: Something Even More`. + Fixed /shwords causing blank messages in chat. - nopo (https://github.com/hannibal002/SkyHanni/pull/3110) @@ -418,7 +418,7 @@ + Fixed kick duration not showing with some kick messages. - Luna (https://github.com/hannibal002/SkyHanni/pull/2837) + Fixed another kick message not being detected by the Kick Duration feature. - Luna (https://github.com/hannibal002/SkyHanni/pull/2861) + Fixed inability to delete characters when searching on trackers on Mac. - Empa (https://github.com/hannibal002/SkyHanni/pull/2868) -+ Fixed white names in Enable Chat Formatting. - !nea (https://github.com/hannibal002/SkyHanni/pull/2871) ++ Fixed white names in Enable Chat Formatting. - nea (https://github.com/hannibal002/SkyHanni/pull/2871) + Fixed Overflow Level/XP calculation being incorrect. - HiZe (https://github.com/hannibal002/SkyHanni/pull/2808) + Hypixel now shows the correct amount of overflow XP when max level is reached. + Fixed item data not loading. - nopo (https://github.com/hannibal002/SkyHanni/pull/2903) @@ -475,7 +475,7 @@ + Added informative comments on PRs when failures are detected. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2790) + Added in-file annotations when 'Detekt' failures occur. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2790) + Added some preprocessing mappings. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2776) -+ Added Shot support to the multi-version build. - !nea (https://github.com/hannibal002/SkyHanni/pull/2800) ++ Added Shot support to the multi-version build. - nea (https://github.com/hannibal002/SkyHanni/pull/2800) + This allows adding nullability annotations (and other simple annotations) to vanilla code. + Added an event handler check to SkyHanni Events. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2755) + Refactored and optimized the `NEUInternalName` class. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2841) @@ -488,8 +488,8 @@ + Used pre-processed methods for GUI scaling operations. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2648) + Fixed a typo in the key of Carnival Repo Patterns. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2842) + Improved the handling of active mayor perks, making it less annoying to work with. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2838) -+ Fixed getFormattedTextCompat. - !nea (https://github.com/hannibal002/SkyHanni/pull/2811) -+ Added buildpaths.txt to limit which files are attempted to be built on 1.21. - !nea (https://github.com/hannibal002/SkyHanni/pull/2811) ++ Fixed getFormattedTextCompat. - nea (https://github.com/hannibal002/SkyHanni/pull/2811) ++ Added buildpaths.txt to limit which files are attempted to be built on 1.21. - nea (https://github.com/hannibal002/SkyHanni/pull/2811) + This file should be populated over time with known good files to enable compilation on 1.21. + Added additional preprocessing mappings. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2809) + Added compatibility files for preprocessing. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2872) @@ -1689,7 +1689,7 @@ + Fixed lore not showing on enchanted books with compressed format. - Vixid (https://github.com/hannibal002/SkyHanni/pull/2301) + Fixed the incorrect "This item has no attributes" message appearing in the Attribute Fusion menu for some items. - Luna (https://github.com/hannibal002/SkyHanni/pull/2304) + Fixed shift-clicking items in GUIs triggering the Item Pickup Log. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2305) -+ Fixed the Master Mode Dungeon stack size display in the party finder menu. - fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2316) ++ Fixed the Master Mode Dungeon stack size display in the party finder menu. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2316) + Fixed the Item Pickup Log detecting "Magical Map" in dungeons when using Skytils. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2351) + Fixed Attribute Shards not displaying their names in the Chest Value feature. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2363) + Fixed Bazaar item movement being counted towards Item Trackers. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2366) From 1ad2f1c0e698c62959c531f8585a2d6a31118bbe Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:37:42 +0100 Subject: [PATCH 66/93] fixed even more contributor names --- docs/CHANGELOG.md | 2 +- docs/FEATURES.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2a756d837362..72da541e7a66 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,7 +36,7 @@ + Options to highlight good rolls in different colors, show only certain attributes, etc. + Added helpers for Essence Shops and Carnival Event Upgrade Shops. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2423) + Assists with maxing upgrades. -+ Added New Year Cake Tracker. - Daveed. (https://github.com/hannibal002/SkyHanni/pull/2237) ++ Added New Year Cake Tracker. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2237) + Highlights unowned cakes in AH. + Displays a list of missing cake years. + Added party mode for Chocolate Factory. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3054) diff --git a/docs/FEATURES.md b/docs/FEATURES.md index df3a0b3a6750..cdf7b0f10c34 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -236,7 +236,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Options to highlight good rolls in different colors, show only certain attributes, etc. + Added helpers for Essence Shops and Carnival Event Upgrade Shops. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2423) + Assists with maxing upgrades. -+ Added New Year Cake Tracker. - Daveed. (https://github.com/hannibal002/SkyHanni/pull/2237) ++ Added New Year Cake Tracker. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2237) + Highlights unowned cakes in AH. + Displays a list of missing cake years. + Added commands "/bp -", "/ec -" and "/shlastopened" to reopen last opened storage pages. - aphased (https://github.com/hannibal002/SkyHanni/pull/2900) @@ -1372,7 +1372,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Quiver Display. - Empa (https://github.com/hannibal002/SkyHanni/pull/1190) + Only shows the type of arrow when wearing a Skeleton Master Chestplate. + Low Quiver Reminder at the end of Dungeon/Kuudra run. - Empa (https://github.com/hannibal002/SkyHanni/pull/1190) -+ party chat commands. - !nea (https://github.com/hannibal002/SkyHanni/pull/1433) ++ party chat commands. - nea (https://github.com/hannibal002/SkyHanni/pull/1433) + Added `!pt` (and aliases) as a command that allows others to transfer the party to themselves. + Added `!pw` (and aliases) as a command that allows others to request a warp. + Option to highlight Zealots holding Chests in a different color. - Luna (https://github.com/hannibal002/SkyHanni/pull/1347) From 47e2bb1f525d413ae8c9f8c4310681f92e9ecba0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:52:09 +0100 Subject: [PATCH 67/93] fixed even more contributor names v2 --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 72da541e7a66..13a798f49667 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -213,7 +213,7 @@ + Added the Minecraft version to the mod file name. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2941) + Added a warning for empty messages left behind by Stash Compact. - Daveed (https://github.com/hannibal002/SkyHanni/pull/3009) + Added option to hide seconds in the Real Time GUI. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2979) -+ Improved graph navigation performance. - hannibal2 & Thunderblade (https://github.com/hannibal002/SkyHanni/pull/3083) ++ Improved graph navigation performance. - hannibal2 & Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/3083) + Added Roman numeral support to slayer names in trackers, Profit Tracker Items, and Scoreboard. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/3113) ### Fixes From 9642ef68e5c8d95af07e1955e07859243158f9d6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 3 Jan 2025 23:11:00 +0100 Subject: [PATCH 68/93] code cleanup --- .../skyhanni/features/combat/BestiaryData.kt | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 512a994d2c71..71e901ba078f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -48,7 +48,7 @@ object BestiaryData { */ private val tierProgressPattern by patternGroup.pattern( "tierprogress", - "§7Progress to Tier [\\dIVXC]+: §b[\\d.]+%" + "§7Progress to Tier [\\dIVXC]+: §b[\\d.]+%", ) /** @@ -57,7 +57,7 @@ object BestiaryData { */ private val overallProgressPattern by patternGroup.pattern( "overallprogress", - "§7Overall Progress: §b[\\d.]+%(?: §7\\(§c§lMAX!§7\\))?" + "§7Overall Progress: §b[\\d.]+%(?: §7\\(§c§lMAX!§7\\))?", ) /** @@ -66,7 +66,7 @@ object BestiaryData { */ private val progressPattern by patternGroup.pattern( "progress", - "(?[0-9kKmMbB,.]+)/(?[0-9kKmMbB,.]+\$)" + "(?[0-9kKmMbB,.]+)/(?[0-9kKmMbB,.]+\$)", ) /** @@ -75,7 +75,7 @@ object BestiaryData { */ private val titlePattern by patternGroup.pattern( "title", - "^(?:\\(\\d+\\/\\d+\\) )?(?Bestiary|.+) ➜ .+\$" + "^(?:\\(\\d+\\/\\d+\\) )?(?<title>Bestiary|.+) ➜ .+\$", ) private var display = emptyList<List<Any>>() @@ -97,7 +97,7 @@ object BestiaryData { if (!isEnabled()) return if (inInventory) { config.position.renderStringsAndItems( - display, extraSpace = -1, itemScale = 0.7, posLabel = "Bestiary Data" + display, extraSpace = -1, itemScale = 0.7, posLabel = "Bestiary Data", ) } } @@ -237,8 +237,8 @@ object BestiaryData { currentTotalKill, totalKillToTier, currentKillToTier, - actualRealTotalKill - ) + actualRealTotalKill, + ), ) } } @@ -293,7 +293,7 @@ object BestiaryData { buildList { add(" §7- ") add("${mob.name}: §cNot unlocked!") - } + }, ) continue } @@ -316,7 +316,7 @@ object BestiaryData { "§6Percent to max: §b${mob.percentToMaxFormatted()}", "§6Percent to tier: §b${mob.percentToTierFormatted()}", "", - "§7More info thing" + "§7More info thing", ) private fun getMobLine(mob: BestiaryMob, isMaxed: Boolean): String { @@ -370,7 +370,7 @@ object BestiaryData { // todo: avoid ordinal config.numberFormat = BestiaryConfig.NumberFormatEntry.entries[(config.numberFormat.ordinal + 1) % 2] update() - } + }, ) newDisplay.addButton( @@ -380,7 +380,7 @@ object BestiaryData { // todo: avoid ordinal config.displayType = DisplayTypeEntry.entries[(config.displayType.ordinal + 1) % 8] update() - } + }, ) newDisplay.addButton( @@ -389,7 +389,7 @@ object BestiaryData { onChange = { config.replaceRoman = !config.replaceRoman update() - } + }, ) newDisplay.addButton( @@ -398,30 +398,29 @@ object BestiaryData { onChange = { config.hideMaxed = !config.hideMaxed update() - } + }, ) } private fun addCategories(newDisplay: MutableList<List<Any>>) { - 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) + if (catList.isEmpty()) return + 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) + }, + ) } } From 28e29676c99638fad88a66d1c5254251e4522981 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 12:35:15 +0100 Subject: [PATCH 69/93] Version 1.0.0 --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 13a798f49667..65a9c887c3b4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,6 @@ # SkyHanni - Change Log -## Version 0.28 (in Beta) +## Version 1.0.0 ### New Features From a610889403a7bb909905b8423cb50601da888afa Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:54:41 +0100 Subject: [PATCH 70/93] Backend: Less Lazy (#3143) Co-authored-by: Empa <itsempa@users.noreply.github.com> --- .../hannibal2/skyhanni/data/NotificationManager.kt | 4 ++-- .../data/hypixel/chat/event/AbstractChatEvent.kt | 4 ++-- .../data/hypixel/chat/event/PartyChatEvent.kt | 4 +--- .../data/hypixel/chat/event/PlayerAllChatEvent.kt | 4 ++-- .../skyhanni/events/InventoryFullyOpenedEvent.kt | 8 ++++---- .../at/hannibal2/skyhanni/events/LorenzEvent.kt | 4 +--- .../skyhanni/events/ServerBlockChangeEvent.kt | 13 +++++-------- .../skyhanni/events/entity/EntityMoveEvent.kt | 2 +- .../skyhanni/features/chat/ChatFilterGui.kt | 3 +-- .../skyhanni/features/dungeon/DungeonAPI.kt | 2 +- .../skyhanni/features/event/diana/DianaAPI.kt | 2 +- .../skyhanni/features/event/hoppity/HoppityAPI.kt | 2 +- .../skyhanni/features/fishing/SeaCreature.kt | 2 +- .../fishing/tracker/FishingProfitTracker.kt | 2 +- .../features/garden/FarmingFortuneDisplay.kt | 2 +- .../features/garden/composter/ComposterDisplay.kt | 2 +- .../features/garden/composter/ComposterOverlay.kt | 8 ++++---- .../features/garden/farming/CropMoneyDisplay.kt | 4 ++-- .../features/garden/fortuneguide/FFStats.kt | 9 ++++----- .../skyhanni/features/garden/pests/SprayFeatures.kt | 2 +- .../garden/visitor/GardenVisitorSupercraft.kt | 6 ++---- .../features/garden/visitor/VisitorReward.kt | 4 ++-- .../gui/customscoreboard/RenderBackground.kt | 2 +- .../features/inventory/CarnivalShopHelper.kt | 5 ++--- .../features/inventory/EssenceShopHelper.kt | 4 ++-- .../skyhanni/features/inventory/HeldTimeInLore.kt | 4 ++-- .../features/inventory/HideNotClickableItems.kt | 2 +- .../inventory/bazaar/BazaarOpenPriceWebsite.kt | 6 ++---- .../features/itemabilities/FireVeilWandParticles.kt | 2 +- .../skyhanni/features/mining/ColdOverlay.kt | 2 +- .../skyhanni/features/mining/DeepCavernsGuide.kt | 6 ++---- .../skyhanni/features/mining/TunnelsMaps.kt | 2 +- .../features/mining/glacitemineshaft/CorpseType.kt | 4 ++-- .../glacitemineshaft/MineshaftWaypointType.kt | 6 ++---- .../features/misc/RestorePieceOfWizardPortalLore.kt | 2 +- .../at/hannibal2/skyhanni/features/rift/RiftAPI.kt | 4 ++-- .../rift/area/westvillage/kloon/KloonHacking.kt | 2 +- .../features/rift/area/wyldwoods/RiftLarva.kt | 2 +- .../features/rift/area/wyldwoods/RiftOdonata.kt | 2 +- .../features/rift/everywhere/PunchcardHighlight.kt | 5 +++-- .../features/rift/everywhere/RiftHorsezookaHider.kt | 2 +- .../at/hannibal2/skyhanni/utils/ItemPriceUtils.kt | 4 ++-- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 2 +- .../at/hannibal2/skyhanni/utils/LorenzRarity.kt | 2 +- .../utils/renderables/RenderableInventory.kt | 2 +- 45 files changed, 75 insertions(+), 92 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/NotificationManager.kt b/src/main/java/at/hannibal2/skyhanni/data/NotificationManager.kt index 301215e58169..9496576700bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/NotificationManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/NotificationManager.kt @@ -102,8 +102,8 @@ data class SkyHanniNotification( var endTime = SimpleTimeMark.farFuture() - val width by lazy { (message.maxOfOrNull { Minecraft.getMinecraft().fontRendererObj.getStringWidth(it) } ?: 0) + 8 } - val height by lazy { message.size * 10 + 18 } + val width = (message.maxOfOrNull { Minecraft.getMinecraft().fontRendererObj.getStringWidth(it) } ?: 0) + 8 + val height = message.size * 10 + 18 fun setEndTime() { if (length.isInfinite()) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/AbstractChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/AbstractChatEvent.kt index 630bd5c8072b..02965fa4c153 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/AbstractChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/AbstractChatEvent.kt @@ -10,6 +10,6 @@ open class AbstractChatEvent( var chatComponent: IChatComponent, var blockedReason: String? = null, ) : SkyHanniEvent() { - val message by lazy { messageComponent.getText().removePrefix("§r") } - val author by lazy { authorComponent.getText() } + val message = messageComponent.getText().removePrefix("§r") + val author = authorComponent.getText() } diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt index e2b9e04ef3ff..668bcc9643c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PartyChatEvent.kt @@ -10,7 +10,5 @@ class PartyChatEvent( chatComponent: IChatComponent, blockedReason: String? = null, ) : AbstractChatEvent(authorComponent, messageComponent, chatComponent, blockedReason) { - val cleanedAuthor by lazy { - author.cleanPlayerName() - } + val cleanedAuthor = author.cleanPlayerName() } diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt index bb2de00104f5..003715d5a223 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/event/PlayerAllChatEvent.kt @@ -14,6 +14,6 @@ class PlayerAllChatEvent( blockedReason: String? = null, ) : AbstractChatEvent(authorComponent, messageComponent, chatComponent, blockedReason) { val levelColor = levelComponent?.sampleStyleAtStart()?.color - val level by lazy { levelComponent?.getText()?.toInt() } - val isAGuest by lazy { privateIslandGuest != null } + val level = levelComponent?.getText()?.toInt() + val isAGuest get() = privateIslandGuest != null } diff --git a/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt index 5374b95d3c2e..d599fdf3aef1 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt @@ -7,10 +7,10 @@ import net.minecraft.item.ItemStack open class InventoryOpenEvent(private val inventory: OtherInventoryData.Inventory) : LorenzEvent() { - val inventoryId: Int by lazy { inventory.windowId } - val inventoryName: String by lazy { inventory.title } - val inventorySize: Int by lazy { inventory.slotCount } - val inventoryItems: Map<Int, ItemStack> by lazy { inventory.items } + val inventoryId: Int get() = inventory.windowId + val inventoryName: String get() = inventory.title + val inventorySize: Int get() = inventory.slotCount + val inventoryItems: Map<Int, ItemStack> get() = inventory.items val inventoryItemsWithNull: Map<Int, ItemStack?> by lazy { (0 until inventorySize).associateWith { inventoryItems[it] } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index afde87dd7e5a..29ba8acec334 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -22,9 +22,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @Deprecated("Use SkyHanniEvent instead") abstract class LorenzEvent : Event() { - private val eventName by lazy { - this::class.simpleName!! - } + private val eventName = this::class.simpleName!! @Deprecated("Use SkyHanniEvent instead") fun postAndCatch() = postAndCatchAndBlock {} diff --git a/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt index ed0ef4ac9311..e2514af9fad1 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt @@ -1,28 +1,25 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.api.event.SkyHanniEvent -import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matchGroup import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.block.state.IBlockState import net.minecraft.util.BlockPos class ServerBlockChangeEvent(blockPos: BlockPos, blockState: IBlockState) : SkyHanniEvent() { - val location by lazy { blockPos.toLorenzVec() } - val old by lazy { location.getBlockAt().toString().getName() } + val location = blockPos.toLorenzVec() + val old by lazy { oldState.block.toString().getName() } val oldState by lazy { location.getBlockStateAt() } val new by lazy { blockState.block.toString().getName() } - val newState by lazy { blockState } + val newState = blockState companion object { private val pattern = "Block\\{minecraft:(?<name>.*)}".toPattern() - private fun String.getName() = pattern.matchMatcher(this) { - group("name") - } ?: this + private fun String.getName() = pattern.matchGroup(this, "name") ?: this } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityMoveEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityMoveEvent.kt index 6043c744cb80..f778c7706577 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityMoveEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityMoveEvent.kt @@ -11,5 +11,5 @@ class EntityMoveEvent<T : Entity>( val newLocation: LorenzVec, val distance: Double, ) : GenericSkyHanniEvent<T>(entity.javaClass) { - val isLocalPlayer by lazy { entity == Minecraft.getMinecraft().thePlayer } + val isLocalPlayer get() = entity == Minecraft.getMinecraft().thePlayer } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt index 6a5f22b6635a..446f8a5a4750 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilterGui.kt @@ -29,9 +29,8 @@ class ChatFilterGui(private val history: List<ChatManager.MessageFilteringResult private fun reasonLength(result: ChatManager.MessageFilteringResult): Int = result.actionReason?.let { Minecraft.getMinecraft().fontRendererObj.getStringWidth(it) } ?: 0 - private val historySize by lazy { + private val historySize = history.sumOf { splitLine(it.message).size * 10 + if (it.modified != null) splitLine(it.modified).size * 10 else 0 } - } override fun drawScreen(originalMouseX: Int, originalMouseY: Int, partialTicks: Float) { super.drawScreen(originalMouseX, originalMouseY, partialTicks) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index 8edb9cefd83c..3f128ddef1de 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -121,7 +121,7 @@ object DungeonAPI { WISDOM(0), TIME(0); - val displayName by lazy { name.firstLetterUppercase() } + val displayName = name.firstLetterUppercase() companion object { fun reset() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt index d06c187ee9d3..0c9342e62b76 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack @SkyHanniModule object DianaAPI { - private val spade by lazy { "ANCESTRAL_SPADE".toInternalName() } + private val spade = "ANCESTRAL_SPADE".toInternalName() fun hasSpadeInHand() = InventoryUtils.itemInHandId == spade diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt index 106e30d40e13..a75465b02cc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt @@ -149,7 +149,7 @@ object HoppityAPI { } } - val hoppityRarities by lazy { LorenzRarity.entries.filter { it <= DIVINE } } + val hoppityRarities = LorenzRarity.entries.filter { it <= DIVINE } private val hoppityDataSet = HoppityStateDataSet() private val processedStraySlots = mutableMapOf<Int, String>() private val miscProcessableItemTypes by lazy { diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt index 18ff93cc9112..05a77b1910d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreature.kt @@ -10,7 +10,7 @@ data class SeaCreature( val rarity: LorenzRarity, ) { - val displayName by lazy { chatColor + rare() + name } + val displayName = chatColor + rare() + name private fun rare() = if (rare) "§l" else "" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt index 77eb80643bfb..b53547e41429 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt @@ -97,7 +97,7 @@ object FishingProfitTracker { private val ItemTrackerData.TrackedItem.timesCaught get() = timesGained - private val MAGMA_FISH by lazy { "MAGMA_FISH".toInternalName() } + private val MAGMA_FISH = "MAGMA_FISH".toInternalName() private const val NAME_ALL: CategoryName = "All" private var currentCategory: CategoryName = NAME_ALL diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 0dc6ce28cf15..92128212a920 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -103,7 +103,7 @@ object FarmingFortuneDisplay { private var lastUniversalFortuneMissingError = SimpleTimeMark.farPast() private var lastCropFortuneMissingError = SimpleTimeMark.farPast() - private val ZORROS_CAPE by lazy { "ZORROS_CAPE".toInternalName() } + private val ZORROS_CAPE = "ZORROS_CAPE".toInternalName() @HandleEvent fun onTabListUpdate(event: TabListUpdateEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index daf26417b52f..292bbef8c90a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -47,7 +47,7 @@ object ComposterDisplay { val displayItem by lazy { icon.toInternalName().getItemStack() } - val pattern by lazy { rawPattern.toPattern() } + val pattern = rawPattern.toPattern() fun addToList(map: Map<DataType, String>): List<Any> { return map[this]?.let { listOf(displayItem, it) }.orEmpty() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index d4bcc6db5ca7..6e731bbb71d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -105,10 +105,10 @@ object ComposterOverlay { ChatUtils.chat("Composter test offset set to $testOffset.") } - private val COMPOST by lazy { "COMPOST".toInternalName() } - private val BIOFUEL by lazy { "BIOFUEL".toInternalName() } - private val VOLTA by lazy { "VOLTA".toInternalName() } - private val OIL_BARREL by lazy { "OIL_BARREL".toInternalName() } + private val COMPOST = "COMPOST".toInternalName() + private val BIOFUEL = "BIOFUEL".toInternalName() + private val VOLTA = "VOLTA".toInternalName() + private val OIL_BARREL = "OIL_BARREL".toInternalName() @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 9e8aac9fbef1..c341449ddd64 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -62,8 +62,8 @@ object CropMoneyDisplay { private val toolHasBountiful get() = GardenAPI.storage?.toolWithBountiful private val BOX_OF_SEEDS by lazy { "BOX_OF_SEEDS".toInternalName().getItemStack() } - private val SEEDS by lazy { "SEEDS".toInternalName() } - private val ENCHANTED_SEEDS by lazy { "ENCHANTED_SEEDS".toInternalName() } + private val SEEDS = "SEEDS".toInternalName() + private val ENCHANTED_SEEDS = "ENCHANTED_SEEDS".toInternalName() @HandleEvent fun onProfileJoin(event: ProfileJoinEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index 53eaae443785..86f008344a00 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -16,12 +16,11 @@ import kotlin.math.floor object FFStats { - private val mathCrops by lazy { - listOf(CropType.WHEAT, CropType.CARROT, CropType.POTATO, CropType.SUGAR_CANE, CropType.NETHER_WART) - } - private val dicerCrops by lazy { listOf(CropType.PUMPKIN, CropType.MELON) } + @Suppress("PropertyWrapping") + private val mathCrops = setOf(CropType.WHEAT, CropType.CARROT, CropType.POTATO, CropType.SUGAR_CANE, CropType.NETHER_WART) + private val dicerCrops = setOf(CropType.PUMPKIN, CropType.MELON) - private val farmingBoots = arrayListOf("RANCHERS_BOOTS", "FARMER_BOOTS") + private val farmingBoots = setOf("RANCHERS_BOOTS", "FARMER_BOOTS") var cakeExpireTime get() = GardenAPI.storage?.fortune?.cakeExpiring ?: SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt index 44a2d3d77704..176dda193322 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt @@ -32,7 +32,7 @@ object SprayFeatures { "§a§lSPRAYONATOR! §r§7Your selected material is now §r§a(?<spray>.*)§r§7!", ) - private val SPRAYONATOR by lazy { "SPRAYONATOR".toInternalName() } + private val SPRAYONATOR = "SPRAYONATOR".toInternalName() private fun SprayType?.getSprayEffect(): String = this?.getPests()?.takeIf { it.isNotEmpty() }?.let { pests -> diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt index a8908e45ceb2..83795371e1a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt @@ -12,12 +12,11 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.PrimitiveIngredient.Companion.toPrimitiveItemStacks import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraft.entity.player.InventoryPlayer +import net.minecraft.init.Items import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -32,9 +31,8 @@ object GardenVisitorSupercraft { private var lastSuperCraftMaterial = "" private val superCraftItem by lazy { - val neuItem = "GOLD_PICKAXE".toInternalName().getItemStack() ItemUtils.createItemStack( - neuItem.item, + Items.golden_pickaxe, "§bSupercraft", "§8(From SkyHanni)", "", diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt index dd68002c5a58..45df0a556974 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorReward.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack enum class VisitorReward( - private val rawInternalName: String, + rawInternalName: String, val displayName: String, private val legacyId: Int = -1, ) : HasLegacyId { @@ -22,7 +22,7 @@ enum class VisitorReward( COPPER_DYE("DYE_COPPER", "§8Copper Dye"), ; - private val internalName by lazy { rawInternalName.toInternalName() } + private val internalName = rawInternalName.toInternalName() val itemStack by lazy { internalName.getItemStack() } // TODO use this instead of hard coded item names once moulconfig no longer calls toString before the neu repo gets loaded // val displayName by lazy { itemStack.nameWithEnchantment ?: internalName.asString() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt index e7ceb138729c..fdd61d194c90 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt @@ -13,7 +13,7 @@ import net.minecraft.util.ResourceLocation object RenderBackground { - private val textureLocation by lazy { ResourceLocation("skyhanni", "scoreboard.png") } + private val textureLocation = ResourceLocation("skyhanni", "scoreboard.png") internal fun addBackground(renderable: Renderable): Renderable { with(backgroundConfig) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt index 270b3492a4f6..ab82b914fc58 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt @@ -17,8 +17,6 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.createItemStack import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal @@ -26,6 +24,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -34,7 +33,7 @@ object CarnivalShopHelper { // Where the informational item stack will be placed in the GUI private const val CUSTOM_STACK_LOCATION = 8 - private val NAME_TAG_ITEM by lazy { "NAME_TAG".toInternalName().getItemStack().item } + private inline val NAME_TAG_ITEM get() = Items.name_tag private var repoEventShops = mutableListOf<EventShop>() private var currentProgress: EventShopProgress? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/EssenceShopHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/EssenceShopHelper.kt index a40a44824140..6aea925e8623 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/EssenceShopHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/EssenceShopHelper.kt @@ -20,7 +20,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal @@ -29,6 +28,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SimpleTimeMark +import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -38,7 +38,7 @@ object EssenceShopHelper { // Where the informational item stack will be placed in the GUI private const val CUSTOM_STACK_LOCATION = 8 - private val GOLD_NUGGET_ITEM by lazy { "GOLD_NUGGET".toInternalName().getItemStack().item } + private inline val GOLD_NUGGET_ITEM get() = Items.gold_nugget private var essenceShops = mutableListOf<EssenceShop>() private var currentProgress: EssenceShopProgress? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 9a4c2e1208d2..43d8634bde8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -18,8 +18,8 @@ import kotlin.time.Duration.Companion.seconds object HeldTimeInLore { private val config get() = SkyHanniMod.feature.inventory - private val jyrreBottle by lazy { "NEW_BOTTLE_OF_JYRRE".toInternalName() } - private val cacaoTruffle by lazy { "DARK_CACAO_TRUFFLE".toInternalName() } + private val jyrreBottle = "NEW_BOTTLE_OF_JYRRE".toInternalName() + private val cacaoTruffle = "DARK_CACAO_TRUFFLE".toInternalName() @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index d928516cd2b5..d85514b98ea9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -85,7 +85,7 @@ object HideNotClickableItems { "SEEDS|CARROT_ITEM|POTATO_ITEM|PUMPKIN_SEEDS|SUGAR_CANE|MELON_SEEDS|CACTUS|INK_SACK-3", ) - private val netherWart by lazy { "NETHER_STALK".toInternalName() } + private val netherWart = "NETHER_STALK".toInternalName() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt index 8fc62a39a02a..266d1a0b6aa1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt @@ -7,11 +7,10 @@ import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraft.entity.player.InventoryPlayer +import net.minecraft.init.Items import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -23,9 +22,8 @@ object BazaarOpenPriceWebsite { private var lastClick = SimpleTimeMark.farPast() private val item by lazy { - val neuItem = "PAPER".toInternalName().getItemStack() ItemUtils.createItemStack( - neuItem.item, + Items.paper, "§bPrice History", "§8(From SkyHanni)", "", diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt index 58ea560393a2..4e996e603911 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -26,7 +26,7 @@ import kotlin.time.Duration.Companion.seconds object FireVeilWandParticles { private val config get() = SkyHanniMod.feature.inventory.itemAbilities.fireVeilWands - private val item by lazy { "FIRE_VEIL_WAND".toInternalName() } + private val item = "FIRE_VEIL_WAND".toInternalName() private var lastClick = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt index c66760423cb1..ba9881242fdd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt @@ -26,7 +26,7 @@ object ColdOverlay { private var lastCold = 0 private var lastColdUpdate = SimpleTimeMark.farPast() - private val textureLocation by lazy { ResourceLocation("skyhanni", "cold_overlay.png") } + private val textureLocation = ResourceLocation("skyhanni", "cold_overlay.png") @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt index 248035f7da77..bc03023bb78b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt @@ -20,13 +20,12 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.ParkourHelper import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.player.inventory.ContainerLocalMenu +import net.minecraft.init.Items import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -40,9 +39,8 @@ object DeepCavernsGuide { private var showStartIcon = false private val startIcon by lazy { - val neuItem = "MAP".toInternalName().getItemStack() ItemUtils.createItemStack( - neuItem.item, + Items.map, "§bDeep Caverns Guide", "§8(From SkyHanni)", "", diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt index b8c9c9df6b8c..523b05dd61bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt @@ -154,7 +154,7 @@ object TunnelsMaps { private var clickTranslate = mapOf<Int, String>() - private val ROYAL_PIGEON by lazy { "ROYAL_PIGEON".toInternalName() } + private val ROYAL_PIGEON = "ROYAL_PIGEON".toInternalName() private var isCommission = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseType.kt index 6e9a80220d4d..28ba533af194 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseType.kt @@ -2,14 +2,14 @@ package at.hannibal2.skyhanni.features.mining.glacitemineshaft import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -enum class CorpseType(val displayName: String, private val keyName: String? = null) { +enum class CorpseType(val displayName: String, key: String? = null) { LAPIS("§9Lapis"), TUNGSTEN("§7Tungsten", "TUNGSTEN_KEY"), UMBER("§6Umber", "UMBER_KEY"), VANGUARD("§fVanguard", "SKELETON_KEY"), ; - val key by lazy { keyName?.toInternalName() } + val key = key?.toInternalName() override fun toString(): String = displayName } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypointType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypointType.kt index feb4b2473967..33b338684b17 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypointType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypointType.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName enum class MineshaftWaypointType( val displayText: String, val color: LorenzColor, - private val itemName: String? = null + itemName: String? = null ) { LAPIS("Lapis Corpse", LorenzColor.DARK_BLUE, "LAPIS_ARMOR_HELMET"), UMBER("Umber Corpse", LorenzColor.GOLD, "ARMOR_OF_YOG_HELMET"), @@ -17,9 +17,7 @@ enum class MineshaftWaypointType( LADDER("Ladder", LorenzColor.YELLOW) ; - val helmet by lazy { - itemName?.toInternalName() - } + val helmet = itemName?.toInternalName() companion object { fun getByHelmetOrNull(internalName: NEUInternalName): MineshaftWaypointType? { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt index 3576b5ccb28a..23a2381d3896 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt @@ -16,7 +16,7 @@ object RestorePieceOfWizardPortalLore { private val config get() = SkyHanniMod.feature.misc - private val item by lazy { "WIZARD_PORTAL_MEMENTO".toInternalName() } + private val item = "WIZARD_PORTAL_MEMENTO".toInternalName() private val earnedPattern by RepoPattern.pattern( "misc.restore.wizard.portal.earned", diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt index 00405c9ff5bf..a8c34e30e39b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt @@ -23,9 +23,9 @@ object RiftAPI { // internal name -> motes var motesPrice = emptyMap<NEUInternalName, Double>() - val farmingTool by lazy { "FARMING_WAND".toInternalName() } + val farmingTool = "FARMING_WAND".toInternalName() - private val blowgun by lazy { "BERBERIS_BLOWGUN".toInternalName() } + private val blowgun = "BERBERIS_BLOWGUN".toInternalName() val ItemStack?.isBlowgun: Boolean get() = this?.getInternalName() == blowgun diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt index 0f0fbe033764..693e0ef48806 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt @@ -42,7 +42,7 @@ object KloonHacking { private val correctButtons = mutableListOf<String>() private var nearestTerminal: KloonTerminal? = null - private val RETRO_ENCABULATING_VISOR by lazy { "RETRO_ENCABULATING_VISOR".toInternalName() } + private val RETRO_ENCABULATING_VISOR = "RETRO_ENCABULATING_VISOR".toInternalName() @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt index a6636fc7575c..f7a88d0af74d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt @@ -23,7 +23,7 @@ object RiftLarva { private val LARVA_SKULL_TEXTURE by lazy { SkullTextureHolder.getTexture("RIFT_LARVA") } - private val LARVA_HOOK by lazy { "LARVA_HOOK".toInternalName() } + private val LARVA_HOOK = "LARVA_HOOK".toInternalName() @SubscribeEvent fun onTick(event: LorenzTickEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt index 2f5275fc066f..b9e23d5fe19a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt @@ -22,7 +22,7 @@ object RiftOdonata { private var hasBottleInHand = false private val ODONATA_SKULL_TEXTURE by lazy { SkullTextureHolder.getTexture("MOB_ODONATA") } - private val emptyBottle by lazy { "EMPTY_ODONATA_BOTTLE".toInternalName() } + private val emptyBottle = "EMPTY_ODONATA_BOTTLE".toInternalName() @SubscribeEvent fun onTick(event: LorenzTickEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/PunchcardHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/PunchcardHighlight.kt index cb402a30337b..7fac9a659521 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/PunchcardHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/PunchcardHighlight.kt @@ -75,7 +75,8 @@ object PunchcardHighlight { private val playerList: MutableSet<String> = mutableSetOf() private val playerQueue = mutableListOf<String>() - private val displayIcon by lazy { "PUNCHCARD_ARTIFACT".toInternalName().getItemStack() } + private val PUNCHCARD_ARTIFACT = "PUNCHCARD_ARTIFACT".toInternalName() + private val displayIcon by lazy { PUNCHCARD_ARTIFACT.getItemStack() } private var display: Renderable = Renderable.string("hello") @SubscribeEvent @@ -120,7 +121,7 @@ object PunchcardHighlight { private fun checkPunchcard() { if (!RiftAPI.inRift()) return - val hasPunchcard = InventoryUtils.isItemInInventory("PUNCHCARD_ARTIFACT".toInternalName()) + val hasPunchcard = InventoryUtils.isItemInInventory(PUNCHCARD_ARTIFACT) if (!hasPunchcard && warningCooldown.passedSince() > 30.seconds) { warningCooldown = SimpleTimeMark.now() ChatUtils.chat("You don't seem to own a Punchcard Artifact, this feature will not work without one.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt index 8d060892a1cd..e5ca70596cef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt @@ -12,7 +12,7 @@ import net.minecraft.entity.passive.EntityHorse @SkyHanniModule object RiftHorsezookaHider { - private val HORSEZOOKA by lazy { "HORSEZOOKA".toInternalName() } + private val HORSEZOOKA = "HORSEZOOKA".toInternalName() @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) fun onCheckRender(event: CheckRenderEntityEvent<EntityHorse>) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt index 022c29b4d121..f578f706a9ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemPriceUtils.kt @@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators object ItemPriceUtils { - private val JACK_O_LANTERN by lazy { "JACK_O_LANTERN".toInternalName() } - private val GOLDEN_CARROT by lazy { "GOLDEN_CARROT".toInternalName() } + private val JACK_O_LANTERN = "JACK_O_LANTERN".toInternalName() + private val GOLDEN_CARROT = "GOLDEN_CARROT".toInternalName() fun NEUInternalName.getPrice( priceSource: ItemPriceSource = ItemPriceSource.BAZAAR_INSTANT_BUY, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index cf0672a09b07..696403b0691a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -56,7 +56,7 @@ object ItemUtils { } } - private val SKYBLOCK_MENU by lazy { "SKYBLOCK_MENU".toInternalName() } + private val SKYBLOCK_MENU = "SKYBLOCK_MENU".toInternalName() fun ItemStack.cleanName() = this.displayName.removeColor() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt index cc0e20efef98..3d80a4f5dd99 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzRarity.kt @@ -18,7 +18,7 @@ enum class LorenzRarity(val color: LorenzColor, val id: Int) { ULTIMATE(LorenzColor.DARK_RED, 10), ; - val chatColorCode by lazy { color.getChatColor() } + val chatColorCode get() = color.getChatColor() val rawName = name.replace("_", " ") fun oneBelow(logError: Boolean = true): LorenzRarity? { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt index 310a0523b72b..30f54ffcdd1a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableInventory.kt @@ -8,7 +8,7 @@ import kotlin.math.ceil object RenderableInventory { - private val inventoryTextures by lazy { ResourceLocation("skyhanni", "gui/slot.png") } + private val inventoryTextures = ResourceLocation("skyhanni", "gui/slot.png") private const val TEXTURE_WIDTH = 90 private const val TEXTURE_HEIGHT = 54 From 04a0e4f3ed643b15baa339746f0be235fc9722b3 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 4 Jan 2025 09:12:30 -0500 Subject: [PATCH 71/93] Backend: *RenderUtils Todos (#3067) --- .../at/hannibal2/skyhanni/utils/ColorUtils.kt | 13 +- .../skyhanni/utils/GuiRenderUtils.kt | 228 ++---------------- .../hannibal2/skyhanni/utils/RenderUtils.kt | 42 +--- .../utils/renderables/RenderableTooltips.kt | 20 +- 4 files changed, 40 insertions(+), 263 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt index 1d61741b4cd9..871f9314f604 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt @@ -14,13 +14,24 @@ object ColorUtils { fun String.getFirstColorCode() = takeIf { it.firstOrNull() == '§' }?.getOrNull(1) + fun getAlpha(color: Int) = color shr 24 and 0xFF + fun getRed(color: Int) = color shr 16 and 0xFF fun getGreen(color: Int) = color shr 8 and 0xFF fun getBlue(color: Int) = color and 0xFF - fun getAlpha(color: Int) = color shr 24 and 0xFF + /** + * Returns a quad of the color's alpha, red, green, and blue values, in that order. + */ + fun getQuad(color: Int): Quad<Float, Float, Float, Float> = + Quad( + getAlpha(color) / 255f, + getRed(color) / 255f, + getGreen(color) / 255f, + getBlue(color) / 255f + ) fun blendRGB(start: Color, end: Color, percent: Double) = Color( (start.red * (1 - percent) + end.red * percent).toInt(), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt index 68ffd74bcca8..f3799815e625 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt @@ -1,8 +1,5 @@ package at.hannibal2.skyhanni.utils -import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressBarConfig -import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager -import at.hannibal2.skyhanni.features.chroma.ChromaType import at.hannibal2.skyhanni.utils.NumberUtil.fractionOf import at.hannibal2.skyhanni.utils.NumberUtil.roundTo import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment @@ -20,16 +17,13 @@ import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL14 import java.awt.Color import java.text.DecimalFormat -import kotlin.math.ceil -import kotlin.math.min /** * Some functions taken from NotEnoughUpdates */ -// TODO cleanup of redundant functions object GuiRenderUtils { - fun drawStringCentered(str: String?, fr: FontRenderer, x: Float, y: Float, shadow: Boolean, color: Int) { + private fun drawStringCentered(str: String?, fr: FontRenderer, x: Float, y: Float, shadow: Boolean, color: Int) { val strLen = fr.getStringWidth(str) val x2 = x - strLen / 2f val y2 = y - fr.FONT_HEIGHT / 2f @@ -46,45 +40,13 @@ object GuiRenderUtils { Minecraft.getMinecraft().fontRendererObj.drawString(str, x.toFloat(), y.toFloat(), 0xffffff, true) } - fun drawTwoLineString(str: String, x: Float, y: Float) { - val desiredSplitIndex = str.length / 2 - var splitIndex = -1 - var lastColorCode = "" - - for (i in desiredSplitIndex downTo 0) { - if (str[i] == ' ') { - splitIndex = i - break - } - } - - if (splitIndex == -1) { - splitIndex = desiredSplitIndex - } - for (i in 0 until desiredSplitIndex) { - if (str[i] == '§' && i + 1 < str.length) { - lastColorCode = str.substring(i, i + 2) - } - } - - val firstString = str.substring(0, splitIndex).trim() - val secondString = lastColorCode + str.substring(splitIndex).trim() - - Minecraft.getMinecraft().fontRendererObj.drawString(firstString, x, y - 5, 0xffffff, true) - Minecraft.getMinecraft().fontRendererObj.drawString(secondString, x, y + 5, 0xffffff, true) - } - fun drawStringCentered(str: String?, x: Int, y: Int) { drawStringCentered( str, Minecraft.getMinecraft().fontRendererObj, x.toFloat(), y.toFloat(), true, 0xffffff, ) } - fun drawStringCentered(str: String?, x: Float, y: Float) { - drawStringCentered(str, x.toInt(), y.toInt()) - } - - fun renderItemStack(item: ItemStack, x: Int, y: Int) { + private fun renderItemStack(item: ItemStack, x: Int, y: Int) { val itemRender = Minecraft.getMinecraft().renderItem RenderHelper.enableGUIStandardItemLighting() itemRender.zLevel = -145f @@ -93,87 +55,6 @@ object GuiRenderUtils { RenderHelper.disableStandardItemLighting() } - // Code taken and edited from NEU - private fun drawTooltip( - textLines: List<String>, - mouseX: Int, - mouseY: Int, - screenHeight: Int, - fr: FontRenderer, - ) { - if (textLines.isNotEmpty()) { - val borderColor = StringUtils.getColor(textLines[0], 0x505000FF) - - GlStateManager.disableRescaleNormal() - RenderHelper.disableStandardItemLighting() - GlStateManager.disableLighting() - GlStateManager.enableDepth() - var tooltipTextWidth = 0 - - for (textLine in textLines) { - val textLineWidth: Int = fr.getStringWidth(textLine) - if (textLineWidth > tooltipTextWidth) { - tooltipTextWidth = textLineWidth - } - } - - val tooltipX = mouseX + 12 - var tooltipY = mouseY - 12 - var tooltipHeight = 8 - - if (textLines.size > 1) tooltipHeight += (textLines.size - 1) * 10 + 2 - GlStateManager.translate(0f, 0f, 100f) - if (tooltipY + tooltipHeight + 6 > screenHeight) tooltipY = screenHeight - tooltipHeight - 6 - // main background - GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, -0xfeffff0, - ) - - // borders - GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColor, - ) - - GuiScreen.drawRect( - tooltipX + tooltipTextWidth + 2, - tooltipY - 3 + 1, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3 - 1, - borderColor, - ) - - GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColor, - ) - - GuiScreen.drawRect( - tooltipX - 3, - tooltipY + tooltipHeight + 2, - tooltipX + tooltipTextWidth + 3, - tooltipY + tooltipHeight + 3, - borderColor, - ) - GlStateManager.translate(0f, 0f, -100f) - GlStateManager.disableDepth() - - for (line in textLines) { - fr.drawString(line, tooltipX.toFloat(), tooltipY.toFloat(), 0xffffff, true) - - tooltipY += if (line == textLines[0]) 12 else 10 - } - - GlStateManager.enableDepth() - GlStateManager.enableLighting() - GlStateManager.enableRescaleNormal() - RenderHelper.enableStandardItemLighting() - } - GlStateManager.disableLighting() - } - - fun drawTooltip(textLines: List<String>, mouseX: Int, mouseY: Int, screenHeight: Int) { - drawTooltip(textLines, mouseX, mouseY, screenHeight, Minecraft.getMinecraft().fontRendererObj) - } - fun isPointInRect(x: Int, y: Int, left: Int, top: Int, width: Int, height: Int) = left <= x && x < left + width && top <= y && y < top + height @@ -217,12 +98,6 @@ object GuiRenderUtils { ) } - private fun barColorGradient(double: Double): Int { - var newDouble = (double - .5) * 2 - if (newDouble < 0) newDouble = 0.0 - return Color((255 * (1 - newDouble)).toInt(), (255 * newDouble).toInt(), 0).rgb - } - fun Int.darkenColor(): Int { val color = Color(this) return Color(color.red / 5, color.green / 5, color.blue / 5).rgb @@ -243,91 +118,18 @@ object GuiRenderUtils { GuiScreen.drawRect(x, y, x + 16, y + 16, color) } - // Taken and edited from NEU <- it's broken - fun renderTexturedBar( - x: Float, - y: Float, - xSize: Float, - completed: Float, - color: Color, - useChroma: Boolean, - texture: SkillProgressBarConfig.TexturedBar.UsedTexture, - height: Float, - ) { - GlStateManager.pushMatrix() - GlStateManager.translate(x, y, 0f) - val w = xSize.toInt() - val w_2 = w / 2 - val k = min(w.toDouble(), ceil((completed * w).toDouble())).toInt() - val vanilla = texture == SkillProgressBarConfig.TexturedBar.UsedTexture.MATCH_PACK - val vMinEmpty = if (vanilla) 64 / 256f else 0f - val vMaxEmpty = if (vanilla) 69 / 256f else .5f - val vMinFilled = if (vanilla) 69 / 256f else .5f - val vMaxFilled = if (vanilla) 74 / 256f else 1f - - if (useChroma) { - ChromaShaderManager.begin(ChromaType.TEXTURED) - GlStateManager.color( - Color.LIGHT_GRAY.darker().red / 255f, - Color.LIGHT_GRAY.darker().green / 255f, - Color.LIGHT_GRAY.darker().blue / 255f, - 1f, - ) - } else { - GlStateManager.color(color.darker().red / 255f, color.darker().green / 255f, color.darker().blue / 255f, 1f) - } - - drawTexturedRect(x, y, w_2.toFloat(), height, 0f, w_2 / xSize, vMinEmpty, vMaxEmpty, GL11.GL_NEAREST) - drawTexturedRect(x + w_2, y, w_2.toFloat(), height, 1 - w_2 / xSize, 1f, vMinEmpty, vMaxEmpty, GL11.GL_NEAREST) - - if (useChroma) { - GlStateManager.color(Color.WHITE.red / 255f, Color.WHITE.green / 255f, Color.WHITE.blue / 255f, 1f) - } else { - GlStateManager.color(color.red / 255f, color.green / 255f, color.blue / 255f, 1f) - } - - if (k > 0) { - val uMax = w_2.toDouble().coerceAtMost(k.toDouble() / xSize).toFloat() - val width = w_2.coerceAtMost(k).toFloat() - drawTexturedRect(x, y, width, height, 0f, uMax, vMinFilled, vMaxFilled, GL11.GL_NEAREST) - if (completed > 0.5f) { - drawTexturedRect( - x + w_2, - y, - (k - w_2).toFloat(), - height, - 1 - w_2 / xSize, - 1 + (k - w) / xSize, - vMinFilled, - vMaxFilled, - GL11.GL_NEAREST, - ) - } - } - if (useChroma) { - ChromaShaderManager.end() - } - GlStateManager.popMatrix() - } - - /**@Mojang */ + /** @Mojang */ fun drawGradientRect( left: Int, top: Int, right: Int, bottom: Int, - startColor: Int, - endColor: Int, - zLevel: Double, + startColor: Int = -0xfeffff0, + endColor: Int = -0xfeffff0, + zLevel: Double = 0.0, ) { - val f = (startColor shr 24 and 255).toFloat() / 255.0f - val g = (startColor shr 16 and 255).toFloat() / 255.0f - val h = (startColor shr 8 and 255).toFloat() / 255.0f - val i = (startColor and 255).toFloat() / 255.0f - val j = (endColor shr 24 and 255).toFloat() / 255.0f - val k = (endColor shr 16 and 255).toFloat() / 255.0f - val l = (endColor shr 8 and 255).toFloat() / 255.0f - val m = (endColor and 255).toFloat() / 255.0f + val (startAlpha, startRed, startGreen, startBlue) = ColorUtils.getQuad(startColor) + val (endAlpha, endRed, endGreen, endBlue) = ColorUtils.getQuad(endColor) GlStateManager.disableTexture2D() GlStateManager.enableBlend() GlStateManager.disableAlpha() @@ -336,10 +138,14 @@ object GuiRenderUtils { val tessellator = Tessellator.getInstance() val worldRenderer = tessellator.worldRenderer worldRenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) - worldRenderer.pos(right.toDouble(), top.toDouble(), zLevel).color(g, h, i, f).endVertex() - worldRenderer.pos(left.toDouble(), top.toDouble(), zLevel).color(g, h, i, f).endVertex() - worldRenderer.pos(left.toDouble(), bottom.toDouble(), zLevel).color(k, l, m, j).endVertex() - worldRenderer.pos(right.toDouble(), bottom.toDouble(), zLevel).color(k, l, m, j).endVertex() + worldRenderer.pos(right.toDouble(), top.toDouble(), zLevel) + .color(startRed, startGreen, startBlue, startAlpha).endVertex() + worldRenderer.pos(left.toDouble(), top.toDouble(), zLevel) + .color(startRed, startGreen, startBlue, startAlpha).endVertex() + worldRenderer.pos(left.toDouble(), bottom.toDouble(), zLevel) + .color(endRed, endGreen, endBlue, endAlpha).endVertex() + worldRenderer.pos(right.toDouble(), bottom.toDouble(), zLevel) + .color(endRed, endGreen, endBlue, endAlpha).endVertex() tessellator.draw() GlStateManager.shadeModel(7424) GlStateManager.disableBlend() @@ -368,7 +174,7 @@ object GuiRenderUtils { } // Taken from NEU - fun drawTexturedRect( + private fun drawTexturedRect( x: Float, y: Float, width: Float, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 3a3a2daaca77..86b5aebd5a89 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -1912,7 +1912,7 @@ object RenderUtils { GlStateManager.pushMatrix() ShaderManager.enableShader(ShaderManager.Shaders.ROUNDED_RECT_OUTLINE) - drawGradientRect( + GuiRenderUtils.drawGradientRect( x - borderAdjustment, y - borderAdjustment, x + width + borderAdjustment, @@ -1925,46 +1925,6 @@ object RenderUtils { GlStateManager.popMatrix() } - // todo merge with the one in GuiRenderUtils - fun drawGradientRect( - left: Int, - top: Int, - right: Int, - bottom: Int, - startColor: Int = -0xfeffff0, - endColor: Int = -0xfeffff0, - ) { - val startAlpha = (startColor shr 24 and 255).toFloat() / 255.0f - val startRed = (startColor shr 16 and 255).toFloat() / 255.0f - val startGreen = (startColor shr 8 and 255).toFloat() / 255.0f - val startBlue = (startColor and 255).toFloat() / 255.0f - val endAlpha = (endColor shr 24 and 255).toFloat() / 255.0f - val endRed = (endColor shr 16 and 255).toFloat() / 255.0f - val endGreen = (endColor shr 8 and 255).toFloat() / 255.0f - val endBlue = (endColor and 255).toFloat() / 255.0f - GlStateManager.disableTexture2D() - GlStateManager.enableBlend() - GlStateManager.disableAlpha() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0) - GlStateManager.shadeModel(7425) - val tessellator = Tessellator.getInstance() - val worldrenderer = tessellator.worldRenderer - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR) - worldrenderer.pos(right.toDouble(), top.toDouble(), 0.0) - .color(startRed, startGreen, startBlue, startAlpha).endVertex() - worldrenderer.pos(left.toDouble(), top.toDouble(), 0.0) - .color(startRed, startGreen, startBlue, startAlpha).endVertex() - worldrenderer.pos(left.toDouble(), bottom.toDouble(), 0.0) - .color(endRed, endGreen, endBlue, endAlpha).endVertex() - worldrenderer.pos(right.toDouble(), bottom.toDouble(), 0.0) - .color(endRed, endGreen, endBlue, endAlpha).endVertex() - tessellator.draw() - GlStateManager.shadeModel(7424) - GlStateManager.disableBlend() - GlStateManager.enableAlpha() - GlStateManager.enableTexture2D() - } - fun getAlpha(): Float { colorBuffer.clear() GlStateManager.getFloat(GL11.GL_CURRENT_COLOR, colorBuffer) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt index 906371bf4300..d1270b3c545c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt @@ -1,9 +1,9 @@ package at.hannibal2.skyhanni.utils.renderables import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.GuiRenderUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.compat.GuiScreenUtils import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned import net.minecraft.client.Minecraft @@ -77,38 +77,38 @@ object RenderableTooltips { val zLevel = 400f GlStateManager.translate(tooltipX.toFloat(), tooltipY.toFloat(), zLevel) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = -4, right = tooltipTextWidth + 2, bottom = -3, ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = tooltipHeight + 3, right = tooltipTextWidth + 2, bottom = tooltipHeight + 4, ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = -3, right = tooltipTextWidth + 2, bottom = tooltipHeight + 3, ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -4, top = -3, right = -3, bottom = tooltipHeight + 3, ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = tooltipTextWidth + 2, top = -3, right = tooltipTextWidth + 3, bottom = tooltipHeight + 3, ) val borderColorEnd = borderColorStart and 0xFEFEFE shr 1 or (borderColorStart and -0x1000000) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = -3 + 1, right = -3 + 1, @@ -116,7 +116,7 @@ object RenderableTooltips { startColor = borderColorStart, endColor = borderColorEnd ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = tooltipTextWidth + 1, top = -3 + 1, right = tooltipTextWidth + 2, @@ -124,7 +124,7 @@ object RenderableTooltips { startColor = borderColorStart, endColor = borderColorEnd ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = -3, right = tooltipTextWidth + 2, @@ -132,7 +132,7 @@ object RenderableTooltips { startColor = borderColorStart, endColor = borderColorStart ) - RenderUtils.drawGradientRect( + GuiRenderUtils.drawGradientRect( left = -3, top = tooltipHeight + 2, right = tooltipTextWidth + 2, From a5a82db0ebfbe20f891f857b60e2364fc3b75ab5 Mon Sep 17 00:00:00 2001 From: Luna <lunaynx@gmail.com> Date: Sat, 4 Jan 2025 15:14:16 +0100 Subject: [PATCH 72/93] Fix: Deep Caverns Guide Small Chat Fixes (#3148) --- .../skyhanni/features/mining/DeepCavernsGuide.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt index bc03023bb78b..1bbb145699ab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -98,7 +99,9 @@ object DeepCavernsGuide { if (!isEnabled()) return if (LorenzUtils.skyBlockArea != "Gunpowder Mines") return if (notUnlockedPattern.matches(event.message)) { - start() + DelayedRun.runNextTick { + start() + } } } @@ -131,8 +134,9 @@ object DeepCavernsGuide { prefixColor = "§c", ) } + @Suppress("MaxLineLength") ChatUtils.chat( - "Automatically enabling Deep Caverns Guide, helping you find the way to the bottom of the Deep Caverns and the path to Rhys." + "Automatically enabling the Deep Caverns Guide, helping you find the way to the bottom of the Deep Caverns and the path to Rhys." ) } From 8c03a5bb44fada3584ed08f2e09d3cda068aab2e Mon Sep 17 00:00:00 2001 From: Luna <lunaynx@gmail.com> Date: Sat, 4 Jan 2025 15:35:04 +0100 Subject: [PATCH 73/93] Fix: Rift Transfer Logic (#3144) --- .../features/inventory/HideNotClickableItems.kt | 12 ++---------- .../hannibal2/skyhanni/features/rift/RiftAPI.kt | 3 +++ .../skyhanni/utils/SkyBlockItemModifierUtils.kt | 17 +++++++++-------- .../hannibal2/skyhanni/utils/UtilsPatterns.kt | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index d85514b98ea9..e0d4e4a4e81c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -261,16 +261,8 @@ object HideNotClickableItems { if (chestName != "Rift Transfer Chest") return false showGreenLine = true - val riftTransferable = stack.isRiftTransferable() ?: return true - if (riftTransferable) { - return false - } - if (RiftAPI.inRift()) { - val riftExportable = stack.isRiftExportable() ?: return true - if (riftExportable) { - return false - } - } + + if (stack.isRiftTransferable() || stack.isRiftExportable()) return false hideReason = "Not Rift-Transferable!" return true diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt index a8c34e30e39b..b01597fa2a68 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/RiftAPI.kt @@ -11,6 +11,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRiftExportable +import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.wasRiftTransferred import net.minecraft.item.ItemStack @SkyHanniModule @@ -31,6 +33,7 @@ object RiftAPI { get() = this?.getInternalName() == blowgun fun ItemStack.motesNpcPrice(): Double? { + if (isRiftExportable() && wasRiftTransferred()) return null val baseMotes = motesPrice[getInternalName()] ?: return null val burgerStacks = config.motes.burgerStacks val pricePer = baseMotes + (burgerStacks * 5) * baseMotes / 100 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index 093b5a45b1f0..ae35772c50e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName +import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.JsonObject import net.minecraft.item.Item @@ -75,22 +76,22 @@ object SkyBlockItemModifierUtils { return data.heldItem } - fun ItemStack.isRiftTransferable(): Boolean? { + fun ItemStack.isRiftTransferable(): Boolean { val data = cachedData - if (data.riftTransferable == null) { - data.riftTransferable = getLore().any { it == "§5§kX§5 Rift-Transferable §kX" } - } return data.riftTransferable + ?: UtilsPatterns.riftTransferablePattern.anyMatches(getLore()) + .also { data.riftTransferable = it } } - fun ItemStack.isRiftExportable(): Boolean? { + fun ItemStack.isRiftExportable(): Boolean { val data = cachedData - if (data.riftExportable == null) { - data.riftExportable = getLore().any { it == "§5§kX§5 Rift-Exportable §kX" } - } return data.riftExportable + ?: UtilsPatterns.riftExportablePattern.anyMatches(getLore()) + .also { data.riftExportable = it } } + fun ItemStack.wasRiftTransferred(): Boolean = getAttributeBoolean("rift_transferred") + private fun ItemStack.getPetInfo() = ConfigManager.gson.fromJson(getExtraAttributes()?.getString("petInfo"), JsonObject::class.java) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 0dc4545944d1..4540fd550756 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -108,6 +108,22 @@ object UtilsPatterns { ".*Sack", ) + /** + * REGEX-TEST: §5§kX§5 Rift-Transferable §kX + */ + val riftTransferablePattern by patternGroup.pattern( + "item.rift.transferable", + "§5§kX§5 Rift-Transferable §kX", + ) + /** + * REGEX-TEST: §5§kX§5 Rift-Exportable §kX + * REGEX-TEST: §5§kX§5 Rift-Exported §kX + */ + val riftExportablePattern by patternGroup.pattern( + "item.rift.exportable", + "§5§kX§5 Rift-Export(?:able|ed) §kX", + ) + /** * REGEX-TEST: Late Winter * REGEX-TEST: Early Spring From c735cfaa9abedb001c1099206d95211f9a7b5054 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 15:36:10 +0100 Subject: [PATCH 74/93] clarify label --- .../skyhanni/features/inventory/HideNotClickableItems.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index e0d4e4a4e81c..cf3ffc0a39c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -264,7 +264,7 @@ object HideNotClickableItems { if (stack.isRiftTransferable() || stack.isRiftExportable()) return false - hideReason = "Not Rift-Transferable!" + hideReason = "Not Rift-Transferable or Rift-Transportable!" return true } From 1f1bc4073d76275bd8a4189a64c04c97c4e9127e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 15:37:42 +0100 Subject: [PATCH 75/93] It's called Rift-Exportable --- .../skyhanni/features/inventory/HideNotClickableItems.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index cf3ffc0a39c8..835a85d1dd49 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -264,7 +264,7 @@ object HideNotClickableItems { if (stack.isRiftTransferable() || stack.isRiftExportable()) return false - hideReason = "Not Rift-Transferable or Rift-Transportable!" + hideReason = "Not Rift-Transferable or Rift-Exportable!" return true } From 33468ebe6a0375e0d2440457d84efb29567301f5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:10:27 +0100 Subject: [PATCH 76/93] code cleanup --- .../hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt | 3 +-- src/main/java/at/hannibal2/skyhanni/utils/json/Shimmy.kt | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt index 6e497efcae3e..dfb6bd6952e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/hotswap/HotswapSupportImpl.kt @@ -29,8 +29,7 @@ class HotswapSupportImpl : HotswapSupportHandle { MinecraftForge.EVENT_BUS.register(instance) } else { SkyHanniMod.modules.remove(instance) - primaryConstructor.isAccessible = true - val newInstance = primaryConstructor.newInstance() + val newInstance = primaryConstructor.makeAccessible().newInstance() ChatUtils.chat("Reconstructing $instance -> $newInstance!") val instanceField = runCatching { instance.javaClass.getDeclaredField("INSTANCE") }.getOrNull() ?.takeIf { it.type == instance.javaClass } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/Shimmy.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/Shimmy.kt index 31022da58d19..cf7707601bfe 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/Shimmy.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/Shimmy.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils.json import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import com.google.gson.JsonElement import java.lang.reflect.Field @@ -13,8 +14,7 @@ class Shimmy private constructor( private fun shimmy(source: Any?, fieldName: String): Any? { if (source == null) return null return try { - val declaredField = source.javaClass.getDeclaredField(fieldName) - declaredField.isAccessible = true + val declaredField = source.javaClass.getDeclaredField(fieldName).makeAccessible() declaredField.get(source) } catch (e: NoSuchFieldException) { null @@ -32,8 +32,7 @@ class Shimmy private constructor( if (source == null) return null val lastName = path.last() return try { - val field = source.javaClass.getDeclaredField(lastName) - field.isAccessible = true + val field = source.javaClass.getDeclaredField(lastName).makeAccessible() Shimmy( source, field, From bdf2d3f3c34d70cb26695e81d33d4786739ed422 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:28:27 +0100 Subject: [PATCH 77/93] Backend: ModVersion changes (#3156) Co-authored-by: Empa <itsempa@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 14 +++----- .../skyhanni/api/event/EventHandler.kt | 2 +- .../hannibal2/skyhanni/config/Features.java | 2 +- .../skyhanni/data/repo/RepoManager.kt | 2 +- .../hannibal2/skyhanni/events/LorenzEvent.kt | 2 +- .../DefaultConfigFeatures.kt | 10 +++--- .../misc/update/GuiOptionEditorUpdateCheck.kt | 2 +- .../features/misc/update/UpdateManager.kt | 24 +++++-------- .../hannibal2/skyhanni/test/DebugCommand.kt | 2 +- .../test/SkyHanniConfigSearchResetCommand.kt | 2 +- .../skyhanni/test/SkyHanniDebugsAndTests.kt | 2 +- .../skyhanni/test/command/ErrorManager.kt | 6 ++-- .../at/hannibal2/skyhanni/utils/APIUtils.kt | 2 +- .../utils/json/SkyHanniTypeAdapters.kt | 5 +-- .../skyhanni/utils/system/ModVersion.kt | 34 ++++++++----------- 15 files changed, 46 insertions(+), 65 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 2777b94f7d81..8feca65b7f98 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -29,7 +29,6 @@ import kotlinx.coroutines.launch import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraftforge.common.MinecraftForge -import net.minecraftforge.fml.common.Loader import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent @@ -43,7 +42,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "@MOD_VERSION@", + version = SkyHanniMod.VERSION, ) class SkyHanniMod { @@ -107,15 +106,10 @@ class SkyHanniMod { companion object { - const val MODID = "skyhanni" + const val MODID: String = "skyhanni" + const val VERSION: String = "@MOD_VERSION@" - val modVersion: ModVersion by lazy { - ModVersion.fromString(Loader.instance().indexedModList[MODID]!!.version) - } - - @JvmStatic - val version: String - get() = modVersion.asString + val modVersion: ModVersion = ModVersion.fromString(VERSION) val isBetaVersion: Boolean get() = modVersion.isBeta diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt index 040ecc43c9a7..43f0879642fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt @@ -73,7 +73,7 @@ class EventHandler<T : SkyHanniEvent> private constructor( val hiddenErrors = errors - 3 ChatUtils.chat( Text.text( - "§c[SkyHanni/${SkyHanniMod.version}] $hiddenErrors more errors in $name are hidden!", + "§c[SkyHanni/${SkyHanniMod.VERSION}] $hiddenErrors more errors in $name are hidden!", ), ) } diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 06eb5c57eff9..11d60fdef999 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -68,7 +68,7 @@ public String getTitle() { if (LorenzUtils.INSTANCE.isAprilFoolsDay()) modName = new StringBuilder().append("اسکای هانی").reverse().toString(); // Minecraft does not render RTL strings very nicely, so we reverse the string here. Not authentic, but close enough. - return modName + " " + SkyHanniMod.getVersion() + " by §channibal2§r, config by §5Moulberry §rand §5nea89"; + return modName + " " + SkyHanniMod.VERSION + " by §channibal2§r, config by §5Moulberry §rand §5nea89"; } /* diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 39f30eec4668..67f714bdd1fd 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -240,7 +240,7 @@ class RepoManager(private val configLocation: File) { val text = mutableListOf<IChatComponent>() text.add( ( - "§c[SkyHanni-${SkyHanniMod.version}] §7Repo Issue! Some features may not work. " + + "§c[SkyHanni-${SkyHanniMod.VERSION}] §7Repo Issue! Some features may not work. " + "Please report this error on the Discord!" ).asComponent(), ) diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 29ba8acec334..81fc79c2f6fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -69,7 +69,7 @@ abstract class LorenzEvent : Event() { val hiddenErrors = errors - visibleErrors ChatUtils.chat( Text.text( - "§c[SkyHanni-${SkyHanniMod.version}] $hiddenErrors more errors in $eventName are hidden!", + "§c[SkyHanni-${SkyHanniMod.VERSION}] $hiddenErrors more errors in $eventName are hidden!", ), ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt index 745928cee13c..b83e1f0e9f06 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt @@ -28,10 +28,10 @@ object DefaultConfigFeatures { } val knownToggles = SkyHanniMod.knownFeaturesData.knownFeatures - val updated = SkyHanniMod.version !in knownToggles + val updated = SkyHanniMod.VERSION !in knownToggles val processor = FeatureToggleProcessor() ConfigProcessorDriver(processor).processConfig(SkyHanniMod.feature) - knownToggles[SkyHanniMod.version] = processor.allOptions.map { it.path } + knownToggles[SkyHanniMod.VERSION] = processor.allOptions.map { it.path } SkyHanniMod.configManager.saveConfig(ConfigFileType.KNOWN_FEATURES, "Updated known feature flags") if (!SkyHanniMod.feature.storage.hasPlayedBefore) { SkyHanniMod.feature.storage.hasPlayedBefore = true @@ -42,12 +42,12 @@ object DefaultConfigFeatures { "§eClick to run /shdefaultoptions!" ) } else if (updated) { - val lastVersion = knownToggles.keys.last { it != SkyHanniMod.version } - val command = "/shdefaultoptions $lastVersion ${SkyHanniMod.version}" + val lastVersion = knownToggles.keys.last { it != SkyHanniMod.VERSION } + val command = "/shdefaultoptions $lastVersion ${SkyHanniMod.VERSION}" ChatUtils.clickableChat( "Looks like you updated SkyHanni. " + "Click here to configure the newly introduced options, or run $command.", - onClick = { onCommand(lastVersion, SkyHanniMod.version) }, + onClick = { onCommand(lastVersion, SkyHanniMod.VERSION) }, "§eClick to run /shdefaultoptions!" ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt index 5eee15d4d941..9f3834de671e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt @@ -45,7 +45,7 @@ class GuiOptionEditorUpdateCheck(option: ProcessedOption) : GuiOptionEditor(opti val widthRemaining = adjustedWidth - button.width - 10 GlStateManager.scale(2F, 2F, 1F) - val currentVersion = SkyHanniMod.version + val currentVersion = SkyHanniMod.VERSION val sameVersion = currentVersion.equals(nextVersion, ignoreCase = true) TextRenderUtils.drawStringCenteredScaledMaxWidth( "${if (UpdateManager.updateState == UpdateManager.UpdateState.NONE) GREEN else RED}$currentVersion" + diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index 9bf25e4fd53a..d6ef3ff612b6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.system.ModVersion import com.google.gson.JsonElement import io.github.notenoughupdates.moulconfig.observer.Property import io.github.notenoughupdates.moulconfig.processor.MoulConfigProcessor @@ -133,21 +134,14 @@ object UpdateManager { CustomGithubReleaseUpdateSource("hannibal002", "SkyHanni"), UpdateTarget.deleteAndSaveInTheSameFolder(UpdateManager::class.java), object : CurrentVersion { - val normalDelegate = CurrentVersion.ofTag(SkyHanniMod.version) - override fun display(): String { - if (SkyHanniMod.feature.dev.debug.alwaysOutdated) - return "Force Outdated" - return normalDelegate.display() - } - - override fun isOlderThan(element: JsonElement): Boolean { - if (SkyHanniMod.feature.dev.debug.alwaysOutdated) - return true - return normalDelegate.isOlderThan(element) - } - - override fun toString(): String { - return "ForceOutdateDelegate($normalDelegate)" + private val debug get() = SkyHanniMod.feature.dev.debug.alwaysOutdated + override fun display(): String = if (debug) "Force Outdated" else SkyHanniMod.VERSION + + override fun isOlderThan(element: JsonElement?): Boolean { + if (debug) return true + val asString = element?.asString ?: return true + val otherVersion = ModVersion.fromString(asString) + return SkyHanniMod.modVersion < otherVersion } }, SkyHanniMod.MODID, diff --git a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt index ba6e10ba590e..8f0897ca82e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt @@ -23,7 +23,7 @@ object DebugCommand { } val list = mutableListOf<String>() list.add("```") - list.add("= Debug Information for SkyHanni ${SkyHanniMod.version} =") + list.add("= Debug Information for SkyHanni ${SkyHanniMod.VERSION} =") list.add("") val search = args.joinToString(" ") diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt index 3dcb831b0ae3..b180cd9cf3c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniConfigSearchResetCommand.kt @@ -169,7 +169,7 @@ object SkyHanniConfigSearchResetCommand { val elements = findConfigElements(configFilter, classFilter) val builder = StringBuilder() builder.append("```\n") - builder.append("Search config for SkyHanni ${SkyHanniMod.version}\n") + builder.append("Search config for SkyHanni ${SkyHanniMod.VERSION}\n") builder.append("configSearchTerm: $configSearchTerm\n") builder.append("classSearchTerm: $classSearchTerm\n") builder.append("\n") diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 8bc25033843a..3b51044d225e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -340,7 +340,7 @@ object SkyHanniDebugsAndTests { } fun debugVersion() { - val name = "SkyHanni ${SkyHanniMod.version}" + val name = "SkyHanni ${SkyHanniMod.VERSION}" ChatUtils.chat("§eYou are using $name") OSUtils.copyToClipboard(name) } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index cb71f7d2a6a0..50e5427cee8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -155,13 +155,13 @@ object ErrorManager { val extraDataString = buildExtraDataString(extraData) val rawMessage = message.removeColor() - errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $rawMessage\n \n$stackTrace\n$extraDataString```" + errorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.VERSION}: $rawMessage\n \n$stackTrace\n$extraDataString```" fullErrorMessages[randomId] = - "```\nSkyHanni ${SkyHanniMod.version}: $rawMessage\n(full stack trace)\n \n$fullStackTrace\n$extraDataString```" + "```\nSkyHanni ${SkyHanniMod.VERSION}: $rawMessage\n(full stack trace)\n \n$fullStackTrace\n$extraDataString```" val finalMessage = buildFinalMessage(message) ?: return ChatUtils.clickableChat( - "§c[SkyHanni-${SkyHanniMod.version}]: $finalMessage Click here to copy the error into the clipboard.", + "§c[SkyHanni-${SkyHanniMod.VERSION}]: $finalMessage Click here to copy the error into the clipboard.", onClick = { copyError(randomId) }, "§eClick to copy!", prefix = false, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt index 9524836e427f..08d029057799 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt @@ -54,7 +54,7 @@ object APIUtils { data class ApiResponse(val success: Boolean, val message: String?, val data: JsonObject) private val builder: HttpClientBuilder = - HttpClients.custom().setUserAgent("SkyHanni/${SkyHanniMod.version}") + HttpClients.custom().setUserAgent("SkyHanni/${SkyHanniMod.VERSION}") .setDefaultHeaders( mutableListOf( BasicHeader("Pragma", "no-cache"), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt index fa98d0587f82..7c81fc8dab34 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt @@ -83,10 +83,7 @@ object SkyHanniTypeAdapters { { SkyblockStat.getValue(this.uppercase()) }, ) - val MOD_VERSION: TypeAdapter<ModVersion> = SimpleStringTypeAdapter( - { asString }, - { ModVersion.fromString(this) }, - ) + val MOD_VERSION: TypeAdapter<ModVersion> = SimpleStringTypeAdapter(ModVersion::asString, ModVersion::fromString) val TRACKER_DISPLAY_MODE = SimpleStringTypeAdapter.forEnum<SkyHanniTracker.DefaultDisplayMode>() val ISLAND_TYPE = SimpleStringTypeAdapter.forEnum<IslandType>() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt index 722f869da873..7fb88a23550a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt @@ -1,10 +1,23 @@ package at.hannibal2.skyhanni.utils.system -data class ModVersion(val major: Int, val minor: Int, val beta: Int) { +data class ModVersion(val major: Int, val minor: Int, val beta: Int) : Comparable<ModVersion> { + + val isBeta get() = beta != 0 + + inline val asString get() = toString() + + override fun toString(): String = "$major.$minor.$beta" + + override fun compareTo(other: ModVersion): Int { + return when { + major != other.major -> major.compareTo(other.major) + minor != other.minor -> minor.compareTo(other.minor) + else -> beta.compareTo(other.beta) + } + } companion object { fun fromString(version: String): ModVersion { - val parts = version.split('.') return ModVersion( parts.getOrNull(0)?.toIntOrNull() ?: 0, @@ -13,21 +26,4 @@ data class ModVersion(val major: Int, val minor: Int, val beta: Int) { ) } } - - val isBeta = beta != 0 - - val asString: String - get() = toString() - - override fun toString(): String { - return "$major.$minor.$beta" - } - - operator fun compareTo(other: ModVersion): Int { - return when { - major != other.major -> major.compareTo(other.major) - minor != other.minor -> minor.compareTo(other.minor) - else -> beta.compareTo(other.beta) - } - } } From 185f92bb77add1117f7ae0c8b006f771b18ed55a Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:11:01 +0100 Subject: [PATCH 78/93] Fix: Carnival Tokens Owned (#3153) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/inventory/CarnivalShopHelper.kt | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt index ab82b914fc58..71339e972fa0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/CarnivalShopHelper.kt @@ -6,9 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuCarnivalTokenCostJson import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuMiscJson import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.features.inventory.EssenceShopHelper.essenceUpgradePattern @@ -125,16 +123,6 @@ object CarnivalShopHelper { tokensNeeded = 0 } - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - processInventoryEvent(event) - } - - @SubscribeEvent - fun onInventoryUpdated(event: InventoryUpdatedEvent) { - processInventoryEvent(event) - } - private fun checkSavedProgress() { val storage = ProfileStorageData.profileSpecific?.carnival?.carnivalShopProgress ?: return for (key in storage.keys) { @@ -225,23 +213,33 @@ object CarnivalShopHelper { ) } - private fun processInventoryEvent(event: InventoryOpenEvent) { + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { if (!isEnabled() || repoEventShops.isEmpty()) return - processTokenShopFooter(event) - val matchingShop = repoEventShops.find { it.shopName.equals(event.inventoryName, ignoreCase = true) } ?: return - currentEventType = matchingShop.shopName - processEventShopUpgrades(event.inventoryItems) + var shouldUpdate = processTokenShopFooter(event) + repoEventShops.find { it.shopName.equals(event.inventoryName, ignoreCase = true) }?.let { matchingShop -> + currentEventType = matchingShop.shopName + processEventShopUpgrades(event.inventoryItems) + shouldUpdate = true + } + + if (!shouldUpdate) return regenerateShopSpecificItemStack() regenerateOverviewItemStack() saveProgress() } - private fun processTokenShopFooter(event: InventoryOpenEvent) { + private fun processTokenShopFooter(event: InventoryOpenEvent): Boolean { val tokenFooterStack = event.inventoryItems[32] - if (tokenFooterStack === null || tokenFooterStack.displayName != "§eCarnival Tokens") return + if (tokenFooterStack === null || tokenFooterStack.displayName != "§eCarnival Tokens") return false currentTokenCountPattern.firstMatcher(tokenFooterStack.getLore()) { - tokensOwned = groupOrNull("tokens")?.formatInt() ?: 0 + val new = groupOrNull("tokens")?.formatInt() ?: 0 + val changed = new != tokensOwned + tokensOwned = new + return changed } + + return false } private fun processEventShopUpgrades(inventoryItems: Map<Int, ItemStack>) { From f981f5c0bd159cf1133afda1a673bb826e83fd50 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:11:17 +0100 Subject: [PATCH 79/93] Fix: ConcurrentModificationException in ChestValue (#3150) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/features/inventory/ChestValue.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index 0baae0861fba..867ed6c98b18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -42,7 +42,7 @@ object ChestValue { private val config get() = SkyHanniMod.feature.inventory.chestValueConfig private var display = emptyList<List<Any>>() - private val chestItems = mutableMapOf<String, Item>() + private var chestItems = mapOf<String, Item>() private val inInventory get() = isValidStorage() private var inOwnInventory = false @@ -88,7 +88,7 @@ object ChestValue { @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { - chestItems.clear() + chestItems = emptyMap() } private fun update() { @@ -197,7 +197,7 @@ object ChestValue { put(it.slotIndex, it.stack) } } - chestItems.clear() + val items = mutableMapOf<String, Item>() for ((i, stack) in stacks) { val internalName = stack.getInternalNameOrNull() ?: continue if (internalName.getItemStackOrNull() == null) continue @@ -208,13 +208,14 @@ object ChestValue { total /= 2 list.add("§aTotal: §6§l${total.formatPrice()} coins") if (total == 0.0) continue - val item = chestItems.getOrPut(key) { + val item = items.getOrPut(key) { Item(mutableListOf(), 0, stack, 0.0, list) } item.index.add(i) item.amount += stack.stackSize item.total += total * stack.stackSize } + chestItems = items } private fun Double.formatPrice(): String { From 08cb97623e8e74b8a69c875f73991a03490eaf29 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 4 Jan 2025 14:32:16 -0500 Subject: [PATCH 80/93] Backend: Storage Classes to Kotlin (#3106) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- .../skyhanni/config/ConfigManager.kt | 8 +- .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../hannibal2/skyhanni/config/Features.java | 163 ---- .../at/hannibal2/skyhanni/config/Features.kt | 148 +++ .../hannibal2/skyhanni/config/SackData.java | 26 - .../at/hannibal2/skyhanni/config/SackData.kt | 21 + .../skyhanni/config/core/config/Position.java | 4 +- .../config/storage/PlayerSpecificStorage.java | 81 -- .../config/storage/PlayerSpecificStorage.kt | 71 ++ .../storage/ProfileSpecificStorage.java | 888 ------------------ .../config/storage/ProfileSpecificStorage.kt | 836 +++++++++++++++++ .../skyhanni/config/storage/Storage.java | 58 -- .../skyhanni/config/storage/Storage.kt | 52 + .../at/hannibal2/skyhanni/data/BitsAPI.kt | 6 +- .../java/at/hannibal2/skyhanni/data/PetAPI.kt | 2 +- .../at/hannibal2/skyhanni/data/QuiverAPI.kt | 54 +- .../features/dungeon/CroesusChestTracker.kt | 2 +- .../features/event/diana/AllBurrowsList.kt | 11 +- .../event/diana/DianaProfitTracker.kt | 20 +- .../diana/MythologicalCreatureTracker.kt | 2 +- .../garden/contest/FarmingPersonalBestGain.kt | 2 + .../inventory/caketracker/CakeTracker.kt | 2 +- .../features/minion/MinionFeatures.kt | 21 +- .../DefaultConfigFeatures.kt | 8 +- .../FeatureToggleProcessor.kt | 10 +- .../misc/update/GuiOptionEditorUpdateCheck.kt | 3 +- .../hannibal2/skyhanni/utils/ConfigUtils.kt | 2 +- .../json/EnumSkippingTypeAdapterFactory.kt | 5 +- 29 files changed, 1215 insertions(+), 1295 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/Features.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/Features.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/SackData.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/SackData.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/storage/Storage.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 926ed02850e8..42348b4ad573 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] libautoupdate = "1.3.1" -moulconfig = "3.0.0-beta.7" +moulconfig = "3.5.0" headlessLwjgl = "1.7.2" jbAnnotations = "24.1.0" diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index dfb6285e78cd..885fd22b57a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.IdentityCharacteristics import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.json.BaseGsonBuilder import at.hannibal2.skyhanni.utils.system.PlatformUtils @@ -92,7 +93,9 @@ class ConfigManager { processor = MoulConfigProcessor(SkyHanniMod.feature) BuiltinMoulConfigGuis.addProcessors(processor) UpdateManager.injectConfigProcessor(processor) - ConfigProcessorDriver(processor).processConfig(features) + val driver = ConfigProcessorDriver(processor) + driver.warnForPrivateFields = false + driver.processConfig(features) try { findPositionLinks(features, mutableSetOf()) @@ -124,8 +127,7 @@ class ConfigManager { if (ic in slog) return slog.add(ic) var missingConfigLink = false - for (field in obj.javaClass.fields) { - field.isAccessible = true + for (field in obj.javaClass.declaredFields.map { it.makeAccessible() }) { if (field.type != Position::class.java && field.type != PositionList::class.java) { findPositionLinks(field.get(obj), slog) continue diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 69ed7f8d8ca2..ca280b224fd0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 69 + const val CONFIG_VERSION = 70 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java deleted file mode 100644 index 11d60fdef999..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ /dev/null @@ -1,163 +0,0 @@ -package at.hannibal2.skyhanni.config; - -import at.hannibal2.skyhanni.SkyHanniMod; -import at.hannibal2.skyhanni.config.features.About; -import at.hannibal2.skyhanni.config.features.chat.ChatConfig; -import at.hannibal2.skyhanni.config.features.combat.CombatConfig; -import at.hannibal2.skyhanni.config.features.crimsonisle.CrimsonIsleConfig; -import at.hannibal2.skyhanni.config.features.dev.DevConfig; -import at.hannibal2.skyhanni.config.features.dungeon.DungeonConfig; -import at.hannibal2.skyhanni.config.features.event.EventConfig; -import at.hannibal2.skyhanni.config.features.fishing.FishingConfig; -import at.hannibal2.skyhanni.config.features.garden.GardenConfig; -import at.hannibal2.skyhanni.config.features.gui.GUIConfig; -import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig; -import at.hannibal2.skyhanni.config.features.mining.MiningConfig; -import at.hannibal2.skyhanni.config.features.misc.MiscConfig; -import at.hannibal2.skyhanni.config.features.rift.RiftConfig; -import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig; -import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig; -import at.hannibal2.skyhanni.config.storage.Storage; -import at.hannibal2.skyhanni.utils.LorenzUtils; -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.Config; -import io.github.notenoughupdates.moulconfig.Social; -import io.github.notenoughupdates.moulconfig.annotations.Category; -import io.github.notenoughupdates.moulconfig.gui.HorizontalAlign; -import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory; -import net.minecraft.util.ResourceLocation; - -import java.util.Arrays; -import java.util.List; - - -public class Features extends Config { - public static final ResourceLocation DISCORD = new ResourceLocation("notenoughupdates:social/discord.png"); - public static final ResourceLocation GITHUB = new ResourceLocation("notenoughupdates:social/github.png"); - public static final ResourceLocation PATREON = new ResourceLocation("notenoughupdates:social/patreon.png"); - - @Override - public boolean shouldAutoFocusSearchbar() { - return true; - } - - @Override - public HorizontalAlign alignCategory(ProcessedCategory category, boolean isSelected) { - if (LorenzUtils.INSTANCE.isAprilFoolsDay()) - return HorizontalAlign.RIGHT; - return super.alignCategory(category, isSelected); - } - - @Override - public List<Social> getSocials() { - return Arrays.asList( - Social.forLink("Discord", DISCORD, "https://discord.com/invite/skyhanni-997079228510117908"), - Social.forLink("GitHub", GITHUB, "https://github.com/hannibal002/SkyHanni"), - Social.forLink("Patreon", PATREON, "https://www.patreon.com/hannibal2") - ); - } - - @Override - public void saveNow() { - SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "close-gui"); - } - - @Override - public String getTitle() { - String modName = "SkyHanni"; - if (LorenzUtils.INSTANCE.isAprilFoolsDay()) - modName = new StringBuilder().append("اسکای هانی").reverse().toString(); // Minecraft does not render RTL strings very nicely, so we reverse the string here. Not authentic, but close enough. - - return modName + " " + SkyHanniMod.VERSION + " by §channibal2§r, config by §5Moulberry §rand §5nea89"; - } - - /* - * If you are adding a new category, please insert it alphabetically - * The only exceptions to this are About and GUI, which are pinned to the top - * and Misc and Dev, which are to be at the bottom. Thanks! - */ - - - // Top - - @Expose - @Category(name = "About", desc = "Information about SkyHanni and updates.") - public About about = new About(); - - @Expose - @Category(name = "GUI", desc = "Change the locations of GUI elements (§e/sh gui§7).") - public GUIConfig gui = new GUIConfig(); - - // Islands - - @Expose - @Category(name = "Garden", desc = "Features for the Garden island.") - public GardenConfig garden = new GardenConfig(); - - @Expose - @Category(name = "Crimson Isle", desc = "Things to do on the Crimson Isle/Nether island.") - public CrimsonIsleConfig crimsonIsle = new CrimsonIsleConfig(); - - @Expose - @Category(name = "The Rift", desc = "Features for The Rift dimension.") - public RiftConfig rift = new RiftConfig(); - - // Skills - - @Expose - @Category(name = "Fishing", desc = "Fishing stuff.") - public FishingConfig fishing = new FishingConfig(); - - @Expose - @Category(name = "Mining", desc = "Features that help you break blocks.") - public MiningConfig mining = new MiningConfig(); - - // Combat like - - @Expose - @Category(name = "Combat", desc = "Everything combat and PvE related.") - public CombatConfig combat = new CombatConfig(); - - @Expose - @Category(name = "Slayer", desc = "Slayer features.") - public SlayerConfig slayer = new SlayerConfig(); - - @Expose - @Category(name = "Dungeon", desc = "Features that change the Dungeons experience in The Catacombs.") - public DungeonConfig dungeon = new DungeonConfig(); - - // Misc - - @Expose - @Category(name = "Inventory", desc = "Change the behavior of items and the inventory.") - public InventoryConfig inventory = new InventoryConfig(); - - @Expose - @Category(name = "Events", desc = "Stuff that is not always available.") - public EventConfig event = new EventConfig(); - - @Expose - @Category(name = "Skill Progress", desc = "Skill Progress related config options.") - public SkillProgressConfig skillProgress = new SkillProgressConfig(); - - @Expose - @Category(name = "Chat", desc = "Change how the chat looks.") - public ChatConfig chat = new ChatConfig(); - - @Expose - @Category(name = "Misc", desc = "Settings without a category.") - public MiscConfig misc = new MiscConfig(); - - // Bottom - - @Expose - @Category(name = "Dev", desc = "Debug and test stuff. Developers are cool.") - public DevConfig dev = new DevConfig(); - - @Expose - public Storage storage = new Storage(); - - @Expose - public int lastVersion = ConfigUpdaterMigrator.CONFIG_VERSION; - -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.kt b/src/main/java/at/hannibal2/skyhanni/config/Features.kt new file mode 100644 index 000000000000..3eb96c9b19e7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.kt @@ -0,0 +1,148 @@ +package at.hannibal2.skyhanni.config + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.features.About +import at.hannibal2.skyhanni.config.features.chat.ChatConfig +import at.hannibal2.skyhanni.config.features.combat.CombatConfig +import at.hannibal2.skyhanni.config.features.crimsonisle.CrimsonIsleConfig +import at.hannibal2.skyhanni.config.features.dev.DevConfig +import at.hannibal2.skyhanni.config.features.dungeon.DungeonConfig +import at.hannibal2.skyhanni.config.features.event.EventConfig +import at.hannibal2.skyhanni.config.features.fishing.FishingConfig +import at.hannibal2.skyhanni.config.features.garden.GardenConfig +import at.hannibal2.skyhanni.config.features.gui.GUIConfig +import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig +import at.hannibal2.skyhanni.config.features.mining.MiningConfig +import at.hannibal2.skyhanni.config.features.misc.MiscConfig +import at.hannibal2.skyhanni.config.features.rift.RiftConfig +import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig +import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig +import at.hannibal2.skyhanni.config.storage.Storage +import at.hannibal2.skyhanni.utils.LorenzUtils.isAprilFoolsDay +import com.google.gson.annotations.Expose +import io.github.notenoughupdates.moulconfig.Config +import io.github.notenoughupdates.moulconfig.Social +import io.github.notenoughupdates.moulconfig.annotations.Category +import io.github.notenoughupdates.moulconfig.common.MyResourceLocation +import io.github.notenoughupdates.moulconfig.gui.HorizontalAlign +import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory + +class Features : Config() { + private val discord = MyResourceLocation("notenoughupdates", "social/discord.png") + private val github = MyResourceLocation("notenoughupdates", "social/github.png") + private val patreon = MyResourceLocation("notenoughupdates", "social/patreon.png") + + // in moulconfig, this value is currently bugged (version 3.5.0) + override fun shouldAutoFocusSearchbar(): Boolean { + return false + } + + override fun alignCategory(category: ProcessedCategory, isSelected: Boolean): HorizontalAlign { + if (isAprilFoolsDay) return HorizontalAlign.RIGHT + return super.alignCategory(category, isSelected) + } + + override fun getSocials(): List<Social> { + return listOf( + Social.forLink("Discord", discord, "https://discord.com/invite/skyhanni-997079228510117908"), + Social.forLink("GitHub", github, "https://github.com/hannibal002/SkyHanni"), + Social.forLink("Patreon", patreon, "https://www.patreon.com/hannibal2"), + ) + } + + override fun saveNow() { + SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "close-gui") + } + + override fun getTitle(): String { + // Minecraft does not render RTL strings very nicely, so we reverse the string here. Not authentic, but close enough. + val modName = if (isAprilFoolsDay) StringBuilder().append("اسکای هانی").reverse().toString() + else "SkyHanni" + + return "$modName ${SkyHanniMod.VERSION} by §channibal2§r, config by §5Moulberry §rand §5nea89" + } + + /* + * If you are adding a new category, please insert it alphabetically + * The only exceptions to this are About and GUI, which are pinned to the top + * and Misc and Dev, which are to be at the bottom. Thanks! + */ + // Top + @Expose + @Category(name = "About", desc = "Information about SkyHanni and updates.") + var about: About = About() + + @JvmField + @Expose + @Category(name = "GUI", desc = "Change the locations of GUI elements (§e/sh gui§7).") + var gui: GUIConfig = GUIConfig() + + // Islands + @Expose + @Category(name = "Garden", desc = "Features for the Garden island.") + var garden: GardenConfig = GardenConfig() + + @Expose + @Category(name = "Crimson Isle", desc = "Things to do on the Crimson Isle/Nether island.") + var crimsonIsle: CrimsonIsleConfig = CrimsonIsleConfig() + + @Expose + @Category(name = "The Rift", desc = "Features for The Rift dimension.") + var rift: RiftConfig = RiftConfig() + + // Skills + @Expose + @Category(name = "Fishing", desc = "Fishing stuff.") + var fishing: FishingConfig = FishingConfig() + + @Expose + @Category(name = "Mining", desc = "Features that help you break blocks.") + var mining: MiningConfig = MiningConfig() + + // Combat like + @Expose + @Category(name = "Combat", desc = "Everything combat and PvE related.") + var combat: CombatConfig = CombatConfig() + + @Expose + @Category(name = "Slayer", desc = "Slayer features.") + var slayer: SlayerConfig = SlayerConfig() + + @Expose + @Category(name = "Dungeon", desc = "Features that change the Dungeons experience in The Catacombs.") + var dungeon: DungeonConfig = DungeonConfig() + + // Misc + @Expose + @Category(name = "Inventory", desc = "Change the behavior of items and the inventory.") + var inventory: InventoryConfig = InventoryConfig() + + @Expose + @Category(name = "Events", desc = "Stuff that is not always available.") + var event: EventConfig = EventConfig() + + @Expose + @Category(name = "Skill Progress", desc = "Skill Progress related config options.") + var skillProgress: SkillProgressConfig = SkillProgressConfig() + + @Expose + @Category(name = "Chat", desc = "Change how the chat looks.") + var chat: ChatConfig = ChatConfig() + + @JvmField + @Expose + @Category(name = "Misc", desc = "Settings without a category.") + var misc: MiscConfig = MiscConfig() + + // Bottom + @Expose + @Category(name = "Dev", desc = "Debug and test stuff. Developers are cool.") + var dev: DevConfig = DevConfig() + + @Expose + var storage: Storage = Storage() + + @Expose + @Suppress("unused") + var lastVersion: Int = ConfigUpdaterMigrator.CONFIG_VERSION +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/SackData.java b/src/main/java/at/hannibal2/skyhanni/config/SackData.java deleted file mode 100644 index 3495f9b8c9ad..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/SackData.java +++ /dev/null @@ -1,26 +0,0 @@ -package at.hannibal2.skyhanni.config; - -import at.hannibal2.skyhanni.data.SackItem; -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class SackData { - - @Expose - public Map<UUID, PlayerSpecific> players = new HashMap<>(); - - public static class PlayerSpecific { - @Expose - public Map<String, ProfileSpecific> profiles = new HashMap<>(); - } - - public static class ProfileSpecific { - - @Expose - public Map<NEUInternalName, SackItem> sackContents = new HashMap<>(); - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/SackData.kt b/src/main/java/at/hannibal2/skyhanni/config/SackData.kt new file mode 100644 index 000000000000..32897a52a47d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/SackData.kt @@ -0,0 +1,21 @@ +package at.hannibal2.skyhanni.config + +import at.hannibal2.skyhanni.data.SackItem +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose +import java.util.* + +class SackData { + @Expose + var players: MutableMap<UUID, PlayerSpecific> = HashMap() + + class PlayerSpecific { + @Expose + var profiles: MutableMap<String, ProfileSpecific> = HashMap() + } + + class ProfileSpecific { + @Expose + var sackContents: Map<NEUInternalName, SackItem> = HashMap() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java index eb37131b120c..7b2b25be7a16 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java @@ -234,13 +234,13 @@ public int moveY(int deltaY, int objHeight) { } public boolean canJumpToConfigOptions() { - return linkField != null && ConfigGuiManager.INSTANCE.getEditorInstance().getProcessedConfig().getOptionFromField(linkField) != null; + return linkField != null && ConfigGuiManager.INSTANCE.getEditorInstance().getOptionFromField(linkField) != null; } public void jumpToConfigOptions() { MoulConfigEditor<Features> editor = ConfigGuiManager.INSTANCE.getEditorInstance(); if (linkField == null) return; - ProcessedOption option = editor.getProcessedConfig().getOptionFromField(linkField); + ProcessedOption option = editor.getOptionFromField(linkField); if (option == null) return; editor.search(""); if (!editor.goToOption(option)) return; diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java deleted file mode 100644 index c3b949c79235..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java +++ /dev/null @@ -1,81 +0,0 @@ -package at.hannibal2.skyhanni.config.storage; - -import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal; -import at.hannibal2.skyhanni.features.fame.UpgradeReminder; -import at.hannibal2.skyhanni.utils.GenericWrapper; -import at.hannibal2.skyhanni.utils.NEUInternalName; -import at.hannibal2.skyhanni.utils.SimpleTimeMark; -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class PlayerSpecificStorage { - - @Expose - public Map<String, ProfileSpecificStorage> profiles = new HashMap<>(); // profile name - - @Expose - public Boolean useRomanNumerals = true; - - @Expose - public Boolean multipleProfiles = false; - - @Expose - public Integer gardenCommunityUpgrade = -1; - - @Expose - public SimpleTimeMark nextCityProjectParticipationTime = GenericWrapper.getSimpleTimeMark(SimpleTimeMark.farPast()).getIt(); - - @Expose - public UpgradeReminder.CommunityShopUpgrade communityShopAccountUpgrade = null; - - @Expose - public List<String> guildMembers = new ArrayList<>(); - - @Expose - public WinterStorage winter = new WinterStorage(); - - public static class WinterStorage { - - @Expose - public Set<String> playersThatHaveBeenGifted = new HashSet<>(); - - @Expose - public int amountGifted = 0; - - @Expose - public int cakeCollectedYear = 0; - } - - @Expose - public Map<Long, BingoSession> bingoSessions = new HashMap<>(); - - public static class BingoSession { - - @Expose - public Set<NEUInternalName> tierOneMinionsDone = new HashSet<>(); - - @Expose - public Map<Integer, BingoGoal> goals = new HashMap<>(); - } - - @Expose - public LimboStats limbo = new LimboStats(); - - public static class LimboStats { - - @Expose - public int playtime = 0; - - @Expose - public int personalBest = 0; - - @Expose - public float userLuck = 0f; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.kt b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.kt new file mode 100644 index 000000000000..3bcb47421253 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.kt @@ -0,0 +1,71 @@ +package at.hannibal2.skyhanni.config.storage + +import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal +import at.hannibal2.skyhanni.features.fame.UpgradeReminder.CommunityShopUpgrade +import at.hannibal2.skyhanni.utils.GenericWrapper.Companion.getSimpleTimeMark +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.farPast +import com.google.gson.annotations.Expose + +class PlayerSpecificStorage { + @Expose + var profiles: MutableMap<String, ProfileSpecificStorage> = HashMap() // profile name + + @Expose + var useRomanNumerals: Boolean = true + + @Expose + var multipleProfiles: Boolean = false + + @Expose + var gardenCommunityUpgrade: Int = -1 + + @Expose + var nextCityProjectParticipationTime: SimpleTimeMark = getSimpleTimeMark(farPast()).it + + @Expose + var communityShopAccountUpgrade: CommunityShopUpgrade? = null + + @Expose + var guildMembers: MutableList<String> = ArrayList() + + @Expose + var winter: WinterStorage = WinterStorage() + + class WinterStorage { + @Expose + var playersThatHaveBeenGifted: MutableSet<String> = HashSet() + + @Expose + var amountGifted: Int = 0 + + @Expose + var cakeCollectedYear: Int = 0 + } + + @Expose + var bingoSessions: MutableMap<Long, BingoSession> = HashMap() + + class BingoSession { + @Expose + var tierOneMinionsDone: MutableSet<NEUInternalName> = HashSet() + + @Expose + var goals: MutableMap<Int, BingoGoal> = HashMap() + } + + @Expose + var limbo: LimboStats = LimboStats() + + class LimboStats { + @Expose + var playtime: Int = 0 + + @Expose + var personalBest: Int = 0 + + @Expose + var userLuck: Float = 0f + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java deleted file mode 100644 index 44e4fd6dfd65..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ /dev/null @@ -1,888 +0,0 @@ -package at.hannibal2.skyhanni.config.storage; - -import at.hannibal2.skyhanni.api.HotmAPI; -import at.hannibal2.skyhanni.api.SkillAPI; -import at.hannibal2.skyhanni.data.IslandType; -import at.hannibal2.skyhanni.data.MaxwellAPI; -import at.hannibal2.skyhanni.data.jsonobjects.local.HotmTree; -import at.hannibal2.skyhanni.data.model.ComposterUpgrade; -import at.hannibal2.skyhanni.data.model.SkyblockStat; -import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker; -import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; -import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker; -import at.hannibal2.skyhanni.features.dungeon.DungeonFloor; -import at.hannibal2.skyhanni.features.event.carnival.CarnivalGoal; -import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker; -import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker; -import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats; -import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType; -import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker; -import at.hannibal2.skyhanni.features.fame.UpgradeReminder; -import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker; -import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker; -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; -import at.hannibal2.skyhanni.features.garden.CropAccessory; -import at.hannibal2.skyhanni.features.garden.CropType; -import at.hannibal2.skyhanni.features.garden.GardenPlotAPI; -import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker; -import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker; -import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane; -import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; -import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker; -import at.hannibal2.skyhanni.features.garden.pests.VinylType; -import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker; -import at.hannibal2.skyhanni.features.inventory.experimentationtable.ExperimentsProfitTracker; -import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI; -import at.hannibal2.skyhanni.features.mining.MineshaftPityDisplay; -import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker; -import at.hannibal2.skyhanni.features.mining.glacitemineshaft.CorpseTracker; -import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; -import at.hannibal2.skyhanni.features.misc.DraconicSacrificeTracker; -import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; -import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker; -import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal; -import at.hannibal2.skyhanni.features.skillprogress.SkillType; -import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker; -import at.hannibal2.skyhanni.utils.GenericWrapper; -import at.hannibal2.skyhanni.utils.LorenzRarity; -import at.hannibal2.skyhanni.utils.LorenzVec; -import at.hannibal2.skyhanni.utils.NEUInternalName; -import at.hannibal2.skyhanni.utils.SimpleTimeMark; -import at.hannibal2.skyhanni.utils.StaticDurations; -import com.google.gson.annotations.Expose; -import kotlin.time.Duration; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -public class ProfileSpecificStorage { - - private static SimpleTimeMark SimpleTimeMarkFarPast() { - return GenericWrapper.getSimpleTimeMark(SimpleTimeMark.farPast()).getIt(); - } - - private static Duration DurationZero() { - return GenericWrapper.getDuration(StaticDurations.getZero()).getIt(); - } - - @Expose - public String currentPet = ""; - - @Expose - public ExperimentationStorage experimentation = new ExperimentationStorage(); - - public static class ExperimentationStorage { - - @Expose - public LorenzVec tablePos = new LorenzVec(); - - @Expose - public ExperimentsDryStreakStorage dryStreak = new ExperimentsDryStreakStorage(); - - public static class ExperimentsDryStreakStorage { - @Expose - public int attemptsSince = 0; - - @Expose - public int xpSince = 0; - } - - @Expose - public ExperimentsProfitTracker.Data experimentsProfitTracker = new ExperimentsProfitTracker.Data(); - } - - @Expose - public ChocolateFactoryStorage chocolateFactory = new ChocolateFactoryStorage(); - - public static class ChocolateFactoryStorage { - @Expose - public int currentRabbits = 0; - - @Expose - public int maxRabbits = -1; - - @Expose - public long currentChocolate = 0; - - @Expose - public long maxChocolate = 0; - - @Expose - public long chocolateThisPrestige = 0; - - @Expose - public long chocolateAllTime = 0; - - @Expose - public int rawChocPerSecond = 0; - - @Expose - public double chocolateMultiplier = 1.0; - - @Expose - public double rawChocolateMultiplier = 1.0; - - @Expose - public int timeTowerLevel = 0; - - @Expose - public SimpleTimeMark currentTimeTowerEnds = SimpleTimeMarkFarPast(); - - @Expose - public SimpleTimeMark nextTimeTower = SimpleTimeMarkFarPast(); - - @Expose - public int currentTimeTowerUses = -1; - - @Expose - public int timeTowerCooldown = 8; - - @Expose - public int maxTimeTowerUses = 0; - - @Expose - public boolean hasMuRabbit = false; - - @Expose - public SimpleTimeMark bestUpgradeAvailableAt = SimpleTimeMarkFarPast(); - - @Expose - public long bestUpgradeCost = 0; - - @Expose - public SimpleTimeMark lastDataSave = SimpleTimeMarkFarPast(); - - @Expose - public PositionChange positionChange = new PositionChange(); - - public static class PositionChange { - @Expose - @Nullable - public SimpleTimeMark lastTime = null; - - @Expose - public int lastPosition = -1; - - @Expose - public String lastLeaderboard = null; - } - - @Expose - public Long targetGoal = null; - - @Expose - public String targetName = null; - - @Expose - public Map<String, Integer> rabbitCounts = new HashMap<>(); - - @Expose - public Map<String, HoppityCollectionStats.LocationRabbit> locationRabbitRequirements = new HashMap<>(); - - @Expose - public Map<IslandType, Set<LorenzVec>> collectedEggLocations = new HashMap<>(); - - @Expose - public Map<IslandType, Map<String, @Nullable Boolean>> residentRabbits = new HashMap<>(); - - public static class HotspotRabbitStorage { - @Expose - @Nullable - public Integer skyblockYear; - - @Expose - public Map<IslandType, Map<String, @Nullable Boolean>> hotspotRabbits; - - public HotspotRabbitStorage(@Nullable Integer year) { - this.skyblockYear = year; - this.hotspotRabbits = new HashMap<>(); - } - } - - @Expose - public HotspotRabbitStorage hotspotRabbitStorage = new HotspotRabbitStorage(null); - - @Expose - public Integer hoppityShopYearOpened = null; - - @Expose - public ChocolateFactoryStrayTracker.Data strayTracker = new ChocolateFactoryStrayTracker.Data(); - - @Expose - public Map<HoppityEggType, SimpleTimeMark> mealLastFound = new HashMap<>(); - - public static class HitmanStatsStorage { - @Expose - @Nullable - public Integer availableEggs = null; - - @Expose - @Nullable - public SimpleTimeMark singleSlotCooldownMark = null; - - @Expose - @Nullable - public SimpleTimeMark allSlotsCooldownMark = null; - - @Expose - @Nullable - public Integer purchasedSlots = null; - } - - @Expose - public HitmanStatsStorage hitmanStats = new HitmanStatsStorage(); - } - - @Expose - public CarnivalStorage carnival = new CarnivalStorage(); - - public static class CarnivalStorage { - - @Expose - @Nullable - public java.time.LocalDate lastClaimedDay = null; - - @Expose - public int carnivalYear = 0; - - @Expose - public Map<CarnivalGoal, Boolean> goals = new HashMap<>(); - - @Expose - // shop name -> (item name, tier) - public Map<String, Map<String, Integer>> carnivalShopProgress = new HashMap<>(); - } - - @Expose - public Map<SkyblockStat, Double> stats = new HashMap<>(SkyblockStat.getEntries().size()); - - @Expose - public MaxwellPowerStorage maxwell = new MaxwellPowerStorage(); - - public static class MaxwellPowerStorage { - @Expose - public String currentPower = null; - - @Expose - public int magicalPower = -1; - - @Expose - public List<MaxwellAPI.ThaumaturgyPowerTuning> tunings = new ArrayList<>(); - - @Expose - public List<String> favoritePowers = new ArrayList<>(); - } - - @Expose - public ArrowsStorage arrows = new ArrowsStorage(); - - public static class ArrowsStorage { - @Expose - public String currentArrow = null; - - @Expose - public Map<NEUInternalName, Integer> arrowAmount = new HashMap<>(); - } - - @Expose - public BitsStorage bits = new BitsStorage(); - - public static class BitsStorage { - @Expose - public int bits = -1; - - @Expose - public int bitsAvailable = -1; - - @Expose - @Nullable - public SimpleTimeMark boosterCookieExpiryTime = null; - } - - @Expose - public Map<LorenzVec, MinionConfig> minions = new HashMap<>(); - - public static class MinionConfig { - - @Expose - public String displayName = ""; - - // TODO use SimpleTimeMark - @Expose - public long lastClicked = -1; - - @Override - public String toString() { - return "MinionConfig{" + - "displayName='" + displayName + '\'' + - ", lastClicked=" + lastClicked + - '}'; - } - } - - @Expose - public BeaconPowerStorage beaconPower = new BeaconPowerStorage(); - - public static class BeaconPowerStorage { - - @Expose - @Nullable - public SimpleTimeMark beaconPowerExpiryTime = null; - - @Expose - public String boostedStat = null; - } - - @Expose - public CrimsonIsleStorage crimsonIsle = new CrimsonIsleStorage(); - - public static class CrimsonIsleStorage { - - @Expose - public List<String> quests = new ArrayList<>(); - - @Expose - public List<String> miniBossesDoneToday = new ArrayList<>(); - - @Expose - public List<String> kuudraTiersDone = new ArrayList<>(); - - @Expose - public Map<String, Map<TrophyRarity, Integer>> trophyFishes = new HashMap<>(); - } - - @Expose - public GardenStorage garden = new GardenStorage(); - - public static class GardenStorage { - - @Expose - public Long experience = null; - - @Expose - public Map<CropType, Long> cropCounter = new HashMap<>(); - - @Expose - public Map<CropType, Integer> cropUpgrades = new HashMap<>(); - - @Expose - public Map<CropType, Integer> cropsPerSecond = new HashMap<>(); - - @Expose - public Map<CropType, Double> latestBlocksPerSecond = new HashMap<>(); - - @Expose - public Map<CropType, Double> latestTrueFarmingFortune = new HashMap<>(); - - // TODO use in /ff guide - @Expose - public Map<CropType, Double> personalBestFF = new HashMap<>(); - - @Expose - @Nullable - public CropAccessory savedCropAccessory = CropAccessory.NONE; - - @Expose - public DicerRngDropTracker.Data dicerDropTracker = new DicerRngDropTracker.Data(); - - @Expose - public SimpleTimeMark informedAboutLowMatter = SimpleTimeMarkFarPast(); - - @Expose - public SimpleTimeMark informedAboutLowFuel = SimpleTimeMarkFarPast(); - - @Expose - public long visitorInterval = 15 * 60_000L; - - @Expose - public SimpleTimeMark nextSixthVisitorArrival = SimpleTimeMarkFarPast(); - - @Expose - public ArmorDropTracker.Data armorDropTracker = new ArmorDropTracker.Data(); - - @Expose - public Map<ComposterUpgrade, Integer> composterUpgrades = new HashMap<>(); - - @Expose - public Map<CropType, Boolean> toolWithBountiful = new HashMap<>(); - - @Expose - public NEUInternalName composterCurrentOrganicMatterItem = NEUInternalName.Companion.getNONE(); - - @Expose - public NEUInternalName composterCurrentFuelItem = NEUInternalName.Companion.getNONE(); - - @Expose - public int uniqueVisitors = 0; - - @Expose - public GardenStorage.VisitorDrops visitorDrops = new GardenStorage.VisitorDrops(); - - public static class VisitorDrops { - @Expose - public int acceptedVisitors = 0; - - @Expose - public int deniedVisitors = 0; - - @Expose - public List<Long> visitorRarities = new ArrayList<>(); - - @Expose - public int copper = 0; - - @Expose - public long farmingExp = 0; - - @Expose - public int gardenExp = 0; - - @Expose - public long coinsSpent = 0; - - @Expose - public long bits = 0; - - @Expose - public long mithrilPowder = 0; - - @Expose - public long gemstonePowder = 0; - - @Expose - public Map<VisitorReward, Integer> rewardsCount = new HashMap<>(); - } - - @Expose - public GardenStorage.PlotIcon plotIcon = new GardenStorage.PlotIcon(); - - public static class PlotIcon { - @Expose - public Map<Integer, NEUInternalName> plotList = new HashMap<>(); - } - - @Expose - public Map<Integer, GardenPlotAPI.PlotData> plotData = new HashMap<>(); - - @Expose - public int scoreboardPests = 0; - - @Expose - public Map<CropType, LorenzVec> cropStartLocations = new HashMap<>(); - - @Expose - public Map<CropType, LorenzVec> cropLastFarmedLocations = new HashMap<>(); - - @Expose - public Map<CropType, FarmingLane> farmingLanes = new HashMap<>(); - - @Expose - public GardenStorage.Fortune fortune = new GardenStorage.Fortune(); - - public static class Fortune { - - @Expose - public Map<FarmingItems, Boolean> outdatedItems = new HashMap<>(); - - @Expose - public int farmingLevel = -1; - - @Expose - public double bestiary = -1.0; - - @Expose - public int plotsUnlocked = -1; - - @Expose - public int anitaUpgrade = -1; - - @Expose - public int farmingStrength = -1; - - @Expose - public SimpleTimeMark cakeExpiring = null; - - @Expose - public Map<CropType, Boolean> carrolyn = new HashMap<>(); - - @Expose - public Map<FarmingItems, ItemStack> farmingItems = new HashMap<>(); - } - - @Expose - public SimpleTimeMark composterEmptyTime = SimpleTimeMarkFarPast(); - - @Expose - public SimpleTimeMark lastComposterEmptyWarningTime = SimpleTimeMarkFarPast(); - - @Expose - public GardenStorage.FarmingWeightConfig farmingWeight = new GardenStorage.FarmingWeightConfig(); - - public static class FarmingWeightConfig { - - @Expose - public int lastFarmingWeightLeaderboard = -1; - } - - @Expose - public Map<String, LorenzVec> npcVisitorLocations = new HashMap<>(); - - @Expose - public Map<CropType, Integer> customGoalMilestone = new HashMap<>(); - - @Expose - public PestProfitTracker.Data pestProfitTracker = new PestProfitTracker.Data(); - - @Expose - public VinylType activeVinyl = null; - } - - @Expose - public GhostStorage ghostStorage = new GhostStorage(); - - public static class GhostStorage { - - @Expose - public GhostTracker.Data ghostTracker = new GhostTracker.Data(); - - @Expose - public Long bestiaryKills = 0L; - - @Expose - public boolean migratedTotalKills = false; - } - - public static class CakeData { - @Expose - public Set<Integer> ownedCakes = new HashSet<>(); - - @Expose - public Set<Integer> missingCakes = new HashSet<>(); - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ownedCakes.hashCode(); - result = prime * result + missingCakes.hashCode(); - return result; - } - } - - @Expose - public CakeData cakeData = new CakeData(); - - @Expose - public PowderTracker.Data powderTracker = new PowderTracker.Data(); - - @Expose - public FrozenTreasureTracker.Data frozenTreasureTracker = new FrozenTreasureTracker.Data(); - - @Expose - public EnderNodeTracker.Data enderNodeTracker = new EnderNodeTracker.Data(); - - @Expose - public RiftStorage rift = new RiftStorage(); - - public static class RiftStorage { - - @Expose - public List<KloonTerminal> completedKloonTerminals = new ArrayList<>(); - - @Expose - public VerminTracker.Data verminTracker = new VerminTracker.Data(); - } - - @Expose - public Map<String, SlayerProfitTracker.Data> slayerProfitData = new HashMap<>(); - - @Expose - public Map<String, SlayerRngMeterStorage> slayerRngMeter = new HashMap<>(); - - public static class SlayerRngMeterStorage { - - @Expose - public long currentMeter = -1; - - @Expose - public long gainPerBoss = -1; - - @Expose - public long goalNeeded = -1; - - @Expose - public String itemGoal = "?"; - - @Override - public String toString() { - return "SlayerRngMeterStorage{" + - "currentMeter=" + currentMeter + - ", gainPerBoss=" + gainPerBoss + - ", goalNeeded=" + goalNeeded + - ", itemGoal='" + itemGoal + '\'' + - '}'; - } - } - - @Expose - public MiningConfig mining = new MiningConfig(); - - public static class MiningConfig { - - @Expose - public List<String> kingsTalkedTo = new ArrayList<>(); - - @Expose - public ExcavatorProfitTracker.Data fossilExcavatorProfitTracker = new ExcavatorProfitTracker.Data(); - - @Expose - public HotmTree hotmTree = new HotmTree(); - - @Expose - public Map<HotmAPI.PowderType, PowderStorage> powder = new HashMap<>(); - - public static class PowderStorage { - - @Expose - public Long available; - - @Expose - public Long total; - } - - @Expose - public int tokens; - - @Expose - public int availableTokens; - - @Expose - public MineshaftStorage mineshaft = new MineshaftStorage(); - - public static class MineshaftStorage { - - @Expose - public long mineshaftTotalBlocks = 0L; - - @Expose - public int mineshaftTotalCount = 0; - - @Expose - public List<MineshaftPityDisplay.PityData> blocksBroken = new ArrayList<>(); - - @Expose - public CorpseTracker.BucketData corpseProfitTracker = new CorpseTracker.BucketData(); - } - } - - @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; - - // TODO change to sh tracker - @Expose - public Map<TrevorTracker.TrapperMobRarity, Integer> animalRarities = new HashMap<>(); - } - - @Expose - public DungeonStorage dungeons = new DungeonStorage(); - - public static class DungeonStorage { - - @Expose - public Map<DungeonFloor, Integer> bosses = new HashMap<>(); - - @Expose - public List<DungeonStorage.DungeonRunInfo> runs = CroesusChestTracker.generateMaxChestAsList(); - - public static class DungeonRunInfo { - - public DungeonRunInfo() { - } - - public DungeonRunInfo(String floor) { - this.floor = floor; - this.openState = CroesusChestTracker.OpenedState.UNOPENED; - } - - @Nullable - @Expose - public String floor = null; - - @Expose - @Nullable - public CroesusChestTracker.OpenedState openState = null; - - @Expose - @Nullable - public Boolean kismetUsed = null; - - } - } - - @Expose - public FishingStorage fishing = new FishingStorage(); - - public static class FishingStorage { - - @Expose - public FishingProfitTracker.Data fishingProfitTracker = new FishingProfitTracker.Data(); - - @Expose - public SeaCreatureTracker.Data seaCreatureTracker = new SeaCreatureTracker.Data(); - - } - - @Expose - public DianaStorage diana = new DianaStorage(); - - public static class DianaStorage { - - @Expose - // TODO rename to 'profitTracker' - public DianaProfitTracker.Data dianaProfitTracker = new DianaProfitTracker.Data(); - - @Expose - public Map<Integer, DianaProfitTracker.Data> dianaProfitTrackerPerElectionSeason = new HashMap<>(); - - @Expose - // TODO rename - public MythologicalCreatureTracker.Data mythologicalMobTracker = new MythologicalCreatureTracker.Data(); - - @Expose - public Map<Integer, MythologicalCreatureTracker.Data> mythologicalMobTrackerPerElectionSeason = new HashMap<>(); - } - - @Expose - public Map<SkillType, SkillAPI.SkillInfo> skillData = new HashMap<>(); - - @Expose - public WardrobeStorage wardrobe = new WardrobeStorage(); - - public static class WardrobeStorage { - @Expose - public Map<Integer, WardrobeAPI.WardrobeData> data = new HashMap<>(); - - @Expose - @Nullable - public Integer currentSlot = null; - } - - @Expose - public DraconicSacrificeTracker.Data draconicSacrificeTracker = new DraconicSacrificeTracker.Data(); - - @Expose - public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null; - - @Expose - @Nullable - public Integer abiphoneContactAmount = null; - - @Expose - public Map<Integer, HoppityEventStats> hoppityEventStats = new HashMap<>(); - - @Expose - public Boolean hoppityStatLiveDisplayToggledOff = false; - - public static class HoppityEventStats { - @Expose - public Map<HoppityEggType, Integer> mealsFound = new HashMap<>(); - - @Expose - public Map<LorenzRarity, RabbitData> rabbitsFound = new HashMap<>(); - - public static class RabbitData { - @Expose - public int uniques = 0; - - @Expose - public int dupes = 0; - - @Expose - public int strays = 0; - - @Override - public int hashCode() { - return Objects.hash(uniques, dupes, strays); - } - } - - @Expose - public long dupeChocolateGained = 0; - - @Expose - public long strayChocolateGained = 0; - - @Expose - public Duration millisInCf = DurationZero(); - - @Expose - public int rabbitTheFishFinds = 0; - - public static class LeaderboardPosition { - @Expose - public int position; - - @Expose - public double percentile; - - public LeaderboardPosition(int position, double percentile) { - this.position = position; - this.percentile = percentile; - } - - @Override - public int hashCode() { - return Objects.hash(position, percentile); - } - } - - @Expose - public LeaderboardPosition initialLeaderboardPosition = new LeaderboardPosition(-1, -1.0); - - @Expose - public LeaderboardPosition finalLeaderboardPosition = new LeaderboardPosition(-1, -1.0); - - @Expose - public SimpleTimeMark lastLbUpdate = SimpleTimeMarkFarPast(); - - @Expose - public boolean summarized = false; - - @Override - public int hashCode() { - return Objects.hash( - mealsFound, - rabbitsFound, - dupeChocolateGained, - strayChocolateGained, - millisInCf, - rabbitTheFishFinds, - initialLeaderboardPosition, - finalLeaderboardPosition, - summarized - ); - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.kt b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.kt new file mode 100644 index 000000000000..f313531c8515 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.kt @@ -0,0 +1,836 @@ +package at.hannibal2.skyhanni.config.storage + +import at.hannibal2.skyhanni.api.HotmAPI.PowderType +import at.hannibal2.skyhanni.api.SkillAPI +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.MaxwellAPI.ThaumaturgyPowerTuning +import at.hannibal2.skyhanni.data.jsonobjects.local.HotmTree +import at.hannibal2.skyhanni.data.model.ComposterUpgrade +import at.hannibal2.skyhanni.data.model.SkyblockStat +import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker +import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker.OpenedState +import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker.generateMaxChestAsList +import at.hannibal2.skyhanni.features.dungeon.DungeonFloor +import at.hannibal2.skyhanni.features.event.carnival.CarnivalGoal +import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker +import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker +import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats.LocationRabbit +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType +import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker +import at.hannibal2.skyhanni.features.fame.UpgradeReminder.CommunityShopUpgrade +import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker +import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity +import at.hannibal2.skyhanni.features.garden.CropAccessory +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.PlotData +import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker +import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker +import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane +import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems +import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker +import at.hannibal2.skyhanni.features.garden.pests.VinylType +import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker +import at.hannibal2.skyhanni.features.inventory.experimentationtable.ExperimentsProfitTracker +import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI.WardrobeData +import at.hannibal2.skyhanni.features.mining.MineshaftPityDisplay.PityData +import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker +import at.hannibal2.skyhanni.features.mining.glacitemineshaft.CorpseTracker.BucketData +import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker +import at.hannibal2.skyhanni.features.misc.DraconicSacrificeTracker +import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker.TrapperMobRarity +import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker +import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal +import at.hannibal2.skyhanni.features.skillprogress.SkillType +import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker +import at.hannibal2.skyhanni.utils.LorenzRarity +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.NONE +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.farPast +import com.google.gson.annotations.Expose +import net.minecraft.item.ItemStack +import java.time.LocalDate +import java.util.* +import kotlin.time.Duration + +class ProfileSpecificStorage { + @Expose + var currentPet: String = "" + + @Expose + var experimentation: ExperimentationStorage = ExperimentationStorage() + + class ExperimentationStorage { + @Expose + var tablePos: LorenzVec = LorenzVec() + + @Expose + var dryStreak: ExperimentsDryStreakStorage = ExperimentsDryStreakStorage() + + class ExperimentsDryStreakStorage { + @Expose + var attemptsSince: Int = 0 + + @Expose + var xpSince: Int = 0 + } + + @Expose + var experimentsProfitTracker: ExperimentsProfitTracker.Data = ExperimentsProfitTracker.Data() + } + + @Expose + var chocolateFactory: ChocolateFactoryStorage = ChocolateFactoryStorage() + + class ChocolateFactoryStorage { + @Expose + var currentRabbits: Int = 0 + + @Expose + var maxRabbits: Int = -1 + + @Expose + var currentChocolate: Long = 0 + + @Expose + var maxChocolate: Long = 0 + + @Expose + var chocolateThisPrestige: Long = 0 + + @Expose + var chocolateAllTime: Long = 0 + + @Expose + var rawChocPerSecond: Int = 0 + + @Expose + var chocolateMultiplier: Double = 1.0 + + @Expose + var rawChocolateMultiplier: Double = 1.0 + + @Expose + var timeTowerLevel: Int = 0 + + @Expose + var currentTimeTowerEnds: SimpleTimeMark = farPast() + + @Expose + var nextTimeTower: SimpleTimeMark = farPast() + + @Expose + var currentTimeTowerUses: Int = -1 + + @Expose + var timeTowerCooldown: Int = 8 + + @Expose + var maxTimeTowerUses: Int = 0 + + @Expose + var bestUpgradeAvailableAt: SimpleTimeMark = farPast() + + @Expose + var bestUpgradeCost: Long = 0 + + @Expose + var lastDataSave: SimpleTimeMark = farPast() + + @Expose + var positionChange: PositionChange = PositionChange() + + class PositionChange { + @Expose + var lastTime: SimpleTimeMark? = null + + @Expose + var lastPosition: Int = -1 + + @Expose + var lastLeaderboard: String? = null + } + + @Expose + var targetGoal: Long? = null + + @Expose + var targetName: String? = null + + @Expose + var rabbitCounts: MutableMap<String, Int> = HashMap() + + @Expose + var locationRabbitRequirements: MutableMap<String, LocationRabbit> = HashMap() + + @Expose + var collectedEggLocations: MutableMap<IslandType, MutableSet<LorenzVec>> = EnumMap(IslandType::class.java) + + @Expose + var residentRabbits: MutableMap<IslandType, MutableMap<String, Boolean?>> = EnumMap(IslandType::class.java) + + class HotspotRabbitStorage(@field:Expose var skyblockYear: Int?) { + @Expose + var hotspotRabbits: MutableMap<IslandType, MutableMap<String, Boolean?>> = EnumMap(IslandType::class.java) + } + + @Expose + var hotspotRabbitStorage: HotspotRabbitStorage = HotspotRabbitStorage(null) + + @Expose + var hoppityShopYearOpened: Int? = null + + @Expose + var strayTracker: ChocolateFactoryStrayTracker.Data = ChocolateFactoryStrayTracker.Data() + + @Expose + var mealLastFound: MutableMap<HoppityEggType, SimpleTimeMark> = EnumMap(HoppityEggType::class.java) + + class HitmanStatsStorage { + @Expose + var availableEggs: Int? = null + + @Expose + var singleSlotCooldownMark: SimpleTimeMark? = null + + @Expose + var allSlotsCooldownMark: SimpleTimeMark? = null + + @Expose + var purchasedSlots: Int? = null + } + + @Expose + var hitmanStats: HitmanStatsStorage = HitmanStatsStorage() + } + + @Expose + var carnival: CarnivalStorage = CarnivalStorage() + + class CarnivalStorage { + @Expose + var lastClaimedDay: LocalDate? = null + + @Expose + var carnivalYear: Int = 0 + + @Expose + var goals: MutableMap<CarnivalGoal, Boolean> = EnumMap(CarnivalGoal::class.java) + + // shop name -> (item name, tier) + @Expose + var carnivalShopProgress: MutableMap<String, Map<String, Int>> = HashMap() + } + + @Expose + var stats: MutableMap<SkyblockStat, Double?> = HashMap<SkyblockStat, Double?>(SkyblockStat.entries.size) + + @Expose + var maxwell: MaxwellPowerStorage = MaxwellPowerStorage() + + class MaxwellPowerStorage { + @Expose + var currentPower: String? = null + + @Expose + var magicalPower: Int = -1 + + @Expose + var tunings: List<ThaumaturgyPowerTuning> = ArrayList() + + @Expose + var favoritePowers: List<String> = ArrayList() + } + + @Expose + var arrows: ArrowsStorage = ArrowsStorage() + + class ArrowsStorage { + @Expose + var currentArrow: String? = null + + @Expose + var arrowAmount: MutableMap<NEUInternalName, Int> = HashMap() + } + + @Expose + var bits: BitsStorage = BitsStorage() + + class BitsStorage { + @Expose + var bits: Int = -1 + + @Expose + var bitsAvailable: Int = -1 + + @Expose + var boosterCookieExpiryTime: SimpleTimeMark? = null + } + + @Expose + var minions: Map<LorenzVec, MinionConfig>? = HashMap() + + class MinionConfig { + @Expose + var displayName: String = "" + + @Expose + var lastClicked: SimpleTimeMark = farPast() + + override fun toString(): String { + return "MinionConfig{" + + "displayName='$displayName'" + + ", lastClicked=$lastClicked" + + "}" + } + } + + @Expose + var beaconPower: BeaconPowerStorage = BeaconPowerStorage() + + class BeaconPowerStorage { + @Expose + var beaconPowerExpiryTime: SimpleTimeMark? = null + + @Expose + var boostedStat: String? = null + } + + @Expose + var crimsonIsle: CrimsonIsleStorage = CrimsonIsleStorage() + + class CrimsonIsleStorage { + @Expose + var quests: MutableList<String> = ArrayList() + + @Expose + var miniBossesDoneToday: MutableList<String> = ArrayList() + + @Expose + var kuudraTiersDone: MutableList<String> = ArrayList() + + @Expose + var trophyFishes: MutableMap<String, MutableMap<TrophyRarity, Int>> = HashMap() + } + + @Expose + var garden: GardenStorage = GardenStorage() + + class GardenStorage { + @Expose + var experience: Long? = null + + @Expose + var cropCounter: MutableMap<CropType, Long> = EnumMap(CropType::class.java) + + @Expose + var cropUpgrades: MutableMap<CropType, Int> = EnumMap(CropType::class.java) + + @Expose + var cropsPerSecond: MutableMap<CropType, Int> = EnumMap(CropType::class.java) + + @Expose + var latestBlocksPerSecond: MutableMap<CropType, Double> = EnumMap(CropType::class.java) + + @Expose + var latestTrueFarmingFortune: MutableMap<CropType, Double> = EnumMap(CropType::class.java) + + // TODO use in /ff guide + @Expose + var personalBestFF: MutableMap<CropType, Double> = EnumMap(CropType::class.java) + + @Expose + var savedCropAccessory: CropAccessory? = CropAccessory.NONE + + @Expose + var dicerDropTracker: DicerRngDropTracker.Data = DicerRngDropTracker.Data() + + @Expose + var informedAboutLowMatter: SimpleTimeMark = farPast() + + @Expose + var informedAboutLowFuel: SimpleTimeMark = farPast() + + @Expose + var visitorInterval: Long = 15 * 60000L + + @Expose + var nextSixthVisitorArrival: SimpleTimeMark = farPast() + + @Expose + var armorDropTracker: ArmorDropTracker.Data = ArmorDropTracker.Data() + + @Expose + var composterUpgrades: MutableMap<ComposterUpgrade, Int> = EnumMap(ComposterUpgrade::class.java) + + @Expose + var toolWithBountiful: MutableMap<CropType, Boolean> = EnumMap(CropType::class.java) + + @Expose + var composterCurrentOrganicMatterItem: NEUInternalName? = NONE + + @Expose + var composterCurrentFuelItem: NEUInternalName? = NONE + + @Expose + var uniqueVisitors: Int = 0 + + @Expose + var visitorDrops: VisitorDrops = VisitorDrops() + + class VisitorDrops { + @Expose + var acceptedVisitors: Int = 0 + + @Expose + var deniedVisitors: Int = 0 + + @Expose + var visitorRarities: MutableList<Long> = ArrayList() + + @Expose + var copper: Int = 0 + + @Expose + var farmingExp: Long = 0 + + @Expose + var gardenExp: Int = 0 + + @Expose + var coinsSpent: Long = 0 + + @Expose + var bits: Long = 0 + + @Expose + var mithrilPowder: Long = 0 + + @Expose + var gemstonePowder: Long = 0 + + @Expose + var rewardsCount: Map<VisitorReward, Int> = EnumMap(VisitorReward::class.java) + } + + @Expose + var plotIcon: PlotIcon = PlotIcon() + + class PlotIcon { + @Expose + var plotList: MutableMap<Int, NEUInternalName> = HashMap() + } + + @Expose + var plotData: MutableMap<Int, PlotData> = HashMap() + + @Expose + var scoreboardPests: Int = 0 + + @Expose + var cropStartLocations: MutableMap<CropType, LorenzVec> = EnumMap(CropType::class.java) + + @Expose + var cropLastFarmedLocations: MutableMap<CropType, LorenzVec> = EnumMap(CropType::class.java) + + @Expose + var farmingLanes: MutableMap<CropType, FarmingLane> = EnumMap(CropType::class.java) + + @Expose + var fortune: Fortune = Fortune() + + class Fortune { + @Expose + var outdatedItems: MutableMap<FarmingItems, Boolean> = EnumMap(FarmingItems::class.java) + + @Expose + var farmingLevel: Int = -1 + + @Expose + var bestiary: Double = -1.0 + + @Expose + var plotsUnlocked: Int = -1 + + @Expose + var anitaUpgrade: Int = -1 + + @Expose + var farmingStrength: Int = -1 + + @Expose + var cakeExpiring: SimpleTimeMark? = null + + @Expose + var carrolyn: MutableMap<CropType, Boolean> = EnumMap(CropType::class.java) + + @Expose + var farmingItems: MutableMap<FarmingItems, ItemStack> = EnumMap(FarmingItems::class.java) + } + + @Expose + var composterEmptyTime: SimpleTimeMark = farPast() + + @Expose + var lastComposterEmptyWarningTime: SimpleTimeMark = farPast() + + @Expose + var farmingWeight: FarmingWeightConfig = FarmingWeightConfig() + + class FarmingWeightConfig { + @Expose + var lastFarmingWeightLeaderboard: Int = -1 + } + + @Expose + var npcVisitorLocations: MutableMap<String, LorenzVec> = HashMap() + + @Expose + var customGoalMilestone: MutableMap<CropType, Int> = EnumMap(CropType::class.java) + + @Expose + var pestProfitTracker: PestProfitTracker.Data = PestProfitTracker.Data() + + @Expose + var activeVinyl: VinylType? = null + } + + @Expose + var ghostStorage: GhostStorage = GhostStorage() + + class GhostStorage { + @Expose + var ghostTracker: GhostTracker.Data = GhostTracker.Data() + + @Expose + var bestiaryKills: Long = 0L + + @Expose + var migratedTotalKills: Boolean = false + } + + class CakeData { + @Expose + var ownedCakes: MutableSet<Int> = HashSet() + + @Expose + var missingCakes: MutableSet<Int> = HashSet() + + override fun hashCode(): Int { + val prime = 31 + var result = 1 + result = prime * result + ownedCakes.hashCode() + result = prime * result + missingCakes.hashCode() + return result + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null) return false + if (javaClass != other.javaClass) return false + val otherProp = other as CakeData + return otherProp.hashCode() == hashCode() + } + } + + @Expose + var cakeData: CakeData = CakeData() + + @Expose + var powderTracker: PowderTracker.Data = PowderTracker.Data() + + @Expose + var frozenTreasureTracker: FrozenTreasureTracker.Data = FrozenTreasureTracker.Data() + + @Expose + var enderNodeTracker: EnderNodeTracker.Data = EnderNodeTracker.Data() + + @Expose + var rift: RiftStorage = RiftStorage() + + class RiftStorage { + @Expose + var completedKloonTerminals: MutableList<KloonTerminal> = ArrayList() + + @Expose + var verminTracker: VerminTracker.Data = VerminTracker.Data() + } + + @Expose + var slayerProfitData: MutableMap<String, SlayerProfitTracker.Data> = HashMap() + + @Expose + var slayerRngMeter: MutableMap<String, SlayerRngMeterStorage> = HashMap() + + class SlayerRngMeterStorage { + @Expose + var currentMeter: Long = -1 + + @Expose + var gainPerBoss: Long = -1 + + @Expose + var goalNeeded: Long = -1 + + @Expose + var itemGoal: String = "?" + + override fun toString(): String { + return "SlayerRngMeterStorage{" + + "currentMeter=$currentMeter" + + ", gainPerBoss=$gainPerBoss" + + ", goalNeeded=$goalNeeded" + + ", itemGoal='$itemGoal'" + + "}" + } + } + + @Expose + var mining: MiningConfig = MiningConfig() + + class MiningConfig { + @Expose + var kingsTalkedTo: MutableList<String> = ArrayList() + + @Expose + var fossilExcavatorProfitTracker: ExcavatorProfitTracker.Data = ExcavatorProfitTracker.Data() + + @Expose + var hotmTree: HotmTree = HotmTree() + + @Expose + var powder: MutableMap<PowderType, PowderStorage> = EnumMap(PowderType::class.java) + + class PowderStorage { + @Expose + var available: Long? = null + + @Expose + var total: Long? = null + } + + @Expose + var tokens: Int = 0 + + @Expose + var availableTokens: Int = 0 + + @Expose + var mineshaft: MineshaftStorage = MineshaftStorage() + + class MineshaftStorage { + @Expose + var mineshaftTotalBlocks: Long = 0L + + @Expose + var mineshaftTotalCount: Int = 0 + + @Expose + var blocksBroken: MutableList<PityData> = ArrayList() + + @Expose + var corpseProfitTracker: BucketData = BucketData() + } + } + + @Expose + var trapperData: TrapperData = TrapperData() + + class TrapperData { + @Expose + var questsDone: Int = 0 + + @Expose + var peltsGained: Int = 0 + + @Expose + var killedAnimals: Int = 0 + + @Expose + var selfKillingAnimals: Int = 0 + + // TODO change to sh tracker + @Expose + var animalRarities: Map<TrapperMobRarity, Int> = EnumMap(TrapperMobRarity::class.java) + } + + @Expose + var dungeons: DungeonStorage = DungeonStorage() + + class DungeonStorage { + @Expose + var bosses: MutableMap<DungeonFloor, Int> = EnumMap(DungeonFloor::class.java) + + @Expose + var runs: MutableList<DungeonRunInfo> = generateMaxChestAsList() + + class DungeonRunInfo { + constructor() + + constructor(floor: String?) { + this.floor = floor + this.openState = OpenedState.UNOPENED + } + + @Expose + var floor: String? = null + + @Expose + var openState: OpenedState? = null + + @Expose + var kismetUsed: Boolean? = null + } + } + + @Expose + var fishing: FishingStorage = FishingStorage() + + class FishingStorage { + @Expose + var fishingProfitTracker: FishingProfitTracker.Data = FishingProfitTracker.Data() + + @Expose + var seaCreatureTracker: SeaCreatureTracker.Data = SeaCreatureTracker.Data() + } + + @Expose + var diana: DianaStorage = DianaStorage() + + class DianaStorage { + @Expose + var profitTracker: DianaProfitTracker.Data = DianaProfitTracker.Data() + + @Expose + var profitTrackerPerElection: MutableMap<Int, DianaProfitTracker.Data> = HashMap() + + @Expose + var mythologicalMobTracker: MythologicalCreatureTracker.Data = MythologicalCreatureTracker.Data() + + @Expose + var mythologicalMobTrackerPerElection: MutableMap<Int, MythologicalCreatureTracker.Data> = HashMap() + } + + @Expose + var skillData: MutableMap<SkillType, SkillAPI.SkillInfo> = EnumMap(SkillType::class.java) + + @Expose + var wardrobe: WardrobeStorage = WardrobeStorage() + + class WardrobeStorage { + @Expose + var data: MutableMap<Int, WardrobeData> = HashMap() + + @Expose + var currentSlot: Int? = null + } + + @Expose + var draconicSacrificeTracker: DraconicSacrificeTracker.Data = DraconicSacrificeTracker.Data() + + @Expose + var communityShopProfileUpgrade: CommunityShopUpgrade? = null + + @Expose + var abiphoneContactAmount: Int? = null + + @Expose + var hoppityEventStats: MutableMap<Int, HoppityEventStats> = HashMap() + + @Expose + var hoppityStatLiveDisplayToggledOff: Boolean = false + + class HoppityEventStats { + @Expose + var mealsFound: MutableMap<HoppityEggType, Int> = EnumMap(HoppityEggType::class.java) + + @Expose + var rabbitsFound: MutableMap<LorenzRarity, RabbitData> = EnumMap(LorenzRarity::class.java) + + class RabbitData { + @Expose + var uniques: Int = 0 + + @Expose + var dupes: Int = 0 + + @Expose + var strays: Int = 0 + + override fun hashCode(): Int { + return Objects.hash(uniques, dupes, strays) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null) return false + if (javaClass != other.javaClass) return false + val otherProp = other as RabbitData + return otherProp.hashCode() == hashCode() + } + } + + @Expose + var dupeChocolateGained: Long = 0 + + @Expose + var strayChocolateGained: Long = 0 + + @Expose + var millisInCf: Duration = Duration.ZERO + + @Expose + var rabbitTheFishFinds: Int = 0 + + class LeaderboardPosition(@field:Expose var position: Int, @field:Expose var percentile: Double) { + override fun hashCode(): Int { + return Objects.hash(position, percentile) + } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null) return false + if (javaClass != other.javaClass) return false + val otherProp = other as LeaderboardPosition + return otherProp.hashCode() == hashCode() + } + } + + @Expose + var initialLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(-1, -1.0) + + @Expose + var finalLeaderboardPosition: LeaderboardPosition = LeaderboardPosition(-1, -1.0) + + @Expose + var lastLbUpdate: SimpleTimeMark = farPast() + + @Expose + var summarized: Boolean = false + + override fun hashCode(): Int { + return Objects.hash( + mealsFound, + rabbitsFound, + dupeChocolateGained, + strayChocolateGained, + millisInCf, + rabbitTheFishFinds, + initialLeaderboardPosition, + finalLeaderboardPosition, + summarized + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null) return false + if (javaClass != other.javaClass) return false + val otherProp = other as HoppityEventStats + return otherProp.hashCode() == hashCode() + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java deleted file mode 100644 index 3b75a64eebbf..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java +++ /dev/null @@ -1,58 +0,0 @@ -package at.hannibal2.skyhanni.config.storage; - -import at.hannibal2.skyhanni.features.misc.reminders.Reminder; -import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; -import at.hannibal2.skyhanni.utils.LorenzVec; -import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker; -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -public class Storage { - - @Expose - public boolean hasPlayedBefore = false; - - @Expose - public Float savedMouselockedSensitivity = .5f; - - @Expose - public Float savedMouseloweredSensitivity = .5f; - - @Deprecated - @Expose - public Map<String, List<String>> knownFeatureToggles = new HashMap<>(); - - @Deprecated - @Expose - public List<VisualWord> modifiedWords = new ArrayList<>(); - - @Expose - public boolean visualWordsImported = false; - - @Expose - public Boolean contestSendingAsked = false; - - @Expose - public Map<String, SkyHanniTracker.DisplayMode> trackerDisplayModes = new HashMap<>(); - - @Expose - public List<LorenzVec> foundDianaBurrowLocations = new ArrayList<>(); - - @Expose - public Map<UUID, PlayerSpecificStorage> players = new HashMap<>(); - - // TODO this should get moved into player specific - @Expose - public String currentFameRank = "New player"; - - @Expose - public List<String> blacklistedUsers = new ArrayList<>(); - - @Expose - public Map<String, Reminder> reminders = new HashMap<>(); -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.kt b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.kt new file mode 100644 index 000000000000..99c39ca7383e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.kt @@ -0,0 +1,52 @@ +package at.hannibal2.skyhanni.config.storage + +import at.hannibal2.skyhanni.features.misc.reminders.Reminder +import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker +import com.google.gson.annotations.Expose +import java.util.* + +class Storage { + @Expose + var hasPlayedBefore: Boolean = false + + @Expose + var savedMouselockedSensitivity: Float = .5f + + @Expose + var savedMouseloweredSensitivity: Float = .5f + + @Deprecated("") + @Expose + var knownFeatureToggles: Map<String, List<String>> = HashMap() + + @Deprecated("") + @Expose + var modifiedWords: List<VisualWord> = ArrayList() + + @Expose + var visualWordsImported: Boolean = false + + @Expose + var contestSendingAsked: Boolean = false + + @Expose + var trackerDisplayModes: MutableMap<String, SkyHanniTracker.DisplayMode> = HashMap() + + @Expose + var foundDianaBurrowLocations: List<LorenzVec> = ArrayList() + + @Expose + var players: MutableMap<UUID, PlayerSpecificStorage> = HashMap() + + // TODO this should get moved into player specific + @Expose + var currentFameRank: String = "New player" + + @Expose + var blacklistedUsers: MutableList<String> = ArrayList() + + @Expose + var reminders: MutableMap<String, Reminder> = HashMap() +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 1fec9965be8b..9bdf37f409ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -36,11 +36,11 @@ object BitsAPI { private set(value) { profileStorage?.bits = value } - var currentFameRank: FameRank? - get() = playerStorage?.currentFameRank?.let { getFameRankByNameOrNull(it) } + private var currentFameRank: FameRank? + get() = getFameRankByNameOrNull(playerStorage.currentFameRank) private set(value) { if (value != null) { - playerStorage?.currentFameRank = value.name + playerStorage.currentFameRank = value.name } } var bitsAvailable: Int diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt index 2bdf568504c2..45ad134c8bb6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt @@ -51,7 +51,7 @@ object PetAPI { var currentPet: String? get() = ProfileStorageData.profileSpecific?.currentPet?.takeIf { it.isNotEmpty() } set(value) { - ProfileStorageData.profileSpecific?.currentPet = value + ProfileStorageData.profileSpecific?.currentPet = value.orEmpty() } fun isCurrentPet(petName: String): Boolean = currentPet?.contains(petName) ?: false diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt index 529294fba609..36a6a6dba503 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.QuiverAPI.currentArrow import at.hannibal2.skyhanni.data.jsonobjects.repo.ArrowTypeJson import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -29,6 +30,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemBow import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Matcher @SkyHanniModule @@ -39,11 +41,8 @@ object QuiverAPI { set(value) { storage?.arrows?.currentArrow = value?.toString() ?: return } - var arrowAmount: MutableMap<NEUInternalName, Int> + private val arrowAmount: MutableMap<NEUInternalName, Int> get() = storage?.arrows?.arrowAmount ?: mutableMapOf() - set(value) { - storage?.arrows?.arrowAmount = value - } var currentAmount: Int get() = currentArrow?.amount ?: 0 set(value) { @@ -142,20 +141,7 @@ object QuiverAPI { } fillUpJaxPattern.matchMatcher(message) { - val type = group("type") - val amount = group("amount").formatInt() - val filledUpType = getArrowByNameOrNull(type) - ?: return ErrorManager.logErrorWithData( - UnknownArrowType("Unknown arrow type: $type"), - "Unknown arrow type: $type", - "message" to message, - ) - - filledUpType.amount += amount - if (filledUpType == currentArrow) { - postUpdateEvent() - } - return + this.handleQuiverAddedMatch(message) } fillUpPattern.matchMatcher(message) { @@ -169,20 +155,7 @@ object QuiverAPI { } addedToQuiverPattern.matchMatcher(message) { - val type = group("type") - val amount = group("amount").formatInt() - val filledUpType = getArrowByNameOrNull(type) - ?: return ErrorManager.logErrorWithData( - UnknownArrowType("Unknown arrow type: $type"), - "Unknown arrow type: $type", - "message" to message, - ) - - filledUpType.amount += amount - if (filledUpType == currentArrow) { - postUpdateEvent() - } - return + this.handleQuiverAddedMatch(message) } clearedPattern.matchMatcher(message) { @@ -202,6 +175,23 @@ object QuiverAPI { } } + private fun Matcher.handleQuiverAddedMatch(message: String) { + val type = group("type") + val amount = group("amount").formatInt() + val filledUpType = getArrowByNameOrNull(type) + ?: return ErrorManager.logErrorWithData( + UnknownArrowType("Unknown arrow type: $type"), + "Unknown arrow type: $type", + "message" to message, + ) + + filledUpType.amount += amount + if (filledUpType == currentArrow) { + postUpdateEvent() + } + return + } + @SubscribeEvent fun onInventoryFullyLoaded(event: InventoryFullyOpenedEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt index 9d58858a73fa..5d9f5ac3d7d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -274,7 +274,7 @@ object CroesusChestTracker { } @JvmStatic - fun generateMaxChestAsList(): List<DungeonRunInfo> = generateMaxChest().toList() + fun generateMaxChestAsList(): MutableList<DungeonRunInfo> = generateMaxChest().toMutableList() private fun generateMaxChest(): Sequence<DungeonRunInfo> = generateSequence { DungeonRunInfo() }.take(MAX_CHESTS) private fun getLastActiveChest(includeDungeonKey: Boolean = false): Int = ( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt index c9e995326976..e994485e3133 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt @@ -21,15 +21,15 @@ object AllBurrowsList { private var list = listOf<LorenzVec>() private val config get() = SkyHanniMod.feature.event.diana.allBurrowsList private var burrowLocations - get() = SkyHanniMod.feature.storage?.foundDianaBurrowLocations + get() = SkyHanniMod.feature.storage.foundDianaBurrowLocations set(value) { - SkyHanniMod.feature.storage?.foundDianaBurrowLocations = value + SkyHanniMod.feature.storage.foundDianaBurrowLocations = value } @HandleEvent fun onBurrowDetect(event: BurrowDetectEvent) { if (!isEnabled()) return - burrowLocations = burrowLocations?.editCopy { + burrowLocations = burrowLocations.editCopy { add(event.burrowLocation) } } @@ -37,7 +37,6 @@ object AllBurrowsList { @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - val burrowLocations = burrowLocations ?: return val range = 5..70 list = burrowLocations.asSequence().map { it to it.distanceToPlayer() } @@ -48,7 +47,6 @@ object AllBurrowsList { } fun copyToClipboard() { - val burrowLocations = burrowLocations ?: return val list = burrowLocations.map { it.printWithAccuracy(0, ":") } OSUtils.copyToClipboard(list.joinToString(";")) ChatUtils.chat("Saved all ${list.size} burrow locations to clipboard.") @@ -57,7 +55,6 @@ object AllBurrowsList { fun addFromClipboard() { SkyHanniMod.coroutineScope.launch { val text = OSUtils.readFromClipboard() ?: return@launch - val burrowLocations = burrowLocations ?: return@launch var new = 0 var duplicate = 0 @@ -71,7 +68,7 @@ object AllBurrowsList { duplicate++ } } - AllBurrowsList.burrowLocations = burrowLocations.editCopy { + burrowLocations = burrowLocations.editCopy { addAll(newEntries) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt index 909d4a4a9984..2a60de842312 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ElectionAPI.getElectionYear import at.hannibal2.skyhanni.data.ItemAddManager import at.hannibal2.skyhanni.data.jsonobjects.repo.DianaDropsJson @@ -52,9 +53,9 @@ object DianaProfitTracker { private val tracker = SkyHanniItemTracker( "Diana Profit Tracker", { Data() }, - { it.diana.dianaProfitTracker }, + { it.diana.profitTracker }, SkyHanniTracker.DisplayMode.MAYOR to { - it.diana.dianaProfitTrackerPerElectionSeason.getOrPut( + it.diana.profitTrackerPerElection.getOrPut( SkyBlockTime.now().getElectionYear(), ::Data, ) }, @@ -177,4 +178,19 @@ object DianaProfitTracker { fun resetCommand() { tracker.resetCommand() } + + private val migrationMapping by lazy { + mapOf( + "dianaProfitTracker" to "profitTracker", + "dianaProfitTrackerPerElectionSeason" to "profitTrackerPerElection", + "mythologicalMobTrackerPerElectionSeason" to "mythologicalMobTrackerPerElection", + ) + } + + @HandleEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + migrationMapping.forEach { (old, new) -> + event.move(70, "#profile.diana.$old", "#profile.diana.$new") + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt index 2068842aec05..e9ebcf99c3a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt @@ -61,7 +61,7 @@ object MythologicalCreatureTracker { private val tracker = SkyHanniTracker( "Mythological Creature Tracker", { Data() }, { it.diana.mythologicalMobTracker }, SkyHanniTracker.DisplayMode.MAYOR to { - it.diana.mythologicalMobTrackerPerElectionSeason.getOrPut( + it.diana.mythologicalMobTrackerPerElection.getOrPut( SkyBlockTime.now().getElectionYear(), ::Data, ) }, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index 43b17c58efe3..21215b6ddd58 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -80,8 +80,10 @@ object FarmingPersonalBestGain { newFFPattern.matchMatcher(event.message) { val cropName = group("crop") newFF = group("ff").formatDouble() + val newFF = newFF ?: return crop = cropName cropType = CropType.getByName(cropName) + val cropType = cropType ?: return GardenAPI.storage?.let { it.personalBestFF[cropType] = newFF } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/caketracker/CakeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/caketracker/CakeTracker.kt index 568d8acf36a0..0bc18150c617 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/caketracker/CakeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/caketracker/CakeTracker.kt @@ -278,7 +278,7 @@ object CakeTracker { private fun recalculateMissingCakes() { val storage = storage ?: return - storage.missingCakes = (1..currentYear).toSet() - storage.ownedCakes + storage.missingCakes = ((1..currentYear).toSet() - storage.ownedCakes).toMutableSet() } private fun getCakePrice(year: Int): Double { diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 251c82a16c04..e3098b9356c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -210,7 +210,7 @@ object MinionFeatures { MinionFeatures.minions = minions.editCopy { this[entity] = ProfileSpecificStorage.MinionConfig().apply { displayName = name - lastClicked = 0 + lastClicked = SimpleTimeMark.farPast() } } } else { @@ -271,7 +271,7 @@ object MinionFeatures { val location = lastMinion ?: return if (location !in minions) { - minions[location]?.lastClicked = 0 + minions[location]?.lastClicked = SimpleTimeMark.farPast() } } MinionCloseEvent().post() @@ -305,17 +305,17 @@ object MinionFeatures { val duration = minions?.get(loc)?.let { val lastClicked = it.lastClicked - if (lastClicked == 0L) { + if (lastClicked.isFarPast()) { return "§cCan't calculate coins/day: No time data available!" } - System.currentTimeMillis() - lastClicked + SimpleTimeMark.now() - lastClicked } ?: return "§cCan't calculate coins/day: No time data available!" // §7Held Coins: §b151,389 // TODO use regex val coins = line.split(": §b")[1].formatDouble() - val coinsPerDay = (coins / (duration.toDouble())) * 1000 * 60 * 60 * 24 + val coinsPerDay = (coins / (duration.inWholeMilliseconds)) * 1000 * 60 * 60 * 24 val format = coinsPerDay.toInt().addSeparators() return "§7Coins/day with ${stack.name}§7: §6$format coins" @@ -337,7 +337,7 @@ object MinionFeatures { val message = event.message if (minionCoinPattern.matches(message) && System.currentTimeMillis() - lastInventoryClosed < 2_000) { minions?.get(lastMinion)?.let { - it.lastClicked = System.currentTimeMillis() + it.lastClicked = SimpleTimeMark.now() } } if (message.startsWith("§aYou picked up a minion!") && lastMinion != null) { @@ -349,8 +349,8 @@ object MinionFeatures { if (message.startsWith("§bYou placed a minion!") && newMinion != null) { minions = minions?.editCopy { this[newMinion!!] = ProfileSpecificStorage.MinionConfig().apply { - displayName = newMinionName - lastClicked = 0 + displayName = newMinionName.orEmpty() + lastClicked = SimpleTimeMark.farPast() } } newMinion = null @@ -387,9 +387,8 @@ object MinionFeatures { event.drawString(location.up(0.65), name, true) } - if (config.emptiedTime.display && lastEmptied != 0L) { - val passedSince = SimpleTimeMark(lastEmptied).passedSince() - val format = passedSince.format(longName = true) + " ago" + if (config.emptiedTime.display && !lastEmptied.isFarPast()) { + val format = lastEmptied.passedSince().format(longName = true) + " ago" val text = "§eHopper Emptied: $format" event.drawString(location.up(1.15), text, true) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt index b83e1f0e9f06..b38d4b8d584b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt @@ -30,7 +30,9 @@ object DefaultConfigFeatures { val knownToggles = SkyHanniMod.knownFeaturesData.knownFeatures val updated = SkyHanniMod.VERSION !in knownToggles val processor = FeatureToggleProcessor() - ConfigProcessorDriver(processor).processConfig(SkyHanniMod.feature) + val driver = ConfigProcessorDriver(processor) + driver.warnForPrivateFields = false + driver.processConfig(SkyHanniMod.feature) knownToggles[SkyHanniMod.VERSION] = processor.allOptions.map { it.path } SkyHanniMod.configManager.saveConfig(ConfigFileType.KNOWN_FEATURES, "Updated known feature flags") if (!SkyHanniMod.feature.storage.hasPlayedBefore) { @@ -62,7 +64,9 @@ object DefaultConfigFeatures { fun onCommand(old: String, new: String) { val processor = FeatureToggleProcessor() - ConfigProcessorDriver(processor).processConfig(SkyHanniMod.feature) + val driver = ConfigProcessorDriver(processor) + driver.warnForPrivateFields = false + driver.processConfig(SkyHanniMod.feature) var optionList = processor.orderedOptions val knownToggles = SkyHanniMod.knownFeaturesData.knownFeatures val togglesInNewVersion = knownToggles[new] diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt index 020004648531..25df673ee4a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/FeatureToggleProcessor.kt @@ -24,8 +24,7 @@ class FeatureToggleProcessor : ConfigStructureReader { latestCategory = Category(name, description) } - @Suppress("EmptyFunctionBlock") - override fun endCategory() {} + override fun endCategory() = Unit override fun beginAccordion(baseObject: Any?, field: Field?, o: ConfigOption?, id: Int) { val option = o ?: return @@ -81,11 +80,8 @@ class FeatureToggleProcessor : ConfigStructureReader { featureToggle.trueIsEnabled, latestCategory!!, setter, - pathStack.joinToString(".") + "." + field.name - ) + pathStack.joinToString(".") + "." + field.name, + ), ) } - - @Suppress("EmptyFunctionBlock") - override fun emitGuiOverlay(baseObject: Any?, field: Field?, option: ConfigOption?) {} } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt index 9f3834de671e..47f671ad6a70 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/GuiOptionEditorUpdateCheck.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.update import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.core.elements.GuiElementButton +import io.github.notenoughupdates.moulconfig.common.RenderContext import io.github.notenoughupdates.moulconfig.gui.GuiOptionEditor import io.github.notenoughupdates.moulconfig.internal.TextRenderUtils import io.github.notenoughupdates.moulconfig.processor.ProcessedOption @@ -15,7 +16,7 @@ class GuiOptionEditorUpdateCheck(option: ProcessedOption) : GuiOptionEditor(opti val button = GuiElementButton("", -1) {} - override fun render(x: Int, y: Int, width: Int) { + override fun render(context: RenderContext?, x: Int, y: Int, width: Int) { val fr = Minecraft.getMinecraft().fontRendererObj GlStateManager.pushMatrix() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt index bcf8e45b25d4..13bd8408d13c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt @@ -80,7 +80,7 @@ object ConfigUtils { } fun KMutableProperty0<*>.tryFindEditor(editor: MoulConfigEditor<*>): ProcessedOption? { - return editor.processedConfig.getOptionFromField(this.javaField ?: return null) + return editor.getOptionFromField(this.javaField ?: return null) } fun KMutableProperty0<*>.jumpToEditor() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt index c17462472eb7..65b56b756b07 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt @@ -12,8 +12,9 @@ import java.lang.reflect.ParameterizedType object ListEnumSkippingTypeAdapterFactory : TypeAdapterFactory { override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? { val rawType = type.rawType - if (rawType == List::class.java) { - val actualType = (type.type as ParameterizedType).actualTypeArguments[0] + if (rawType == List::class.java && type.type is ParameterizedType) { + val paramType = type.type as ParameterizedType + val actualType = paramType.actualTypeArguments[0] if (actualType is Class<*> && actualType.isEnum) { @Suppress("UNCHECKED_CAST") return ListEnumSkippingTypeAdapter(actualType as Class<out Enum<*>>) as TypeAdapter<T> From e440dad405e6221fd001a004f8b4b55901bbfbf4 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:34:38 +0100 Subject: [PATCH 81/93] Fix: Custom Scoreboard not showing Kuudra Lines - Part 3 (#3157) --- .../gui/customscoreboard/CustomScoreboard.kt | 8 +---- .../events/ScoreboardEventKuudra.kt | 5 +-- .../features/nether/kuudra/KuudraAPI.kt | 33 ++++++++++--------- versions/1.8.9/detekt/baseline.xml | 8 +---- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt index 001537ced2d0..aa5b443f3571 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt @@ -201,13 +201,7 @@ object CustomScoreboard { @HandleEvent fun onIslandChange(event: IslandChangeEvent) { - if (event.newIsland != IslandType.NONE) { - updateIslandEntries() - - runDelayed(3.seconds) { - updateIslandEntries() - } - } + if (event.newIsland != IslandType.NONE) updateIslandEntries() } private fun updateIslandEntries() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventKuudra.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventKuudra.kt index de5231f74292..a067d262c5d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventKuudra.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventKuudra.kt @@ -1,8 +1,9 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.events +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getSbLines import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern -import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.allMatches // scoreboard @@ -23,5 +24,5 @@ object ScoreboardEventKuudra : ScoreboardEvent() { override val configLine = "§7(All Kuudra Lines)" - override fun showIsland() = KuudraAPI.inKuudra() + override fun showIsland() = IslandType.KUUDRA_ARENA.isInIsland() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt index e820bf2da039..1d1603c32f09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt @@ -1,15 +1,16 @@ package at.hannibal2.skyhanni.features.nether.kuudra -import at.hannibal2.skyhanni.data.ScoreboardData +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent import at.hannibal2.skyhanni.events.kuudra.KuudraCompleteEvent import at.hannibal2.skyhanni.events.kuudra.KuudraEnterEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.removePrefix +import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchGroup import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -21,13 +22,17 @@ object KuudraAPI { private val patternGroup = RepoPattern.group("data.kuudra") + /** + * REGEX-TEST: §7⏣ §cKuudra's Hollow §8(T5) + * REGEX-TEST: §7⏣ §cKuudra's Hollow §8(T2) + */ private val tierPattern by patternGroup.pattern( "scoreboard.tier", - " §7⏣ §cKuudra's Hollow §8\\(T(?<tier>.*)\\)" + " §7⏣ §cKuudra's Hollow §8\\(T(?<tier>\\d+)\\)", ) private val completePattern by patternGroup.pattern( "chat.complete", - "§.\\s*(?:§.)*KUUDRA DOWN!" + "§.\\s*(?:§.)*KUUDRA DOWN!", ) /** @@ -38,7 +43,7 @@ object KuudraAPI { */ private val kuudraArmorPattern by patternGroup.pattern( "internalname.armor", - "(?<tier>HOT|BURNING|FIERY|INFERNAL|)_?(?<type>AURORA|CRIMSON|TERROR|HOLLOW|FERVOR)_(?:HELMET|CHESTPLATE|LEGGINGS|BOOTS)" + "(?<tier>HOT|BURNING|FIERY|INFERNAL|)_?(?<type>AURORA|CRIMSON|TERROR|HOLLOW|FERVOR)_(?:HELMET|CHESTPLATE|LEGGINGS|BOOTS)", ) private val kuudraTiers = listOf("", "HOT", "BURNING", "FIERY", "INFERNAL") @@ -61,16 +66,14 @@ object KuudraAPI { fun inKuudra() = kuudraTier != null - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + @HandleEvent + fun onScoreboardChange(event: ScoreboardUpdateEvent) { if (!LorenzUtils.inSkyBlock) return if (kuudraTier != null) return - for (line in ScoreboardData.sidebarLinesFormatted) { - tierPattern.matchMatcher(line) { - val tier = group("tier").toInt() - kuudraTier = tier - KuudraEnterEvent(tier).post() - } + tierPattern.firstMatcher(event.added) { + val tier = group("tier").toInt() + kuudraTier = tier + KuudraEnterEvent(tier).post() } } @@ -81,8 +84,8 @@ object KuudraAPI { @SubscribeEvent fun onChat(event: LorenzChatEvent) { - val message = event.message - completePattern.matchMatcher(message) { + if (!LorenzUtils.inSkyBlock) return + completePattern.matchMatcher(event.message) { val tier = kuudraTier ?: return KuudraCompleteEvent(tier).post() } diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index 11754ba60de3..c2ea857bbf2c 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -13,7 +13,6 @@ <ID>CyclomaticComplexMethod:AdvancedPlayerList.kt$AdvancedPlayerList$fun newSorting(original: List<String>): List<String></ID> <ID>CyclomaticComplexMethod:CropMoneyDisplay.kt$CropMoneyDisplay$private fun calculateMoneyPerHour(debugList: MutableList<List<Any>>): Map<NEUInternalName, Array<Double>></ID> <ID>CyclomaticComplexMethod:CropMoneyDisplay.kt$CropMoneyDisplay$private fun drawDisplay(): List<List<Any>></ID> - <ID>CyclomaticComplexMethod:DamageIndicatorManager.kt$DamageIndicatorManager$private fun checkThorn(realHealth: Long, realMaxHealth: Long): String?</ID> <ID>CyclomaticComplexMethod:EstimatedItemValueCalculator.kt$EstimatedItemValueCalculator$private fun addEnchantments(stack: ItemStack, list: MutableList<String>): Double</ID> <ID>CyclomaticComplexMethod:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$private fun drawProgressDisplay(crop: CropType): List<Renderable></ID> <ID>CyclomaticComplexMethod:GardenVisitorFeatures.kt$GardenVisitorFeatures$private fun readToolTip(visitor: VisitorAPI.Visitor, itemStack: ItemStack?, toolTip: MutableList<String>)</ID> @@ -186,8 +185,7 @@ <ID>RepoPatternRegexTest:ItemPickupLog.kt$ItemPickupLog$by patternGroup.pattern( "shoppattern", "^(?<itemName>.+?)(?: x\\d+)?\$", )</ID> <ID>RepoPatternRegexTest:JacobFarmingContestsInventory.kt$JacobFarmingContestsInventory$by RepoPattern.pattern( "garden.jacob.contests.inventory.medal", "§7§7You placed in the (?<medal>.*) §7bracket!" )</ID> <ID>RepoPatternRegexTest:KloonHacking.kt$KloonHacking$by RepoPattern.pattern( "rift.area.westvillage.kloon.color", "You've set the color of this terminal to (?<color>.*)!" )</ID> - <ID>RepoPatternRegexTest:KuudraAPI.kt$KuudraAPI$by patternGroup.pattern( "chat.complete", "§.\\s*(?:§.)*KUUDRA DOWN!" )</ID> - <ID>RepoPatternRegexTest:KuudraAPI.kt$KuudraAPI$by patternGroup.pattern( "scoreboard.tier", " §7⏣ §cKuudra's Hollow §8\\(T(?<tier>.*)\\)" )</ID> + <ID>RepoPatternRegexTest:KuudraAPI.kt$KuudraAPI$by patternGroup.pattern( "chat.complete", "§.\\s*(?:§.)*KUUDRA DOWN!", )</ID> <ID>RepoPatternRegexTest:MaxPurseItems.kt$MaxPurseItems$by patternGroup.pattern( "instant", ".*Price per unit: §6(?<coins>[\\d.,]+) coins.*", )</ID> <ID>RepoPatternRegexTest:MaxPurseItems.kt$MaxPurseItems$by patternGroup.pattern( "order", ".*§6(?<coins>[\\d.,]+) coins §7each.*", )</ID> <ID>RepoPatternRegexTest:MaxwellAPI.kt$MaxwellAPI$by patternGroup.pattern( "gui.noselectedpower", "(?:§.)*Visit Maxwell in the Hub to learn", )</ID> @@ -281,8 +279,6 @@ <ID>ReturnCount:CompactBingoChat.kt$CompactBingoChat$private fun onSkyBlockLevelUp(message: String): Boolean</ID> <ID>ReturnCount:CrimsonMinibossRespawnTimer.kt$CrimsonMinibossRespawnTimer$private fun updateArea()</ID> <ID>ReturnCount:CropMoneyDisplay.kt$CropMoneyDisplay$private fun drawDisplay(): List<List<Any>></ID> - <ID>ReturnCount:DamageIndicatorManager.kt$DamageIndicatorManager$private fun checkThorn(realHealth: Long, realMaxHealth: Long): String?</ID> - <ID>ReturnCount:DamageIndicatorManager.kt$DamageIndicatorManager$private fun getCustomHealth( entityData: EntityData, health: Long, entity: EntityLivingBase, maxHealth: Long, ): String?</ID> <ID>ReturnCount:EnchantParser.kt$EnchantParser$private fun parseEnchants( loreList: MutableList<String>, enchants: Map<String, Int>, chatComponent: IChatComponent?, )</ID> <ID>ReturnCount:EstimatedItemValueCalculator.kt$EstimatedItemValueCalculator$private fun calculateStarPrice( internalName: NEUInternalName, inputStars: Int, ): Pair<EssenceItemUtils.EssenceUpgradePrice, Pair<Int, Int>>?</ID> <ID>ReturnCount:FishingAPI.kt$FishingAPI$fun seaCreatureCount(entity: EntityArmorStand): Int</ID> @@ -315,7 +311,6 @@ <ID>TooManyFunctions:CollectionUtils.kt$CollectionUtils</ID> <ID>TooManyFunctions:DailyQuestHelper.kt$DailyQuestHelper</ID> <ID>TooManyFunctions:EstimatedItemValueCalculator.kt$EstimatedItemValueCalculator</ID> - <ID>TooManyFunctions:GuiRenderUtils.kt$GuiRenderUtils</ID> <ID>TooManyFunctions:HypixelCommands.kt$HypixelCommands</ID> <ID>TooManyFunctions:InventoryUtils.kt$InventoryUtils</ID> <ID>TooManyFunctions:LocationUtils.kt$LocationUtils</ID> @@ -402,7 +397,6 @@ <ID>UnsafeCallOnNullableType:SackAPI.kt$SackAPI$oldData!!</ID> <ID>UnsafeCallOnNullableType:SkyHanniBucketedItemTracker.kt$SkyHanniBucketedItemTracker$it.get(DisplayMode.SESSION).getItemsProp()[internalName]!!</ID> <ID>UnsafeCallOnNullableType:SkyHanniBucketedItemTracker.kt$SkyHanniBucketedItemTracker$it.get(DisplayMode.TOTAL).getItemsProp()[internalName]!!</ID> - <ID>UnsafeCallOnNullableType:SkyHanniMod.kt$SkyHanniMod.Companion$Loader.instance().indexedModList[MODID]!!</ID> <ID>UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$distance!!</ID> <ID>UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$distance2!!</ID> <ID>UnsafeCallOnNullableType:SoopyGuessBurrow.kt$SoopyGuessBurrow$firstParticlePoint?.distance(pos)!!</ID> From 4272869f467eab9ddf340cf64a130e55ad965087 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:37:33 +0100 Subject: [PATCH 82/93] Improvement: Widget Display, Hypixel Profile (#3152) --- .../hannibal2/skyhanni/features/gui/TabWidgetDisplay.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/TabWidgetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/TabWidgetDisplay.kt index efcc539d0d80..472cff77d5f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/TabWidgetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/TabWidgetDisplay.kt @@ -35,6 +35,15 @@ enum class TabWidgetDisplay(private val configName: String?, vararg val widgets: FIRE_SALE(null, TabWidget.FIRE_SALE), RAIN("Park Rain", TabWidget.RAIN), PEST_TRAPS("Pest Traps", TabWidget.PEST_TRAPS), + FULL_PROFILE_WIDGET( + "Profile Widget", + TabWidget.PROFILE, + TabWidget.SB_LEVEL, + TabWidget.BANK, + TabWidget.INTEREST, + TabWidget.SOULFLOW, + TabWidget.FAIRY_SOULS, + ) ; val position get() = config.displayPositions[ordinal] From 7b9b76d568701308e9aca40a9dc1f0615f91a20c Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:39:47 +0100 Subject: [PATCH 83/93] Backend: More Regex Tests (#3158) --- .../at/hannibal2/skyhanni/data/QuiverAPI.kt | 26 ++++++++-- .../skyhanni/features/bingo/BingoAPI.kt | 3 ++ .../features/bingo/card/BingoCardTips.kt | 18 +++++-- .../nextstephelper/BingoNextStepHelper.kt | 48 ++++++++++------- .../skyhanni/features/chat/ChatFilter.kt | 3 ++ .../features/dungeon/DungeonFinderFeatures.kt | 42 +++++++++------ .../features/garden/GardenLevelDisplay.kt | 18 ++++--- .../garden/fortuneguide/CaptureFarmingGear.kt | 12 +++++ .../inventory/AuctionOutbidWarning.kt | 4 ++ .../AuctionHouseCopyUnderbidPrice.kt | 12 +++++ .../misc/compacttablist/AdvancedPlayerList.kt | 5 ++ .../features/misc/pets/CurrentPetDisplay.kt | 13 +++++ .../teleportpad/TeleportPadCompactName.kt | 8 +++ .../hannibal2/skyhanni/utils/UtilsPatterns.kt | 26 +++++++--- versions/1.8.9/detekt/baseline.xml | 52 +++++-------------- 15 files changed, 191 insertions(+), 99 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt index 36a6a6dba503..4367c14829ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt @@ -68,7 +68,18 @@ object QuiverAPI { private val group = RepoPattern.group("data.quiver") private val chatGroup = group.group("chat") - private val selectPattern by chatGroup.pattern("select", "§aYou set your selected arrow type to §.(?<arrow>.*)§a!") + + /** + * REGEX-TEST: §aYou set your selected arrow type to §r§fFlint Arrow§r§a! + */ + private val selectPattern by chatGroup.pattern( + "select", + "§aYou set your selected arrow type to §.(?<arrow>.*)§a!", + ) + + /** + * REGEX-TEST: §aJax forged §r§fFlint Arrow§r§8 x386 §r§afor §r§61,930 Coins§r§a! + */ private val fillUpJaxPattern by chatGroup.pattern( "fillupjax", "(?:§.)*Jax forged (?:§.)*(?<type>.*?)(?:§.)* x(?<amount>[\\d,]+)(?: (?:§.)*for (?:§.)*(?<coins>[\\d,]+) Coins)?(?:§.)*!", @@ -85,11 +96,18 @@ object QuiverAPI { "cleared", "§aCleared your quiver!|§c§lYour quiver is now completely empty!", ) + + /** + * REGEX-TEST: §c§lQUIVER! §r§cYou have run out of §r§fFlint Arrows§r§c! + */ private val arrowRanOutPattern by chatGroup.pattern( "ranout", "§c§lQUIVER! §cYou have run out of §f(?<type>.*)s§c!", ) - private val arrowResetPattern by chatGroup.pattern("arrowreset", "§cYour favorite arrow has been reset!") + private val arrowResetPattern by chatGroup.pattern( + "arrowreset", + "§cYour favorite arrow has been reset!", + ) private val addedToQuiverPattern by chatGroup.pattern( "addedtoquiver", "(?:§.)*You've added (?:§.)*(?<type>.*) x(?<amount>.*) (?:§.)*to your quiver!", @@ -100,8 +118,8 @@ object QuiverAPI { * REGEX-TEST: BOSS_SPIRIT_BOW * REGEX-TEST: CRYPT_BOW */ - private val fakeBowsPattern by group.pattern("fakebows", "^(?:BOSS_SPIRIT_BOW|CRYPT_BOW)$") - private val quiverInventoryNamePattern by group.pattern("quivername", "^Quiver$") + private val fakeBowsPattern by group.pattern("fakebows", "BOSS_SPIRIT_BOW|CRYPT_BOW") + private val quiverInventoryNamePattern by group.pattern("quivername", "Quiver") /** * REGEX-TEST: §7Active Arrow: §fFlint Arrow §7(§e2880§7) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt index 06a6745082ab..9dc59bc27481 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt @@ -32,6 +32,9 @@ object BingoAPI { val communityGoals get() = bingoGoals.values.filter { it.type == GoalType.COMMUNITY } var lastBingoCardOpenTime = SimpleTimeMark.farPast() + /** + * REGEX-TEST: §9Ⓑ §9Bingo + */ private val detectionPattern by RepoPattern.pattern( "bingo.detection.scoreboard", " §.Ⓑ §.Bingo" diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt index abf8bbedc701..68fd3913ba06 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt @@ -26,19 +26,27 @@ object BingoCardTips { private val patternGroup = RepoPattern.group("bingo.card.tips") private val inventoryPattern by patternGroup.pattern( "card", - "Bingo Card" + "Bingo Card", ) + + /** + * REGEX-TEST: §7Reward + */ private val rewardPattern by patternGroup.pattern( "reward", - "§.§.§7Reward" + "(§.)+Reward", ) private val contributionRewardsPattern by patternGroup.pattern( "reward.contribution", - "§.§.§7Contribution Rewards.*" + "(§.)+Contribution Rewards.*", ) + + /** + * REGEX-TEST: §eRow #4 + */ private val rowNamePattern by patternGroup.pattern( "row.name", - "§o§.Row #.*" + "(§.)+Row #.*", ) @SubscribeEvent @@ -71,7 +79,7 @@ object BingoCardTips { "BingoCardTips reward line not found", "goal displayName" to goal.displayName, "slot slotNumber" to slot.slotNumber, - "toolTip" to toolTip + "toolTip" to toolTip, ) return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt index 128ca00d1fa2..70bdab6cc548 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/BingoNextStepHelper.kt @@ -39,23 +39,31 @@ object BingoNextStepHelper { private val patternGroup = RepoPattern.group("bingo.steps") private val crystalObtainedPattern by patternGroup.pattern( "crystal.obtained", - " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal" + " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal", ) + + /** + * REGEX-TEST: §7§7Reach §a1,000 §7Ink Sac Collection. + */ private val collectionPattern by patternGroup.pattern( "collection", - "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\." + "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\.", ) private val crystalPattern by patternGroup.pattern( "crystal.obtain", - "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\." + "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\.", ) + + /** + * REGEX-TEST: §7§7Obtain level §e10§7 in the §6Foraging §7Skill. + */ private val skillPattern by patternGroup.pattern( "skill", - "Obtain level (?<level>.*) in the (?<skill>.*) Skill." + "Obtain level (?<level>.*) in the (?<skill>.*) Skill.", ) private val crystalFoundPattern by patternGroup.pattern( "crystal.found", - " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)" + " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)", ) private val itemIslandRequired = mutableMapOf<String, IslandVisitStep>() @@ -276,7 +284,7 @@ object BingoNextStepHelper { "32x Enchanted Emerald", "Emerald", 160 * 32, - mapOf("Emerald" to 1, "Enchanted Emerald" to 160) + mapOf("Emerald" to 1, "Enchanted Emerald" to 160), ) requires IslandType.DWARVEN_MINES.getStep() ) } @@ -287,7 +295,7 @@ object BingoNextStepHelper { "32x Jacob's Ticket", "Jacob's Ticket", 32, - mapOf("Jacob's Ticket" to 1) + mapOf("Jacob's Ticket" to 1), ).addItemRequirements() requires IslandType.GARDEN.getStep() ) } @@ -344,7 +352,7 @@ object BingoNextStepHelper { rhys() IslandType.DWARVEN_MINES.getStep() requires SkillLevelStep( "Mining", - 12 + 12, ).also { it requires IslandType.THE_FARMING_ISLANDS.getStep() } IslandType.CRYSTAL_HOLLOWS.getStep() requires IslandType.DWARVEN_MINES.getStep() @@ -361,7 +369,7 @@ object BingoNextStepHelper { ChatMessageStep("Get Ender Armor").makeFinalStep() requires IslandType.THE_END.getStep() IslandType.THE_END.getStep() requires SkillLevelStep( "Combat", - 12 + 12, ).also { it requires IslandType.DEEP_CAVERNS.getStep() } // enchantedCharcoal(7) // compactor(7) @@ -372,7 +380,7 @@ object BingoNextStepHelper { RHYS_TASK_NAME, "Redstone", 160 * 10, - mapOf("Redstone" to 1, "Enchanted Redstone" to 160) + mapOf("Redstone" to 1, "Enchanted Redstone" to 160), ) redstoneForRhys requires IslandType.DEEP_CAVERNS.getStep() @@ -380,7 +388,7 @@ object BingoNextStepHelper { RHYS_TASK_NAME, "Lapis Lazuli", 160 * 10, - mapOf("Lapis Lazuli" to 1, "Enchanted Lapis Lazuli" to 160) + mapOf("Lapis Lazuli" to 1, "Enchanted Lapis Lazuli" to 160), ) lapisForRhys requires IslandType.DEEP_CAVERNS.getStep() @@ -388,7 +396,7 @@ object BingoNextStepHelper { RHYS_TASK_NAME, "Coal", 160 * 10, - mapOf("Coal" to 1, "Enchanted Coal" to 160) + mapOf("Coal" to 1, "Enchanted Coal" to 160), ) coalForRhys requires IslandType.DEEP_CAVERNS.getStep() @@ -403,25 +411,25 @@ object BingoNextStepHelper { "Compactor (for Minions)", "Compactor", amount, - mapOf("Compactor" to 1) + mapOf("Compactor" to 1), ).apply { finalSteps.add(this) } compactorForMinions requires CollectionStep( "Cobblestone", - 2_500 + 2_500, ).apply { this requires IslandType.HUB.getStep() } compactorForMinions requires ItemsStep( "" + (7 * amount) + " Enchanted Cobblestone (For Minions)", "Enchanted Cobblestone", amount * 7 * 160, - mapOf("Cobblestone" to 1, "Enchanted Cobblestone" to 160) + mapOf("Cobblestone" to 1, "Enchanted Cobblestone" to 160), ) compactorForMinions requires ItemsStep( "$amount Enchanted Redstone (For Minions)", "Enchanted Redstone", amount * 160, - mapOf("Redstone" to 1, "Enchanted Redstone" to 160) + mapOf("Redstone" to 1, "Enchanted Redstone" to 160), ) } @@ -430,25 +438,25 @@ object BingoNextStepHelper { "Enchanted Charcoal (for Minions)", "Enchanted Charcoal", amount, - mapOf("Enchanted Charcoal" to 1) + mapOf("Enchanted Charcoal" to 1), ).apply { finalSteps.add(this) } enchantedCharcoalForMinions requires CollectionStep( "Coal", - 2_500 + 2_500, ).apply { this requires IslandType.GOLD_MINES.getStep() } enchantedCharcoalForMinions requires ItemsStep( "Oak Wood (For Minions)", "Oak Wood", amount * 32, - mapOf("Oak Wood" to 1) + mapOf("Oak Wood" to 1), ) enchantedCharcoalForMinions requires ItemsStep( "Coal (For Minions)", "Coal", amount * 64 * 2, - mapOf("Coal" to 1) + mapOf("Coal" to 1), ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt index 6f596c20fa26..2b3b377c62b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -305,6 +305,9 @@ object ChatFilter { "§e\\[NPC] Jacob§f: §rYour §9Anita's \\w+ §fis giving you §6\\+\\d{1,2}☘ .+ Fortune §fduring the contest!", ) + /** + * REGEX-TEST: §eNew buff§r§r§r: §r§fGain §r§6+50☘ Mining Fortune§r§f. + */ private val skymallPerkPattern by RepoPattern.pattern( "chat.skymall.perk", "§eNew buff§r§r§r:.*", diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt index aabc785c3a95..4cad888c3818 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt @@ -31,10 +31,18 @@ object DungeonFinderFeatures { // Repo group and patterns private val patternGroup = RepoPattern.group("dungeon.finder") + + /** + * REGEX-TEST: §7§7Note: §f3m comp carry + */ private val pricePattern by patternGroup.pattern( "price", "(?i).*(?:[0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?MIL).*", ) + /** + * REGEX-TEST: §7§7Note: §f3m comp carry + * REGEX-TEST: §7§7Note: §f250k comp carry + */ private val carryPattern by patternGroup.pattern( "carry", "(?i).*(?:CARRY|CARY|CARRIES|CARIES|COMP|TO CATA [0-9]{2}).*", @@ -61,16 +69,6 @@ object DungeonFinderFeatures { "§c(?:Requires .*$|You don't meet the requirement!|Complete previous floor first!$)", ) - // TODO why is this same pattern here twice? - /** - * REGEX-TEST: §b4sn_§f: §eArcher§b (§e29§b) - * REGEX-TEST: §akaydo_odyak§f: §eBerserk§b (§e26§b) - */ - private val classLevelPattern by patternGroup.pattern( - "class.level", - " §.(?<playerName>.*)§f: §e(?<className>.*)§b \\(§e(?<level>.*)§b\\)", - ) - /** * REGEX-TEST: §7§7Note: §fs+ clear first */ @@ -107,10 +105,18 @@ object DungeonFinderFeatures { "select.floor", "Select Floor", ) + + /** + * REGEX-TEST: §a§aThe Catacombs §8- §eEntrance + */ private val entranceFloorPattern by patternGroup.pattern( "entrance", ".*Entrance", ) + + /** + * REGEX-TEST: Floor: Floor VII + */ private val floorPattern by patternGroup.pattern( "floor", "Floor .*", @@ -128,14 +134,18 @@ object DungeonFinderFeatures { "floor.mastermode", "(?:MM|.*Master Mode) The Catacombs.*", ) + + /** + * REGEX-TEST: Dungeon: The Catacombs + */ private val dungeonFloorPattern by patternGroup.pattern( "floor.dungeon", "Dungeon: .*", ) - private val floorFloorPattern by patternGroup.pattern( - "floor.pattern", - "Floor: .*", - ) + + /** + * REGEX-TEST: Floor VII + */ private val floorNumberPattern by patternGroup.pattern( "floor.number", ".* (?<floorNum>[IV\\d]+)", @@ -201,7 +211,7 @@ object DungeonFinderFeatures { val name = stack.displayName.removeColor() if (!checkIfPartyPattern.matches(name)) continue val lore = stack.getLore() - val floor = lore.find { floorFloorPattern.matches(it.removeColor()) } ?: continue + val floor = lore.find { floorPattern.matches(it.removeColor()) } ?: continue val dungeon = lore.find { dungeonFloorPattern.matches(it.removeColor()) } ?: continue val floorNum = floorNumberPattern.matchMatcher(floor) { group("floorNum").romanToDecimalIfNecessary() @@ -308,7 +318,7 @@ object DungeonFinderFeatures { val classNames = mutableListOf("Healer", "Mage", "Berserk", "Archer", "Tank") val toolTip = stack.getLore().toMutableList() for ((index, line) in stack.getLore().withIndex()) { - classLevelPattern.matchMatcher(line) { + memberPattern.matchMatcher(line) { val playerName = group("playerName") val className = group("className") val level = group("level").toInt() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index 8344f6b32022..0b4992ed1208 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -46,27 +46,31 @@ object GardenLevelDisplay { private val patternGroup = RepoPattern.group("garden.level") private val expToNextLevelPattern by patternGroup.pattern( "inventory.nextxp", - ".* §e(?<nextLevelExp>.*)§6/.*" + ".* §e(?<nextLevelExp>.*)§6/.*", ) + + /** + * REGEX-TEST: §aGarden Level 17 + */ private val gardenItemNamePattern by patternGroup.pattern( "inventory.name", - "Garden (?:Desk|Level (?<currentLevel>.*))" + "Garden (?:Desk|Level (?<currentLevel>.*))", ) private val overflowPattern by patternGroup.pattern( "inventory.overflow", - ".*§r §6(?<overflow>.*)" + ".*§r §6(?<overflow>.*)", ) private val gardenLevelPattern by patternGroup.pattern( "inventory.levelprogress", - "§7Progress to Level (?<currentLevel>[^:]*).*" + "§7Progress to Level (?<currentLevel>[^:]*).*", ) private val gardenMaxLevelPattern by patternGroup.pattern( "inventory.max", - "§5§o§7§8Max level reached!" + "§5§o§7§8Max level reached!", ) private val visitorRewardPattern by patternGroup.pattern( "chat.increase", - " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience" + " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience", ) private var display = "" @@ -101,7 +105,7 @@ object GardenLevelDisplay { " §8+§aRespect from Elite Farmers and SkyHanni members :)\n ", onClick = { HypixelCommands.gardenLevels() }, "§eClick to view your Garden Level progress and rewards!", - prefix = false + prefix = false, ) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 34e1f9faffdb..8c06e3456223 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -40,6 +40,10 @@ object CaptureFarmingGear { private val outdatedItems get() = GardenAPI.storage?.fortune?.outdatedItems private val patternGroup = RepoPattern.group("garden.fortuneguide.capture") + + /** + * REGEX-TEST: SKILL LEVEL UP Farming 1 ➜ 2 + */ private val farmingLevelUpPattern by patternGroup.pattern( "farminglevel", "SKILL LEVEL UP Farming .*➜(?<level>.*)", @@ -48,6 +52,10 @@ object CaptureFarmingGear { "fortuneupgrade", "You claimed the Garden Farming Fortune (?<level>.*) upgrade!", ) + + /** + * REGEX-TEST: §6+48☘ Farming Fortune + */ private val bestiaryPattern by patternGroup.pattern( "bestiary", ".*§6+(?<fortune>.*)☘ Farming Fortune.*", @@ -68,6 +76,10 @@ object CaptureFarmingGear { "lotusupgrade", "Lotus (?<piece>.*) upgraded to [+].*☘!", ) + + /** + * REGEX-TEST: Your Bingo leveled up to level 2! + */ private val petLevelUpPattern by patternGroup.pattern( "petlevelup", "Your (?<pet>.*) leveled up to level .*!", diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt index d2d28e8198d8..d9db3375b68b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt @@ -13,6 +13,10 @@ import kotlin.time.Duration.Companion.seconds @SkyHanniModule object AuctionOutbidWarning { + + /** + * REGEX-TEST: §6[Auction] §aMrBaiacu §eoutbid you by §659,083 coins §efor §fFiredust Dagger §e§lCLICK + */ private val outbidPattern by RepoPattern.pattern( "auction.outbid", "§6\\[Auction].*§eoutbid you by.*§e§lCLICK" diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt index 0b297c120767..621af3f27695 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt @@ -28,10 +28,22 @@ object AuctionHouseCopyUnderbidPrice { private val config get() = SkyHanniMod.feature.inventory.auctions private val patternGroup = RepoPattern.group("auctions.underbid") + + /** + * REGEX-TEST: §7Buy it now: §61,000,000,000 coins + * REGEX-TEST: §7Starting bid: §6200,000,000 coins + * REGEX-TEST: §7Top bid: §6220,000 coins + */ private val auctionPricePattern by patternGroup.pattern( "price", "§7(?:Buy it now|Starting bid|Top bid): §6(?<coins>[0-9,]+) coins", ) + + /** + * REGEX-TEST: Auctions Browser + * REGEX-TEST: Manage Auctions + * REGEX-TEST: Auctions: "aaa" + */ private val allowedInventoriesPattern by patternGroup.pattern( "allowedinventories", "Auctions Browser|Manage Auctions|Auctions: \".*\"?", diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index 856677cd2c2c..0b330b6a2f38 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -34,6 +34,11 @@ object AdvancedPlayerList { private val config get() = SkyHanniMod.feature.gui.compactTabList.advancedPlayerList + /** + * REGEX-TEST: §8[§r§9290§r§8] §r§bSkirtwearer §r§6ꀾ§r§7♲ + * REGEX-TEST: §8[§r§714§r§8] §r§bSrColombianoGood §r§6Ⓑ + * REGEX-TEST: §8[§r§b218§r§8] §r§bnightdives + */ private val levelPattern by RepoPattern.pattern( "misc.compacttablist.advanced.level", ".*\\[(?<level>.*)] §r(?<name>.*)", diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt index b07a921a945f..80cd20c54948 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/pets/CurrentPetDisplay.kt @@ -24,14 +24,27 @@ object CurrentPetDisplay { private val config get() = SkyHanniMod.feature.misc.pets private val patternGroup = RepoPattern.group("misc.currentpet") + + /** + * REGEX-TEST: §7§7Selected pet: §6Enderman + * REGEX-TEST: §7§7Selected pet: §cNone + */ private val inventorySelectedPetPattern by patternGroup.pattern( "inventory.selected", "§7§7Selected pet: (?<pet>.*)", ) + + /** + * REGEX-TEST: §aYou summoned your §r§6Enderman§r§a! + */ private val chatSpawnPattern by patternGroup.pattern( "chat.spawn", "§aYou summoned your §r(?<pet>.*)§r§a!", ) + + /** + * REGEX-TEST: §aYou despawned your §r§6Enderman§r§a! + */ private val chatDespawnPattern by patternGroup.pattern( "chat.despawn", "§aYou despawned your §r.*§r§a!", diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt index 05a10afe7a36..8b9eec5502ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt @@ -15,10 +15,18 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object TeleportPadCompactName { private val patternGroup = RepoPattern.group("misc.teleportpad") + + /** + * REGEX-TEST: §a✦ §aWarp To §9Blue + */ private val namePattern by patternGroup.pattern( "name", "§.✦ §aWarp To (?<name>.*)" ) + + /** + * REGEX-TEST: §c✦ §cNo Destination + */ private val noNamePattern by patternGroup.pattern( "noname", "§.✦ §cNo Destination" diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 4540fd550756..0f5d195b82be 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -9,14 +9,14 @@ object UtilsPatterns { private val patternGroup = RepoPattern.group("utils") - /** Examples: - * §d§l§ka§r §d§lMYTHIC ACCESSORY §d§l§ka - * §d§l§ka§r §d§lSHINY MYTHIC DUNGEON CHESTPLATE §d§l§ka - * §c§l§ka§r §c§lVERY SPECIAL HATCESSORY §c§l§ka - * §6§lSHINY LEGENDARY DUNGEON BOOTS - * §6§lLEGENDARY DUNGEON BOOTS - * §5§lEPIC BOOTS - * §f§lCOMMON + /** + * REGEX-TEST: §d§l§ka§r §d§lMYTHIC ACCESSORY §d§l§ka + * REGEX-TEST: §d§l§ka§r §d§lSHINY MYTHIC DUNGEON CHESTPLATE §d§l§ka + * REGEX-TEST: §c§l§ka§r §c§lVERY SPECIAL HATCESSORY §c§l§ka + * REGEX-TEST: §6§lSHINY LEGENDARY DUNGEON BOOTS + * REGEX-TEST: §6§lLEGENDARY DUNGEON BOOTS + * REGEX-TEST: §5§lEPIC BOOTS + * REGEX-TEST: §f§lCOMMON */ val rarityLoreLinePattern by patternGroup.pattern( "item.lore.rarity.line", @@ -25,6 +25,9 @@ object UtilsPatterns { ") ?(?:DUNGEON )?(?<itemCategory>[^§]*)(?: (?:§.){3}.)?$", ) + /** + * REGEX-TEST: §5Abiphone XIII Pro Giga + */ val abiPhonePattern by patternGroup.pattern( "item.name.abiphone", ".{2}Abiphone .*", @@ -94,6 +97,10 @@ object UtilsPatterns { "string.playerchat", "(?<important>.*?)(?:§[f7r])*: .*", ) + + /** + * REGEX-TEST: 8[§r§2164§r§8] §r§7❤ §r§a[VIP§6+§a] Heaven_Reaper§f§r§f: stop + */ val chatUsernamePattern by patternGroup.pattern( "string.chatusername", "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\w+))(?: (?:§\\w)?\\[.+?])?", @@ -103,6 +110,9 @@ object UtilsPatterns { "^M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})", ) + /** + * REGEX-TEST: §5Large Enchanted Husbandry Sack + */ val sackPattern by patternGroup.pattern( "item.sack", ".*Sack", diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index c2ea857bbf2c..e646f8c4d25d 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -76,11 +76,7 @@ <ID>NoNameShadowing:RepoPatternManager.kt$RepoPatternManager${ it == '.' }</ID> <ID>NoNameShadowing:Shimmy.kt$Shimmy.Companion$source</ID> <ID>NoNameShadowing:SkyHanniBucketedItemTracker.kt$SkyHanniBucketedItemTracker${ ItemPriceSource.entries[it.ordinal] }</ID> - <ID>RepoPatternRegexTest:AdvancedPlayerList.kt$AdvancedPlayerList$by RepoPattern.pattern( "misc.compacttablist.advanced.level", ".*\\[(?<level>.*)] §r(?<name>.*)", )</ID> <ID>RepoPatternRegexTest:AshfangFreezeCooldown.kt$AshfangFreezeCooldown$by RepoPattern.pattern( "ashfang.freeze.cryogenic", "§cAshfang Follower's Cryogenic Blast hit you for .* damage!", )</ID> - <ID>RepoPatternRegexTest:AuctionHouseCopyUnderbidPrice.kt$AuctionHouseCopyUnderbidPrice$by patternGroup.pattern( "allowedinventories", "Auctions Browser|Manage Auctions|Auctions: \".*\"?", )</ID> - <ID>RepoPatternRegexTest:AuctionHouseCopyUnderbidPrice.kt$AuctionHouseCopyUnderbidPrice$by patternGroup.pattern( "price", "§7(?:Buy it now|Starting bid|Top bid): §6(?<coins>[0-9,]+) coins", )</ID> - <ID>RepoPatternRegexTest:AuctionOutbidWarning.kt$AuctionOutbidWarning$by RepoPattern.pattern( "auction.outbid", "§6\\[Auction].*§eoutbid you by.*§e§lCLICK" )</ID> <ID>RepoPatternRegexTest:AuctionsHighlighter.kt$AuctionsHighlighter$by patternGroup.pattern( "auction", "§7(?:Starting bid|Top bid): §6(?<coins>.*) coins" )</ID> <ID>RepoPatternRegexTest:AuctionsHighlighter.kt$AuctionsHighlighter$by patternGroup.pattern( "buyitnow", "§7Buy it now: §6(?<coins>.*) coins" )</ID> <ID>RepoPatternRegexTest:BasketWaypoints.kt$BasketWaypoints$by patternGroup.pattern( "basket", "^(?:(?:§.)+You found a Candy Basket! (?:(?:§.)+\\((?:§.)+(?<current>\\d+)(?:§.)+/(?:§.)+(?<max>\\d+)(?:§.)+\\))?|(?:§.)+You already found this Candy Basket!)\$" )</ID> @@ -89,30 +85,23 @@ <ID>RepoPatternRegexTest:BazaarCancelledBuyOrderClipboard.kt$BazaarCancelledBuyOrderClipboard$by patternGroup.pattern( "cancelledmessage", "§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(?<coins>.*) coins §r§7from cancelling Buy Order!", )</ID> <ID>RepoPatternRegexTest:BeaconPower.kt$BeaconPower$by group.pattern( "stat", "§7Current Stat: (?<stat>.+)", )</ID> <ID>RepoPatternRegexTest:BeaconPower.kt$BeaconPower$by group.pattern( "time", "§7Power Remaining: §e(?<time>.+)", )</ID> - <ID>RepoPatternRegexTest:BingoAPI.kt$BingoAPI$by RepoPattern.pattern( "bingo.detection.scoreboard", " §.Ⓑ §.Bingo" )</ID> <ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "goalcomplete", "§6§lBINGO GOAL COMPLETE! §r§e(?<name>.*)" )</ID> <ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "hiddengoal", ".*§7§eThe next hint will unlock in (?<time>.*)" )</ID> <ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "percentage", " {2}§8Top §.(?<percentage>.*)%" )</ID> - <ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward", "§.§.§7Reward" )</ID> - <ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "§.§.§7Contribution Rewards.*" )</ID> - <ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "row.name", "§o§.Row #.*" )</ID> - <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "collection", "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\." )</ID> - <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.found", " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)" )</ID> - <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.obtain", "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\." )</ID> - <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.obtained", " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal" )</ID> - <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "skill", "Obtain level (?<level>.*) in the (?<skill>.*) Skill." )</ID> + <ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "(§.)+Contribution Rewards.*", )</ID> + <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "collection", "Reach (?<amount>[0-9]+(?:,\\d+)*) (?<name>.*) Collection\\.", )</ID> + <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.found", " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)", )</ID> + <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.obtain", "Obtain a (?<name>\\w+) Crystal in the Crystal Hollows\\.", )</ID> + <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.obtained", " *§r§e(?<crystalName>Topaz|Sapphire|Jade|Amethyst|Amber) Crystal", )</ID> + <ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "skill", "Obtain level (?<level>.*) in the (?<skill>.*) Skill.", )</ID> <ID>RepoPatternRegexTest:BitsPerCookieVisual.kt$BitsPerCookieVisual$by patternGroup.pattern("wrong", "§[de]Booster Cookie")</ID> <ID>RepoPatternRegexTest:BlazeSlayerDaggerHelper.kt$BlazeSlayerDaggerHelper$by RepoPattern.pattern( "slayer.blaze.dagger.attunement", "§cStrike using the §r.+ §r§cattunement on your dagger!" )</ID> <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "anitabuff", "You tiered up the Extra Farming Drops upgrade to [+](?<level>.*)%!", )</ID> - <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "bestiary", ".*§6+(?<fortune>.*)☘ Farming Fortune.*", )</ID> - <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "farminglevel", "SKILL LEVEL UP Farming .*➜(?<level>.*)", )</ID> <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "fortuneupgrade", "You claimed the Garden Farming Fortune (?<level>.*) upgrade!", )</ID> <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "lotusupgrade", "Lotus (?<piece>.*) upgraded to [+].*☘!", )</ID> - <ID>RepoPatternRegexTest:CaptureFarmingGear.kt$CaptureFarmingGear$by patternGroup.pattern( "petlevelup", "Your (?<pet>.*) leveled up to level .*!", )</ID> <ID>RepoPatternRegexTest:CarryTracker.kt$CarryTracker$by patternGroup.pattern( "trade.coins.gained", " §r§a§l\\+ §r§6(?<coins>.*) coins", )</ID> <ID>RepoPatternRegexTest:CarryTracker.kt$CarryTracker$by patternGroup.pattern( "trade.completed", "§6Trade completed with (?<name>.*)§r§6!", )</ID> <ID>RepoPatternRegexTest:ChatFilter.kt$ChatFilter$by RepoPattern.pattern( "chat.firesale", "§6§k§lA§r §c§lFIRE SALE §r§6§k§lA(?:\\n|.)*", )</ID> - <ID>RepoPatternRegexTest:ChatFilter.kt$ChatFilter$by RepoPattern.pattern( "chat.skymall.perk", "§eNew buff§r§r§r:.*", )</ID> <ID>RepoPatternRegexTest:CityProjectFeatures.kt$CityProjectFeatures$by patternGroup.pattern( "completed", "§aProject is (?:being built|released)!", )</ID> <ID>RepoPatternRegexTest:CityProjectFeatures.kt$CityProjectFeatures$by patternGroup.pattern( "contribute", "§7Contribute again: §e(?<time>.*)", )</ID> <ID>RepoPatternRegexTest:CompactBingoChat.kt$CompactBingoChat$by patternGroup.pattern( "border", "§[e3]§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬" )</ID> @@ -121,9 +110,6 @@ <ID>RepoPatternRegexTest:CroesusChestTracker.kt$CroesusChestTracker$by patternGroup.pattern("chest.floor", "§7Tier: §eFloor (?<floor>[IV]+)")</ID> <ID>RepoPatternRegexTest:CroesusChestTracker.kt$CroesusChestTracker$by patternGroup.pattern("chest.master", ".*Master.*")</ID> <ID>RepoPatternRegexTest:CroesusChestTracker.kt$CroesusChestTracker$by patternGroup.pattern("chest.state.opened", "§8Opened Chest:.*")</ID> - <ID>RepoPatternRegexTest:CurrentPetDisplay.kt$CurrentPetDisplay$by patternGroup.pattern( "chat.despawn", "§aYou despawned your §r.*§r§a!", )</ID> - <ID>RepoPatternRegexTest:CurrentPetDisplay.kt$CurrentPetDisplay$by patternGroup.pattern( "chat.spawn", "§aYou summoned your §r(?<pet>.*)§r§a!", )</ID> - <ID>RepoPatternRegexTest:CurrentPetDisplay.kt$CurrentPetDisplay$by patternGroup.pattern( "inventory.selected", "§7§7Selected pet: (?<pet>.*)", )</ID> <ID>RepoPatternRegexTest:DianaProfitTracker.kt$DianaProfitTracker$by patternGroup.pattern( "burrow.dug", "(?:§eYou dug out a Griffin Burrow!|§eYou finished the Griffin burrow chain!) .*", )</ID> <ID>RepoPatternRegexTest:DianaProfitTracker.kt$DianaProfitTracker$by patternGroup.pattern( "coins", "§6§lWow! §r§eYou dug out §r§6(?<coins>.*) coins§r§e!", )</ID> <ID>RepoPatternRegexTest:DicerRngDropTracker.kt$DicerRngDropTracker$by melonPatternGroup.pattern( "crazyrare", "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9]\\d+x §r§[a|9]Enchanted Melon(?: Block)?§r§e!", )</ID> @@ -139,14 +125,7 @@ <ID>RepoPatternRegexTest:DungeonArchitectFeatures.kt$DungeonArchitectFeatures$by patternGroup.pattern( "puzzle.fail.normal", "(?:§c§lPUZZLE FAIL!|§4) §.§.(?<name>\\S*) .*" )</ID> <ID>RepoPatternRegexTest:DungeonArchitectFeatures.kt$DungeonArchitectFeatures$by patternGroup.pattern( "puzzle.fail.quiz", "§4\\[STATUE] Oruo the Omniscient§r§f: (?:§.)*(?<name>\\S*) (?:§.)*chose the wrong .*" )</ID> <ID>RepoPatternRegexTest:DungeonCopilot.kt$DungeonCopilot$by patternGroup.pattern( "countdown", ".* has started the dungeon countdown. The dungeon will begin in 1 minute.", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "carry", "(?i).*(?:CARRY|CARY|CARRIES|CARIES|COMP|TO CATA [0-9]{2}).*", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "entrance", ".*Entrance", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "floor", "Floor .*", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "floor.dungeon", "Dungeon: .*", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "floor.number", ".* (?<floorNum>[IV\\d]+)", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "floor.pattern", "Floor: .*", )</ID> <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "nonpug", "(?i).*(?:PERM|VC|DISCORD).*", )</ID> - <ID>RepoPatternRegexTest:DungeonFinderFeatures.kt$DungeonFinderFeatures$by patternGroup.pattern( "price", "(?i).*(?:[0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?MIL).*", )</ID> <ID>RepoPatternRegexTest:EnchantParser.kt$EnchantParser$by patternGroup.pattern( "enchants.new", "(?:§7§l|§d§l|§9|§7)(?<enchant>[A-Za-z][A-Za-z '-]+) (?<levelNumeral>[IVXLCDM]+|[0-9]+)(?<stacking>(?:§r)?§9, |\$| §8\\d{1,3}(?:[,.]\\d{1,3})*[kKmMbB]?)", )</ID> <ID>RepoPatternRegexTest:EnchantParser.kt$EnchantParser$by patternGroup.pattern( "grayenchants", "^(?:Respiration|Aqua Affinity|Depth Strider|Efficiency).*", )</ID> <ID>RepoPatternRegexTest:FarmingContestAPI.kt$FarmingContestAPI$by patternGroup.pattern( "crop", "§8(?<crop>.*) Contest", )</ID> @@ -161,11 +140,10 @@ <ID>RepoPatternRegexTest:FarmingFortuneDisplay.kt$FarmingFortuneDisplay$by patternGroup.pattern( "tooltip.new", "^§7Farming Fortune: §a\\+(?<display>[\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(?<reforge>\\d+)\\))?(?: §d\\(\\+(?<gemstone>\\d+)\\))?\$", )</ID> <ID>RepoPatternRegexTest:FishingProfitTracker.kt$FishingProfitTracker$by RepoPattern.pattern( "fishing.tracker.chat.coins", ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\.", )</ID> <ID>RepoPatternRegexTest:GardenCropMilestoneFix.kt$GardenCropMilestoneFix$by patternGroup.pattern( "levelup", " {2}§r§b§lGARDEN MILESTONE §3(?<crop>.*) §8.*➜§3(?<tier>.*)", )</ID> - <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "chat.increase", " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience" )</ID> - <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.levelprogress", "§7Progress to Level (?<currentLevel>[^:]*).*" )</ID> - <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.name", "Garden (?:Desk|Level (?<currentLevel>.*))" )</ID> - <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.nextxp", ".* §e(?<nextLevelExp>.*)§6/.*" )</ID> - <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.overflow", ".*§r §6(?<overflow>.*)" )</ID> + <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "chat.increase", " {4}§r§8\\+§r§2(?<exp>.*) §r§7Garden Experience", )</ID> + <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.levelprogress", "§7Progress to Level (?<currentLevel>[^:]*).*", )</ID> + <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.nextxp", ".* §e(?<nextLevelExp>.*)§6/.*", )</ID> + <ID>RepoPatternRegexTest:GardenLevelDisplay.kt$GardenLevelDisplay$by patternGroup.pattern( "inventory.overflow", ".*§r §6(?<overflow>.*)", )</ID> <ID>RepoPatternRegexTest:GardenNextJacobContest.kt$GardenNextJacobContest$by patternGroup.pattern( "day", "§aDay (?<day>.*)", )</ID> <ID>RepoPatternRegexTest:GardenPlotAPI.kt$GardenPlotAPI$by patternGroup.pattern( "spray.target", "§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b(?<plot>.*) §r§7with §r§a(?<spray>.*)§r§7!" )</ID> <ID>RepoPatternRegexTest:GlacitePowderFeatures.kt$GlacitePowderFeatures$by patternGroup.pattern( "glacitepowder", "Glacite Powder x(?<amount>.*)" )</ID> @@ -219,9 +197,7 @@ <ID>RepoPatternRegexTest:PresentWaypoints.kt$PresentWaypoints$by patternGroup.pattern( "found", "§aYou found a.*present! §r§e\\(§r§b\\d+§r§e/§r§b\\d+§r§e\\)", )</ID> <ID>RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "addedtoquiver", "(?:§.)*You've added (?:§.)*(?<type>.*) x(?<amount>.*) (?:§.)*to your quiver!", )</ID> <ID>RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "cleared", "§aCleared your quiver!|§c§lYour quiver is now completely empty!", )</ID> - <ID>RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "fillupjax", "(?:§.)*Jax forged (?:§.)*(?<type>.*?)(?:§.)* x(?<amount>[\\d,]+)(?: (?:§.)*for (?:§.)*(?<coins>[\\d,]+) Coins)?(?:§.)*!", )</ID> <ID>RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern( "ranout", "§c§lQUIVER! §cYou have run out of §f(?<type>.*)s§c!", )</ID> - <ID>RepoPatternRegexTest:QuiverAPI.kt$QuiverAPI$by chatGroup.pattern("select", "§aYou set your selected arrow type to §.(?<arrow>.*)§a!")</ID> <ID>RepoPatternRegexTest:RestorePieceOfWizardPortalLore.kt$RestorePieceOfWizardPortalLore$by RepoPattern.pattern( "misc.restore.wizard.portal.earned", "§7Earned by:.*" )</ID> <ID>RepoPatternRegexTest:RiftBloodEffigies.kt$RiftBloodEffigies$by patternGroup.pattern( "heart", "Effigies: (?<hearts>(?:(?:§[7c])?⧯)*)" )</ID> <ID>RepoPatternRegexTest:RiftBloodEffigies.kt$RiftBloodEffigies$by patternGroup.pattern( "respawn", "§eRespawn §c(?<time>.*) §7\\(or click!\\)" )</ID> @@ -241,8 +217,6 @@ <ID>RepoPatternRegexTest:TabListReader.kt$TabListReader$by patternGroup.pattern( "upgrades", "(?<firstPart>§e[A-Za-z ]+)(?<secondPart> §f[\\w ]+)" )</ID> <ID>RepoPatternRegexTest:TabListReader.kt$TabListReader$by patternGroup.pattern( "winterpowerups", "Active Power Ups(?:§.)*(?:\\n(?:§.)*§7.+)*" )</ID> <ID>RepoPatternRegexTest:TabListRenderer.kt$TabListRenderer$by RepoPattern.pattern( "tablist.firesaletitle", "§.§lFire Sales: §r§f\\([0-9]+\\)" )</ID> - <ID>RepoPatternRegexTest:TeleportPadCompactName.kt$TeleportPadCompactName$by patternGroup.pattern( "name", "§.✦ §aWarp To (?<name>.*)" )</ID> - <ID>RepoPatternRegexTest:TeleportPadCompactName.kt$TeleportPadCompactName$by patternGroup.pattern( "noname", "§.✦ §cNo Destination" )</ID> <ID>RepoPatternRegexTest:TeleportPadInventoryNumber.kt$TeleportPadInventoryNumber$by RepoPattern.pattern( "misc.teleportpad.number", "§.(?<number>.*) teleport pad" )</ID> <ID>RepoPatternRegexTest:TerracottaPhase.kt$TerracottaPhase$by repoGroup.pattern( "start", "§c\\[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me\\? Sadan\\?!", )</ID> <ID>RepoPatternRegexTest:TestCopyBestiaryValues.kt$TestCopyBestiaryValues$by RepoPattern.pattern( "test.bestiary.type", "\\[Lv(?<lvl>.*)] (?<text>.*)" )</ID> @@ -262,14 +236,14 @@ <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by RepoPattern.pattern( "string.isroman", "^M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.amount.behind", "(?<name>(?:§.)*(?:[^§] ?)+)(?:§8x(?<amount>[\\d,]+))?", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.amount.front", "(?: +§8(?:\\+§.)?(?<amount>[\\d.,]+[km]?)x? )?(?<name>.*)", )</ID> - <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.name.abiphone", ".{2}Abiphone .*", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.name.potion", ".*Potion", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.neuitems.enchantmentname", "^(?<format>(?:§.)*)(?<name>[^§]+) (?<level>[IVXL]+)(?: Book)?$", )</ID> - <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "item.sack", ".*Sack", )</ID> - <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "string.chatusername", "^(?:§\\w\\[§\\w\\d+§\\w] )?(?:(?:§\\w)+\\S )?(?<rankedName>(?:§\\w\\[\\w.+] )?(?:§\\w)?(?<username>\\w+))(?: (?:§\\w)?\\[.+?])?", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "string.playerchat", "(?<important>.*?)(?:§[f7r])*: .*", )</ID> <ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "time.amount", "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?", )</ID> <ID>RepoPatternRegexTest:VisitorListener.kt$VisitorListener$by RepoPattern.pattern( "garden.visitor.offersaccepted", "§7Offers Accepted: §a(?<offersAccepted>\\d+)", )</ID> + <ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward", "(§.)+Reward", )</ID> + <ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "(§.)+Contribution Rewards.*", )</ID> + <ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "row.name", "(§.)+Row #.*", )</ID> <ID>ReturnCount:ArachneChatMessageHider.kt$ArachneChatMessageHider$private fun shouldHide(message: String): Boolean</ID> <ID>ReturnCount:BingoNextStepHelper.kt$BingoNextStepHelper$private fun readDescription(description: String): NextStep?</ID> <ID>ReturnCount:BroodmotherFeatures.kt$BroodmotherFeatures$private fun onStageUpdate()</ID> From 47e5c559f2acddeaab30366477de8ef000a1bea7 Mon Sep 17 00:00:00 2001 From: appable <16139460+appable0@users.noreply.github.com> Date: Sat, 4 Jan 2025 12:47:46 -0800 Subject: [PATCH 84/93] Fix: skill overflow event not posted (#3146) --- src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt | 5 +++++ .../skyhanni/features/skillprogress/SkillProgress.kt | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 63230a194c9e..3aa7aaf080af 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SkillExpGainEvent +import at.hannibal2.skyhanni.events.SkillOverflowLevelUpEvent import at.hannibal2.skyhanni.features.skillprogress.SkillProgress import at.hannibal2.skyhanni.features.skillprogress.SkillType import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.SPACE_SPLITTER @@ -367,6 +368,10 @@ object SkillAPI { val (currentLevel, currentOverflow, currentMaxOverflow, totalOverflow) = calculateSkillLevel(levelXp, defaultSkillCap[skillType.lowercaseName] ?: 60) + if (skillInfo.overflowLevel > 60 && currentLevel == skillInfo.overflowLevel + 1) { + SkillOverflowLevelUpEvent(skillType, skillInfo.overflowLevel, currentLevel).post() + } + skillInfo.apply { this.overflowCurrentXp = currentOverflow this.overflowCurrentXpMax = currentMaxOverflow diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index e46d7ab8841a..56b43a0cca35 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -63,7 +63,7 @@ object SkillProgress { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!isEnabled()) return + if (!isDisplayEnabled()) return if (display.isEmpty()) return if (showDisplay) { @@ -81,7 +81,7 @@ object SkillProgress { @SubscribeEvent fun onGuiRender(event: GuiRenderEvent) { - if (!isEnabled()) return + if (!isDisplayEnabled()) return if (display.isEmpty()) return if (allSkillConfig.enabled.get()) { @@ -145,7 +145,7 @@ object SkillProgress { @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { - if (!isEnabled()) return + if (!isDisplayEnabled()) return if (lastUpdate.passedSince() > 3.seconds) showDisplay = config.alwaysShow.get() allDisplay = formatAllDisplay(drawAllDisplay()) @@ -159,7 +159,7 @@ object SkillProgress { @HandleEvent fun onLevelUp(event: SkillOverflowLevelUpEvent) { - if (!isEnabled()) return + if (!LorenzUtils.inSkyBlock) return if (!config.overflowConfig.enableInChat) return val skillName = event.skill.displayName val oldLevel = event.oldLevel @@ -220,7 +220,7 @@ object SkillProgress { @HandleEvent(priority = HandleEvent.LOW) fun onActionBar(event: ActionBarUpdateEvent) { - if (!config.hideInActionBar || !isEnabled()) return + if (!config.hideInActionBar || !isDisplayEnabled()) return var msg = event.actionBar for (line in hideInActionBar) { msg = msg.replace(Regex("\\s*" + Regex.escape(line)), "") @@ -532,5 +532,5 @@ object SkillProgress { xpInfo.isActive = true } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled.get() + private fun isDisplayEnabled() = LorenzUtils.inSkyBlock && config.enabled.get() } From 808ccd91e379572ee1d41e61fde42d9dd5edf346 Mon Sep 17 00:00:00 2001 From: Ovi <142670705+Ovi-111@users.noreply.github.com> Date: Sun, 5 Jan 2025 02:51:05 +0600 Subject: [PATCH 85/93] Feature: Minion Upgrade Helper (#2589) Co-authored-by: Ovi <ovi2561@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../config/features/minion/MinionsConfig.java | 6 + .../features/minion/MinionUpgradeHelper.kt | 131 ++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/minion/MinionUpgradeHelper.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java index 233a7fc35d1e..02d4d7c42757 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java @@ -21,6 +21,12 @@ public class MinionsConfig { @ConfigEditorBoolean public boolean nameOnlyTier = false; + @Expose + @ConfigOption(name = "Minion Upgrade Helper", desc = "Shows a button in Minion menu to get required items for next Minion upgrade from sacks or bazaar.") + @ConfigEditorBoolean + @FeatureToggle + public boolean minionConfigHelper = true; + @Expose @ConfigOption(name = "Last Clicked", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionUpgradeHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionUpgradeHelper.kt new file mode 100644 index 000000000000..ef70c643f972 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionUpgradeHelper.kt @@ -0,0 +1,131 @@ +package at.hannibal2.skyhanni.features.minion + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.GetFromSackAPI +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacksOrNull +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.MinionCloseEvent +import at.hannibal2.skyhanni.events.MinionOpenEvent +import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPriceOrNull +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.ItemUtils.setLore +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat +import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.entity.player.InventoryPlayer +import net.minecraft.init.Blocks +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object MinionUpgradeHelper { + private val config get() = SkyHanniMod.feature.misc.minions + + private var displayItem: ItemStack? = null + private var itemsNeeded: Int = 0 + private var internalName: NEUInternalName? = null + private var itemsInSacks: Int = 0 + + /** + * REGEX-TEST: §7§cYou need §6512 §cmore Nether Quartz. + */ + private val requiredItemsPattern by RepoPattern.pattern( + "minion.items.upgrade", + "§7§cYou need §6(?<amount>\\d+) §cmore (?<itemName>.+)\\.", + ) + + @HandleEvent + fun onMinionOpen(event: MinionOpenEvent) { + if (!config.minionConfigHelper) return + val lore = event.inventoryItems[50]?.getLore()?.joinToString(" ") ?: return + requiredItemsPattern.findMatcher(lore) { + internalName = NEUInternalName.fromItemName(group("itemName").removeColor()) + itemsNeeded = group("amount")?.toInt() ?: 0 + } ?: resetItems() + + val internalName = internalName ?: return + if (itemsNeeded > 0) { + itemsInSacks = internalName.getAmountInSacksOrNull() ?: 0 + displayItem = createDisplayItem(internalName) + } + } + + @HandleEvent + fun onMinionClose(event: MinionCloseEvent) { + if (!config.minionConfigHelper) return + resetItems() + } + + private fun resetItems() { + internalName = null + itemsNeeded = 0 + itemsInSacks = 0 + displayItem = null + } + + private fun createDisplayItem(internalName: NEUInternalName): ItemStack { + val lore = createLore(internalName) + return ItemStack(Blocks.diamond_block).setLore(lore).setStackDisplayName("§bGet Required Items") + } + + private fun createLore(internalName: NEUInternalName): List<String> { + val itemPrice = internalName.getPriceOrNull() ?: 0.0 + val lore = buildList { + val itemsRemaining = itemsNeeded - itemsInSacks + val totalCost = itemsNeeded * itemPrice + val remainingCost = itemsRemaining * itemPrice + val itemName = internalName.itemName + + add("§8(From SkyHanni)") + add("") + + if (itemsInSacks > 0) { + add("§7In sacks: §a${itemsInSacks.addSeparators()}§7x §b$itemName") + } + + if (itemsRemaining > 0) { + add("§7From Bazaar: §a$itemsRemaining§7x §b$itemName") + add("§7Cost: §6${remainingCost.shortFormat()} coins") + } else { + add("§7All needed items are already in sacks!") + } + + add("") + add("§7Total price: §6${totalCost.shortFormat()} coins") + + add("") + add(if (itemsRemaining > 0) "§eClick to open Bazaar!" else "§eClick to retrieve items from the sacks!") + } + return lore + } + + @HandleEvent + fun replaceItem(event: ReplaceItemEvent) { + if (!config.minionConfigHelper) return + if (event.inventory !is InventoryPlayer && event.slot == 51) { + displayItem?.let { event.replace(it) } + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!config.minionConfigHelper || displayItem == null || event.slotId != 51) return + event.cancel() + val internalName = internalName ?: return + val remainingItems = itemsNeeded - itemsInSacks + if (remainingItems > 0) { + BazaarApi.searchForBazaarItem(internalName, remainingItems) + } else { + GetFromSackAPI.getFromSack(internalName, itemsNeeded) + } + } +} From 1abe3cfec6e161afb53e62cc5d2a56232bd9fc7e Mon Sep 17 00:00:00 2001 From: Luna <lunaynx@gmail.com> Date: Sat, 4 Jan 2025 22:26:41 +0100 Subject: [PATCH 86/93] Improvement: Discrite Held Time (#3101) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/inventory/InventoryConfig.java | 5 +-- .../features/inventory/HeldTimeInLore.kt | 19 +--------- .../inventory/ItemDisplayOverlayFeatures.kt | 37 +++++++++++++------ .../utils/SkyBlockItemModifierUtils.kt | 9 +++-- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index c5f17354f6dc..8df3d69672cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -174,8 +174,7 @@ public enum ItemNumberEntry implements HasLegacyId { LARVA_HOOK("§bLarva Hook", 12), DUNGEON_POTION_LEVEL("§bDungeon Potion Level", 13), VACUUM_GARDEN("§bVacuum (Garden)", 14), - BOTTLE_OF_JYRRE("§bBottle Of Jyrre", 15), - DARK_CACAO_TRUFFLE("§bDark Cacao Truffle"), + TIME_POCKET_ITEMS("§bTime Pocket Items (Jyrre, Truffle, Discrite)", 15), EDITION_NUMBER("§bEdition Number", 16), ENCHANTING_EXP("§bEnchanting EXP (Superpairs)"), BINGO_GOAL_RANK("§bBingo Goal Rank"), @@ -291,7 +290,7 @@ public String toString() { public boolean shiftClickBrewing = false; @Expose - @ConfigOption(name = "Time Held in Lore", desc = "Show time held for Bottle of Jyrre and Dark Cacao Truffle in the lore.") + @ConfigOption(name = "Time Held in Lore", desc = "Show time held for Time Pocket items (Bottle of Jyrre, Dark Cacao Truffle, Discrite) in the lore.") @ConfigEditorBoolean @FeatureToggle public boolean timeHeldInLore = false; diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 43d8634bde8f..492d8d74749a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -4,13 +4,9 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrInsert -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName -import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getSecondsHeld import at.hannibal2.skyhanni.utils.TimeUtils.format -import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -18,25 +14,14 @@ import kotlin.time.Duration.Companion.seconds object HeldTimeInLore { private val config get() = SkyHanniMod.feature.inventory - private val jyrreBottle = "NEW_BOTTLE_OF_JYRRE".toInternalName() - private val cacaoTruffle = "DARK_CACAO_TRUFFLE".toInternalName() - @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.timeHeldInLore) return - val seconds = event.itemStack.getSeconds() ?: return - val formatted = seconds.seconds.format() + val seconds = event.itemStack.getSecondsHeld() ?: return + val formatted = seconds.seconds.format(maxUnits = 2) event.toolTip.addOrInsert(10, "§7Time Held: §b$formatted") } - - private fun ItemStack.getSeconds(): Int? = when (getInternalName()) { - jyrreBottle -> getBottleOfJyrreSeconds() - cacaoTruffle -> getSecondsHeld() - else -> null - } } - - diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index c517bef7e131..0c8e7cc467d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -8,9 +8,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BESTIARY_LEVEL import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BINGO_GOAL_RANK -import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BOTTLE_OF_JYRRE import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.COLLECTION_LEVEL -import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DARK_CACAO_TRUFFLE import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_HEAD_FLOOR_NUMBER import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.DUNGEON_POTION_LEVEL import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.EDITION_NUMBER @@ -25,6 +23,7 @@ import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumbe import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.RANCHERS_BOOTS_SPEED import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKILL_LEVEL import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.SKYBLOCK_LEVEL +import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.TIME_POCKET_ITEMS import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.VACUUM_GARDEN import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.events.RenderItemTipEvent @@ -49,7 +48,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getBottleOfJyrreSeconds import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEdition import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getNewYearCake import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel @@ -59,6 +57,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray import com.google.gson.JsonElement +import com.google.gson.JsonPrimitive import net.minecraft.item.ItemStack @SkyHanniModule @@ -282,14 +281,10 @@ object ItemDisplayOverlayFeatures { } } - if (BOTTLE_OF_JYRRE.isSelected() && internalName == "NEW_BOTTLE_OF_JYRRE".toInternalName()) { - val seconds = item.getBottleOfJyrreSeconds() ?: 0 - return "§a${(seconds / 3600)}" - } - - if (DARK_CACAO_TRUFFLE.isSelected() && internalName == "DARK_CACAO_TRUFFLE".toInternalName()) { - val seconds = item.getSecondsHeld() ?: 0 - return "§a${(seconds / 3600)}" + if (TIME_POCKET_ITEMS.isSelected()) { + item.getSecondsHeld()?.let { seconds -> + return "§a${(seconds / 3600)}" + } } if (EDITION_NUMBER.isSelected()) { @@ -367,6 +362,9 @@ object ItemDisplayOverlayFeatures { event.transform(29, "inventory.itemNumberAsStackSize") { element -> fixRemovedConfigElement(element) } + event.transform(70, "inventory.itemNumberAsStackSize") { element -> + migrateTimePocketItems(element) + } } private fun fixRemovedConfigElement(data: JsonElement): JsonElement { @@ -379,5 +377,22 @@ object ItemDisplayOverlayFeatures { return newList } + private fun migrateTimePocketItems(data: JsonElement): JsonElement { + if (!data.isJsonArray) return data + val newList = JsonArray() + val oldValues = setOf("BOTTLE_OF_JYRRE", "DARK_CACAO_TRUFFLE") + val timePocketItems = JsonPrimitive("TIME_POCKET_ITEMS") + for (element in data.asJsonArray) { + if (element.asString in oldValues) { + if (timePocketItems !in newList) { + newList.add(timePocketItems) + } + continue + } + newList.add(element) + } + return newList + } + fun ItemNumberEntry.isSelected() = config.itemNumberAsStackSize.contains(this) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt index ae35772c50e4..ada3dfb27fa8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt @@ -189,9 +189,12 @@ object SkyBlockItemModifierUtils { fun ItemStack.getLivingMetalProgress() = getAttributeInt("lm_evo") - fun ItemStack.getSecondsHeld() = getAttributeInt("seconds_held") - - fun ItemStack.getBottleOfJyrreSeconds() = getAttributeInt("bottle_of_jyrre_seconds") + fun ItemStack.getSecondsHeld() = when (getItemId()) { + "NEW_BOTTLE_OF_JYRRE" -> getAttributeInt("bottle_of_jyrre_seconds") + "DARK_CACAO_TRUFFLE" -> getAttributeInt("seconds_held") + "DISCRITE" -> getAttributeInt("rift_discrite_seconds") + else -> null + } fun ItemStack.getEdition() = getAttributeInt("edition") From b8141199b6bda98f65438033383aa6201568d0cd Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:36:23 -0500 Subject: [PATCH 87/93] Backend: Preprocess Data Watcher (#2876) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../hannibal2/skyhanni/api/DataWatcherAPI.kt | 58 ++++++++++++++++++- .../at/hannibal2/skyhanni/data/EntityData.kt | 40 ------------- .../events/DataWatcherUpdatedEvent.kt | 10 +++- ...rEventPatch.java => MixinDataWatcher.java} | 5 +- .../mixins/transformers/MixinDataWatcher.java | 25 ++++++++ versions/1.8.9/detekt/baseline.xml | 1 + 6 files changed, 95 insertions(+), 44 deletions(-) rename src/main/java/at/hannibal2/skyhanni/mixins/transformers/{UpdateDataWatcherEventPatch.java => MixinDataWatcher.java} (82%) create mode 100644 versions/1.12.2/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java diff --git a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt index 7d0e73caca39..05bfbc7730f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt @@ -3,22 +3,76 @@ package at.hannibal2.skyhanni.api import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent import at.hannibal2.skyhanni.events.entity.EntityCustomNameUpdateEvent +import at.hannibal2.skyhanni.events.entity.EntityHealthUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.derpy +import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.Entity +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.boss.EntityWither +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.item.EntityItem +import net.minecraft.entity.item.EntityItemFrame +import net.minecraft.entity.item.EntityXPOrb + +//#if MC > 1.12 +//$$ import net.minecraft.network.datasync.DataSerializers +//$$ import net.minecraft.network.datasync.EntityDataManager +//#endif @SkyHanniModule object DataWatcherAPI { + private val ignoredEntities = setOf( + EntityArmorStand::class.java, + EntityXPOrb::class.java, + EntityItem::class.java, + EntityItemFrame::class.java, + EntityOtherPlayerMP::class.java, + EntityPlayerSP::class.java, + ) + + //#if MC < 1.12 private const val DATA_VALUE_CUSTOM_NAME = 2 + //#else + //$$ private val DATA_VALUE_CUSTOM_NAME = EntityDataManager.createKey(Entity::class.java, DataSerializers.STRING) + //#endif + + //#if MC < 1.12 + private const val DATA_VALUE_HEALTH = 6 + //#else + //$$ private val DATA_VALUE_HEALTH = EntityDataManager.createKey(EntityLivingBase::class.java, DataSerializers.FLOAT) + //#endif @HandleEvent fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent<Entity>) { for (updatedEntry in event.updatedEntries) { + //#if MC < 1.12 if (updatedEntry.dataValueId == DATA_VALUE_CUSTOM_NAME) { + //#else + //$$ if (updatedEntry.key == DATA_VALUE_CUSTOM_NAME) { + //#endif EntityCustomNameUpdateEvent(event.entity, event.entity.customNameTag).post() } + + //#if MC < 1.12 + if (updatedEntry.dataValueId == DATA_VALUE_HEALTH) { + val health = (updatedEntry.`object` as? Float)?.toInt() ?: continue + //#else + //$$ if (updatedEntry.key == DATA_VALUE_HEALTH) { + //$$ val health = (updatedEntry.value as? Float)?.toInt() ?: continue + //#endif + + val entity = EntityUtils.getEntityByID(event.entity.entityId) ?: continue + if (entity.javaClass in ignoredEntities) continue + + if (event.entity is EntityWither && health == 300 && event.entity.entityId < 0) continue + if (event.entity is EntityLivingBase) { + EntityHealthUpdateEvent(event.entity, health.derpy()).post() + } + } } } - - // TODO move EntityHealthUpdateEvent logic from EntityData in here } diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index 28af572e618d..c5b735b7de48 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -5,25 +5,15 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent import at.hannibal2.skyhanni.events.entity.EntityHealthDisplayEvent -import at.hannibal2.skyhanni.events.entity.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.entity.EntityLeaveWorldEvent import at.hannibal2.skyhanni.events.entity.EntityMaxHealthUpdateEvent -import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.derpy import at.hannibal2.skyhanni.utils.TimeLimitedCache -import net.minecraft.client.entity.EntityOtherPlayerMP -import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase -import net.minecraft.entity.boss.EntityWither -import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.entity.item.EntityItem -import net.minecraft.entity.item.EntityItemFrame -import net.minecraft.entity.item.EntityXPOrb -import net.minecraft.network.play.server.S1CPacketEntityMetadata import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds @@ -35,15 +25,6 @@ object EntityData { private val nametagCache = TimeLimitedCache<Entity, ChatComponentText>(50.milliseconds) private val healthDisplayCache = TimeLimitedCache<String, String>(50.milliseconds) - private val ignoredEntities = setOf( - EntityArmorStand::class.java, - EntityXPOrb::class.java, - EntityItem::class.java, - EntityItemFrame::class.java, - EntityOtherPlayerMP::class.java, - EntityPlayerSP::class.java, - ) - @SubscribeEvent fun onTick(event: LorenzTickEvent) { for (entity in EntityUtils.getEntities<EntityLivingBase>()) { // this completely ignores the ignored entities list? @@ -67,27 +48,6 @@ object EntityData { maxHealthMap.clear() } - @HandleEvent - fun onHealthUpdatePacket(event: PacketReceivedEvent) { - val packet = event.packet - - if (packet !is S1CPacketEntityMetadata) return - - val watchableObjects = packet.func_149376_c() ?: return - val entityId = packet.entityId - - val entity = EntityUtils.getEntityByID(entityId) ?: return - if (entity.javaClass in ignoredEntities) return - - watchableObjects.find { it.dataValueId == 6 }?.let { - val health = (it.`object` as Float).toInt() - if (entity is EntityWither && health == 300 && entityId < 0) return - if (entity is EntityLivingBase) { - EntityHealthUpdateEvent(entity, health.derpy()).post() - } - } - } - @JvmStatic fun getDisplayName(entity: Entity, oldValue: ChatComponentText): ChatComponentText { return postRenderNametag(entity, oldValue) diff --git a/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt index df2049517f5b..347554237fcb 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt @@ -1,10 +1,18 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent -import net.minecraft.entity.DataWatcher import net.minecraft.entity.Entity +//#if MC < 1.12 +import net.minecraft.entity.DataWatcher +//#else +//$$ import net.minecraft.network.datasync.EntityDataManager +//#endif data class DataWatcherUpdatedEvent<T : Entity>( val entity: T, + //#if MC < 1.12 val updatedEntries: List<DataWatcher.WatchableObject>, + //#else + //$$ val updatedEntries: List<EntityDataManager.DataEntry<*>> + //#endif ) : GenericSkyHanniEvent<T>(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java similarity index 82% rename from src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java rename to src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java index f5f3555f5791..a81e43ff99ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java @@ -12,8 +12,11 @@ import java.util.List; +/** + * Note: This mixin is changed in 1.12 so any changes to this mixin should also be applied to the mixin in the versions/1.12 folder + */ @Mixin(DataWatcher.class) -public class UpdateDataWatcherEventPatch { +public class MixinDataWatcher { @Shadow @Final private Entity owner; diff --git a/versions/1.12.2/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java b/versions/1.12.2/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java new file mode 100644 index 000000000000..8e0ca68ec32e --- /dev/null +++ b/versions/1.12.2/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinDataWatcher.java @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.mixins.transformers; + +import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent; +import net.minecraft.entity.Entity; +import net.minecraft.network.datasync.EntityDataManager; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; + +@Mixin(EntityDataManager.class) +public class MixinDataWatcher { + @Shadow + @Final + private Entity entity; + + @Inject(method = "setEntryValues", at = @At("TAIL")) + public void onSetEntryValues(List<EntityDataManager.DataEntry<?>> list, CallbackInfo ci) { + new DataWatcherUpdatedEvent(this.entity, list).postAndCatch(); + } +} diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index e646f8c4d25d..a33fb06b795c 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -40,6 +40,7 @@ <ID>LongMethod:VisualWordGui.kt$VisualWordGui$override fun drawScreen(unusedX: Int, unusedY: Int, partialTicks: Float)</ID> <ID>LoopWithTooManyJumpStatements:AdvancedPlayerList.kt$AdvancedPlayerList$for</ID> <ID>LoopWithTooManyJumpStatements:CropMoneyDisplay.kt$CropMoneyDisplay$for</ID> + <ID>LoopWithTooManyJumpStatements:DataWatcherAPI.kt$DataWatcherAPI$for</ID> <ID>LoopWithTooManyJumpStatements:EstimatedItemValueCalculator.kt$EstimatedItemValueCalculator$for</ID> <ID>LoopWithTooManyJumpStatements:GardenComposterInventoryFeatures.kt$GardenComposterInventoryFeatures$for</ID> <ID>LoopWithTooManyJumpStatements:GardenVisitorFeatures.kt$GardenVisitorFeatures$for</ID> From 619d1ad050880a7327a8cfbbb2b98c7942c7398f Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 4 Jan 2025 16:39:45 -0500 Subject: [PATCH 88/93] Improvement: Nucleus Highlight Colors (#3062) * Done * Remove comments since that worked * formatting --------- Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com> --- .../mining/CrystalHighlighterColorConfig.java | 34 +++++++++++++++++++ .../mining/CrystalHighlighterConfig.java | 13 +++---- .../event/hoppity/NucleusBarriersBox.kt | 21 +++++++----- 3 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterColorConfig.java diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterColorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterColorConfig.java new file mode 100644 index 000000000000..29b867fe5aea --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterColorConfig.java @@ -0,0 +1,34 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class CrystalHighlighterColorConfig { + + @Expose + @ConfigOption(name = "Amber", desc = "§7Default: §#§c§b§6§4§0§0§/#CB6400") + @ConfigEditorColour + public Property<String> amber = Property.of("0:127:203:100:0"); + + @Expose + @ConfigOption(name = "Amethyst", desc = "§7Default: §#§a§8§0§b§c§b§/#A80BCB") + @ConfigEditorColour + public Property<String> amethyst = Property.of("0:127:168:11:203"); + + @Expose + @ConfigOption(name = "Topaz", desc = "§7Default: §#§c§d§c§4§0§0§/#CDC400") + @ConfigEditorColour + public Property<String> topaz = Property.of("0:127:205:196:0"); + + @Expose + @ConfigOption(name = "Jade", desc = "§7Default: §#§6§8§c§b§0§0§/#68CB00") + @ConfigEditorColour + public Property<String> jade = Property.of("0:85:104:203:0"); + + @Expose + @ConfigOption(name = "Sapphire", desc = "§7Default: §#§2§9§6§4§c§b§/#2964CB") + @ConfigEditorColour + public Property<String> sapphire = Property.of("0:127:41:100:203"); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterConfig.java index 06c60b507024..be26bcfb3cb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterConfig.java @@ -2,15 +2,15 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; public class CrystalHighlighterConfig { @Expose @ConfigOption( - name = "Highlight Crystal Nucleus barriers", + name = "Highlight Nucleus Barriers", desc = "Draw visible bounding boxes around the Crystal Nucleus crystal barrier blocks." ) @ConfigEditorBoolean @@ -18,12 +18,9 @@ public class CrystalHighlighterConfig { public boolean enabled = true; @Expose - @ConfigOption( - name = "Highlight Opacity", - desc = "Set the opacity of the highlighted boxes.\n§70§8: §7Transparent\n§7100§8: §7Solid" - ) - @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) - public int opacity = 60; + @Accordion + @ConfigOption(name = "Highlight Colors", desc = "") + public CrystalHighlighterColorConfig colors = new CrystalHighlighterColorConfig(); @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt index 3d3fed53c8dd..4a1a9cc24c3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt @@ -6,10 +6,11 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBoxNea import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock +import at.hannibal2.skyhanni.utils.SpecialColor.toSpecialColor +import io.github.notenoughupdates.moulconfig.observer.Property import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -18,44 +19,48 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object NucleusBarriersBox { private val config get() = SkyHanniMod.feature.mining.crystalHighlighter + private val colorConfig get() = config.colors private var inNucleus = false - private enum class Crystal(val color: LorenzColor, val boundingBox: AxisAlignedBB) { + private enum class Crystal( + val boundingBox: AxisAlignedBB, + val configColorOption: Property<String>, + ) { AMBER( - LorenzColor.GOLD, AxisAlignedBB( BlockPos(474.0, 124.0, 524.0), BlockPos(485.0, 111.0, 535.0), ).expandBlock(), + colorConfig.amber, ), AMETHYST( - LorenzColor.DARK_PURPLE, AxisAlignedBB( BlockPos(474.0, 124.0, 492.0), BlockPos(485.0, 111.0, 503.0), ).expandBlock(), + colorConfig.amethyst, ), TOPAZ( - LorenzColor.YELLOW, AxisAlignedBB( BlockPos(508.0, 124.0, 473.0), BlockPos(519.0, 111.0, 484.0), ).expandBlock(), + colorConfig.topaz, ), JADE( - LorenzColor.GREEN, AxisAlignedBB( BlockPos(542.0, 124.0, 492.0), BlockPos(553.0, 111.0, 503.0), ).expandBlock(), + colorConfig.jade, ), SAPPHIRE( - LorenzColor.BLUE, AxisAlignedBB( BlockPos(542.0, 124.0, 524.0), BlockPos(553.0, 111.0, 535.0), ).expandBlock(), + colorConfig.sapphire, ), } @@ -71,7 +76,7 @@ object NucleusBarriersBox { Crystal.entries.forEach { crystal -> event.drawFilledBoundingBoxNea( crystal.boundingBox, - crystal.color.addOpacity(config.opacity), + crystal.configColorOption.get().toSpecialColor(), renderRelativeToCamera = false, ) } From a6ab087040d5f73002a0531708d16e6f2ae25a6e Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:50:13 +0100 Subject: [PATCH 89/93] code cleanup --- .../skyhanni/features/mining/eventtracker/MiningEventDisplay.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt index 6868a651241f..e03674d97f3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt @@ -89,7 +89,6 @@ object MiningEventDisplay { Renderable.string("§8:"), ) - private val unknownDisplay = Renderable.string("§7???") private val transitionDisplay = Renderable.string("§8->") From f20cb917e98321918e317425b6fd57a2254accac Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 4 Jan 2025 17:11:59 -0500 Subject: [PATCH 90/93] Fix: Moby Highlight (again) (#3159) --- .../skyhanni/features/misc/trevor/TrevorFeatures.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 dd8f47deadb8..c646c1fb5e0e 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 @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.TrevorTheTrapperConfig.TrackerEntry import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.Perk +import at.hannibal2.skyhanni.data.mob.MobData import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -26,7 +27,6 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.MobUtils.mob import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -275,7 +275,8 @@ object TrevorFeatures { if (entityTrapper !is EntityLivingBase) entityTrapper = EntityUtils.getEntityByID(BACKUP_TRAPPER_ID) if (entityTrapper is EntityLivingBase && config.trapperTalkCooldown) { // Solve for the fact that Moby also has the same ID as the Trapper - if (entityTrapper.mob?.name == "Moby") return + val entityMob = MobData.entityToMob[entityTrapper] ?: return + if (entityMob.name == "Moby") return RenderLivingEntityHelper.setEntityColorWithNoHurtTime(entityTrapper, currentStatus.color) { config.trapperTalkCooldown } From 9b8761e5c8bb719e37e517b788761fe42bd3f99a Mon Sep 17 00:00:00 2001 From: penguin4life21 <69492010+penguin4life21@users.noreply.github.com> Date: Sun, 5 Jan 2025 08:19:29 +1000 Subject: [PATCH 91/93] Improvement: Mining Event Display Sorting (#3117) Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../mining/eventtracker/MiningEventDisplay.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt index e03674d97f3e..f896dfb47759 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt @@ -49,7 +49,17 @@ object MiningEventDisplay { add(Renderable.string("§cSwap servers to try again!")) } - for ((islandType, eventDetails) in islandEventData) { + val sortedIslandEventData = islandEventData.entries + .sortedBy { entry -> + when (entry.key) { + IslandType.DWARVEN_MINES -> 0 + IslandType.CRYSTAL_HOLLOWS -> 1 + else -> Int.MAX_VALUE + } + } + .associate { it.key to it.value } + + for ((islandType, eventDetails) in sortedIslandEventData) { val shouldShow = when (config.showType) { MiningEventConfig.ShowType.DWARVEN -> islandType == IslandType.DWARVEN_MINES MiningEventConfig.ShowType.CRYSTAL -> islandType == IslandType.CRYSTAL_HOLLOWS From 057d535cbd236f6e7bf3600f5a9d506820b0bbd0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 4 Jan 2025 23:47:35 +0100 Subject: [PATCH 92/93] code cleanup --- .../skyhanni/features/mining/eventtracker/MiningEventDisplay.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt index f896dfb47759..ea2c7585a233 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt @@ -35,7 +35,7 @@ object MiningEventDisplay { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!shouldDisplay()) return - config.position.renderRenderables(display, posLabel = "Upcoming Mining Events") + config.position.renderRenderables(display, posLabel = "Mining Event Tracker") } private fun updateDisplay() { From 2fe67fcf9be36f6718219916dc2d52c9ee3d73d5 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 5 Jan 2025 00:25:31 +0100 Subject: [PATCH 93/93] improved wording --- .../skyhanni/config/features/minion/MinionsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java index 02d4d7c42757..3c56269d8022 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/minion/MinionsConfig.java @@ -22,7 +22,7 @@ public class MinionsConfig { public boolean nameOnlyTier = false; @Expose - @ConfigOption(name = "Minion Upgrade Helper", desc = "Shows a button in Minion menu to get required items for next Minion upgrade from sacks or bazaar.") + @ConfigOption(name = "Minion Upgrade Helper", desc = "Add a button in the Minion menu to obtain required items for the next upgrade from Sacks or Bazaar.") @ConfigEditorBoolean @FeatureToggle public boolean minionConfigHelper = true;