From 3faabc82ca6ce9299d8d0471cc814166aa2e4383 Mon Sep 17 00:00:00 2001 From: Cal Date: Fri, 25 Oct 2024 01:00:47 +1100 Subject: fix pr-check action not commenting --- .github/workflows/pr-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a28577b77..4cf997e2c 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -43,6 +43,7 @@ jobs: labels: 'Wrong Title/Changelog' - name: Check if this is the latest workflow run + if: failure() id: check_latest run: | PR_LATEST_SHA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -- cgit From 0507e8b55ad2e5756191ad546a1eb1d23aafb4d9 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:53:39 -0400 Subject: Backend Fix: Detekt Runner (#2812) --- .github/workflows/detekt.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml index f4251d798..97909596a 100644 --- a/.github/workflows/detekt.yml +++ b/.github/workflows/detekt.yml @@ -29,6 +29,7 @@ jobs: run: | ./gradlew detektMain --stacktrace - name: Check if SARIF file exists + if: always() id: check_sarif run: | if [ -f "versions/1.8.9/build/reports/detekt/main.sarif" ]; then -- cgit From 26835af63de4f0f6808c55ee7f249827df3c58db Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:53:19 +0200 Subject: Improvement + Fix: Profile Type in Custom Scoreboard (#2810) --- .../features/gui/customscoreboard/DisplayConfig.java | 5 +++++ .../elements/ScoreboardElementProfile.kt | 17 +++++++++++++++-- .../events/ScoreboardEventBroodmother.kt | 2 +- 3 files changed, 21 insertions(+), 3 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 b54d7519d..26c6b125e 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 @@ -149,6 +149,11 @@ public class DisplayConfig { @ConfigEditorDropdown public RenderUtils.HorizontalAlignment textAlignment = RenderUtils.HorizontalAlignment.LEFT; + @Expose + @ConfigOption(name = "Show Profile Name", desc = "Show profile name instead of the type in the profile element.") + @ConfigEditorBoolean + public boolean showProfileName = false; + @Expose @ConfigOption(name = "Date in Lobby Code", desc = "Show the current date infront of the server name, like Hypixel does.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementProfile.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementProfile.kt index c8a4bc993..2d85d6776 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementProfile.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementProfile.kt @@ -1,15 +1,28 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase // internal and scoreboard // island change event object ScoreboardElementProfile : ScoreboardElement() { - override fun getDisplay() = CustomScoreboardUtils.getProfileTypeSymbol() + HypixelData.profileName.firstLetterUppercase() + override fun getDisplay() = buildString { + append(CustomScoreboardUtils.getProfileTypeSymbol()) + if (CustomScoreboard.displayConfig.showProfileName) { + append(HypixelData.profileName.firstLetterUppercase()) + } else { + when { + HypixelData.ironman -> append("Ironman") + HypixelData.stranded -> append("Stranded") + HypixelData.bingo -> append("Bingo") + else -> append("Normal") + } + } + } - override val configLine = "§7♲ Blueberry" + override val configLine = "§7♲ Ironman" } // click: does a command for profile management exist? diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventBroodmother.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventBroodmother.kt index 2d10a1847..3b6a23a18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventBroodmother.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/events/ScoreboardEventBroodmother.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland // scoreboard // widget update event object ScoreboardEventBroodmother : ScoreboardEvent() { - override fun getDisplay() = TabWidget.BROODMOTHER.lines + override fun getDisplay() = TabWidget.BROODMOTHER.lines.map { it.trim() } override val configLine = "Broodmother§7: §eDormant" -- cgit From 31d2b539f480a75066f6ab967bcd299df4d023e5 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:53:52 +0200 Subject: Fix: Colored Classlevel Tablist (#2814) --- src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt index 91a53f62b..1a4574be8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt @@ -79,7 +79,7 @@ object RegexUtils { */ fun Matcher.groupOrNull(groupName: String): String? = runCatching { group(groupName) }.getOrNull() - fun Matcher.groupOrEmpty(groupName: String): String = runCatching { group(groupName) }.getOrDefault("") + fun Matcher.groupOrEmpty(groupName: String): String = groupOrNull(groupName).orEmpty() fun Matcher.hasGroup(groupName: String): Boolean = groupOrNull(groupName) != null -- cgit From ceba80c79f22ede70d7dd24d44b2243a2006bc06 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 26 Oct 2024 03:13:09 +0200 Subject: Fix: Own player messages not being rewritten by chat formatting (#2806) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../data/hypixel/chat/PlayerChatManager.kt | 3 +- .../data/hypixel/chat/PlayerNameFormatter.kt | 87 ++++++++++++++-------- .../skyhanni/utils/ComponentMatcherUtils.kt | 2 +- .../at/hannibal2/skyhanni/utils/StringUtils.kt | 1 + 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt index 5199e8b7e..2529e7ff1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt @@ -32,10 +32,11 @@ object PlayerChatManager { /** * REGEX-TEST: [58] §7nea89o§7: haiiiii * REGEX-TEST: [266] ♫ §b[MVP§d+§b] lrg89§f: a + * REGEX-TEST: [302] ♫ [MVP+] lrg89: problematic */ private val globalPattern by patternGroup.pattern( "global", - "(?:\\[(?\\d+)] )?(?.+)(?§f|§7): (?.*)" + "(?:\\[(?\\d+)] )?(?.+?)(?§f|§7|): (?.*)" ) /** diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt index 35356f32f..bd7a407df 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt @@ -15,6 +15,7 @@ import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.changeColor +import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.intoSpan import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.matchStyledMatcher import at.hannibal2.skyhanni.utils.ComponentSpan import at.hannibal2.skyhanni.utils.LorenzColor @@ -22,12 +23,15 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.applyFormattingFrom import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toCleanChatComponent import at.hannibal2.skyhanni.utils.chat.Text +import at.hannibal2.skyhanni.utils.chat.Text.style import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonArray import com.google.gson.JsonNull import net.minecraft.util.ChatComponentText +import net.minecraft.util.EnumChatFormatting import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -51,7 +55,7 @@ object PlayerNameFormatter { */ private val emblemPattern by patternGroup.pattern( "emblem", - "(?(?:§.){0,2}.) (?.*)" + "(?(?:§.){0,2}.) (?.*)", ) @SubscribeEvent @@ -72,7 +76,7 @@ object PlayerNameFormatter { levelColor?.toString(), level = levelComponent, privateIslandRank = privateIslandRank, - privateIslandGuest = privateIslandGuest + privateIslandGuest = privateIslandGuest, ) val all = ChatComponentText("") all.appendSibling(name) @@ -91,7 +95,7 @@ object PlayerNameFormatter { appendSibling(nameFormat(event.authorComponent)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) - } + }, ) ?: return } @@ -104,7 +108,7 @@ object PlayerNameFormatter { appendSibling(nameFormat(event.authorComponent, guildRank = event.guildRank)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) - } + }, ) ?: return } @@ -117,23 +121,22 @@ object PlayerNameFormatter { appendSibling(nameFormat(event.authorComponent)) appendText("§f: ") appendSibling(event.messageComponent.intoComponent()) - } + }, ) ?: return } @SubscribeEvent fun onPrivateChat(event: PrivateMessageChatEvent) { if (!isEnabled()) return - event.chatComponent = - StringUtils.replaceIfNeeded( - event.chatComponent, - Text.text("§d${event.direction}") { - appendText(" ") - appendSibling(nameFormat(event.authorComponent)) - appendText("§f: ") - appendSibling(event.messageComponent.intoComponent()) - } - ) ?: return + event.chatComponent = StringUtils.replaceIfNeeded( + event.chatComponent, + Text.text("§d${event.direction}") { + appendText(" ") + appendSibling(nameFormat(event.authorComponent)) + appendText("§f: ") + appendSibling(event.messageComponent.intoComponent()) + }, + ) ?: return } @SubscribeEvent @@ -146,8 +149,8 @@ object PlayerNameFormatter { nameFormat( event.authorComponent, levelColor = event.levelComponent?.sampleStyleAtStart()?.color?.toString(), - level = event.levelComponent - ) + level = event.levelComponent, + ), ) appendText(" ") @@ -155,7 +158,7 @@ object PlayerNameFormatter { appendText(" ") appendSibling(event.item.intoComponent()) - } + }, ) ?: return } @@ -175,7 +178,7 @@ object PlayerNameFormatter { cleanAuthor = groupOrThrow("author").stripHypixelMessage() } - val name = formatAuthor(cleanAuthor.getText(), levelColor).applyFormattingFrom(cleanAuthor) + val name = formatAuthor(cleanAuthor, levelColor) val levelFormat = formatLevel(levelColor, level) val guildRankFormat = guildRank?.intoComponent() val privateIslandRankFormat = privateIslandRank?.intoComponent() @@ -192,7 +195,7 @@ object PlayerNameFormatter { val map = mutableMapOf() map[PlayerMessagesConfig.MessagePart.SKYBLOCK_LEVEL] = levelFormat map[PlayerMessagesConfig.MessagePart.EMBLEM] = emblemFormat - map[PlayerMessagesConfig.MessagePart.PLAYER_NAME] = name + map[PlayerMessagesConfig.MessagePart.PLAYER_NAME] = name.intoComponent() map[PlayerMessagesConfig.MessagePart.CRIMSON_FACTION] = faction map[PlayerMessagesConfig.MessagePart.MODE_IRONMAN] = ironman map[PlayerMessagesConfig.MessagePart.BINGO_LEVEL] = bingo @@ -229,19 +232,41 @@ object PlayerNameFormatter { return author.stripHypixelMessage().removePrefix("§f") } - private fun formatAuthor(author: String, levelColor: String?): String { - if (author.contains("ADMIN")) return author - if (config.ignoreYouTube && author.contains("YOUTUBE")) return author + private fun ComponentSpan.splitPlayerNameAndExtras(): Pair { + val space = getText().indexOf(' ') + if (space < 0) return Pair(null, this) + return Pair(slice(0, space + 1), slice(space + 1)) + } - var result = author.cleanPlayerName(displayName = true) - levelColor?.let { - if (config.useLevelColorForName) { - val cleanPlayerName = author.cleanPlayerName() - result = result.replace(cleanPlayerName, it + cleanPlayerName) - } - } + private fun formatAuthor(author: ComponentSpan, levelColor: String?): ComponentSpan { + if (author.getText().contains("ADMIN")) return author + if (config.ignoreYouTube && author.getText().contains("YOUTUBE")) return author + val (rank, name) = author.splitPlayerNameAndExtras() + val coloredName = createColoredName(name, levelColor, name.getText().removeColor()) + return if (config.playerRankHider || rank == null) coloredName else rank + coloredName + } + + private fun createColoredName( + name: ComponentSpan, + levelColor: String?, + removeColor: String, + ): ComponentSpan = when { + MarkedPlayerManager.isMarkedPlayer(removeColor) && MarkedPlayerManager.config.highlightInChat -> + ChatComponentText(MarkedPlayerManager.replaceInChat(removeColor)) + .setChatStyle(name.sampleStyleAtStart()).intoSpan() + + levelColor != null && config.useLevelColorForName -> + ChatComponentText(levelColor + removeColor) + .setChatStyle(name.sampleStyleAtStart()) + .intoSpan() + + config.playerRankHider -> + ChatComponentText(removeColor) + .setChatStyle(name.sampleStyleAtStart()?.createShallowCopy()) + .style { color = EnumChatFormatting.AQUA } + .intoSpan() - return MarkedPlayerManager.replaceInChat(result) + else -> name } fun isEnabled() = LorenzUtils.inSkyBlock && config.enable diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt index f332cc05e..f13f8b66e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt @@ -165,7 +165,7 @@ class ComponentSpan internal constructor( */ fun slice(start: Int = 0, end: Int = length): ComponentSpan { require(0 <= start) { "start is bigger than 0: start=$start, cachedText=$cachedText" } - require(start <= end) { "start is bigger than length: start=$start, length=$length, cachedText=$cachedText" } + require(start <= end) { "start is bigger than end: start=$start, end=$end, cachedText=$cachedText" } require(end <= length) { "end is bigger than length: end=$end, length=$length, cachedText=$cachedText" } return ComponentSpan(textComponent, cachedText, this.start + start, this.start + end) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index b6d38fd7f..160b8ffd1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -509,6 +509,7 @@ object StringUtils { fun String.toCleanChatComponent(): IChatComponent = ChatComponentText(this) + @Deprecated("This function strips internal formatting changes like the color of the pluses of the MVP+ rank") fun IChatComponent.cleanPlayerName(displayName: Boolean = false): IChatComponent = formattedText.cleanPlayerName(displayName).applyFormattingFrom(this) -- cgit From 9436627b03dcb9a32e713f4967c59471afde77b6 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 26 Oct 2024 03:51:22 +0200 Subject: Backend; Contributing.md Added our two Optional Plugins (#2817) --- CONTRIBUTING.md | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8229a00d5..53ec5bc27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -153,6 +153,37 @@ for more information and usages. - 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"). +## Additional Useful Development Tools + +### DevAuth + +[DevAuth](https://github.com/DJtheRedstoner/DevAuth) is a tool that allows logging in to a Minecraft account while +debugging in IntelliJ. This is very useful for coding live on Hypixel without the need to compile a jar. + +- The library is already downloaded by Gradle. +- SkyHanni will automatically set up DevAuth. +- Start Minecraft inside IntelliJ normally. + - Click on the link in the console and verify with a Microsoft account. + - The verification process will reappear every few days (after the session token expires). + +### Hot Swap + +Hot Swap allows reloading edited code while debugging, removing the need to restart the whole game every time. + +We use [dcevm](https://dcevm.github.io/) and the IntelliJ +Plugin [HotSwap Agent](https://plugins.jetbrains.com/plugin/9552-hotswapagent) to quickly reload code changes. + +Follow [this](https://forums.Minecraftforge.net/topic/82228-1152-3110-intellij-and-gradlew-forge-hotswap-and-dcevm-tutorial/) +tutorial. + +### [Live Plugin](https://plugins.jetbrains.com/plugin/7282-liveplugin) + +Allows project specific plugins to run. Eg: Regex Intention + +### [Live Templates Sharing](https://plugins.jetbrains.com/plugin/25007-live-templates-sharing) + +Imports our custom live templates automatically. Live Templates allow for quicker code writing. + ## Software Used in SkyHanni ### Basics @@ -218,29 +249,6 @@ For info on usage, look at [DiscordRPCManager.kt](https://github.com/hannibal002 We use the [auto update library](https://github.com/nea89o/libautoupdate) from nea89. -## Additional Useful Development Tools - -### DevAuth - -[DevAuth](https://github.com/DJtheRedstoner/DevAuth) is a tool that allows logging in to a Minecraft account while -debugging in IntelliJ. This is very useful for coding live on Hypixel without the need to compile a jar. - -- The library is already downloaded by Gradle. -- SkyHanni will automatically set up DevAuth. -- Start Minecraft inside IntelliJ normally. - - Click on the link in the console and verify with a Microsoft account. - - The verification process will reappear every few days (after the session token expires). - -### Hot Swap - -Hot Swap allows reloading edited code while debugging, removing the need to restart the whole game every time. - -We use [dcevm](https://dcevm.github.io/) and the IntelliJ -Plugin [HotSwap Agent](https://plugins.jetbrains.com/plugin/9552-hotswapagent) to quickly reload code changes. - -Follow [this](https://forums.Minecraftforge.net/topic/82228-1152-3110-intellij-and-gradlew-forge-hotswap-and-dcevm-tutorial/) -tutorial. - ## 1.21 / Modern version development You might have noticed that while the SkyHanni source code is found in `src/`, the actual tasks for compiling, building and running the mod -- cgit From 697e9e2dd6e5bb1d32e5b330623199099d9750bf Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:16:26 +1100 Subject: Backend: Add in event handler check to SkyHanni Events (#2755) --- .../hannibal2/skyhanni/api/event/EventHandler.kt | 26 +++++++++++++++++++--- .../at/hannibal2/skyhanni/config/ConfigManager.kt | 3 ++- .../at/hannibal2/skyhanni/utils/ConfigUtils.kt | 3 ++- .../utils/repopatterns/RepoPatternManager.kt | 9 +++----- 4 files changed, 30 insertions(+), 11 deletions(-) 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 63d3e14cf..040ecc43c 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt @@ -2,12 +2,15 @@ package at.hannibal2.skyhanni.api.event import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.mixins.hooks.getValue +import at.hannibal2.skyhanni.mixins.hooks.setValue import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.chat.Text +import at.hannibal2.skyhanni.utils.system.PlatformUtils class EventHandler private constructor( val name: String, @@ -21,9 +24,24 @@ class EventHandler private constructor( constructor(event: Class, listeners: List) : this( (event.name.split(".").lastOrNull() ?: event.name).replace("$", "."), listeners.sortedBy { it.options.priority }.toList(), - listeners.any { it.options.receiveCancelled } + listeners.any { it.options.receiveCancelled }, ) + companion object { + private var eventHandlerDepth by object : ThreadLocal() { + override fun initialValue(): Int { + return 0 + } + } + + /** + * Returns true if the current thread is in an event handler. This is because the event handler catches exceptions which means + * that we are free to throw exceptions in the event handler without crashing the game. + * We also return true if we are in a dev environment to alert the developer of any errors effectively. + */ + val isInEventHandler get() = eventHandlerDepth > 0 || PlatformUtils.isDevEnvironment + } + fun post(event: T, onError: ((Throwable) -> Unit)? = null): Boolean { invokeCount++ if (this.listeners.isEmpty()) return false @@ -32,6 +50,7 @@ class EventHandler private constructor( var errors = 0 + eventHandlerDepth++ for (listener in listeners) { if (!shouldInvoke(event, listener)) continue try { @@ -48,13 +67,14 @@ class EventHandler private constructor( } if (event.isCancelled && !canReceiveCancelled) break } + eventHandlerDepth-- if (errors > 3) { 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!", + ), ) } return event.isCancelled diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index b82d4d8f9..a534eac89 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.EventHandler import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.core.config.PositionList import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson @@ -96,7 +97,7 @@ class ConfigManager { try { findPositionLinks(features, mutableSetOf()) } catch (e: Exception) { - if (LorenzEvent.isInGuardedEventHandler) throw e + if (LorenzEvent.isInGuardedEventHandler || EventHandler.isInEventHandler) throw e } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt index 94d981d8e..bcf8e45b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ConfigUtils.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.EventHandler import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.HasLegacyId import at.hannibal2.skyhanni.events.LorenzEvent @@ -86,7 +87,7 @@ object ConfigUtils { if (tryJumpToEditor(ConfigGuiManager.getEditorInstance())) return // TODO create utils function "crashIfInDevEnv" - if (LorenzEvent.isInGuardedEventHandler) { + if (LorenzEvent.isInGuardedEventHandler || EventHandler.isInEventHandler) { throw Error("can not jump to editor $name") } ErrorManager.logErrorStateWithData( diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt index ad10ba195..8bef5061f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.utils.repopatterns import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.EventHandler import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.features.dev.RepoPatternConfig @@ -60,11 +61,6 @@ object RepoPatternManager { private var usedKeys: NavigableMap> = TreeMap() private var wasPreInitialized = false - private val isInDevEnv = try { - Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean - } catch (_: Exception) { - true - } private val insideTest = Launch.blackboard == null @@ -88,8 +84,9 @@ object RepoPatternManager { * Crash if in a development environment, or if inside a guarded event handler. */ fun crash(reason: String) { - if (isInDevEnv || LorenzEvent.isInGuardedEventHandler) + if (LorenzEvent.isInGuardedEventHandler || EventHandler.isInEventHandler) { throw RuntimeException(reason) + } } /** -- cgit From 9d21e7b150a88df224bd35e702bf71e456019db1 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:18:15 +1100 Subject: Backend: Fix code in PlayerChatManager (#2756) --- .../skyhanni/data/hypixel/chat/PlayerChatManager.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt index 2529e7ff1..eb48bb4e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerChatManager.kt @@ -206,24 +206,20 @@ object PlayerChatManager { private fun sendSystemMessage(event: LorenzChatEvent) { with(SystemMessageEvent(event.message, event.chatComponent)) { - val cancelled = postAndCatch() - event.handleChat(cancelled, blockedReason, chatComponent) + postAndCatch() + event.handleChat(blockedReason, chatComponent) } } private fun AbstractChatEvent.postChat(event: LorenzChatEvent) { - val cancelled = postAndCatch() - event.handleChat(cancelled, blockedReason, chatComponent) + postAndCatch() + event.handleChat(blockedReason, chatComponent) } private fun LorenzChatEvent.handleChat( - cancelled: Boolean, blockedReason: String?, chatComponent: IChatComponent, ) { - if (cancelled) { - this.cancel() - } blockedReason?.let { this.blockedReason = it } -- cgit From c84af157a6c82ac25baf60431e1e839bc58fb517 Mon Sep 17 00:00:00 2001 From: NeoNyaa <56982408+NeoNyaa@users.noreply.github.com> Date: Sat, 26 Oct 2024 05:03:02 +0100 Subject: Backend: Reworded a previous commit (#2818) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53ec5bc27..a30f9178b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,7 +85,7 @@ out [their guide](https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/mast If you are not very familiar with git, you might want to try this out: https://learngitbranching.js.org/. -Proposed changes are better off being in their own branch, you can do this by doing the following from within IntelliJ with the SkyHanni project already open. +Proposed changes are better off being in their own branch as this makes development easier for both you and the maintainers of this repository, you can do this by following the instructions from within the IntelliJ window with the SkyHanni project already open. - Click the beta dropdown at the top of IntelliJ - Click new branch - Give the branch a name relating to the changes you plan to make -- cgit From 742d175b2f9d103e7af8adf2aee11882be3107b8 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 26 Oct 2024 04:37:28 -0400 Subject: Backend Fix: Detekt Artifact not Uploading (#2822) --- .github/workflows/detekt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml index 97909596a..a258661f1 100644 --- a/.github/workflows/detekt.yml +++ b/.github/workflows/detekt.yml @@ -43,7 +43,7 @@ jobs: chmod +x .github/scripts/process_detekt_sarif.sh ./.github/scripts/process_detekt_sarif.sh versions/1.8.9/build/reports/detekt/main.sarif | tee detekt_output.txt - name: Upload detekt output as artifact - if: ${{ steps.check_sarif.outputs.exists == 'true' }} + if: ${{ !cancelled() && steps.check_sarif.outputs.exists == 'true' }} uses: actions/upload-artifact@v4 with: name: detekt-output -- cgit From 69e74cce8912fe00dac3120b465f413870ec2526 Mon Sep 17 00:00:00 2001 From: Phoebe <77941535+catgirlseraid@users.noreply.github.com> Date: Sun, 27 Oct 2024 06:19:12 +1300 Subject: Fix: update dungeon potion regex (#2825) --- .../skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt | 7 ++++++- 1 file changed, 6 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 e8cd7cdae..97a5a5737 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -78,9 +78,14 @@ object ItemDisplayOverlayFeatures { "harvest", "§7§7You may harvest §6(?.).*", ) + + /** + * REGEX-TEST: Dungeon VII Potion + * REGEX-TEST: Dungeon VII Potion x1 + */ private val dungeonPotionPattern by patternGroup.pattern( "dungeonpotion", - "Dungeon (?.*) Potion", + "Dungeon (?.*) Potion(?: x1)?", ) private val bingoGoalRankPattern by patternGroup.pattern( "bingogoalrank", -- cgit From 79580af37a5ea70511717b8e34a4607db46583f9 Mon Sep 17 00:00:00 2001 From: Phoebe <77941535+catgirlseraid@users.noreply.github.com> Date: Sun, 27 Oct 2024 06:30:20 +1300 Subject: Fix: brewing stand shift click close button (#2824) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt index 65c0d3940..824d95789 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt @@ -11,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ShiftClickBrewing { + private val closeButtonIndex = 49 @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { @@ -19,7 +20,7 @@ object ShiftClickBrewing { if (event.gui !is GuiChest) return - if (event.slot == null) return + if (event.slot == null || event.slotId == closeButtonIndex) return val chestName = InventoryUtils.openInventoryName() if (!chestName.startsWith("Brewing Stand")) return -- cgit From 1f6b0995cbb82aef2842f4ea4f4019de8864b28d Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:31:28 -0400 Subject: Fix: Typo in Rabbit the Fish Config (#2820) --- src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../skyhanni/config/features/event/hoppity/HoppityEggsConfig.java | 4 ++-- .../skyhanni/features/event/hoppity/HoppityEventSummary.kt | 6 ++++++ .../skyhanni/features/event/hoppity/HoppityRabbitTheFishChecker.kt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index f8afe645c..d90ce7730 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 = 63 + const val CONFIG_VERSION = 64 fun JsonElement.at(chain: List, 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/event/hoppity/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java index f34959bd8..e339574e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java @@ -218,8 +218,8 @@ public class HoppityEggsConfig { public boolean petWarning = false; @Expose - @ConfigOption(name = "Prevent Missing Fish the Rabbit", desc = "Prevent closing a Meal Egg's inventory if Fish the Rabbit is present.") + @ConfigOption(name = "Prevent Missing Rabbit the Fish", desc = "Prevent closing a Meal Egg's inventory if Rabbit the Fish is present.") @ConfigEditorBoolean @FeatureToggle - public boolean preventMissingFish = true; + public boolean preventMissingRabbitTheFish = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt index 41d5142d8..a7c731a18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEventSummary.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.event.hoppity.HoppityEventSummaryConfig.HoppityStat import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage.HoppityEventStats import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage.HoppityEventStats.RabbitData @@ -48,6 +49,11 @@ object HoppityEventSummary { if (event.chocGained > 0) stats.dupeChocolateGained += event.chocGained } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(64, "event.hoppity.preventMissingFish", "event.hoppity.preventMissingRabbitTheFish") + } + @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityRabbitTheFishChecker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityRabbitTheFishChecker.kt index 02e800dcc..f1f9eee07 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityRabbitTheFishChecker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityRabbitTheFishChecker.kt @@ -94,5 +94,5 @@ object HoppityRabbitTheFishChecker { return shouldContinue } - private fun isEnabled() = LorenzUtils.inSkyBlock && HoppityAPI.isHoppityEvent() && config.preventMissingFish + private fun isEnabled() = LorenzUtils.inSkyBlock && HoppityAPI.isHoppityEvent() && config.preventMissingRabbitTheFish } -- cgit From f226fc113014dea6c8fcccd7e00d52a610f8f8bc Mon Sep 17 00:00:00 2001 From: Kaeso <24925519+ptlthg@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:32:36 -0400 Subject: Fix: Catch JSON Parse Errors in APIUtils (#2819) --- src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt index f331ab3e3..9524836e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtils.kt @@ -181,9 +181,16 @@ object APIUtils { private fun readResponse(entity: HttpEntity): JsonObject { val retSrc = EntityUtils.toString(entity) ?: return JsonObject() - val parsed = parser.parse(retSrc) - if (parsed.isJsonNull) return JsonObject() - return parsed as JsonObject + + try { + val parsed = parser.parse(retSrc) + if (parsed.isJsonNull) return JsonObject() + + return parsed as JsonObject + } catch (_: Throwable) { + // This causes content types that aren't JSON to be ignored + return JsonObject() + } } fun postJSONIsSuccessful(url: String, body: String, silentError: Boolean = false): Boolean { -- cgit From 257640fdd4708356cebf8898d43e8ec4d7bd7351 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 26 Oct 2024 20:14:40 +0200 Subject: fixed detekt and wording --- src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt | 2 +- .../java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt index 386fb8bbf..acf1b6e0c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt @@ -466,7 +466,7 @@ object IslandGraphs { componentText.onClick( onClick = { stop() - "§e[SkyHanni] Navigation manually stopped!".asComponent().send(PATHFIND_ID) + "§e[SkyHanni] Navigation stopped!".asComponent().send(PATHFIND_ID) }, ) componentText.hover = "§eClick to stop navigating!".asComponent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt index 824d95789..141ec7585 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt @@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object ShiftClickBrewing { - private val closeButtonIndex = 49 + private const val closeButtonIndex = 49 @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { -- cgit From 6b4f3a330869360b55a9f55fc0f9dc554e195feb Mon Sep 17 00:00:00 2001 From: martimavocado <39881008+martimavocado@users.noreply.github.com> Date: Sat, 26 Oct 2024 19:14:57 +0100 Subject: Fix: Great Spook mob cooldown and timer (#2804) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/config/features/dev/DebugConfig.java | 5 + .../skyhanni/data/jsonobjects/repo/EventsJson.kt | 9 + .../skyhanni/features/event/spook/TheGreatSpook.kt | 188 +++++++++++++++++---- .../java/at/hannibal2/skyhanni/utils/ChatUtils.kt | 16 +- 4 files changed, 178 insertions(+), 40 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventsJson.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java index 56a17dfb9..9f92436cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java @@ -162,6 +162,11 @@ public class DebugConfig { @ConfigEditorBoolean public boolean alwaysHoppitys = false; + @Expose + @ConfigOption(name = "Always Great Spook", desc = "Assumes the Great Spook is always active.") + @ConfigEditorBoolean + public Property forceGreatSpook = Property.of(false); + // Does not have a config element! @Expose public Position trackSoundPosition = new Position(0, 0); diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventsJson.kt new file mode 100644 index 000000000..cab8ae7fe --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventsJson.kt @@ -0,0 +1,9 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class EventsJson( + @Expose @SerializedName("great_spook") val greatSpook: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt index 4e88237e0..9125f25a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -1,84 +1,167 @@ package at.hannibal2.skyhanni.features.event.spook import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.jsonobjects.repo.EventsJson import at.hannibal2.skyhanni.data.model.SkyblockStat +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUCalculator import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils -import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.TimeUnit +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 +import kotlin.time.Duration.Companion.seconds @SkyHanniModule object TheGreatSpook { - - // §r§cPrimal Fears§r§7: §r§6§lREADY!! private val config get() = SkyHanniMod.feature.event.spook - private var displayTimer = "" - private var displayTimeLeft = "" - private var notificationSeconds = 0 + + private var isGreatSpookActive = false + private var greatSpookTimeRange: ClosedRange? = null + private var greatSpookEndTime = SimpleTimeMark.farPast() + + private var displayMobCooldown: Renderable? = null + private var displayGreatSpookEnd: Renderable? = null + + private var timeUntilNextMob = SimpleTimeMark.farPast() + + private val patternGroup = RepoPattern.group("event.greatspook") + + /** + * REGEX-TEST: §d§lQUICK MATHS! §r§7Solve: §r§e(10*2)+12*5 + */ + private val mathFearMessagePattern by patternGroup.pattern( + "chat.math", + "§d§lQUICK MATHS! §r§7Solve: §r§e(?.*)", + ) + + /** + * REGEX-TEST: §4[FEAR] Public Speaking Demon§r§f: Speak PlasticEating! + */ + private val speakingFearMessagePattern by patternGroup.pattern( + "chat.speaking", + "§4\\[FEAR] Public Speaking Demon§r§f: (Speak|Say something interesting) (?.*)!", + ) + + /** + * REGEX-TEST: §5§lFEAR. §r§eA §r§dPrimal Fear §r§ehas been summoned! + */ + private val primalFearSpawnPattern by patternGroup.pattern( + "mob.spawn", + "§5§lFEAR\\. §r§eA §r§dPrimal Fear §r§ehas been summoned!", + ) @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return + if (!isGreatSpookActive) return + + val fear = SkyblockStat.FEAR.lastKnownValue ?: 0.0 + val mobCooldown = timeUntilNextMob.minus((3 * fear).seconds) + val mobCooldownString = if (mobCooldown.isInFuture()) { + "§5Next fear in: §b${ + mobCooldown.timeUntil().format( + biggestUnit = TimeUnit.MINUTE, + showMilliSeconds = false, + showSmallerUnits = false, + ) + }" + } else { + "§5§lPrimal Fear Ready!" + } + displayMobCooldown = Renderable.string(mobCooldownString) - if (config.primalFearTimer || config.primalFearNotification) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ") - if (config.greatSpookTimeLeft) displayTimeLeft = checkTabList(" §r§dEnds In§r§7: ") - if (config.primalFearNotification) { - if (displayTimer.endsWith("READY!!")) { - if (notificationSeconds > 0) { - SoundUtils.playBeepSound() - notificationSeconds-- + if (config.primalFearNotification && mobCooldown.isInFuture()) { + SoundUtils.playPlingSound() + } + + val greatSpookEnd = greatSpookTimeRange?.endInclusive ?: return + val timeLeftString = if (greatSpookEnd.isInFuture()) { + "§5Great Spook time left: §b${ + greatSpookEnd.timeUntil().format( + biggestUnit = TimeUnit.DAY, + maxUnits = 2, + ) + }" + } else { + "§5§lThe Great Spook has ended!" + } + displayGreatSpookEnd = Renderable.string(timeLeftString) + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val config = SkyHanniMod.feature.dev.debug.forceGreatSpook + config.afterChange { + if (config.get()) { + isGreatSpookActive = true + greatSpookEndTime = SimpleTimeMark.farFuture() + } else { + val timeRange = greatSpookTimeRange + if (timeRange == null) { + isGreatSpookActive = false + greatSpookEndTime = SimpleTimeMark.farPast() + return@afterChange } - } else if (displayTimer.isNotEmpty()) { - notificationSeconds = 5 + isGreatSpookActive = SimpleTimeMark.now() in timeRange + greatSpookEndTime = timeRange.endInclusive } } } - private fun checkTabList(matchString: String): String { - return (TabListData.getTabList().find { it.contains(matchString) }.orEmpty()).trim() + @SubscribeEvent + fun onWorldSwitch(event: IslandChangeEvent) { + val currentTime = SimpleTimeMark.now() + val timeRange = greatSpookTimeRange ?: run { + isGreatSpookActive = false + return + } + + isGreatSpookActive = currentTime in timeRange } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!LorenzUtils.inSkyBlock) return + if (!isGreatSpookActive) return - if (config.primalFearTimer) config.positionTimer.renderString(displayTimer, posLabel = "Primal Fear Timer") + if (config.primalFearTimer) { + displayMobCooldown.let { + config.positionTimer.renderRenderable(it, posLabel = "Primal Fear Timer") + } + } if (config.fearStatDisplay) { SkyblockStat.FEAR.displayValue?.let { config.positionFear.renderString(it, posLabel = "Fear Stat Display") } } - if (config.greatSpookTimeLeft) config.positionTimeLeft.renderString(displayTimeLeft, posLabel = "Time Left Display") + if (config.greatSpookTimeLeft) { + displayGreatSpookEnd.let { + config.positionTimeLeft.renderRenderable(it, posLabel = "Great Spook Time Left") + } + } } - /** - * REGEX-TEST: §d§lQUICK MATHS! §r§7Solve: §r§e(10*2)+12*5 - */ - private val mathFearMessagePattern by RepoPattern.pattern( - "chat.math", - "§d§lQUICK MATHS! §r§7Solve: §r§e(?.*)", - ) - - /** - * REGEX-TEST: §4[FEAR] Public Speaking Demon§r§f: Speak PlasticEating! - */ - private val speakingFearMessagePattern by RepoPattern.pattern( - "chat.speaking", - "§4\\[FEAR] Public Speaking Demon§r§f: (Speak|Say something interesting) (?.*)!", - ) - private fun mathSolver(query: String?) { val answer = query?.let { NEUCalculator.calculateOrNull(it)?.toInt() } ?: run { ChatUtils.userError("Failed to solve $query!") @@ -108,6 +191,18 @@ object TheGreatSpook { @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return + if (!isGreatSpookActive) return + + if (primalFearSpawnPattern.matches(event.message)) { + timeUntilNextMob = SimpleTimeMark.now().plus(6.minutes) + if (SkyblockStat.FEAR.lastKnownValue == null && (config.primalFearNotification || config.primalFearTimer)) { + ChatUtils.userError( + "Fear stat not found! Please enable the Stats widget and enable the Fear stat for the best results.", + replaceSameMessage = true, + ) + } + return + } if (config.primalFearSolver.math) { mathFearMessagePattern.matchMatcher(event.message) { @@ -125,4 +220,27 @@ object TheGreatSpook { } } } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant("Events").greatSpook + + val startTime = data["start_time"] ?: SimpleTimeMark.farPast() + val endTime = data["end_time"] ?: SimpleTimeMark.farPast() + + greatSpookTimeRange = startTime..endTime + greatSpookEndTime = if (SkyHanniMod.feature.dev.debug.forceGreatSpook.get()) SimpleTimeMark.farFuture() else endTime + } + + @SubscribeEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Great Spook") + + event.addIrrelevant { + add("isActive: $isGreatSpookActive") + add("activeTimeRange: $greatSpookTimeRange") + add("eventEndTime: $greatSpookEndTime") + add("timeUntilNextMob: $timeUntilNextMob") + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt index 1547e39b5..d48c8d8a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt @@ -44,8 +44,11 @@ object ChatUtils { * * @see DEBUG_PREFIX */ - fun debug(message: String) { - if (LorenzUtils.debug && internalChat(DEBUG_PREFIX + message)) { + fun debug( + message: String, + replaceSameMessage: Boolean = false, + ) { + if (LorenzUtils.debug && internalChat(DEBUG_PREFIX + message, replaceSameMessage)) { LorenzUtils.consoleLog("[Debug] $message") } } @@ -58,8 +61,11 @@ object ChatUtils { * * @see USER_ERROR_PREFIX */ - fun userError(message: String) { - internalChat(USER_ERROR_PREFIX + message) + fun userError( + message: String, + replaceSameMessage: Boolean = false, + ) { + internalChat(USER_ERROR_PREFIX + message, replaceSameMessage) } /** @@ -87,7 +93,7 @@ object ChatUtils { private fun internalChat( message: String, - replaceSameMessage: Boolean = false, + replaceSameMessage: Boolean, ): Boolean { val text = ChatComponentText(message) -- cgit From 6b27638c293da2ff318ac5b0f99c7bc2f5ea488d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 26 Oct 2024 21:04:57 +0200 Subject: Version 0.28 Beta 8 --- docs/CHANGELOG.md | 22 ++++++++++++++++++++++ root.gradle.kts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 086b77122..f91b89c13 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -95,6 +95,15 @@ + Improved the Time Tower Usage Warning so it doesn't spam messages. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2730) +#### Great Spook Improvements + ++ Highlight Great Spook's answer in blue. - not_a_cow (https://github.com/hannibal002/SkyHanni/pull/2798) + +#### Custom Scoreboard Improvements + ++ Added the date to the Custom Scoreboard Lobby code. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2802) ++ Added an option to display the profile type instead of the name in the Custom Scoreboard. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2810) + #### Misc Improvements + Added distance display to waypoints created by Patcher's Send Coords feature. - jani (https://github.com/hannibal002/SkyHanni/pull/2704) @@ -128,6 +137,8 @@ + 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) ++ Fixed "Dungeon Potion level as stack size" not working in shop menus. - phoebe (https://github.com/hannibal002/SkyHanni/pull/2825) ++ Fixed being unable to use the "Close" button when "Change all clicks to shift clicks in brewing stands" is enabled. - phoebe (https://github.com/hannibal002/SkyHanni/pull/2824) #### Combat Fixes @@ -144,6 +155,7 @@ + Fixed Custom Scoreboard duplicating the Party Leader. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2780) + Fixed some Custom Scoreboard errors. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2779) + Fixed party leader not displaying correctly in the Custom Scoreboard. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2783) ++ Fixed the Broodmother line in the Custom Scoreboard having a leading space. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2810) #### Hoppity Fixes @@ -151,11 +163,14 @@ + Fixed El Dorado not receiving a compacted chat message. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2742) + Fixed issues with El Dorado stray detection. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2786) + Fixed an error when Rabbit the Fish was found in Meal Eggs. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2785) ++ Fixed dyes being incorrectly modified in Hoppity's Collection after disabling "Re-Color Missing Rabbit Dyes". - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2803) #### Garden Fixes + Fixed farming weight not disappearing when the config option is off. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2731) + Fixed New Visitor Ping triggering too late if the player is actively farming. - Luna (https://github.com/hannibal002/SkyHanni/pull/2767) ++ Fixed the mouse not unlocking when teleporting to the Barn. - not_a_cow (https://github.com/hannibal002/SkyHanni/pull/2799) ++ Fixed API error when sending Jacob Contests. - Ke5o (https://github.com/hannibal002/SkyHanni/pull/2819) #### Crimson Isle Fixes @@ -183,6 +198,7 @@ + Fixed Fear Stat Display. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2766) + Fixed Carnival Goal display rarely showing outside the Hub Island. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2772) ++ Fixed the Great Spook features. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/2804) #### Rift Fixes @@ -191,6 +207,8 @@ #### 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) + + Also fixed ranks losing their "+" colors. #### Misc Fixes @@ -198,6 +216,7 @@ + Fixed the formatting of negative durations. - Empa (https://github.com/hannibal002/SkyHanni/pull/2726) + Fixed debug messages not sending when debug mode is enabled. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2793) + Fixed TPS display not working outside Skyblock. - Empa (https://github.com/hannibal002/SkyHanni/pull/2791) ++ Fixed the "Colored Class Level" tab list displaying "null". - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2814) ### Technical Details @@ -227,6 +246,9 @@ + 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) + + 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) ## Version 0.27 diff --git a/root.gradle.kts b/root.gradle.kts index 46d24729e..11cd8a409 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.7" + version = "0.28.Beta.8" repositories { mavenCentral() mavenLocal() -- cgit From b87483b531cbbd295ab335531dfa5ac6a4697f8e Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 26 Oct 2024 22:55:45 +0200 Subject: Fix: Primal Fear Notify backwards logic (#2831) --- .../java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt index 9125f25a2..22408ebfb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -91,7 +91,7 @@ object TheGreatSpook { } displayMobCooldown = Renderable.string(mobCooldownString) - if (config.primalFearNotification && mobCooldown.isInFuture()) { + if (config.primalFearNotification && mobCooldown.isInPast()) { SoundUtils.playPlingSound() } -- cgit From d030f24e0a721a50d22d494c46b1a5d273ffce65 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 26 Oct 2024 22:56:43 +0200 Subject: Fix: "null" in Custom Scoreboard LobbyCode (#2832) --- .../gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementLobbyCode.kt index f4f64ed17..fcb07f2a3 100644 --- a/src/main/java/at/hannib