diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 143c59466cd1..7ab0e6c7543f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,14 +23,14 @@ jobs: - uses: ./.github/actions/setup-normal-workspace - name: Build with Gradle run: ./gradlew assemble -x test --stacktrace - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 name: Upload development build with: name: "Development Build" path: build/libs/*.jar - name: Test with Gradle run: ./gradlew test - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 name: "Upload test report" if: ${{ !cancelled() }} with: diff --git a/.github/workflows/generate-constants.yaml b/.github/workflows/generate-constants.yaml index c589676d0e2f..f6fab6f243ac 100644 --- a/.github/workflows/generate-constants.yaml +++ b/.github/workflows/generate-constants.yaml @@ -29,7 +29,7 @@ jobs: - name: Generate Repo Patterns using Gradle run: | ./gradlew generateRepoPatterns --stacktrace - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 name: Upload generated repo regexes with: name: Repo Regexes @@ -45,7 +45,7 @@ jobs: with: repository: ${{ env.data_repo }} branch: main - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 name: Upload generated repo regexes with: name: Repo Regexes diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 000000000000..3702088f8387 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,57 @@ +name: "PR Changelog Verification" + +on: + pull_request_target: + types: [ opened, edited ] + +jobs: + verify-changelog: + if: github.event.pull_request.state == 'open' && '511310721' == github.repository_id + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-normal-workspace + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Run ChangeLog verification + env: + PR_TITLE: ${{ github.event.pull_request.title }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + ./gradlew checkPrDescription -PprTitle="${PR_TITLE}" -PprBody="${PR_BODY}" + + - name: Add label if changelog verification fails + if: failure() + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'Wrong Title/Changelog' + + - name: Remove label if changelog verification passes + if: success() + uses: actions-ecosystem/action-remove-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: 'Wrong Title/Changelog' + + - name: Add comment to PR if changelog verification fails + if: failure() + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const test = fs.readFileSync('versions/1.8.9/build/changelog_errors.txt', 'utf8'); + const commentBody = `${test}` + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }) diff --git a/.live-plugins/module/plugin.kts b/.live-plugins/module/plugin.kts index c0a65d3f431b..f7471e9fd98c 100644 --- a/.live-plugins/module/plugin.kts +++ b/.live-plugins/module/plugin.kts @@ -18,6 +18,7 @@ val forgeEvent = "SubscribeEvent" val handleEvent = "HandleEvent" val skyHanniModule = "SkyHanniModule" +val skyhanniPath = "at.hannibal2.skyhanni" val patternGroup = "at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGroup" val pattern = "java.util.regex.Pattern" @@ -36,12 +37,17 @@ fun isRepoPattern(property: KtProperty): Boolean { return false } +fun isFromSkyhanni(declaration: KtNamedDeclaration): Boolean { + return declaration.fqName?.asString()?.startsWith(skyhanniPath) ?: false +} + class ModuleInspectionKotlin : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { val visitor = object : KtVisitorVoid() { override fun visitClass(klass: KtClass) { + if (!isFromSkyhanni(klass)) return val hasAnnotation = klass.annotationEntries.any { it.shortName?.asString() == skyHanniModule } if (hasAnnotation) { @@ -54,6 +60,7 @@ class ModuleInspectionKotlin : AbstractKotlinInspection() { } override fun visitObjectDeclaration(declaration: KtObjectDeclaration) { + if (!isFromSkyhanni(declaration)) return val hasAnnotation = declaration.annotationEntries.any { it.shortName?.asString() == skyHanniModule } if (hasAnnotation) return diff --git a/build.gradle.kts b/build.gradle.kts index 190385c1e4ee..dde5ac410ed2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,11 +3,12 @@ import at.skyhanni.sharedvariables.MultiVersionStage import at.skyhanni.sharedvariables.ProjectTarget import at.skyhanni.sharedvariables.SHVersionInfo import at.skyhanni.sharedvariables.versionString +import io.gitlab.arturbosch.detekt.Detekt +import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask import net.fabricmc.loom.task.RunGameTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import io.gitlab.arturbosch.detekt.Detekt -import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask +import skyhannibuildsystem.ChangelogVerification plugins { idea @@ -102,6 +103,13 @@ tasks.runClient { }, ) } + +tasks.register("checkPrDescription", ChangelogVerification::class) { + this.outputDirectory.set(layout.buildDirectory) + this.prTitle = project.findProperty("prTitle") as String + this.prBody = project.findProperty("prBody") as String +} + val shot = shots.shot("minecraft", rootProject.file("shots.txt")) dependencies { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000000..505f438b98c2 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + maven("https://jitpack.io") { + content { + includeGroupByRegex("com\\.github\\..*") + } + } +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib") + implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.0.1") +} diff --git a/buildSrc/src/main/kotlin/skyhannibuildsystem/ChangelogVerification.kt b/buildSrc/src/main/kotlin/skyhannibuildsystem/ChangelogVerification.kt new file mode 100644 index 000000000000..8ac54d6fc0b1 --- /dev/null +++ b/buildSrc/src/main/kotlin/skyhannibuildsystem/ChangelogVerification.kt @@ -0,0 +1,64 @@ +package skyhannibuildsystem + +import at.hannibal2.changelog.SkyHanniChangelogBuilder +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.TaskAction +import java.io.File + +abstract class ChangelogVerification : DefaultTask() { + + @get:OutputDirectory + abstract val outputDirectory: DirectoryProperty + + @Input + var prTitle: String = "" + + @Input + var prBody: String = "" + + @get:Internal + val prBodyLines get() = prBody.lines() + + private val prLink = "ignored" + private val templateLocation = "https://github.com/hannibal002/SkyHanni/blob/beta/pull_request_template.md" + + @TaskAction + fun scanChangelog() { + if (prBodyLines.contains("exclude_from_changelog")) { + println("PR is excluded from changelog verification") + return + } + + val (changes, bodyErrors) = SkyHanniChangelogBuilder.findChanges(prBodyLines, prLink) + val titleErrors = SkyHanniChangelogBuilder.findPullRequestNameErrors(prTitle, changes) + + if (bodyErrors.isEmpty() && titleErrors.isEmpty()) { + println("Changelog and title verification successful") + } else { + bodyErrors.forEach { println(it.message) } + titleErrors.forEach { println(it.message) } + + // Export errors so that they can be listed in the PR comment + val errorFile = File(outputDirectory.get().asFile, "changelog_errors.txt") + println("saved error file to: ${errorFile.path}") + + errorFile.appendText("I have detected some issues with your pull request:\n\n") + + if (bodyErrors.isNotEmpty()) { + errorFile.appendText("Body issues:\n${bodyErrors.joinToString("\n") { it.formatLine() }}\n\n") + } + if (titleErrors.isNotEmpty()) { + errorFile.appendText("Title issues:\n${titleErrors.joinToString("\n") { it.message }}\n\n") + } + + errorFile.appendText("Please fix these issues. For the correct format, refer to the [pull request template]($templateLocation).") + + throw GradleException("Changelog verification failed") + } + } +} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6f2dcbba0155..a65aebe3eefb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,18 @@ + Added Focus Mode. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/2694) + In Focus Mode, only the name of the item is displayed instead of the full description. +#### Fishing Features + ++ Added Lava Replacement. - HiZe (https://github.com/hannibal002/SkyHanni/pull/1885) + + Replaces the lava texture with the water texture. + + Primarily used for lava fishing in the Crimson Isle, but can be used anywhere else if the option is enabled. + +#### Mining Features + ++ Added Precision Mining Highlighter. - Cuz_Im_Clicks (https://github.com/hannibal002/SkyHanni/pull/2614) + + Draws a box over the Precision Mining particles. ++ Added highlighting boxes to Crystal Nucleus crystals during Hoppity's Hunt. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2598) + ### Improvements #### Inventory Improvements @@ -27,8 +39,20 @@ + Added support for Guilds in player-related tab completions. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2637) + Added support for all Guild and Friend commands in tab completions. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2637) +#### Combat Improvements + ++ Added Totem of Corruption and Enrager to the Ability Cooldown feature. - DungeonHub (https://github.com/hannibal002/SkyHanni/pull/2706) + +#### Misc Improvements + ++ Added distance display to waypoints created by Patcher's Send Coords feature. - jani (https://github.com/hannibal002/SkyHanni/pull/2704) + ### Fixes +#### Dungeon Fixes + ++ Fixed Magical Power resetting to 0 when opening "Your Bags" in the Catacombs. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2710) + #### Fishing Fixes + Fixed fishing displays showing in dungeons. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2697) @@ -37,11 +61,25 @@ + Fixed "No Guardian Pet warning" not supporting Pet Rule "On open Experimentation Table". - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2699) + Fixed an error with compact experiment rewards chat messages. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2702) ++ Fixed Craft Materials Bazaar not working with long item names. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2703) ++ Fixed the debug feature that allows you to add/remove stars being enabled by default. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2715) #### Combat Fixes + Fixed Ghost Counter display appearing while in incorrect areas on the map. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2696) +#### Custom Scoreboard Fixes + ++ Fixed Custom Scoreboard not showing the Second Barbarian Quest. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2709) + +#### Hoppity Fixes + ++ Fixed the chocolate egg share message sometimes displaying the wrong location name. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/2711) + +#### Commands Fixes + ++ Fixed /shtranslate not working in most cases. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2693) + ### Technical Details + Assigned 'backend' label to PRs with 'backend' in the title. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2690) @@ -49,6 +87,13 @@ + Added SuggestionProvider. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2637) + This new class simplifies building suggestion trees. + Added Stats API. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/2253) ++ Cleaned up LorenzVec and added drawLineToEye. - Empa (https://github.com/hannibal002/SkyHanni/pull/2056) ++ Added SkyHanni event inheritance. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2047) ++ Added /shtranslateadvanced command. - Obsidian (https://github.com/hannibal002/SkyHanni/pull/2693) + + Allows specifying both the source and target language. ++ Added changelog verification. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2692) + + This action ensures your PR is in the correct format so that it can be used by the release notes tool. ++ Added dungeon phase detection. - martimavocado (https://github.com/hannibal002/SkyHanni/pull/1865) ## Version 0.27 diff --git a/docs/FEATURES.md b/docs/FEATURES.md index ed5c74ad3e0b..24c8e437252f 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -376,6 +376,9 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Added an alert for Gold or Diamond Trophy Fish catches. - ReyMaratov (https://github.com/hannibal002/SkyHanni/pull/2615) + Displays a popup with the trophy name, rarity, and amount of the catch. + Optionally, also plays a sound. ++ Added Lava Replacement. - HiZe (https://github.com/hannibal002/SkyHanni/pull/1885) + + Replaces the lava texture with the water texture. + + Primarily used for lava fishing in the Crimson Isle, but can be used anywhere else if the option is enabled.
@@ -911,6 +914,9 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Added a "Get from Sack" button in the forge recipe menu to retrieve ingredients. - minhperry (https://github.com/hannibal002/SkyHanni/pull/2106) + Added Tracker for Glacite Corpses. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2306) + Tracks overall loot and loot per type. ++ Added Precision Mining Highlighter. - Cuz_Im_Clicks (https://github.com/hannibal002/SkyHanni/pull/2614) + + Draws a box over the Precision Mining particles. ++ Added highlighting boxes to Crystal Nucleus crystals during Hoppity's Hunt. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2598)
diff --git a/root.gradle.kts b/root.gradle.kts index e3af39d26071..f97425b88a97 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -14,7 +14,7 @@ plugins { allprojects { group = "at.hannibal2.skyhanni" - version = "0.28.Beta.1" + version = "0.28.Beta.2" repositories { mavenCentral() mavenLocal() diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 45d02f5445f6..3aa57db320e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.Features import at.hannibal2.skyhanni.config.SackData -import at.hannibal2.skyhanni.config.commands.Commands +import at.hannibal2.skyhanni.config.commands.RegisterCommandsEvent import at.hannibal2.skyhanni.data.OtherInventoryData import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson @@ -59,7 +59,7 @@ class SkyHanniMod { SkyHanniEvents.init(modules) - Commands.init() + RegisterCommandsEvent.post() PreInitFinishedEvent().post() } diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 48a17974f0be..aa930adb1dc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -318,18 +318,24 @@ object SkillAPI { } val existingLevel = getSkillInfo(skillType) ?: SkillInfo() - val gained = matcher.group("gained") tablistLevel?.let { level -> if (isPercentPatternFound) { val levelXp = calculateLevelXp(existingLevel.level - 1) val nextLevelDiff = levelArray.getOrNull(level)?.toDouble() ?: 7_600_000.0 val nextLevelProgress = nextLevelDiff * xpPercentage / 100 val totalXp = levelXp + nextLevelProgress - updateSkillInfo(existingLevel, level, nextLevelProgress.toLong(), nextLevelDiff.toLong(), totalXp.toLong(), gained) + updateSkillInfo( + existingLevel, + level, + nextLevelProgress.toLong(), + nextLevelDiff.toLong(), + totalXp.toLong(), + matcher.group("gained"), + ) } else { val exactLevel = getLevelExact(needed) val levelXp = calculateLevelXp(existingLevel.level - 1).toLong() + current - updateSkillInfo(existingLevel, exactLevel, current, needed, levelXp, gained) + updateSkillInfo(existingLevel, exactLevel, current, needed, levelXp, matcher.group("gained")) } storage?.set(skillType, existingLevel) } @@ -469,7 +475,9 @@ object SkillAPI { val skill = storage?.get(skillType) ?: return if (targetLevel <= skill.overflowLevel) { - ChatUtils.userError("Custom goal level ($targetLevel) must be greater than your current level (${skill.overflowLevel}).") + ChatUtils.userError( + "Custom goal level ($targetLevel) must be greater than your current level (${skill.overflowLevel})." + ) return } 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 d164e0e774d7..63d3e14cfb21 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt @@ -8,77 +8,25 @@ 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 java.lang.invoke.LambdaMetafactory -import java.lang.invoke.MethodHandles -import java.lang.invoke.MethodType -import java.lang.reflect.Method -import java.lang.reflect.ParameterizedType -import java.util.function.Consumer -class EventHandler private constructor(val name: String, private val isGeneric: Boolean) { - - private val listeners: MutableList = mutableListOf() - - private var isFrozen = false - private var canReceiveCancelled = false +class EventHandler private constructor( + val name: String, + private val listeners: List, + private val canReceiveCancelled: Boolean, +) { var invokeCount: Long = 0L private set - constructor(event: Class) : this( + constructor(event: Class, listeners: List) : this( (event.name.split(".").lastOrNull() ?: event.name).replace("$", "."), - GenericSkyHanniEvent::class.java.isAssignableFrom(event) + listeners.sortedBy { it.options.priority }.toList(), + listeners.any { it.options.receiveCancelled } ) - fun addListener(method: Method, instance: Any, options: HandleEvent) { - if (isFrozen) throw IllegalStateException("Cannot add listener to frozen event handler") - val generic: Class<*>? = if (isGeneric) { - method.genericParameterTypes - .firstNotNullOfOrNull { it as? ParameterizedType } - ?.let { it.actualTypeArguments.firstOrNull() as? Class<*> } - ?: throw IllegalArgumentException("Generic event handler must have a generic type") - } else { - null - } - val name = "${method.declaringClass.name}.${method.name}${ - method.parameterTypes.joinTo( - StringBuilder(), - prefix = "(", - postfix = ")", - separator = ", ", - transform = Class<*>::getTypeName - ) - }" - listeners.add(Listener(name, createEventConsumer(name, instance, method), options, generic)) - } - - @Suppress("UNCHECKED_CAST") - private fun createEventConsumer(name: String, instance: Any, method: Method): Consumer { - try { - val handle = MethodHandles.lookup().unreflect(method) - return LambdaMetafactory.metafactory( - MethodHandles.lookup(), - "accept", - MethodType.methodType(Consumer::class.java, instance::class.java), - MethodType.methodType(Nothing::class.javaPrimitiveType, Object::class.java), - handle, - MethodType.methodType(Nothing::class.javaPrimitiveType, method.parameterTypes[0]) - ).target.bindTo(instance).invokeExact() as Consumer - } catch (e: Throwable) { - throw IllegalArgumentException("Method $name is not a valid consumer", e) - } - } - - fun freeze() { - isFrozen = true - listeners.sortBy { it.options.priority } - canReceiveCancelled = listeners.any { it.options.receiveCancelled } - } - fun post(event: T, onError: ((Throwable) -> Unit)? = null): Boolean { invokeCount++ if (this.listeners.isEmpty()) return false - if (!isFrozen) error("Cannot invoke event on unfrozen event handler") if (SkyHanniEvents.isDisabledHandler(name)) return false @@ -112,7 +60,7 @@ class EventHandler private constructor(val name: String, priv return event.isCancelled } - private fun shouldInvoke(event: SkyHanniEvent, listener: Listener): Boolean { + private fun shouldInvoke(event: SkyHanniEvent, listener: EventListeners.Listener): Boolean { if (SkyHanniEvents.isDisabledInvoker(listener.name)) return false if (listener.options.onlyOnSkyblock && !LorenzUtils.inSkyBlock) return false if (IslandType.ANY !in listener.onlyOnIslandTypes && !inAnyIsland(listener.onlyOnIslandTypes)) return false @@ -126,19 +74,4 @@ class EventHandler private constructor(val name: String, priv } return true } - - private class Listener( - val name: String, - val invoker: Consumer, - val options: HandleEvent, - val generic: Class<*>?, - ) { - val onlyOnIslandTypes: Set = getIslands(options) - - companion object { - private fun getIslands(options: HandleEvent): Set = - if (options.onlyOnIslands.isEmpty()) setOf(options.onlyOnIsland) - else options.onlyOnIslands.toSet() - } - } } diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/EventListeners.kt b/src/main/java/at/hannibal2/skyhanni/api/event/EventListeners.kt new file mode 100644 index 000000000000..ce8194ebc5f3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventListeners.kt @@ -0,0 +1,78 @@ +package at.hannibal2.skyhanni.api.event + +import at.hannibal2.skyhanni.data.IslandType +import java.lang.invoke.LambdaMetafactory +import java.lang.invoke.MethodHandles +import java.lang.invoke.MethodType +import java.lang.reflect.Method +import java.lang.reflect.ParameterizedType +import java.util.function.Consumer + +class EventListeners private constructor(val name: String, private val isGeneric: Boolean) { + + private val listeners: MutableList = mutableListOf() + + constructor(event: Class<*>) : this( + (event.name.split(".").lastOrNull() ?: event.name).replace("$", "."), + GenericSkyHanniEvent::class.java.isAssignableFrom(event) + ) + + fun addListener(method: Method, instance: Any, options: HandleEvent) { + val generic: Class<*>? = if (isGeneric) { + method.genericParameterTypes + .firstNotNullOfOrNull { it as? ParameterizedType } + ?.let { it.actualTypeArguments.firstOrNull() as? Class<*> } + ?: throw IllegalArgumentException("Generic event handler must have a generic type") + } else { + null + } + val name = "${method.declaringClass.name}.${method.name}${ + method.parameterTypes.joinTo( + StringBuilder(), + prefix = "(", + postfix = ")", + separator = ", ", + transform = Class<*>::getTypeName + ) + }" + listeners.add(Listener(name, createEventConsumer(name, instance, method), options, generic)) + } + + /** + * Creates a consumer using LambdaMetafactory, this is the most efficient way to reflectively call + * a method from within code. + */ + @Suppress("UNCHECKED_CAST") + private fun createEventConsumer(name: String, instance: Any, method: Method): Consumer { + try { + val handle = MethodHandles.lookup().unreflect(method) + return LambdaMetafactory.metafactory( + MethodHandles.lookup(), + "accept", + MethodType.methodType(Consumer::class.java, instance::class.java), + MethodType.methodType(Nothing::class.javaPrimitiveType, Object::class.java), + handle, + MethodType.methodType(Nothing::class.javaPrimitiveType, method.parameterTypes[0]) + ).target.bindTo(instance).invokeExact() as Consumer + } catch (e: Throwable) { + throw IllegalArgumentException("Method $name is not a valid consumer", e) + } + } + + fun getListeners(): List = listeners + + class Listener( + val name: String, + val invoker: Consumer, + val options: HandleEvent, + val generic: Class<*>?, + ) { + val onlyOnIslandTypes: Set = getIslands(options) + + companion object { + private fun getIslands(options: HandleEvent): Set = + if (options.onlyOnIslands.isEmpty()) setOf(options.onlyOnIsland) + else options.onlyOnIslands.toSet() + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt index e3dff201485b..ace86b224de4 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt @@ -11,6 +11,7 @@ import java.lang.reflect.Method @SkyHanniModule object SkyHanniEvents { + private val listeners: MutableMap, EventListeners> = mutableMapOf() private val handlers: MutableMap, EventHandler<*>> = mutableMapOf() private var disabledHandlers = emptySet() private var disabledHandlerInvokers = emptySet() @@ -21,12 +22,14 @@ object SkyHanniEvents { registerMethod(it, instance) } } - handlers.values.forEach { it.freeze() } } @Suppress("UNCHECKED_CAST") fun getEventHandler(event: Class): EventHandler = handlers.getOrPut(event) { - EventHandler(event) + EventHandler( + event, + getEventClasses(event).mapNotNull { listeners[it] }.flatMap(EventListeners::getListeners) + ) } as EventHandler fun isDisabledHandler(handler: String): Boolean = handler in disabledHandlers @@ -38,8 +41,8 @@ object SkyHanniEvents { val options = method.getAnnotation(HandleEvent::class.java) ?: return val event = method.parameterTypes[0] if (!SkyHanniEvent::class.java.isAssignableFrom(event)) return - val handler = getEventHandler(event as Class) - handler.addListener(method, instance, options) + listeners.getOrPut(event as Class) { EventListeners(event) } + .addListener(method, instance, options) } @SubscribeEvent @@ -61,4 +64,23 @@ object SkyHanniEvents { } } } + + /** + * Returns a list of all super classes and the class itself up to [SkyHanniEvent]. + */ + private fun getEventClasses(clazz: Class<*>): List> { + val classes = mutableListOf>() + classes.add(clazz) + + var current = clazz + while (current.superclass != null) { + val superClass = current.superclass + if (superClass == SkyHanniEvent::class.java) break + if (superClass == GenericSkyHanniEvent::class.java) break + if (superClass == CancellableSkyHanniEvent::class.java) break + classes.add(superClass) + current = superClass + } + return classes + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt index ffb3b7256bfc..2aad75a40e3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.GuiEditManager import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper import io.github.notenoughupdates.moulconfig.gui.MoulConfigEditor @@ -18,4 +19,16 @@ object ConfigGuiManager { } SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor) } + + fun onCommand(args: Array) { + if (args.isNotEmpty()) { + if (args[0].lowercase() == "gui") { + GuiEditManager.openGuiPositionEditor(hotkeyReminder = true) + } else { + openConfigGui(args.joinToString(" ")) + } + } else { + openConfigGui() + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index b00fc7a8f749..24a3748c6340 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -151,7 +151,10 @@ class ConfigManager { } if (missingConfigLink) { println("") - println("This crash is here to remind you to fix the missing @ConfigLink annotation over your new config position config element.") + println( + "This crash is here to remind you to fix the missing " + + "@ConfigLink annotation over your new config position config element." + ) println("") println("Steps to fix:") println("1. Search for `WEE WOO WEE WOO` in the console output.") diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index c9ae8c2c7e89..f6d6c72de14d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -81,7 +81,10 @@ object ConfigUpdaterMigrator { } val newParentElement = new.at(np.dropLast(1), true) if (newParentElement !is JsonObject) { - logger.log("Catastrophic: element at path $old could not be relocated to $new, since another element already inhabits that path") + logger.log( + "Catastrophic: element at path $old could not be relocated to $new, " + + "since another element already inhabits that path" + ) return } movesPerformed++ diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/CommandBuilder.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/CommandBuilder.kt new file mode 100644 index 000000000000..98227fc8ccb4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/CommandBuilder.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.config.commands + +class CommandBuilder(val name: String) { + var description: String = "" + var category: CommandCategory = CommandCategory.MAIN + var aliases: List = emptyList() + private var autoComplete: ((Array) -> List) = { listOf() } + private var callback: (Array) -> Unit = {} + + fun callback(callback: (Array) -> Unit) { + this.callback = callback + } + + fun autoComplete(autoComplete: (Array) -> List) { + this.autoComplete = autoComplete + } + + fun toSimpleCommand() = SimpleCommand(name.lowercase(), aliases, callback, autoComplete) +} + diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/CommandCategory.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/CommandCategory.kt new file mode 100644 index 000000000000..b0474ae47797 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/CommandCategory.kt @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.config.commands + +enum class CommandCategory(val color: String, val categoryName: String, val description: String) { + MAIN( + "§6", + "Main Command", + "Most useful commands of SkyHanni", + ), + USERS_ACTIVE( + "§e", + "Normal Command", + "Normal Command for everyone to use", + ), + USERS_RESET( + "§e", + "Normal Reset Command", + "Normal Command that resents some data", + ), + USERS_BUG_FIX( + "§f", + "User Bug Fix", + "A Command to fix small bugs", + ), + DEVELOPER_TEST( + "§5", + "Developer Test Commands", + "A Command to edit/test/change some features. §cIntended for developers only!", + ), + DEVELOPER_DEBUG( + "§9", + "Developer Debug Commands", + "A Command to debug/read/copy/monitor features. §cIntended for developers only!", + ), + INTERNAL( + "§8", + "Internal Command", + "A Command that should §cnever §7be called manually!", + ), + SHORTENED_COMMANDS( + "§b", + "Shortened Commands", + "Commands that shorten or improve existing Hypixel commands!", + ) +} 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 6b50e38ac49f..2ba25cadca14 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -2,12 +2,11 @@ package at.hannibal2.skyhanni.config.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.SkillAPI +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigGuiManager -import at.hannibal2.skyhanni.config.features.About.UpdateStream import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix -import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.data.ScoreboardData @@ -25,6 +24,7 @@ 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 import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker @@ -80,6 +80,7 @@ import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker import at.hannibal2.skyhanni.features.rift.everywhere.PunchcardHighlight import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.DebugCommand import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.SkyBlockIslandTest @@ -97,640 +98,738 @@ import at.hannibal2.skyhanni.test.command.TrackParticlesCommand import at.hannibal2.skyhanni.test.command.TrackSoundsCommand import at.hannibal2.skyhanni.test.graph.GraphEditor import at.hannibal2.skyhanni.utils.APIUtils -import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ExtendedChatColor import at.hannibal2.skyhanni.utils.ItemPriceUtils -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.chat.ChatClickActionManager import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui -import net.minecraft.command.ICommandSender -import net.minecraft.util.BlockPos -import net.minecraftforge.client.ClientCommandHandler +@SkyHanniModule object Commands { - private val openMainMenu: (Array) -> Unit = { - if (it.isNotEmpty()) { - if (it[0].lowercase() == "gui") { - GuiEditManager.openGuiPositionEditor(hotkeyReminder = true) - } else { - ConfigGuiManager.openConfigGui(it.joinToString(" ")) - } - } else { - ConfigGuiManager.openConfigGui() - } - } - - // command -> description - private val commands = mutableListOf() - - enum class CommandCategory(val color: String, val categoryName: String, val description: String) { - MAIN("§6", "Main Command", "Most useful commands of SkyHanni"), - USERS_NORMAL("§e", "Normal Command", "Normal Command for everyone to use"), - USERS_BUG_FIX("§f", "User Bug Fix", "A Command to fix small bugs"), - DEVELOPER_CODING_HELP( - "§5", - "Developer Coding Help", - "A Command that can help with developing new features. §cIntended for developers only!", - ), - DEVELOPER_DEBUG_FEATURES( - "§9", - "Developer Debug Features", - "A Command that is useful for monitoring/debugging existing features. §cIntended for developers only!", - ), - INTERNAL("§8", "Internal Command", "A Command that should §cnever §7be called manually!"), - SHORTENED_COMMANDS("§b", "Shortened Commands", "Commands that shorten or improve existing Hypixel commands!") - } - - class CommandInfo(val name: String, val description: String, val category: CommandCategory) - - private var currentCategory = CommandCategory.MAIN - - fun init() { - currentCategory = CommandCategory.MAIN - usersMain() - - currentCategory = CommandCategory.USERS_NORMAL - usersNormal() - - currentCategory = CommandCategory.USERS_BUG_FIX - usersBugFix() - - currentCategory = CommandCategory.DEVELOPER_CODING_HELP - developersCodingHelp() - - currentCategory = CommandCategory.DEVELOPER_DEBUG_FEATURES - developersDebugFeatures() - - currentCategory = CommandCategory.INTERNAL - internalCommands() - - currentCategory = CommandCategory.SHORTENED_COMMANDS - shortenedCommands() - } - - private fun usersMain() { - registerCommand("sh", "Opens the main SkyHanni config", openMainMenu) - registerCommand("skyhanni", "Opens the main SkyHanni config", openMainMenu) - registerCommand("ff", "Opens the Farming Fortune Guide") { openFortuneGuide() } - registerCommand("shcommands", "Shows this list") { HelpCommand.onCommand(it, commands) } - registerCommand0( - "shdefaultoptions", - "Select default options", - { DefaultConfigFeatures.onCommand(it) }, - DefaultConfigFeatures::onComplete, - ) - registerCommand("shremind", "Set a reminder for yourself") { ReminderManager.command(it) } - registerCommand("shwords", "Opens the config list for modifying visual words") { openVisualWords() } - registerCommand("shcustomlines", "Opens the config list for modifying custom lines") { openCustomLines() } - registerCommand("shnavigate", "Using path finder to go to locatons") { NavigationHelper.onCommand(it) } - } - - @Suppress("LongMethod") - private fun usersNormal() { - registerCommand( - "shmarkplayer", - "Add a highlight effect to a player for better visibility", - ) { MarkedPlayerManager.command(it) } - registerCommand("shtrackcollection", "Tracks your collection gain over time") { CollectionTracker.command(it) } - registerCommand( - "shcroptime", - "Calculates with your current crop per second speed how long you need to farm a crop to collect this amount of items", - ) { GardenCropTimeCommand.onCommand(it) } - registerCommand( - "shcropsin", - "Calculates with your current crop per second how many items you can collect in this amount of time", - ) { GardenCropsInCommand.onCommand(it) } - registerCommand( - "shrpcstart", - "Manually starts the Discord Rich Presence feature", - ) { DiscordRPCManager.startCommand() } - registerCommand( - "shcropstartlocation", - "Manually sets the crop start location", - ) { GardenStartLocation.setLocationCommand() } - registerCommand( - "shclearslayerprofits", - "Clearing the total slayer profit for the current slayer type", - ) { SlayerProfitTracker.clearProfitCommand(it) } - registerCommand( - "shimportghostcounterdata", - "Manually importing the ghost counter data from GhostCounterV3", - ) { GhostUtil.importCTGhostCounterData() } - registerCommand( - "shclearfarmingitems", - "Clear farming items saved for the Farming Fortune Guide", - ) { clearFarmingItems() } - registerCommand("shresetghostcounter", "Resets the ghost counter") { GhostUtil.reset() } - registerCommand("shresetpowdertracker", "Resets the Powder Tracker") { PowderTracker.resetCommand() } - registerCommand("shresetdicertracker", "Resets the Dicer Drop Tracker") { DicerRngDropTracker.resetCommand() } - registerCommand("shresetcorpsetracker", "Resets the Glacite Mineshaft Corpse Tracker") { CorpseTracker.resetCommand() } - registerCommand( - "shresetendernodetracker", - "Resets the Ender Node Tracker", - ) { EnderNodeTracker.resetCommand() } - registerCommand( - "shresetarmordroptracker", - "Resets the Armor Drop Tracker", - ) { ArmorDropTracker.resetCommand() } - registerCommand( - "shresetfrozentreasuretracker", - "Resets the Frozen Treasure Tracker", - ) { FrozenTreasureTracker.resetCommand() } - registerCommand( - "shresetfishingtracker", - "Resets the Fishing Profit Tracker", - ) { FishingProfitTracker.resetCommand() } - registerCommand( - "shresetvisitordrops", - "Reset the Visitors Drop Statistics", - ) { GardenVisitorDropStatistics.resetCommand() } - registerCommand("shbingotoggle", "Toggle the bingo card display mode") { BingoCardDisplay.toggleCommand() } - registerCommand( - "shfarmingprofile", - "Look up the farming profile from yourself or another player on elitebot.dev", - ) { FarmingWeightDisplay.lookUpCommand(it) } - registerCommand( - "shcopytranslation", - "Copy the English translation of a message in another language to the clipboard.\n" + "Uses a 2 letter language code that can be found at the end of a translation message.", - ) { Translator.fromEnglish(it) } - registerCommand( - "shtranslate", - "Translate a message in another language to English.", - ) { Translator.toEnglish(it) } - registerCommand( - "shmouselock", - "Lock/Unlock the mouse so it will no longer rotate the player (for farming)", - ) { LockMouseLook.toggleLock() } - registerCommand( - "shsensreduce", - "Lowers the mouse sensitivity for easier small adjustments (for farming)", - ) { SensitivityReducer.manualToggle() } - registerCommand( - "shresetvermintracker", - "Resets the Vermin Tracker", - ) { VerminTracker.resetCommand() } - registerCommand( - "shresetdianaprofittracker", - "Resets the Diana Profit Tracker", - ) { DianaProfitTracker.resetCommand() } - registerCommand( - "shresetpestprofittracker", - "Resets the Pest Profit Tracker", - ) { PestProfitTracker.resetCommand() } - registerCommand( - "shresetexperimentsprofittracker", - "Resets the Experiments Profit Tracker", - ) { ExperimentsProfitTracker.resetCommand() } - registerCommand( - "shresetmythologicalcreaturetracker", - "Resets the Mythological Creature Tracker", - ) { MythologicalCreatureTracker.resetCommand() } - registerCommand( - "shresetseacreaturetracker", - "Resets the Sea Creature Tracker", - ) { SeaCreatureTracker.resetCommand() } - registerCommand( - "shresetstrayrabbittracker", - "Resets the Stray Rabbit Tracker", - ) { ChocolateFactoryStrayTracker.resetCommand() } - registerCommand( - "shresetexcavatortracker", - "Resets the Fossil Excavator Profit Tracker", - ) { ExcavatorProfitTracker.resetCommand() } - registerCommand( - "shfandomwiki", - "Searches the fandom wiki with SkyHanni's own method.", - ) { WikiManager.otherWikiCommands(it, true) } - registerCommand( - "shfandomwikithis", - "Searches the fandom wiki with SkyHanni's own method.", - ) { WikiManager.otherWikiCommands(it, true, true) } - registerCommand( - "shofficialwiki", - "Searches the official wiki with SkyHanni's own method.", - ) { WikiManager.otherWikiCommands(it, false) } - registerCommand( - "shofficialwikithis", - "Searches the official wiki with SkyHanni's own method.", - ) { WikiManager.otherWikiCommands(it, false, true) } - registerCommand0( - "shcalccrop", - "Calculate how many crops need to be farmed between different crop milestones.", - { - FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) - }, - FarmingMilestoneCommand::onComplete, - ) - registerCommand0( - "shcalccroptime", - "Calculate how long you need to farm crops between different crop milestones.", - { - FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), true) - }, - FarmingMilestoneCommand::onComplete, - ) - registerCommand0( - "shcropgoal", - "Define a custom milestone goal for a crop.", - { FarmingMilestoneCommand.setGoal(it) }, - FarmingMilestoneCommand::onComplete, - ) - registerCommand0( - "shskills", - "Skills XP/Level related command", - { SkillAPI.onCommand(it) }, - SkillAPI::onComplete, - ) - registerCommand( - "shlimbostats", - "Prints your Limbo Stats.\n §7This includes your Personal Best, Playtime, and §aSkyHanni User Luck§7!", - ) { LimboTimeTracker.printStats() } - registerCommand( - "shlanedetection", - "Detect a farming lane in the Garden", - ) { FarmingLaneCreator.commandLaneDetection() } - registerCommand( - "shignore", - "Add/Remove a user from your", - ) { PartyChatCommands.blacklist(it) } - registerCommand( - "shtpinfested", - "Teleports you to the nearest infested plot", - ) { PestFinder.teleportNearestInfestedPlot() } - registerCommand( - "shhoppitystats", - "Look up stats for a Hoppity's Event (by SkyBlock year).\nRun standalone for a list of years that have stats.", - ) { HoppityEventSummary.sendStatsMessage(it) } - registerCommand( - "shcolors", - "Prints a list of all Minecraft color & formatting codes in chat.", - ) { ColorFormattingHelper.printColorCodeList() } - registerCommand( - "shtps", - "Informs in chat about the server ticks per second (TPS).", - ) { TpsCounter.tpsCommand() } - registerCommand( - "shcarry", - "Keep track of carries you do.", - ) { CarryTracker.onCommand(it) } - } + val commands = mutableListOf() - private fun usersBugFix() { - registerCommand("shupdaterepo", "Download the SkyHanni repo again") { SkyHanniMod.repo.updateRepo() } - registerCommand( - "shresetburrowwarps", - "Manually resetting disabled diana burrow warp points", - ) { BurrowWarpHelper.resetDisabledWarps() } - registerCommand( - "shtogglehypixelapierrors", - "Show/hide hypixel api error messages in chat", - ) { APIUtils.toggleApiErrorMessages() } - registerCommand( - "shclearcropspeed", - "Reset garden crop speed data and best crop time data", - ) { GardenAPI.clearCropSpeed() } - registerCommand( - "shclearminiondata", - "Removed bugged minion locations from your private island", - ) { MinionFeatures.removeBuggedMinions(isCommand = true) } - registerCommand( - "shwhereami", - "Print current island in chat", - ) { SkyHanniDebugsAndTests.whereAmI() } - registerCommand( - "shclearcontestdata", - "Resets Jacob's Contest Data", - ) { SkyHanniDebugsAndTests.clearContestData() } - registerCommand( - "shconfig", - "Search or reset config elements §c(warning, dangerous!)", - ) { SkyHanniConfigSearchResetCommand.command(it) } - registerCommand( - "shdebug", - "Copies SkyHanni debug data in the clipboard.", - ) { DebugCommand.command(it) } - registerCommand( - "shversion", - "Prints the SkyHanni version in the chat", - ) { SkyHanniDebugsAndTests.debugVersion() } - registerCommand( - "shrendertoggle", - "Disables/enables the rendering of all skyhanni guis.", - ) { SkyHanniDebugsAndTests.toggleRender() } - registerCommand( - "shcarrolyn", - "Toggles if the specified crops effect is active from carrolyn", - ) { - CaptureFarmingGear.handelCarrolyn(it) - } - registerCommand( - "shrepostatus", - "Shows the status of all the mods constants", - ) { SkyHanniMod.repo.displayRepoStatus(false) } - registerCommand( - "shclearkismet", - "Clears the saved values of the applied kismet feathers in Croesus", - ) { CroesusChestTracker.resetChest() } - registerCommand( - "shkingfix", - "Resets the local King Talisman Helper offset.", - ) { KingTalismanHelper.kingFix() } - registerCommand( - "shupdate", - "Updates the mod to the specified update stream.", - ) { forceUpdate(it) } - registerCommand( - "shUpdateBazaarPrices", - "Forcefully updating the bazaar prices right now.", - ) { HypixelBazaarFetcher.fetchNow() } - registerCommand( - "shclearsavedrabbits", - "Clears the saved rabbits on this profile.", - ) { HoppityCollectionStats.clearSavedRabbits() } - registerCommand( - "shresetpunchcard", - "Resets the Rift Punchcard Artifact player list.", - ) { PunchcardHighlight.clearList() } - registerCommand( - "shedittracker", - "Changes the tracked item amount for Diana, Fishing, Pest, Excavator, and Slayer Item Trackers.", - ) { TrackerManager.commandEditTracker(it) } + @HandleEvent + fun registerCommands(event: RegisterCommandsEvent) { + usersMain(event) + usersNormal(event) + usersNormalReset(event) + usersBugFix(event) + devTest(event) + devDebug(event) + internalCommands(event) + shortenedCommands(event) } - private fun developersDebugFeatures() { - registerCommand("shtestbingo", "dev command") { TestBingo.toggle() } - registerCommand("shprintbingohelper", "dev command") { BingoNextStepHelper.command() } - registerCommand("shreloadbingodata", "dev command") { BingoCardDisplay.command() } - registerCommand("shtestgardenvisitors", "dev command") { SkyHanniDebugsAndTests.testGardenVisitors() } - registerCommand("shtestcomposter", "dev command") { ComposterOverlay.onCommand(it) } - registerCommand("shtestinquisitor", "dev command") { InquisitorWaypointShare.test() } - registerCommand("shshowcropmoneycalculation", "dev command") { CropMoneyDisplay.toggleShowCalculation() } - registerCommand("shcropspeedmeter", "Debugs how many crops you collect over time") { CropSpeedMeter.toggle() } - registerCommand0( - "shworldedit", - "Select regions in the world", - { WorldEdit.command(it) }, - { listOf("copy", "reset", "help", "left", "right") }, - ) - registerCommand( - "shconfigsave", - "Manually saving the config", - ) { SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "manual-command") } - registerCommand( - "shtestburrow", - "Sets a test burrow waypoint at your location", - ) { GriffinBurrowHelper.setTestBurrow(it) } - registerCommand( - "shtestsackapi", - "Get the amount of an item in sacks according to internal feature SackAPI", - ) { SackAPI.testSackAPI(it) } - registerCommand( - "shtestgriffinspots", - "Show potential griffin spots around you.", - ) { GriffinBurrowHelper.testGriffinSpots() } - registerCommand( - "shtestisland", - "Sets the current skyblock island for testing purposes.", - ) { SkyBlockIslandTest.onCommand(it) } - registerCommand( - "shdebugprice", - "Debug different price sources for an item.", - ) { ItemPriceUtils.debugItemPrice(it) } - registerCommand( - "shdebugscoreboard", - "Monitors the scoreboard changes: Prints the raw scoreboard lines in the console after each update, with time since last update.", - ) { ScoreboardData.toggleMonitor() } + private fun usersMain(event: RegisterCommandsEvent) { + event.register("sh") { + aliases = listOf("skyhanni") + description = "Opens the main SkyHanni config" + callback { ConfigGuiManager.onCommand(it) } + } + event.register("ff") { + description = "Opens the Farming Fortune Guide" + callback { FFGuideGUI.onCommand() } + } + event.register("shcommands") { + description = "Shows this list" + callback { HelpCommand.onCommand(it) } + } + event.register("shdefaultoptions") { + description = "Select default options" + callback { DefaultConfigFeatures.onCommand(it) } + autoComplete { DefaultConfigFeatures.onComplete(it) } + } + event.register("shremind") { + description = "Set a reminder for yourself" + callback { ReminderManager.command(it) } + } + event.register("shwords") { + description = "Opens the config list for modifying visual words" + callback { VisualWordGui.onCommand() } + } + event.register("shnavigate") { + description = "Using path finder to go to locations" + callback { NavigationHelper.onCommand(it) } + } + event.register("shcarry") { + description = "Keep track of carries you do." + callback { CarryTracker.onCommand(it) } + } + event.register("shmarkplayer") { + description = "Add a highlight effect to a player for better visibility" + callback { MarkedPlayerManager.command(it) } + } + event.register("shtrackcollection") { + description = "Tracks your collection gain over time" + callback { CollectionTracker.command(it) } + } } @Suppress("LongMethod") - private fun developersCodingHelp() { - registerCommand("shrepopatterns", "See where regexes are loaded from") { RepoPatternGui.open() } - registerCommand("shtest", "Unused test command.") { SkyHanniDebugsAndTests.testCommand(it) } - registerCommand("shtestrabbitpaths", "Tests pathfinding to rabbit eggs. Use a number 0-14.") { - HoppityEggLocator.testPathfind(it) - } - registerCommand( - "shtestitem", - "test item internal name resolving", - ) { SkyHanniDebugsAndTests.testItemCommand(it) } - registerCommand( - "shfindnullconfig", - "Find config elements that are null and prints them into the console", - ) { SkyHanniDebugsAndTests.findNullConfig(it) } - registerCommand("shtestwaypoint", "Set a waypoint on that location") { SkyHanniDebugsAndTests.waypoint(it) } - registerCommand("shtesttablist", "Set your clipboard as a fake tab list.") { TabListData.toggleDebug() } - registerCommand("shreloadlocalrepo", "Reloading the local repo data") { SkyHanniMod.repo.reloadLocalRepo() } - registerCommand("shchathistory", "Show the unfiltered chat history") { ChatManager.openChatFilterGUI(it) } - registerCommand( - "shstoplisteners", - "Unregistering all loaded forge event listeners", - ) { SkyHanniDebugsAndTests.stopListeners() } - registerCommand( - "shreloadlisteners", - "Trying to load all forge event listeners again. Might not work at all", - ) { SkyHanniDebugsAndTests.reloadListeners() } - registerCommand( - "shcopylocation", - "Copies the player location as LorenzVec format to the clipboard", - ) { SkyHanniDebugsAndTests.copyLocation(it) } - registerCommand( - "shcopyentities", - "Copies entities in the specified radius around the player to the clipboard", - ) { CopyNearbyEntitiesCommand.command(it) } - registerCommand( - "shtracksounds", - "Tracks the sounds for the specified duration (in seconds) and copies it to the clipboard", - ) { TrackSoundsCommand.command(it) } - registerCommand( - "shtrackparticles", - "Tracks the particles for the specified duration (in seconds) and copies it to the clipboard", - ) { TrackParticlesCommand.command(it) } - registerCommand( - "shcopytablist", - "Copies the tab list data to the clipboard", - ) { TabListData.copyCommand(it) } - registerCommand( - "shcopyactionbar", - "Copies the action bar to the clipboard, including formatting codes", - ) { CopyActionBarCommand.command(it) } - registerCommand( - "shcopyscoreboard", - "Copies the scoreboard data to the clipboard", - ) { CopyScoreboardCommand.command(it) } - registerCommand( - "shcopybossbar", - "Copies the name of the bossbar to the clipboard, including formatting codes", - ) { CopyBossbarCommand.command(it) } - registerCommand( - "shcopyitem", - "Copies information about the item in hand to the clipboard", - ) { CopyItemCommand.command() } - registerCommand("shtestpacket", "Logs incoming and outgoing packets to the console") { PacketTest.command(it) } - registerCommand( - "shtestmessage", - "Sends a custom chat message client side in the chat", - ) { TestChatCommand.command(it) } - registerCommand( - "shtestrainbow", - "Sends a rainbow in chat", - ) { ExtendedChatColor.testCommand() } - registerCommand( - "shcopyinternalname", - "Copies the internal name of the item in hand to the clipboard.", - ) { SkyHanniDebugsAndTests.copyItemInternalName() } - registerCommand( - "shpartydebug", - "List persons into the chat SkyHanni thinks are in your party.", - ) { PartyAPI.listMembers() } - registerCommand( - "shplaysound", - "Play the specified sound effect at the given pitch and volume.", - ) { SoundUtils.command(it) } - registerCommand( - "shsendtitle", - "Display a title on the screen with the specified settings.", - ) { TitleManager.command(it) } - registerCommand( - "shresetconfig", - "Reloads the config manager and rendering processors of MoulConfig. " + "This §cWILL RESET §7your config, but also updating the java config files " + "(names, description, orderings and stuff).", - ) { SkyHanniDebugsAndTests.resetConfigCommand() } - registerCommand( - "shreadcropmilestonefromclipboard", - "Read crop milestone from clipboard. This helps fixing wrong crop milestone data", - ) { GardenCropMilestonesCommunityFix.readDataFromClipboard() } - registerCommand( - "shcopyfoundburrowlocations", - "Copy all ever found burrow locations to clipboard", - ) { AllBurrowsList.copyToClipboard() } - registerCommand( - "shaddfoundburrowlocationsfromclipboard", - "Add all ever found burrow locations from clipboard", - ) { AllBurrowsList.addFromClipboard() } - registerCommand( - "shgraph", - "Enables the graph editor", - ) { GraphEditor.commandIn() } - registerCommand( - "shtoggleegglocationdebug", - "Shows Hoppity egg locations with their internal API names and status.", - ) { HoppityEggLocations.toggleDebug() } - registerCommand( - "shresetmineshaftpitystats", - "Resets the mineshaft pity display stats", - ) { MineshaftPityDisplay.fullResetCounter() } - } - - private fun internalCommands() { - registerCommand("shaction", "") { ChatClickActionManager.onCommand(it) } + private fun usersNormal(event: RegisterCommandsEvent) { + event.register("shimportghostcounterdata") { + description = "Manually importing the ghost counter data from GhostCounterV3" + category = CommandCategory.USERS_ACTIVE + callback { GhostUtil.importCTGhostCounterData() } + } + event.register("shcroptime") { + description = + "Calculates with your current crop per second speed " + "how long you need to farm a crop to collect this amount of items" + category = CommandCategory.USERS_ACTIVE + callback { GardenCropTimeCommand.onCommand(it) } + } + event.register("shcropsin") { + description = "Calculates with your current crop per second how many items you can collect in this amount of time" + category = CommandCategory.USERS_ACTIVE + callback { GardenCropsInCommand.onCommand(it) } + } + event.register("shrpcstart") { + description = "Manually starts the Discord Rich Presence feature" + category = CommandCategory.USERS_ACTIVE + callback { DiscordRPCManager.startCommand() } + } + event.register("shcropstartlocation") { + description = "Manually sets the crop start location" + category = CommandCategory.USERS_ACTIVE + callback { GardenStartLocation.setLocationCommand() } + } + event.register("shbingotoggle") { + description = "Toggle the bingo card display mode" + category = CommandCategory.USERS_ACTIVE + callback { BingoCardDisplay.toggleCommand() } + } + event.register("shfarmingprofile") { + description = "Look up the farming profile from yourself or another player on elitebot.dev" + category = CommandCategory.USERS_ACTIVE + callback { FarmingWeightDisplay.lookUpCommand(it) } + } + event.register("shcopytranslation") { + description = + "Copy the translation of a message in another language to your clipboard.\n" + + "Uses a 2 letter language code that can be found at the end of a translation message." + category = CommandCategory.USERS_ACTIVE + callback { Translator.fromNativeLanguage(it) } + } + event.register("shtranslate") { + description = "Translate a message in another language your language." + category = CommandCategory.USERS_ACTIVE + callback { Translator.toNativeLanguage(it) } + } + event.register("shmouselock") { + description = "Lock/Unlock the mouse so it will no longer rotate the player (for farming)" + category = CommandCategory.USERS_ACTIVE + callback { LockMouseLook.toggleLock() } + } + event.register("shsensreduce") { + description = "Lowers the mouse sensitivity for easier small adjustments (for farming)" + category = CommandCategory.USERS_ACTIVE + callback { SensitivityReducer.manualToggle() } + } + event.register("shfandomwiki") { + description = "Searches the fandom wiki with SkyHanni's own method." + category = CommandCategory.USERS_ACTIVE + callback { WikiManager.otherWikiCommands(it, true) } + } + event.register("shfandomwikithis") { + description = "Searches the fandom wiki with SkyHanni's own method." + category = CommandCategory.USERS_ACTIVE + callback { WikiManager.otherWikiCommands(it, true, true) } + } + event.register("shofficialwiki") { + description = "Searches the official wiki with SkyHanni's own method." + category = CommandCategory.USERS_ACTIVE + callback { WikiManager.otherWikiCommands(it, false) } + } + event.register("shofficialwikithis") { + description = "Searches the official wiki with SkyHanni's own method." + category = CommandCategory.USERS_ACTIVE + callback { WikiManager.otherWikiCommands(it, false, true) } + } + event.register("shcalccrop") { + description = "Calculate how many crops need to be farmed between different crop milestones." + category = CommandCategory.USERS_ACTIVE + autoComplete { FarmingMilestoneCommand.onComplete(it) } + callback { FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) } + } + event.register("shcalccroptime") { + description = "Calculate how long you need to farm crops between different crop milestones." + category = CommandCategory.USERS_ACTIVE + autoComplete { FarmingMilestoneCommand.onComplete(it) } + callback { FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), true) } + } + event.register("shcropgoal") { + description = "Define a custom milestone goal for a crop." + category = CommandCategory.USERS_ACTIVE + callback { FarmingMilestoneCommand.setGoal(it) } + autoComplete { FarmingMilestoneCommand.onComplete(it) } + } + event.register("shskills") { + description = "Skills XP/Level related command" + category = CommandCategory.USERS_ACTIVE + callback { SkillAPI.onCommand(it) } + autoComplete { SkillAPI.onComplete(it) } + } + event.register("shlimbostats") { + description = "Prints your Limbo Stats.\n §7This includes your Personal Best, Playtime, and §aSkyHanni User Luck§7!" + category = CommandCategory.USERS_ACTIVE + callback { LimboTimeTracker.printStats() } + } + event.register("shlanedetection") { + description = "Detect a farming lane in the Garden" + category = CommandCategory.USERS_ACTIVE + callback { FarmingLaneCreator.commandLaneDetection() } + } + event.register("shignore") { + description = "Add/Remove a user from your blacklist" + category = CommandCategory.USERS_ACTIVE + callback { PartyChatCommands.blacklist(it) } + } + event.register("shtpinfested") { + description = "Teleports you to the nearest infested plot" + category = CommandCategory.USERS_ACTIVE + callback { PestFinder.teleportNearestInfestedPlot() } + } + event.register("shhoppitystats") { + description = "Look up stats for a Hoppity's Event (by SkyBlock year).\nRun standalone for a list of years that have stats." + category = CommandCategory.USERS_ACTIVE + callback { HoppityEventSummary.sendStatsMessage(it) } + } + event.register("shcolors") { + description = "Prints a list of all Minecraft color & formatting codes in chat." + category = CommandCategory.USERS_ACTIVE + aliases = listOf("shcolor", "shcolours", "shcolour") + callback { ColorFormattingHelper.printColorCodeList() } + } + event.register("shtps") { + description = "Informs in chat about the server ticks per second (TPS)." + category = CommandCategory.USERS_ACTIVE + callback { TpsCounter.tpsCommand() } + } } - private fun shortenedCommands() { - registerCommand("pko", "Kicks offline party members") { PartyCommands.kickOffline() } - registerCommand("pw", "Warps your party") { PartyCommands.warp() } - registerCommand("pk", "Kick a specific party member") { PartyCommands.kick(it) } - registerCommand("pt", "Transfer the party to another party member") { PartyCommands.transfer(it) } - registerCommand("pp", "Promote a specific party member") { PartyCommands.promote(it) } - registerCommand("pd", "Disbands the party") { PartyCommands.disband() } - registerCommand("rpt", "Reverse transfer party to the previous leader") { PartyCommands.reverseTransfer() } - } + private fun usersNormalReset(event: RegisterCommandsEvent) { - @JvmStatic - fun openFortuneGuide() { - if (!LorenzUtils.inSkyBlock) { - ChatUtils.userError("Join SkyBlock to open the fortune guide!") - } else { - FFGuideGUI.open() + // Trackers + event.register("shresetslayerprofits") { + description = "Resets the total slayer profit for the current slayer type" + category = CommandCategory.USERS_RESET + callback { SlayerProfitTracker.resetCommand() } } - } - - @JvmStatic - fun openVisualWords() { - if (!LorenzUtils.onHypixel) { - ChatUtils.userError("You need to join Hypixel to use this feature!") - } else { - if (VisualWordGui.sbeConfigPath.exists()) VisualWordGui.drawImport = true - SkyHanniMod.screenToOpen = VisualWordGui() + event.register("shresetpowdertracker") { + description = "Resets the Powder Tracker" + category = CommandCategory.USERS_RESET + callback { PowderTracker.resetCommand() } + } + event.register("shresetdicertracker") { + description = "Resets the Dicer Drop Tracker" + category = CommandCategory.USERS_RESET + callback { DicerRngDropTracker.resetCommand() } + } + event.register("shresetcorpsetracker") { + description = "Resets the Glacite Mineshaft Corpse Tracker" + category = CommandCategory.USERS_RESET + callback { CorpseTracker.resetCommand() } + } + event.register("shresetendernodetracker") { + description = "Resets the Ender Node Tracker" + category = CommandCategory.USERS_RESET + callback { EnderNodeTracker.resetCommand() } + } + event.register("shresetarmordroptracker") { + description = "Resets the Armor Drop Tracker" + category = CommandCategory.USERS_RESET + callback { ArmorDropTracker.resetCommand() } + } + event.register("shresetfrozentreasuretracker") { + description = "Resets the Frozen Treasure Tracker" + category = CommandCategory.USERS_RESET + callback { FrozenTreasureTracker.resetCommand() } + } + event.register("shresetfishingtracker") { + description = "Resets the Fishing Profit Tracker" + category = CommandCategory.USERS_RESET + callback { FishingProfitTracker.resetCommand() } + } + event.register("shresetvisitordrops") { + description = "Resets the Visitors Drop Statistics" + category = CommandCategory.USERS_RESET + callback { GardenVisitorDropStatistics.resetCommand() } + } + event.register("shresetvermintracker") { + description = "Resets the Vermin Tracker" + category = CommandCategory.USERS_RESET + callback { VerminTracker.resetCommand() } + } + event.register("shresetdianaprofittracker") { + description = "Resets the Diana Profit Tracker" + category = CommandCategory.USERS_RESET + callback { DianaProfitTracker.resetCommand() } + } + event.register("shresetpestprofittracker") { + description = "Resets the Pest Profit Tracker" + category = CommandCategory.USERS_RESET + callback { PestProfitTracker.resetCommand() } + } + event.register("shresetexperimentsprofittracker") { + description = "Resets the Experiments Profit Tracker" + category = CommandCategory.USERS_RESET + callback { ExperimentsProfitTracker.resetCommand() } + } + event.register("shresetmythologicalcreaturetracker") { + description = "Resets the Mythological Creature Tracker" + category = CommandCategory.USERS_RESET + callback { MythologicalCreatureTracker.resetCommand() } + } + event.register("shresetseacreaturetracker") { + description = "Resets the Sea Creature Tracker" + category = CommandCategory.USERS_RESET + callback { SeaCreatureTracker.resetCommand() } + } + event.register("shresetstrayrabbittracker") { + description = "Resets the Stray Rabbit Tracker" + category = CommandCategory.USERS_RESET + callback { ChocolateFactoryStrayTracker.resetCommand() } + } + event.register("shresetexcavatortracker") { + description = "Resets the Fossil Excavator Profit Tracker" + category = CommandCategory.USERS_RESET + callback { ExcavatorProfitTracker.resetCommand() } } - } - @JvmStatic - fun openCustomLines() { - if (!LorenzUtils.onHypixel) { - ChatUtils.userError("You need to join Hypixel to use this feature!") - } else { - SkyHanniMod.screenToOpen = CustomLinesGui + // non trackers + event.register("shresetghostcounter") { + description = "Resets the ghost counter" + category = CommandCategory.USERS_RESET + callback { GhostUtil.reset() } + } + event.register("shresetcropspeed") { + description = "Resets garden crop speed data and best crop time data" + category = CommandCategory.USERS_RESET + callback { GardenAPI.resetCropSpeed() } + } + event.register("shresetkismet") { + description = "Resets the saved values of the applied kismet feathers in Croesus" + category = CommandCategory.USERS_RESET + callback { CroesusChestTracker.resetChest() } + } + event.register("shresetburrowwarps") { + description = "Manually resetting disabled diana burrow warp points" + category = CommandCategory.USERS_RESET + callback { BurrowWarpHelper.resetDisabledWarps() } + } + event.register("shresetcontestdata") { + description = "Resets Jacob's Contest Data" + category = CommandCategory.USERS_RESET + callback { SkyHanniDebugsAndTests.resetContestData() } + } + event.register("shresetfarmingitems") { + description = "Resets farming items saved for the Farming Fortune Guide" + category = CommandCategory.USERS_RESET + callback { CaptureFarmingGear.onResetGearCommand() } + } + event.register("shresetmineshaftpitystats") { + description = "Resets the mineshaft pity display stats" + category = CommandCategory.USERS_RESET + callback { MineshaftPityDisplay.fullResetCounter() } + } + event.register("shresetterminal") { + description = "Resets terminal highlights in F7." + category = CommandCategory.USERS_RESET + callback { TerminalInfo.resetTerminals() } + } + event.register("shresetsavedrabbits") { + description = "Resets the saved rabbits on this profile." + category = CommandCategory.USERS_RESET + callback { HoppityCollectionStats.resetSavedRabbits() } + } + event.register("shresetpunchcard") { + description = "Resets the Rift Punchcard Artifact player list." + category = CommandCategory.USERS_RESET + callback { PunchcardHighlight.onResetCommand() } } } - private fun clearFarmingItems() { - val storage = GardenAPI.storage?.fortune ?: return - ChatUtils.chat("clearing farming items") - storage.farmingItems.clear() - storage.outdatedItems.clear() + private fun usersBugFix(event: RegisterCommandsEvent) { + event.register("shupdaterepo") { + description = "Download the SkyHanni repo again" + category = CommandCategory.USERS_BUG_FIX + callback { SkyHanniMod.repo.updateRepo() } + } + event.register("shtogglehypixelapierrors") { + description = "Show/hide hypixel api error messages in chat" + category = CommandCategory.USERS_BUG_FIX + callback { APIUtils.toggleApiErrorMessages() } + } + event.register("shfixminions") { + description = "Removed bugged minion locations from your private island" + category = CommandCategory.USERS_BUG_FIX + callback { MinionFeatures.removeBuggedMinions(isCommand = true) } + } + event.register("shwhereami") { + description = "Print current island in chat" + category = CommandCategory.USERS_BUG_FIX + callback { SkyHanniDebugsAndTests.whereAmI() } + } + event.register("shrendertoggle") { + description = "Disables/enables the rendering of all skyhanni guis." + category = CommandCategory.USERS_BUG_FIX + callback { SkyHanniDebugsAndTests.toggleRender() } + } + event.register("shcarrolyn") { + description = "Toggles if the specified crops effect is active from carrolyn" + category = CommandCategory.USERS_BUG_FIX + callback { CaptureFarmingGear.handelCarrolyn(it) } + } + event.register("shrepostatus") { + description = "Shows the status of all the mods constants" + category = CommandCategory.USERS_BUG_FIX + callback { SkyHanniMod.repo.displayRepoStatus(false) } + } + event.register("shkingfix") { + description = "Resets the local King Talisman Helper offset." + category = CommandCategory.USERS_BUG_FIX + callback { KingTalismanHelper.kingFix() } + } + event.register("shupdate") { + description = "Updates the mod to the specified update stream." + category = CommandCategory.USERS_BUG_FIX + callback { UpdateManager.updateCommand(it) } + } + event.register("shupdatebazaarprices") { + description = "Forcefully updating the bazaar prices right now." + category = CommandCategory.USERS_BUG_FIX + callback { HypixelBazaarFetcher.fetchNow() } + } + event.register("shedittracker") { + description = "Changes the tracked item amount for Diana, Fishing, Pest, Excavator, and Slayer Item Trackers." + category = CommandCategory.USERS_BUG_FIX + callback { TrackerManager.commandEditTracker(it) } + } } - private fun forceUpdate(args: Array) { - val currentStream = SkyHanniMod.feature.about.updateStream.get() - val arg = args.firstOrNull() ?: "current" - val updateStream = when { - arg.equals("(?i)(?:full|release)s?".toRegex()) -> UpdateStream.RELEASES - arg.equals("(?i)(?:beta|latest)s?".toRegex()) -> UpdateStream.BETA - else -> currentStream + private fun devDebug(event: RegisterCommandsEvent) { + event.register("shdebug") { + description = "Copies SkyHanni debug data in the clipboard." + category = CommandCategory.DEVELOPER_DEBUG + callback { DebugCommand.command(it) } } - - val switchingToBeta = updateStream == UpdateStream.BETA && (currentStream != UpdateStream.BETA || !UpdateManager.isCurrentlyBeta()) - if (switchingToBeta) { - ChatUtils.clickableChat( - "Are you sure you want to switch to beta? These versions may be less stable.", - onClick = { - UpdateManager.checkUpdate(true, updateStream) - }, - "§eClick to confirm!", - oneTimeClick = true, - ) - } else { - UpdateManager.checkUpdate(true, updateStream) + event.register("shconfig") { + description = "Searches or resets config elements §c(warning, dangerous!)" + category = CommandCategory.DEVELOPER_DEBUG + callback { SkyHanniConfigSearchResetCommand.command(it) } + } + event.register("shversion") { + description = "Prints the SkyHanni version in the chat" + category = CommandCategory.DEVELOPER_DEBUG + callback { SkyHanniDebugsAndTests.debugVersion() } + } + event.register("shtestbingo") { + description = "Toggle the test bingo card display mode" + category = CommandCategory.DEVELOPER_DEBUG + callback { TestBingo.toggle() } + } + event.register("shprintbingohelper") { + description = "Prints the next step helper for the bingo card" + category = CommandCategory.DEVELOPER_DEBUG + callback { BingoNextStepHelper.command() } + } + event.register("shreloadbingodata") { + description = "Reloads the bingo card data" + category = CommandCategory.DEVELOPER_DEBUG + callback { BingoCardDisplay.command() } + } + event.register("shtestgardenvisitors") { + description = "Test the garden visitor drop statistics" + category = CommandCategory.DEVELOPER_DEBUG + callback { SkyHanniDebugsAndTests.testGardenVisitors() } + } + event.register("shtestcomposter") { + description = "Test the composter overlay" + category = CommandCategory.DEVELOPER_DEBUG + callback { ComposterOverlay.onCommand(it) } + } + event.register("shtestinquisitor") { + description = "Test the inquisitor waypoint share" + category = CommandCategory.DEVELOPER_DEBUG + callback { InquisitorWaypointShare.test() } + } + event.register("shshowcropmoneycalculation") { + description = "Show the calculation of the crop money" + category = CommandCategory.DEVELOPER_DEBUG + callback { CropMoneyDisplay.toggleShowCalculation() } + } + event.register("shcropspeedmeter") { + description = "Debugs how many crops you collect over time" + category = CommandCategory.DEVELOPER_DEBUG + callback { CropSpeedMeter.toggle() } + } + event.register("shworldedit") { + description = "Select regions in the world" + category = CommandCategory.DEVELOPER_DEBUG + callback { WorldEdit.command(it) } + autoComplete { listOf("copy", "reset", "help", "left", "right") } + } + event.register("shtestsackapi") { + description = "Get the amount of an item in sacks according to internal feature SackAPI" + category = CommandCategory.DEVELOPER_DEBUG + callback { SackAPI.testSackAPI(it) } + } + event.register("shtestgriffinspots") { + description = "Show potential griffin spots around you." + category = CommandCategory.DEVELOPER_DEBUG + callback { GriffinBurrowHelper.testGriffinSpots() } + } + event.register("shdebugprice") { + description = "Debug different price sources for an item." + category = CommandCategory.DEVELOPER_DEBUG + callback { ItemPriceUtils.debugItemPrice(it) } + } + event.register("shdebugscoreboard") { + description = + "Monitors the scoreboard changes: " + + "Prints the raw scoreboard lines in the console after each update, with time since last update." + category = CommandCategory.DEVELOPER_DEBUG + callback { ScoreboardData.toggleMonitor() } + } + event.register("shcopyinternalname") { + description = "Copies the internal name of the item in hand to the clipboard." + category = CommandCategory.DEVELOPER_DEBUG + callback { SkyHanniDebugsAndTests.copyItemInternalName() } + } + event.register("shcopylocation") { + description = "Copies the player location as LorenzVec format to the clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { SkyHanniDebugsAndTests.copyLocation(it) } + } + event.register("shcopyentities") { + description = "Copies entities in the specified radius around the player to the clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { CopyNearbyEntitiesCommand.command(it) } + } + event.register("shcopytablist") { + description = "Copies the tab list data to the clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { TabListData.copyCommand(it) } + } + event.register("shcopyactionbar") { + description = "Copies the action bar to the clipboard, including formatting codes" + category = CommandCategory.DEVELOPER_DEBUG + callback { CopyActionBarCommand.command(it) } + } + event.register("shcopyscoreboard") { + description = "Copies the scoreboard data to the clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { CopyScoreboardCommand.command(it) } + } + event.register("shcopybossbar") { + description = "Copies the name of the bossbar to the clipboard, including formatting codes" + category = CommandCategory.DEVELOPER_DEBUG + callback { CopyBossbarCommand.command(it) } + } + event.register("shcopyitem") { + description = "Copies information about the item in hand to the clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { CopyItemCommand.command() } + } + event.register("shcopyfoundburrowlocations") { + description = "Copy all ever found burrow locations to clipboard" + category = CommandCategory.DEVELOPER_DEBUG + callback { AllBurrowsList.copyToClipboard() } } } - private fun registerCommand(rawName: String, description: String, function: (Array) -> Unit) { - val name = rawName.lowercase() - if (commands.any { it.name == name }) { - error("The command '$name is already registered!'") + @Suppress("LongMethod") + private fun devTest(event: RegisterCommandsEvent) { + event.register("shtest") { + description = "Unused test command." + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.testCommand(it) } + } + event.register("shchathistory") { + description = "Show the unfiltered chat history" + category = CommandCategory.DEVELOPER_TEST + callback { ChatManager.openChatFilterGUI(it) } + } + event.register("shreloadlocalrepo") { + description = "Reloading the local repo data" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniMod.repo.reloadLocalRepo() } + } + event.register("shgraph") { + description = "Enables the graph editor" + category = CommandCategory.DEVELOPER_TEST + callback { GraphEditor.commandIn() } + } + event.register("shrepopatterns") { + description = "See where regexes are loaded from" + category = CommandCategory.DEVELOPER_TEST + callback { RepoPatternGui.open() } + } + event.register("shtestrabbitpaths") { + description = "Tests pathfinding to rabbit eggs. Use a number 0-14." + category = CommandCategory.DEVELOPER_TEST + callback { HoppityEggLocator.testPathfind(it) } + } + event.register("shtestitem") { + description = "test item internal name resolving" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.testItemCommand(it) } + } + event.register("shfindnullconfig") { + description = "Find config elements that are null and prints them into the console" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.findNullConfig(it) } + } + event.register("shtestwaypoint") { + description = "Set a waypoint on that location" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.waypoint(it) } + } + event.register("shtesttablist") { + description = "Set your clipboard as a fake tab list." + category = CommandCategory.DEVELOPER_TEST + callback { TabListData.toggleDebug() } + } + event.register("shstoplisteners") { + description = "Unregistering all loaded forge event listeners" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.stopListeners() } + } + event.register("shreloadlisteners") { + description = "Trying to load all forge event listeners again. Might not work at all" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.reloadListeners() } + } + event.register("shtracksounds") { + description = "Tracks the sounds for the specified duration (in seconds) and copies it to the clipboard" + category = CommandCategory.DEVELOPER_TEST + callback { TrackSoundsCommand.command(it) } + } + event.register("shtrackparticles") { + description = "Tracks the particles for the specified duration (in seconds) and copies it to the clipboard" + category = CommandCategory.DEVELOPER_TEST + callback { TrackParticlesCommand.command(it) } + } + event.register("shtestpacket") { + description = "Logs incoming and outgoing packets to the console" + category = CommandCategory.DEVELOPER_TEST + callback { PacketTest.command(it) } + } + event.register("shtestmessage") { + description = "Sends a custom chat message client side in the chat" + category = CommandCategory.DEVELOPER_TEST + callback { TestChatCommand.command(it) } + } + event.register("shtestrainbow") { + description = "Sends a rainbow in chat" + category = CommandCategory.DEVELOPER_TEST + callback { ExtendedChatColor.testCommand() } + } + event.register("shpartydebug") { + description = "List persons into the chat SkyHanni thinks are in your party." + category = CommandCategory.DEVELOPER_TEST + callback { PartyAPI.listMembers() } + } + event.register("shplaysound") { + description = "Play the specified sound effect at the given pitch and volume." + category = CommandCategory.DEVELOPER_TEST + callback { SoundUtils.command(it) } + } + event.register("shsendtitle") { + description = "Display a title on the screen with the specified settings." + category = CommandCategory.DEVELOPER_TEST + callback { TitleManager.command(it) } + } + event.register("shresetconfig") { + description = + "Reloads the config manager and rendering processors of MoulConfig. " + + "This §cWILL RESET §7your config, but also updating the java config files " + + "(names, description, orderings and stuff)." + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniDebugsAndTests.resetConfigCommand() } + } + event.register("shreadcropmilestonefromclipboard") { + description = "Read crop milestone from clipboard. This helps fixing wrong crop milestone data" + category = CommandCategory.DEVELOPER_TEST + callback { GardenCropMilestonesCommunityFix.readDataFromClipboard() } + } + event.register("shaddfoundburrowlocationsfromclipboard") { + description = "Add all ever found burrow locations from clipboard" + category = CommandCategory.DEVELOPER_TEST + callback { AllBurrowsList.addFromClipboard() } + } + event.register("shtoggleegglocationdebug") { + description = "Shows Hoppity egg locations with their internal API names and status." + category = CommandCategory.DEVELOPER_TEST + callback { HoppityEggLocations.toggleDebug() } + } + event.register("shtranslateadvanced") { + description = "Translates a message in an inputted language to another inputted language." + category = CommandCategory.DEVELOPER_TEST + callback { Translator.translateAdvancedCommand(it) } + } + event.register("shconfigsave") { + description = "Manually saving the config" + category = CommandCategory.DEVELOPER_TEST + callback { SkyHanniMod.configManager.saveConfig(ConfigFileType.FEATURES, "manual-command") } + } + event.register("shtestburrow") { + description = "Sets a test burrow waypoint at your location" + category = CommandCategory.DEVELOPER_TEST + callback { GriffinBurrowHelper.setTestBurrow(it) } + } + event.register("shtestisland") { + description = "Sets the current skyblock island for testing purposes." + category = CommandCategory.DEVELOPER_TEST + callback { SkyBlockIslandTest.onCommand(it) } } - ClientCommandHandler.instance.registerCommand(SimpleCommand(name, createCommand(function))) - commands.add(CommandInfo(name, description, currentCategory)) } - private fun registerCommand0( - name: String, - description: String, - function: (Array) -> Unit, - autoComplete: ((Array) -> List) = { listOf() }, - ) { - val command = SimpleCommand( - name, - createCommand(function), - object : SimpleCommand.TabCompleteRunnable { - override fun tabComplete( - sender: ICommandSender?, - args: Array?, - pos: BlockPos?, - ): List { - return autoComplete(args ?: emptyArray()) - } - }, - ) - ClientCommandHandler.instance.registerCommand(command) - commands.add(CommandInfo(name, description, currentCategory)) + private fun internalCommands(event: RegisterCommandsEvent) { + event.register("shaction") { + description = "Internal command for chat click actions" + category = CommandCategory.INTERNAL + callback { ChatClickActionManager.onCommand(it) } + } } - private fun createCommand(function: (Array) -> Unit) = object : SimpleCommand.ProcessCommandRunnable() { - override fun processCommand(sender: ICommandSender?, args: Array?) { - if (args != null) function(args.asList().toTypedArray()) + private fun shortenedCommands(event: RegisterCommandsEvent) { + 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/config/commands/RegisterCommandsEvent.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/RegisterCommandsEvent.kt new file mode 100644 index 000000000000..448b5d836650 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/RegisterCommandsEvent.kt @@ -0,0 +1,16 @@ +package at.hannibal2.skyhanni.config.commands + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent +import at.hannibal2.skyhanni.config.commands.Commands.commands +import net.minecraftforge.client.ClientCommandHandler + +object RegisterCommandsEvent : SkyHanniEvent() { + fun register(name: String, block: CommandBuilder.() -> Unit) { + val info = CommandBuilder(name).apply(block) + if (commands.any { it.name == name }) { + error("The command '$name is already registered!'") + } + ClientCommandHandler.instance.registerCommand(info.toSimpleCommand()) + commands.add(info) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt index b8a5871b77a6..6240b43bf8e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.kt @@ -5,47 +5,26 @@ import net.minecraft.command.CommandBase import net.minecraft.command.ICommandSender import net.minecraft.util.BlockPos -class SimpleCommand : CommandBase { - - private val commandName: String - private val runnable: ProcessCommandRunnable - private var tabRunnable: TabCompleteRunnable? = null - - constructor(commandName: String, runnable: ProcessCommandRunnable) { - this.commandName = commandName - this.runnable = runnable - } - - constructor(commandName: String, runnable: ProcessCommandRunnable, tabRunnable: TabCompleteRunnable?) { - this.commandName = commandName - this.runnable = runnable - this.tabRunnable = tabRunnable - } - - abstract class ProcessCommandRunnable { - - abstract fun processCommand(sender: ICommandSender?, args: Array?) - } - - interface TabCompleteRunnable { - - fun tabComplete(sender: ICommandSender?, args: Array?, pos: BlockPos?): List - } +class SimpleCommand( + private val name: String, + private val aliases: List, + private val callback: (Array) -> Unit, + private val tabCallback: ((Array) -> List) = { emptyList() }, +) : CommandBase() { override fun canCommandSenderUseCommand(sender: ICommandSender) = true - - override fun getCommandName() = commandName - - override fun getCommandUsage(sender: ICommandSender) = "/$commandName" + override fun getCommandName() = name + override fun getCommandAliases() = aliases + override fun getCommandUsage(sender: ICommandSender) = "/$name" override fun processCommand(sender: ICommandSender, args: Array) { try { - runnable.processCommand(sender, args) + callback(args) } catch (e: Throwable) { - ErrorManager.logErrorWithData(e, "Error while running command /$commandName") + ErrorManager.logErrorWithData(e, "Error while running command /$name") } } override fun addTabCompletionOptions(sender: ICommandSender, args: Array, pos: BlockPos) = - if (tabRunnable != null) tabRunnable!!.tabComplete(sender, args, pos) else null + tabCallback(args).takeIf { it.isNotEmpty() } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt b/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt index e7914e794da8..9180273aab78 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/enums/OutsideSbFeature.kt @@ -24,5 +24,5 @@ enum class OutsideSbFeature(private val displayName: String) { override fun toString() = displayName - fun isSelected() = Minecraft.getMinecraft().thePlayer != null && this in SkyHanniMod.feature.misc.showOutsideSB.get() + fun isSelected() = Minecraft.getMinecraft().thePlayer != null && SkyHanniMod.feature.misc.showOutsideSB.get().contains(this) } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/TranslatorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/TranslatorConfig.java index 648afbd8739c..fdd678d0b2dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/TranslatorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/TranslatorConfig.java @@ -2,8 +2,10 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.features.chat.translation.TranslatableLanguage; +import at.hannibal2.skyhanni.utils.OSUtils; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; @@ -14,7 +16,7 @@ public class TranslatorConfig { @Expose @ConfigOption( name = "Translate On Click", - desc = "Click on a message to translate it to English.\n" + + desc = "Click on a message to translate it to your language.\n" + "Use §e/shcopytranslation§7 to translate from English.\n" + "§cTranslation is not guaranteed to be 100% accurate." ) @@ -22,7 +24,7 @@ public class TranslatorConfig { @FeatureToggle public boolean translateOnClick = false; - @ConfigOption(name = "Language Name", desc = "The name of the language selected below. Note that languages marked as unknown might still be supported.") + @ConfigOption(name = "Your Language", desc = "The language that messages should be translated to.") @Expose @ConfigEditorDropdown public Property languageName = Property.of(TranslatableLanguage.ENGLISH); @@ -30,8 +32,18 @@ public class TranslatorConfig { @Expose @ConfigOption( name = "Language Code", - desc = "Enter a language code here to translate on chat click into another language. " + - "E.g. `es` for spanish or 'de' for german. Empty for english.") + desc = "If your language doesn't show in the dropdown, enter your language code here. " + + "E.g. 'es' for Spanish or 'de' for German. Empty will use English." + ) @ConfigEditorText public Property languageCode = Property.of("en"); + + @ConfigOption( + name = "List of Language Codes", + desc = "A list of Google Translate's suppored language codes." + ) + @ConfigEditorButton(buttonText = "Open") + public Runnable langCodesURL = () -> OSUtils.openBrowser( + "https://cloud.google.com/translate/docs/languages#try-it-for-yourself" + ); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java index ec2bc0c4b0f9..0be6c1e853f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dungeon/DungeonConfig.java @@ -138,6 +138,12 @@ public class DungeonConfig { @FeatureToggle public boolean shadowAssassinJumpNotifier = false; + @Expose + @ConfigOption(name = "Terminal Waypoints", desc = "Displays Waypoints in the F7/M7 Goldor Phase.") + @ConfigEditorBoolean + @FeatureToggle + public boolean terminalWaypoints = false; + @Expose @ConfigOption(name = "Dungeon Races Guide", desc = "") @Accordion diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java index 6eb4660d6010..a1cb92be0269 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.config.features.garden; import at.hannibal2.skyhanni.config.FeatureToggle; -import at.hannibal2.skyhanni.config.commands.Commands; import at.hannibal2.skyhanni.config.core.config.Position; +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; @@ -21,7 +21,7 @@ public class FarmingFortuneConfig { @ConfigOption(name = "Farming Fortune Guide", desc = "Open a guide that breaks down your Farming Fortune.\n§eCommand: /ff") @ConfigEditorButton(buttonText = "Open") - public Runnable open = Commands::openFortuneGuide; + public Runnable open = FFGuideGUI::onCommand; @Expose @ConfigLink(owner = FarmingFortuneConfig.class, field = "display") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/ModifyWordsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/ModifyWordsConfig.java index 21cfee5c5c74..5a0db7ac4535 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/ModifyWordsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/ModifyWordsConfig.java @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.config.features.gui; import at.hannibal2.skyhanni.config.FeatureToggle; -import at.hannibal2.skyhanni.config.commands.Commands; +import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; @@ -17,6 +17,6 @@ public class ModifyWordsConfig { @ConfigOption(name = "Open Config", desc = "Open the menu to setup the visual words.\n§eCommand: /shwords") @ConfigEditorButton(buttonText = "Open") - public Runnable open = Commands::openVisualWords; + public Runnable open = VisualWordGui::onCommand; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java index e8e47caec14d..5ff1d50b2338 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.config.features.gui.customscoreboard; -import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsManager; +import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; @@ -17,7 +17,7 @@ public class ChunkedStatsConfig { desc = "Select the stats you want to display chunked on the scoreboard." ) @ConfigEditorDraggableList - public List chunkedStats = new ArrayList<>(ChunkedStatsManager.getEntries()); + public List chunkedStats = new ArrayList<>(ChunkedStatsLines.getEntries()); @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java index 830234a9bf62..89d4768509cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/CustomScoreboardConfig.java @@ -2,7 +2,8 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; -import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEntry; +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard; +import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardConfigElement; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; @@ -31,15 +32,11 @@ public class CustomScoreboardConfig { desc = "Drag text to change the appearance of the advanced scoreboard." ) @ConfigEditorDraggableList() - public Property> scoreboardEntries = Property.of(new ArrayList<>(ScoreboardEntry.defaultOption)); + public Property> scoreboardEntries = Property.of(new ArrayList<>(ScoreboardConfigElement.defaultOption)); @ConfigOption(name = "Reset Appearance", desc = "Reset the appearance of the advanced scoreboard.") @ConfigEditorButton(buttonText = "Reset") - public Runnable reset = () -> { - scoreboardEntries.get().clear(); - scoreboardEntries.get().addAll(ScoreboardEntry.defaultOption); - scoreboardEntries.notifyObservers(); - }; + public Runnable reset = CustomScoreboard::resetAppearance; @Expose @ConfigOption(name = "Display Options", desc = "") @@ -57,7 +54,11 @@ public class CustomScoreboardConfig { public InformationFilteringConfig informationFiltering = new InformationFilteringConfig(); @Expose - @ConfigOption(name = "Unknown Lines warning", desc = "Give a chat warning when unknown lines are found in the scoreboard.\n§cReporting these in the Discord Server are very important, so we can know what lines are missing.") + @ConfigOption( + name = "Unknown Lines warning", + desc = "Give a chat warning when unknown lines are found in the scoreboard." + + "\n§cReporting these in the Discord Server are very important, so we can know what lines are missing." + ) @ConfigEditorBoolean public boolean unknownLinesWarning = true; 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 98c2f0cbd59f..b3acfa68178e 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 @@ -155,7 +155,11 @@ public String toString() { public RenderUtils.HorizontalAlignment textAlignment = RenderUtils.HorizontalAlignment.LEFT; @Expose - @ConfigOption(name = "Cache Scoreboard on Island Switch", desc = "Will stop the Scoreboard from updating while switching islands.\nRemoves the shaking when loading data.") + @ConfigOption( + name = "Cache Scoreboard on Island Switch", + desc = "Will stop the Scoreboard from updating while switching islands.\n" + + "Removes the shaking when loading data." + ) @ConfigEditorBoolean public boolean cacheScoreboardOnIslandSwitch = false; } 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 8061a5a8c146..3145d7d8c22e 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 @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.config.features.gui.customscoreboard; -import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEventEntry; +import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardConfigEventElement; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; @@ -19,13 +19,13 @@ public class EventsConfig { desc = "Drag your list to select the priority of each event." ) @ConfigEditorDraggableList() - public Property> eventEntries = Property.of(new ArrayList<>(ScoreboardEventEntry.defaultOption)); + public Property> eventEntries = Property.of(new ArrayList<>(ScoreboardConfigEventElement.defaultOption)); @ConfigOption(name = "Reset Events Priority", desc = "Reset the priority of all events.") @ConfigEditorButton(buttonText = "Reset") public Runnable reset = () -> { eventEntries.get().clear(); - eventEntries.get().addAll(ScoreboardEventEntry.defaultOption); + eventEntries.get().addAll(ScoreboardConfigEventElement.defaultOption); eventEntries.notifyObservers(); }; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/PartyConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/PartyConfig.java index 4b4e222b1a53..5a553369f37c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/PartyConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/PartyConfig.java @@ -4,6 +4,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; public class PartyConfig { @Expose @@ -13,7 +14,7 @@ public class PartyConfig { maxValue = 25, minStep = 1 ) - public Integer maxPartyList = 4; + public Property maxPartyList = Property.of(4); @Expose @ConfigOption(name = "Show Party Everywhere", desc = "Show the party list everywhere.\n" + 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 new file mode 100644 index 000000000000..06c60b507024 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/CrystalHighlighterConfig.java @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +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", + desc = "Draw visible bounding boxes around the Crystal Nucleus crystal barrier blocks." + ) + @ConfigEditorBoolean + @FeatureToggle + 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; + + @Expose + @ConfigOption( + name = "Only Show During Hoppity's", + desc = "Only show the highlighted boxes during Hoppity's Hunt." + ) + @ConfigEditorBoolean + public boolean onlyDuringHoppity = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java index 2c460bd2f0f2..f6a5a83baca6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java @@ -73,6 +73,11 @@ public class MiningConfig { @Accordion public MineshaftPityDisplayConfig mineshaftPityDisplay = new MineshaftPityDisplayConfig(); + @Expose + @ConfigOption(name = "Crystal Nucleus Crystal Highlights", desc = "") + @Accordion + public CrystalHighlighterConfig crystalHighlighter = new CrystalHighlighterConfig(); + @Expose @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight mobs that are part of active commissions.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java index 3f5874ac0941..2bdae5c59290 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java @@ -106,5 +106,6 @@ public String toString() { @Expose @ConfigLink(owner = EstimatedItemValueConfig.class, field = "enabled") + // TODO rename "position" public Position itemPriceDataPos = new Position(140, 90, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index e9e58fa463d3..022a18d926e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -68,7 +68,8 @@ object BitsAPI { private val bitsFromFameRankUpChatPattern by bitsChatGroup.pattern( "rankup.bits", - "§eYou gained §3(?.*) Bits Available §ecompounded from all your §epreviously eaten §6cookies§e! Click here to open §6cookie menu§e!", + "§eYou gained §3(?.*) Bits Available §ecompounded from all your " + + "§epreviously eaten §6cookies§e! Click here to open §6cookie menu§e!", ) private val fameRankUpPattern by bitsChatGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 965b4af578b8..8780561921af 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -38,7 +38,9 @@ object ChatManager { private val loggerFilteredTypes = mutableMapOf() private val messageHistory = object : LinkedHashMap, MessageFilteringResult>() { - override fun removeEldestEntry(eldest: MutableMap.MutableEntry, MessageFilteringResult>?): Boolean { + override fun removeEldestEntry( + eldest: MutableMap.MutableEntry, MessageFilteringResult>?, + ): Boolean { return size > 100 } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index d2f81a6d8191..04147ce7794c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -5,9 +5,9 @@ import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent import at.hannibal2.skyhanni.events.entity.EntityHealthDisplayEvent +import at.hannibal2.skyhanni.events.entity.EntityLeaveWorldEvent import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils @@ -31,27 +31,35 @@ import kotlin.time.Duration.Companion.milliseconds @SkyHanniModule object EntityData { - private val maxHealthMap = mutableMapOf() + private val maxHealthMap = mutableMapOf() private val nametagCache = TimeLimitedCache(50.milliseconds) private val healthDisplayCache = TimeLimitedCache(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()) { + for (entity in EntityUtils.getEntities()) { // this completely ignores the ignored entities list? val maxHealth = entity.baseMaxHealth - val oldMaxHealth = maxHealthMap.getOrDefault(entity, -1) + val id = entity.entityId + val oldMaxHealth = maxHealthMap.getOrDefault(id, -1) if (oldMaxHealth != maxHealth) { - maxHealthMap[entity] = maxHealth + maxHealthMap[id] = maxHealth EntityMaxHealthUpdateEvent(entity, maxHealth.derpy()).postAndCatch() } } } - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (event.repeatSeconds(30)) { - maxHealthMap.keys.removeIf { it.isDead } - } + @HandleEvent + fun onEntityLeaveWorld(event: EntityLeaveWorldEvent) { + maxHealthMap -= event.entity.entityId } @SubscribeEvent @@ -69,26 +77,11 @@ object EntityData { val entityId = packet.entityId val entity = EntityUtils.getEntityByID(entityId) ?: return - if (entity is EntityArmorStand) return - if (entity is EntityXPOrb) return - if (entity is EntityItem) return - if (entity is EntityItemFrame) return - - if (entity is EntityOtherPlayerMP) return - if (entity is EntityPlayerSP) return - - for (watchableObject in watchableObjects) { - - val dataValueId = watchableObject.dataValueId - val any = watchableObject.`object` - if (dataValueId != 6) continue - - val health = (any as Float).toInt() - - if (entity is EntityWither && health == 300 && entityId < 0) { - 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()).postAndCatch() } @@ -100,6 +93,11 @@ object EntityData { return postRenderNametag(entity, oldValue) } + @JvmStatic + fun despawnEntity(entity: Entity) { + EntityLeaveWorldEvent(entity).post() + } + private fun postRenderNametag(entity: Entity, chatComponent: ChatComponentText) = nametagCache.getOrPut(entity) { val event = EntityDisplayNameEvent(entity, chatComponent) event.postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt index e7fa75331924..2bcf589a3d50 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -24,23 +24,23 @@ object ItemClickData { packet is C08PacketPlayerBlockPlacement -> { if (packet.placedBlockDirection != 255) { val position = packet.position.toLorenzVec() - BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch() + BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).post() } else { - ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).postAndCatch() + ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).post() } } packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK -> { val position = packet.position.toLorenzVec() val blockClickCancelled = - BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).postAndCatch() + BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).post() ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).also { - it.isCanceled = blockClickCancelled - }.postAndCatch() + if (blockClickCancelled) it.cancel() + }.post() } packet is C0APacketAnimation -> { - ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).postAndCatch() + ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).post() } packet is C02PacketUseEntity -> { @@ -51,7 +51,7 @@ object ItemClickData { else -> return } val clickedEntity = packet.getEntityFromWorld(Minecraft.getMinecraft().theWorld) ?: return - EntityClickEvent(clickType, clickedEntity, InventoryUtils.getItemInHand()).postAndCatch() + EntityClickEvent(clickType, clickedEntity, InventoryUtils.getItemInHand()).post() } else -> { diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt index ebdb3af1fc83..5fd644818903 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard -import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEntry +import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardConfigElement import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils @@ -135,15 +135,11 @@ object MaxwellAPI { chatPowerPattern.tryReadPower(message) chatPowerUnlockedPattern.tryReadPower(message) - if (tuningAutoAssignedPattern.matches(event.message)) { - if (tunings.isNullOrEmpty()) return - with(CustomScoreboard.config) { - if (enabled.get() && ScoreboardEntry.TUNING in scoreboardEntries.get()) { - ChatUtils.chat( - "Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.", - ) - } - } + if (!tuningAutoAssignedPattern.matches(event.message)) return + if (tunings.isNullOrEmpty()) return + with(CustomScoreboard.config) { + if (!enabled.get() || ScoreboardConfigElement.TUNING !in scoreboardEntries.get()) return + ChatUtils.chat("Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.") } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index 57042679484e..84fcfedf6f24 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -46,11 +46,14 @@ object MiningAPI { private val glaciteAreaPattern by group.pattern("area.glacite", "Glacite Tunnels|Great Glacite Lake") private val dwarvenBaseCampPattern by group.pattern("area.basecamp", "Dwarven Base Camp") - // TODO add regex test private val coldResetPattern by group.pattern( "cold.reset", "§6The warmth of the campfire reduced your §r§b❄ Cold §r§6to §r§a0§r§6!|§c ☠ §r§7You froze to death§r§7\\.", ) + + /** + * REGEX-TEST: Cold: §b-1❄ + */ val coldPattern by group.pattern( "cold", "(?:§.)*Cold: §.(?-?\\d+)❄", @@ -171,7 +174,7 @@ object MiningAPI { } } - @SubscribeEvent + @HandleEvent fun onBlockClick(event: BlockClickEvent) { if (!inCustomMiningIsland()) return if (event.clickType != ClickType.LEFT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 7581b3b1ec94..24dacafbd2ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -49,10 +49,12 @@ object SackAPI { "sack", "^(.* Sack|Enchanted .* Sack)\$", ) + @Suppress("MaxLineLength") private val numPattern by patternGroup.pattern( "number", "(?:(?:§[0-9a-f](?I{1,3})§7:)?|(?:§7Stored:)?) (?§[0-9a-f])(?[0-9.,kKmMbB]+)§7/(?\\d+(?:[0-9.,]+)?[kKmMbB]?)", ) + @Suppress("MaxLineLength") private val gemstonePattern by patternGroup.pattern( "gemstone", " §[0-9a-f](?[A-z]*): §[0-9a-f](?\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?", 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 b6c0e16f9cca..5199e8b7e230 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 @@ -88,6 +88,7 @@ object PlayerChatManager { * REGEX-TEST: §b[MVP§c+§b] hannibal2§f§7 has §8[§6Heroic Aspect of the Void§8] * REGEX-TEST: §8[§b209§8] §b[MVP§d+§b] lrg89§f§7 is holding §8[§5Heroic Aspect of the Void§8] */ + @Suppress("MaxLineLength") private val itemShowPattern by patternGroup.pattern( "itemshow", "(?:§8\\[(?§.)(?\\d+)§8] )?(?.*)§f§7 (?is (?:holding|friends with a|wearing)|has) (?.*)" diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt index e9eb6729de43..062acc4b3d6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.toSingletonListOrEmpty import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen import at.hannibal2.skyhanni.utils.EntityUtils.cleanName +import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.EntityUtils.isCorrupted import at.hannibal2.skyhanni.utils.EntityUtils.isRunic import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -17,6 +18,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityZombie +import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.AxisAlignedBB import java.awt.Color import java.util.UUID @@ -111,7 +113,7 @@ class Mob( fun canBeSeen() = baseEntity.canBeSeen() - fun isInvisible() = if (baseEntity !is EntityZombie) baseEntity.isInvisible else false + fun isInvisible() = baseEntity !is EntityZombie && baseEntity.isInvisible && baseEntity.inventory.isNullOrEmpty() private var highlightColor: Color? = null diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt index f955384c5f4e..2363945d21df 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt @@ -103,11 +103,6 @@ object MobData { notSeenMobs.remove(event.mob) } - @SubscribeEvent - fun onMobFirstSeen(event: MobEvent.FirstSeen) { - notSeenMobs.remove(event.mob) - } - @SubscribeEvent fun onSkyblockMobSpawnEvent(event: MobEvent.Spawn.SkyblockMob) { skyblockMobs.add(event.mob) diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt index 014e0a846613..dbfbfe533d4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt @@ -159,13 +159,15 @@ object MobDetection { private fun canBeSeen(mob: Mob): Boolean { val isVisible = !mob.isInvisible() && mob.canBeSeen() - if (isVisible) when (mob.mobType) { - Mob.Type.PLAYER -> MobEvent.FirstSeen.Player(mob) - Mob.Type.SUMMON -> MobEvent.FirstSeen.Summon(mob) - Mob.Type.SPECIAL -> MobEvent.FirstSeen.Special(mob) - Mob.Type.PROJECTILE -> MobEvent.FirstSeen.Projectile(mob) - Mob.Type.DISPLAY_NPC -> MobEvent.FirstSeen.DisplayNPC(mob) - Mob.Type.BASIC, Mob.Type.DUNGEON, Mob.Type.BOSS, Mob.Type.SLAYER -> MobEvent.FirstSeen.SkyblockMob(mob) + if (isVisible) { + when (mob.mobType) { + Mob.Type.PLAYER -> MobEvent.FirstSeen.Player(mob) + Mob.Type.SUMMON -> MobEvent.FirstSeen.Summon(mob) + Mob.Type.SPECIAL -> MobEvent.FirstSeen.Special(mob) + Mob.Type.PROJECTILE -> MobEvent.FirstSeen.Projectile(mob) + Mob.Type.DISPLAY_NPC -> MobEvent.FirstSeen.DisplayNPC(mob) + Mob.Type.BASIC, Mob.Type.DUNGEON, Mob.Type.BOSS, Mob.Type.SLAYER -> MobEvent.FirstSeen.SkyblockMob(mob) + }.postAndCatch() } return isVisible } @@ -353,11 +355,12 @@ object MobDetection { is S0FPacketSpawnMob -> addEntityUpdate(packet.entityID) is S0CPacketSpawnPlayer -> addEntityUpdate(packet.entityID) // is S0EPacketSpawnObject -> addEntityUpdate(packet.entityID) - is S01PacketJoinGame -> // one of the first packets that is sent when switching servers inside the BungeeCord Network (please some prove this, I just found it out via Testing) - { - shouldClear.set(true) - allEntitiesViaPacketId.clear() - } + is S01PacketJoinGame -> { + // one of the first packets that is sent when switching servers inside the BungeeCord Network + // (please some prove this, I just found it out via Testing) + shouldClear.set(true) + allEntitiesViaPacketId.clear() + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt index 5d6111336fbd..6938958e97b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt @@ -120,14 +120,20 @@ object MobFilter { "^§8\\[§7Lv\\d+§8] §.(?Horse|Armadillo|Skeleton Horse|Pig|Rat)$", ) + // TODO: Move all of these to repo + @Suppress("MaxLineLength") internal const val RAT_SKULL = "ewogICJ0aW1lc3RhbXAiIDogMTYxODQxOTcwMTc1MywKICAicHJvZmlsZUlkIiA6ICI3MzgyZGRmYmU0ODU0NTVjODI1ZjkwMGY4OGZkMzJmOCIsCiAgInByb2ZpbGVOYW1lIiA6ICJCdUlJZXQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYThhYmI0NzFkYjBhYjc4NzAzMDExOTc5ZGM4YjQwNzk4YTk0MWYzYTRkZWMzZWM2MWNiZWVjMmFmOGNmZmU4IiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0=" + @Suppress("MaxLineLength") private const val HELLWISP_TENTACLE_SKULL = "ewogICJ0aW1lc3RhbXAiIDogMTY0OTM4MzAyMTQxNiwKICAicHJvZmlsZUlkIiA6ICIzYjgwOTg1YWU4ODY0ZWZlYjA3ODg2MmZkOTRhMTVkOSIsCiAgInByb2ZpbGVOYW1lIiA6ICJLaWVyYW5fVmF4aWxpYW4iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDI3MDQ2Mzg0OTM2MzhiODVjMzhkZDYzZmZkYmUyMjJmZTUzY2ZkNmE1MDk3NzI4NzU2MTE5MzdhZTViNWUyMiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" + @Suppress("MaxLineLength") private const val RIFT_EYE_SKULL1 = "ewogICJ0aW1lc3RhbXAiIDogMTY0ODA5MTkzNTcyMiwKICAicHJvZmlsZUlkIiA6ICJhNzdkNmQ2YmFjOWE0NzY3YTFhNzU1NjYxOTllYmY5MiIsCiAgInByb2ZpbGVOYW1lIiA6ICIwOEJFRDUiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjI2YmRlNDUwNDljN2I3ZDM0NjA1ZDgwNmEwNjgyOWI2Zjk1NWI4NTZhNTk5MWZkMzNlN2VhYmNlNDRjMDgzNCIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" + @Suppress("MaxLineLength") private const val RIFT_EYE_SKULL2 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTdkYjE5MjNkMDNjNGVmNGU5ZjZlODcyYzVhNmFkMjU3OGIxYWZmMmIyODFmYmMzZmZhNzQ2NmM4MjVmYjkifX19" + @Suppress("MaxLineLength") internal const val NPC_TURD_SKULL = "ewogICJ0aW1lc3RhbXAiIDogMTYzOTUxMjYxNzc5MywKICAicHJvZmlsZUlkIiA6ICIwZjczMDA3NjEyNGU0NGM3YWYxMTE1NDY5YzQ5OTY3OSIsCiAgInByb2ZpbGVOYW1lIiA6ICJPcmVfTWluZXIxMjMiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjM2MzBkOWIwMjA4OGVhMTkyNGE4NzIyNDJhYmM3NWI2MjYyYzJhY2E5MmFlY2Y4NzE0YTU3YTQxZWVhMGI5ZCIKICAgIH0KICB9Cn0=" diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt index 8efcf4621e37..2873ac9a4a11 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt @@ -17,6 +17,7 @@ enum class GraphNodeTag( AREA("area", LorenzColor.DARK_GREEN, "Area", "A big SkyBlock area."), SMALL_AREA("small_area", LorenzColor.GREEN, "Small Area", "A small SkyBlock area, e.g. a house."), POI("poi", LorenzColor.WHITE, "Point of Interest", "A relevant spot or a landmark on the map."), + // LAUNCH_PAD("launch", LorenzColor.WHITE, "Launch Pad", "Slime blocks sending you to another server."), TELEPORT("teleport", LorenzColor.BLUE, "Teleport", "A spot from/to teleport."), @@ -42,7 +43,13 @@ enum class GraphNodeTag( // Rift RIFT_ENIGMA("rift_enigma", LorenzColor.DARK_PURPLE, "Enigma Soul", "Enigma Souls in the Rift.", onlyIsland = IslandType.THE_RIFT), - RIFT_BUTTONS_QUEST("rift_buttons_quest", LorenzColor.LIGHT_PURPLE, "Wooden Buttons", "A spot to hit wooden buttons for the Dreadfarm Enigma Soul.", onlyIsland = IslandType.THE_RIFT), + RIFT_BUTTONS_QUEST( + "rift_buttons_quest", + LorenzColor.LIGHT_PURPLE, + "Wooden Buttons", + "A spot to hit wooden buttons for the Dreadfarm Enigma Soul.", + onlyIsland = IslandType.THE_RIFT, + ), RIFT_EYE("rift_eye", LorenzColor.DARK_RED, "Rift Eye", "An Eye in the Rift to teleport to.", onlyIsland = IslandType.THE_RIFT), RIFT_MONTEZUMA( "rift_montezuma", diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt index cde482de2c79..7a57de667dd1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -423,11 +423,13 @@ enum class TabWidget( val removeIndexes = mutableListOf() for ((index, header) in headers) when { - PLAYER_LIST.pattern.matches(header) -> if (playerListFound) removeIndexes.add(index - removeIndexes.size) else playerListFound = - true + PLAYER_LIST.pattern.matches(header) -> + if (playerListFound) removeIndexes.add(index - removeIndexes.size) + else playerListFound = true - INFO.pattern.matches(header) -> if (infoFound) removeIndexes.add(index - removeIndexes.size) else infoFound = - true + INFO.pattern.matches(header) -> + if (infoFound) removeIndexes.add(index - removeIndexes.size) + else infoFound = true } return tabList.transformIf({ size > 81 }, { dropLast(size - 80) }).editCopy { diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt index 74241946faf2..71c545912803 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoUtils.kt @@ -48,7 +48,8 @@ object RepoUtils { File(newFile.parent).mkdirs() if (!isInTree(dir, newFile)) { throw RuntimeException( - "SkyHanni detected an invalid zip file. This is a potential security risk, please report this on the SkyHanni discord." + "SkyHanni detected an invalid zip file. This is a potential security risk, " + + "please report this on the SkyHanni discord." ) } val fos = FileOutputStream(newFile) diff --git a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt index 2822c28a98c5..42587b3909db 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt @@ -4,9 +4,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.Cancelable -@Cancelable class BlockClickEvent(clickType: ClickType, val position: LorenzVec, itemInHand: ItemStack?) : WorldClickEvent(itemInHand, clickType) { diff --git a/src/main/java/at/hannibal2/skyhanni/events/DungeonBossPhaseChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DungeonBossPhaseChangeEvent.kt new file mode 100644 index 000000000000..92d6be3d5892 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/DungeonBossPhaseChangeEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent +import at.hannibal2.skyhanni.features.dungeon.DungeonBossAPI + +class DungeonBossPhaseChangeEvent(val newPhase: DungeonBossAPI.DungeonBossPhase) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt index d0cf14214789..2c85ef110670 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt @@ -3,8 +3,6 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.ClickType import net.minecraft.entity.Entity import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.Cancelable -@Cancelable class EntityClickEvent(clickType: ClickType, val clickedEntity: Entity?, itemInHand: ItemStack?) : WorldClickEvent(itemInHand, clickType) diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt index a34cb43f19de..e0a96d7e5db6 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt @@ -2,7 +2,5 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.data.ClickType import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.Cancelable -@Cancelable class ItemClickEvent(itemInHand: ItemStack?, clickType: ClickType) : WorldClickEvent(itemInHand, clickType) diff --git a/src/main/java/at/hannibal2/skyhanni/events/MobEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/MobEvent.kt index 10172cb5fcd8..07990ff222c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/MobEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/MobEvent.kt @@ -21,8 +21,6 @@ open class MobEvent(val mob: Mob) : LorenzEvent() { class Projectile(mob: Mob) : DeSpawn(mob) } - // TODO replace with "isFirstTime" parameter in the Spawn event. Also create an actual "player sees the mob for the first time" event - @Deprecated("Old. Will get replaced soon.") open class FirstSeen(mob: Mob) : MobEvent(mob) { class SkyblockMob(mob: Mob) : FirstSeen(mob) class Summon(mob: Mob) : FirstSeen(mob) diff --git a/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt index 4597041a1d32..ff3892859ce4 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt @@ -1,8 +1,7 @@ package at.hannibal2.skyhanni.events +import at.hannibal2.skyhanni.api.event.CancellableSkyHanniEvent import at.hannibal2.skyhanni.data.ClickType import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.Cancelable -@Cancelable -open class WorldClickEvent(val itemInHand: ItemStack?, val clickType: ClickType) : LorenzEvent() +open class WorldClickEvent(val itemInHand: ItemStack?, val clickType: ClickType) : CancellableSkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityLeaveWorldEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityLeaveWorldEvent.kt new file mode 100644 index 000000000000..74d885e1190e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityLeaveWorldEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.entity + +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent +import net.minecraft.entity.Entity + +class EntityLeaveWorldEvent(val entity: T) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index 6f7a062f85e5..b476a116001e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -98,7 +98,8 @@ object MinionCraftHelper { return newDisplay } - private fun loadFromInventory(mainInventory: Array): Pair, MutableMap> { + private fun loadFromInventory(mainInventory: Array): + Pair, MutableMap> { init() val minions = mutableMapOf() @@ -144,7 +145,8 @@ object MinionCraftHelper { if (ingredientInternalName == internalName) return true val ingredientPrimitive = NEUItems.getPrimitiveMultiplier(ingredientInternalName) - if (primitiveStack.internalName == ingredientPrimitive.internalName && primitiveStack.amount < ingredientPrimitive.amount) return true + if (primitiveStack.internalName == ingredientPrimitive.internalName && + primitiveStack.amount < ingredientPrimitive.amount) return true } } } 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 69602ec70765..d233387cd2e1 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 @@ -167,7 +167,8 @@ object BingoNextStepHelper { } } } - if (currentStep is PartialProgressItemsStep && currentStep.displayName == RHYS_TASK_NAME && event.message == "§e[NPC] §dRhys§f: §rThank you for the items!§r") { + if (currentStep is PartialProgressItemsStep && currentStep.displayName == RHYS_TASK_NAME && + event.message == "§e[NPC] §dRhys§f: §rThank you for the items!§r") { currentStep.amountHavingHidden -= 10 } } 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 28a2b4b4f081..e32769cf615f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -29,6 +29,7 @@ object ChatFilter { // // Lobby Messages + @Suppress("MaxLineLength") private val lobbyPatterns = listOf( // player join "(?: §b>§c>§a>§r §r)?.* §6(?:joined|(?:spooked|slid) into) the lobby!(?:§r §a<§c<§b<)?".toPattern(), @@ -159,6 +160,7 @@ object ChatFilter { ) // Slayer Drop + @Suppress("MaxLineLength") private val slayerDropPatterns = listOf( // Zombie "§b§lRARE DROP! §r§7\\(§r§f§r§9Revenant Viscera§r§7\\) (.*)".toPattern(), @@ -263,6 +265,7 @@ object ChatFilter { ) // Annoying Spam + @Suppress("MaxLineLength") private val annoyingSpamPatterns = listOf( "§7Your Implosion hit (.*) for §r§c(.*) §r§7damage.".toPattern(), "§7Your Molten Wave hit (.*) for §r§c(.*) §r§7damage.".toPattern(), @@ -520,7 +523,7 @@ object ChatFilter { * @param message The message to check * @return The reason why the message was blocked, empty if not blocked */ - @Suppress("CyclomaticComplexMethod") + @Suppress("CyclomaticComplexMethod", "MaxLineLength") private fun block(message: String): String? = when { config.hypixelHub && message.isPresent("lobby") -> "lobby" config.empty && StringUtils.isEmpty(message) -> "empty" diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt index 7547ae6ab24b..745116d16f44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt @@ -15,6 +15,7 @@ object CompactSplashPotionMessage { private val config get() = SkyHanniMod.feature.chat.compactPotionMessages + @Suppress("MaxLineLength") private val potionEffectPatternList = listOf( "§a§lBUFF! §fYou were splashed by (?.*) §fwith §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern(), "§a§lBUFF! §fYou have gained §r(?.*)§r§f! Press TAB or type /effects to view your active effects!".toPattern(), diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PowderMiningChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PowderMiningChatFilter.kt index 624a2d0c2b95..22db96d30882 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PowderMiningChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PowderMiningChatFilter.kt @@ -62,10 +62,12 @@ object PowderMiningChatFilter { /** * REGEX-TEST: §cYou need a tool with a §r§aBreaking Power §r§cof §r§66§r§c to mine Ruby Gemstone Block§r§c! Speak to §r§dFragilis §r§cby the entrance to the Crystal Hollows to learn more! + * REGEX-TEST: §cYou need a tool with a §r§aBreaking Power §r§cof §r§64§r§c to mine Mithril§r§c! Speak to §r§dFragilis §r§cby the entrance to the Crystal Hollows to learn more! */ + @Suppress("MaxLineLength") private val breakingPowerPattern by patternGroup.pattern( "warning.breakingpower", - "§cYou need a tool with a §r§aBreaking Power §r§cof (?:§.)*\\d+§r§c to mine (Ruby|Amethyst|Jade|Amber|Sapphire|Topaz) Gemstone Block§r§c!.+", + "§cYou need a tool with a §r§aBreaking Power §r§cof (?:§.)*\\d+§r§c to mine .+", ) /** @@ -216,6 +218,7 @@ object PowderMiningChatFilter { * REGEX-TEST: §r§9Electron Transmitter * REGEX-TEST: §r§9Superlite Motor */ + @Suppress("MaxLineLength") private val robotPartsPattern by patternGroup.pattern( "reward.robotparts", "§r§9(?:FTX 3070|Synthetic Heart|Control Switch|Robotron Reflector|Electron Transmitter|Superlite Motor)( §r§8x(?[\\d,]+))?", diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/translation/TranslatableLanguage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/translation/TranslatableLanguage.kt index 13a19a1dcbc8..7f5db80d1ef8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/translation/TranslatableLanguage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/translation/TranslatableLanguage.kt @@ -34,8 +34,8 @@ enum class TranslatableLanguage(private val englishName: String, private val nat TAGALOG("Tagalog", "Tagalog", "tl"), // Major language in the Philippines PUNJABI("Punjabi", "ਪੰਜਾਬੀ", "pa"), // Significant in India and Pakistan - // 5. need better name - UNKNOWN("Unknown Language", "", ""), + // 5. Other Language + UNKNOWN("Other", "", ""), ; // Limit to 20 characters so that the text is not too small in the config diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/translation/Translator.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/translation/Translator.kt index 24809faac798..b4e434c1a2d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/translation/Translator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/translation/Translator.kt @@ -66,7 +66,7 @@ object Translator { if (text.isEmpty()) { config.languageName.set(TranslatableLanguage.ENGLISH) } else { - for (language in TranslatableLanguage.values()) { + for (language in TranslatableLanguage.entries) { if (language.languageCode.equals(text, ignoreCase = true)) { config.languageName.set(language) return@onToggle @@ -107,102 +107,107 @@ object Translator { * ] * ], * null, - * '"target language as a two-letter code following ISO 639-1"', + * '"target language as a (usually) two-letter code following ISO 639-1"', * ] */ - private fun getJSONResponse(urlString: String) = - APIUtils.getJSONResponseAsElement(urlString, false, "Google Translate API") + private fun getJSONResponse(urlString: String) = APIUtils.getJSONResponseAsElement(urlString, false, "Google Translate API") - private fun getTranslationToEnglish(message: String): String { - val url = - "https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q=" + - URLEncoder.encode(message, "UTF-8") + fun getTranslation( + message: String, + targetLanguage: String, + sourceLanguage: String = "auto", + ): Array? { + // TODO add &dj=1 to use named json + val encode = URLEncoder.encode(message, "UTF-8") + val url = "https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&sl=$sourceLanguage&tl=$targetLanguage&q=$encode" var messageToSend = "" - val layer1 = getJSONResponse(url).asJsonArray - if (layer1.size() <= 2) return "Error!" + val fullResponse = getJSONResponse(url).asJsonArray + if (fullResponse.size() < 3) return null - val language = layer1[2].toString() - if (language == "\"en\"") return "Unable to translate!" - if (language.length != 4) return "Error!" + val language = fullResponse[2].toString() // the detected language the message is in + val sentences = fullResponse[0] as? JsonArray ?: return null - val layer2 = try { - layer1[0] as JsonArray - } catch (_: Exception) { - return "Error!" - } - - for (layer3 in layer2) { - val arrayLayer3 = layer3 as? JsonArray ?: continue - val sentence = arrayLayer3[0].toString() + for (rawSentence in sentences) { + val arrayPhrase = rawSentence as? JsonArray ?: continue + val sentence = arrayPhrase[0].toString() val sentenceWithoutQuotes = sentence.substring(1, sentence.length - 1) messageToSend = "$messageToSend$sentenceWithoutQuotes" } - messageToSend = "$messageToSend §7(Language: $language)" + messageToSend = URLDecoder.decode(messageToSend, "UTF-8").replace("\\", "") // Not sure if this is actually needed + return arrayOf(messageToSend, language) + } - return URLDecoder.decode(messageToSend, "UTF-8").replace("\\", "") + @Deprecated("Use toNativeLanguage() instead", ReplaceWith("Translator.toNativeLanguage(args)")) + fun toEnglish(args: Array) { + toNativeLanguage(args) } - private fun getTranslationFromEnglish(message: String, lang: String): String { - val url = - "https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=$lang&dt=t&q=" + - URLEncoder.encode(message, "UTF-8") - - val layer1 = getJSONResponse(url).asJsonArray - if (layer1.size() < 1) return "Error!" - val layer2 = layer1[0] as? JsonArray - - val firstSentence = (layer2?.get(0) as? JsonArray)?.get(0).toString() - var messageToSend = firstSentence.substring(0, firstSentence.length - 1) - if (layer2 != null) { - for (sentenceIndex in 1..) { + fromNativeLanguage(args) } - fun toEnglish(args: Array) { + fun toNativeLanguage(args: Array) { val message = args.joinToString(" ").removeColor() coroutineScope.launch { - var lang = config.languageCode.get() - val translation = if (lang.isEmpty()) { - getTranslationToEnglish(message) - } else { - getTranslationFromEnglish(message, lang) - } - if (message == translation) { - ChatUtils.userError("Translation is the same as the original message!") - return@launch - } + val translation = getTranslation(message, nativeLanguage()) + val translatedMessage = translation?.get(0) ?: "Error!" + val detectedLanguage = translation?.get(1) ?: "Error!" - if (translation == "Unable to translate!") { - ChatUtils.userError("Unable to translate message :( (is it in English?)") + if (message == translatedMessage) { + ChatUtils.userError("Translation is the same as the original message!") return@launch } - ChatUtils.chat("Found translation: §f$translation") + ChatUtils.clickableChat( + "Found translation: §f$translatedMessage", + onClick = { OSUtils.copyToClipboard(translatedMessage) }, + "§eClick to copy!\n§eOriginal message: §f$message §7(Language: $detectedLanguage)", + ) } } - fun fromEnglish(args: Array) { - if (args.size < 2 || args[0].length != 2) { // args[0] is the language code - ChatUtils.userError("Usage: /shcopytranslation ") + fun fromNativeLanguage(args: Array) { + if (args.size < 2) { + ChatUtils.userError("Usage: /shcopytranslation ") return } val language = args[0] val message = args.drop(1).joinToString(" ") coroutineScope.launch { - val translation = getTranslationFromEnglish(message, language) - ChatUtils.chat("Copied translation to clipboard: §f$translation") - OSUtils.copyToClipboard(translation) + val translation = getTranslation(message, language, nativeLanguage())?.get(0) ?: "Error!" + ChatUtils.clickableChat( + "Copied §f$language §etranslation to clipboard: §f$translation", + onClick = { OSUtils.copyToClipboard(translation) }, + "§eClick to copy!\n§eOriginal message: §f$message", + ) } } + fun translateAdvancedCommand(args: Array) { + if (args.size < 3) { + ChatUtils.userError("Usage: /shtranslateadvanced ") + return + } + val sourceLanguage = args[0] + val targetLanguage = args[1] + val message = args.drop(2).joinToString(" ") + + val translation = getTranslation(message, sourceLanguage, targetLanguage) + val translatedMessage = translation?.get(0) ?: "Error!" + val detectedLanguage = if (sourceLanguage == "auto") " ${translation?.get(1) ?: "Error!"}" else "" + + ChatUtils.clickableChat( + "Found translation from sl: $sourceLanguage: §f$translatedMessage §7(tl: $targetLanguage)", + onClick = { OSUtils.copyToClipboard(translatedMessage) }, + "§eClick to copy!\n§eOriginal message: §f$message §7(sl: $sourceLanguage$detectedLanguage)", + ) + } + + fun nativeLanguage(): String = config.languageCode.get().ifEmpty { "en" } + fun isEnabled() = config.translateOnClick } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt index c5804ea37c40..93f9f0452ffe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt @@ -42,6 +42,8 @@ object FlareDisplay { private val MAX_FLARE_TIME = 3.minutes + // TODO: Move to repo + @Suppress("MaxLineLength") private val flareSkins = mapOf( "ewogICJ0aW1lc3RhbXAiIDogMTY0NjY4NzMwNjIyMywKICAicHJvZmlsZUlkIiA6ICI0MWQzYWJjMmQ3NDk0MDBjOTA5MGQ1NDM0ZDAzODMxYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJNZWdha2xvb24iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjJlMmJmNmMxZWMzMzAyNDc5MjdiYTYzNDc5ZTU4NzJhYzY2YjA2OTAzYzg2YzgyYjUyZGFjOWYxYzk3MTQ1OCIKICAgIH0KICB9Cn0=" to FlareType.WARNING, diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/SpidersDenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/SpidersDenAPI.kt index c2833500c35e..8b9ff035e662 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/SpidersDenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/SpidersDenAPI.kt @@ -12,6 +12,9 @@ object SpidersDenAPI { private val repoGroup = RepoPattern.group("combat.spidersden") + /** + * REGEX-TEST: §4Broodmother§7: §6Soon + */ val broodmotherPattern by repoGroup.pattern( "broodmother", "§4Broodmother§7: §[e64](?:Slain|Dormant|Soon|Awakening|Imminent|Alive!)", diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index 2ef652e4a93a..fe14093ef9d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -81,6 +81,8 @@ object GhostCounter { "skillxp", "[+](?[0-9,.]+) \\((?[0-9,.]+)(?:/(?[0-9,.]+))?\\)", ) + + @Suppress("MaxLineLength") private val combatSectionPattern by patternGroup.pattern( "combatsection", ".*[+](?[0-9,.]+) (?[A-Za-z]+) \\((?(?[0-9.,]+)/(?[0-9.,]+)|(?[0-9.]+)%)\\).*", @@ -282,7 +284,8 @@ object GhostCounter { val moneyMadeTips = buildList { for ((name, count, value) in priceMap) { moneyMade += (count.toLong() * value.toLong()) - add("$name: §b${value.addSeparators()} §fx §b${count.addSeparators()} §f= §6${(value.toLong() * count.toLong()).addSeparators()}") + add("$name: §b${value.addSeparators()} §fx §b${count.addSeparators()} §f= " + + "§6${(value.toLong() * count.toLong()).addSeparators()}") } add("§bTotal: §6${moneyMade.addSeparators()}") add("§eClick to copy to clipboard!") diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt index 2eb5dc3fb893..ffffc7511c6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/HelpCommand.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.commands +import at.hannibal2.skyhanni.config.commands.CommandBuilder import at.hannibal2.skyhanni.config.commands.Commands +import at.hannibal2.skyhanni.config.commands.Commands.commands import at.hannibal2.skyhanni.utils.StringUtils.splitLines import at.hannibal2.skyhanni.utils.chat.Text import at.hannibal2.skyhanni.utils.chat.Text.hover @@ -12,7 +14,7 @@ object HelpCommand { private const val COMMANDS_PER_PAGE = 15 private const val HELP_ID = -6457563 - private fun createCommandEntry(command: Commands.CommandInfo): IChatComponent { + private fun createCommandEntry(command: CommandBuilder): IChatComponent { val category = command.category val color = category.color val description = command.description.splitLines(200).replace("§r", "§7") @@ -30,7 +32,7 @@ object HelpCommand { } } - private fun showPage(page: Int, search: String, commands: List) { + private fun showPage(page: Int, search: String, commands: List) { val filtered = commands.filter { it.name.contains(search, ignoreCase = true) || it.description.contains(search, ignoreCase = true) } @@ -47,7 +49,7 @@ object HelpCommand { ) { createCommandEntry(it) } } - fun onCommand(args: Array, commands: List) { + fun onCommand(args: Array) { val page: Int val search: String if (args.firstOrNull() == "-p") { 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 377d7bfd405f..5db28465e554 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -269,7 +269,7 @@ object CroesusChestTracker { fun resetChest() = croesusChests?.let { it.clear() it.addAll(generateMaxChest()) - ChatUtils.chat("Kismet State was cleared!") + ChatUtils.chat("Kismet State was Reset!") } @JvmStatic 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 f95c846b2a0a..254e04dca523 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.dungeon +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.ClickedBlockType import at.hannibal2.skyhanni.data.IslandType @@ -62,6 +63,8 @@ object DungeonAPI { val bossStorage: MutableMap? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses private val patternGroup = RepoPattern.group("dungeon") + // TODO: Move to repo + @Suppress("MaxLineLength") private const val WITHER_ESSENCE_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRkYjRhZGZhOWJmNDhmZjVkNDE3MDdhZTM0ZWE3OGJkMjM3MTY1OWZjZDhjZDg5MzQ3NDlhZjRjY2U5YiJ9fX0=" @@ -360,9 +363,9 @@ object DungeonAPI { } } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) fun onBlockClick(event: BlockClickEvent) { - if (!inDungeon() || event.clickType != ClickType.RIGHT_CLICK) return + if (event.clickType != ClickType.RIGHT_CLICK) return val position = event.position val blockType: ClickedBlockType = when (position.getBlockAt()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossAPI.kt new file mode 100644 index 000000000000..d30553a28581 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossAPI.kt @@ -0,0 +1,174 @@ +package at.hannibal2.skyhanni.features.dungeon + +import at.hannibal2.skyhanni.events.DungeonBossPhaseChangeEvent +import at.hannibal2.skyhanni.events.DungeonCompleteEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.dungeonFloor +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object DungeonBossAPI { + var bossPhase: DungeonBossPhase? = null + + enum class DungeonBossPhase { + F6_TERRACOTTA, + F6_GIANTS, + F6_SADAN, + F7_MAXOR, + F7_STORM, + F7_GOLDOR_1, + F7_GOLDOR_2, + F7_GOLDOR_3, + F7_GOLDOR_4, + F7_GOLDOR_5, + F7_NECRON, + M7_WITHER_KING, + ; + + fun isCurrent(): Boolean = bossPhase == this + } + + private val patternGroup = RepoPattern.group("dungeon.boss.message") + + /** + * REGEX-TEST: §c[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me\? Sadan\?! + */ + private val terracottaStartPattern by patternGroup.pattern( + "f6.terracotta", + "§c\\[BOSS] Sadan§r§f: So you made it all the way here\\.\\.\\. Now you wish to defy me\\? Sadan\\?!", + ) + + /** + * REGEX-TEST: §c[BOSS] Sadan§r§f: ENOUGH! + */ + private val giantsStartPattern by patternGroup.pattern( + "f6.giants", + "§c\\[BOSS] Sadan§r§f: ENOUGH!", + ) + + /** + * REGEX-TEST: §c[BOSS] Sadan§r§f: You did it. I understand now, you have earned my respect. + */ + private val sadanStartPattern by patternGroup.pattern( + "f6.sadan", + "§c\\[BOSS] Sadan§r§f: You did it\\. I understand now, you have earned my respect\\.", + ) + + /** + * REGEX-TEST: §4[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE! + */ + private val maxorStartPattern by patternGroup.pattern( + "f7.maxor", + "§4\\[BOSS] Maxor§r§c: §r§cWELL! WELL! WELL! LOOK WHO'S HERE!", + ) + + /** + * REGEX-TEST: §4[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected. + */ + private val stormStartPattern by patternGroup.pattern( + "f7.storm", + "§4\\[BOSS] Storm§r§c: §r§cPathetic Maxor, just like expected\\.", + ) + + /** + * REGEX-TEST: §4[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain? + */ + private val goldorStartPattern by patternGroup.pattern( + "f7.goldor.start", + "§4\\[BOSS] Goldor§r§c: §r§cWho dares trespass into my domain\\?", + ) + + /** + * REGEX-TEST: §bmartimavocado§r§a activated a lever! (§r§c7§r§a/7) + * REGEX-TEST: §bmartimavocado§r§a completed a device! (§r§c3§r§a/8) + * REGEX-TEST: §bmartimavocado§r§a activated a terminal! (§r§c4§r§a/7) + */ + val goldorTerminalPattern by patternGroup.pattern( + "f7.goldor.terminalcomplete", + "§.(?\\w+)§r§a (?:activated|completed) a (?lever|terminal|device)! \\(§r§c(?\\d)§r§a/(?\\d)\\)", + ) + + /** + * REGEX-TEST: §aThe Core entrance is opening! + */ + private val goldor5StartPattern by patternGroup.pattern( + "f7.goldor.5", + "§aThe Core entrance is opening!", + ) + + /** + * REGEX-TEST: §4[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations. + */ + private val necronStartPattern by patternGroup.pattern( + "f7.necron.start", + "§4\\[BOSS] Necron§r§c: §r§cYou went further than any human before, congratulations\\.", + ) + + /** + * REGEX-TEST: §4[BOSS] Necron§r§c: §r§cAll this, for nothing... + */ + private val witherKingStartPattern by patternGroup.pattern( + "m7.witherking", + "§4\\[BOSS] Necron§r§c: §r§cAll this, for nothing\\.\\.\\.", + ) + + private fun handlePhaseMessage(message: String) { + if (dungeonFloor == "F6" || dungeonFloor == "M6") when { //move to enum + terracottaStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_TERRACOTTA) + giantsStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_GIANTS) + sadanStartPattern.matches(message) -> changePhase(DungeonBossPhase.F6_SADAN) + } + + if (dungeonFloor == "F7" || dungeonFloor == "M7") { //move to enum + goldorTerminalPattern.matchMatcher(message) { + val currentTerminal = group("currentTerminal").toIntOrNull() ?: return + val totalTerminals = group("total").toIntOrNull() ?: return + if (currentTerminal != totalTerminals) return + changePhase( + when (bossPhase) { + DungeonBossPhase.F7_GOLDOR_1 -> DungeonBossPhase.F7_GOLDOR_2 + DungeonBossPhase.F7_GOLDOR_2 -> DungeonBossPhase.F7_GOLDOR_3 + DungeonBossPhase.F7_GOLDOR_3 -> DungeonBossPhase.F7_GOLDOR_4 + else -> return + }, + ) + } + when { + maxorStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_MAXOR) + stormStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_STORM) + goldorStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_GOLDOR_1) + goldor5StartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_GOLDOR_5) + necronStartPattern.matches(message) -> changePhase(DungeonBossPhase.F7_NECRON) + witherKingStartPattern.matches(message) -> if (bossPhase != null) changePhase(DungeonBossPhase.M7_WITHER_KING) + } + } + } + + private fun changePhase(newPhase: DungeonBossPhase) { + DungeonBossPhaseChangeEvent(newPhase).post() + bossPhase = newPhase + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + bossPhase = null + } + + @SubscribeEvent + fun onDungeonEnd(event: DungeonCompleteEvent) { + bossPhase = null + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock) return + + handlePhaseMessage(event.message) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt index 1a566c22579d..6b992e798690 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt @@ -25,6 +25,7 @@ object DungeonChatFilter { private val endMessagesEndWith = listOf( " Experience §r§b(Team Bonus)" ) + @Suppress("MaxLineLength") private val abilityPatterns = listOf( "§7Your Guided Sheep hit §r§c(.*) §r§7enemy for §r§c(.*) §r§7damage.".toPattern(), "§a§lBUFF! §fYou were splashed by (.*) §fwith §r§cHealing VIII§r§f!".toPattern(), @@ -99,11 +100,13 @@ object DungeonChatFilter { private val buffMessages = listOf( "§a§lBUFF! §fYou have gained §r§cHealing V§r§f!" ) + @Suppress("MaxLineLength") private val puzzlePatterns = listOf( "§a§lPUZZLE SOLVED! (.*) §r§ewasn't fooled by §r§c(.*)§r§e! §r§4G§r§co§r§6o§r§ed§r§a §r§2j§r§bo§r§3b§r§5!".toPattern(), "§a§lPUZZLE SOLVED! (.*) §r§etied Tic Tac Toe! §r§4G§r§co§r§6o§r§ed§r§a §r§2j§r§bo§r§3b§r§5!".toPattern(), "§4\\[STATUE] Oruo the Omniscient§r§f: §r(.*) §r§fthinks the answer is §r§6 . §r(.*)§r§f! §r§fLock in your party's answer in my Chamber!".toPattern(), ) + @Suppress("MaxLineLength") private val puzzleMessages = listOf( "§4[STATUE] Oruo the Omniscient§r§f: §r§fThough I sit stationary in this prison that is §r§cThe Catacombs§r§f, my knowledge knows no bounds.", "§4[STATUE] Oruo the Omniscient§r§f: §r§fProve your knowledge by answering 3 questions and I shall reward you in ways that transcend time!", @@ -122,6 +125,7 @@ object DungeonChatFilter { "§e§lRIGHT CLICK §r§7on §r§7a §r§8WITHER §r§7door§r§7 to open it. This key can only be used to open §r§a1§r§7 door!", "§e§lRIGHT CLICK §r§7on §r§7the §r§cBLOOD DOOR§r§7 to open it. This key can only be used to open §r§a1§r§7 door!" ) + @Suppress("MaxLineLength") private val pickupPatterns = listOf( "(.*) §r§ehas obtained §r§a§r§9Superboom TNT§r§e!".toPattern(), "(.*) §r§ehas obtained §r§a§r§9Superboom TNT §r§8x2§r§e!".toPattern(), @@ -160,6 +164,7 @@ object DungeonChatFilter { "(.*)§a is now ready!".toPattern(), "§aDungeon starts in (.*) seconds.".toPattern(), ) + @Suppress("MaxLineLength") private val prepareMessages = listOf( "§aYour active Potion Effects have been paused and stored. They will be restored when you leave Dungeons! You are not allowed to use existing Potion Effects while in Dungeons.", "§aDungeon starts in 1 second.", diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt index 4f29aca52eac..967af0dd3d4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt @@ -29,25 +29,32 @@ object DungeonHideItems { private val movingSkeletonSkulls = mutableMapOf() // TODO put in skull data repo part - + @Suppress("MaxLineLength") private const val SOUL_WEAVER_HIDER = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmYyNGVkNjg3NTMwNGZhNGExZjBjNzg1YjJjYjZhNmE3MjU2M2U5ZjNlMjRlYTU1ZTE4MTc4NDUyMTE5YWE2NiJ9fX0=" + @Suppress("MaxLineLength") private const val BLESSING_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkzZTIwNjg2MTc4NzJjNTQyZWNkYTFkMjdkZjRlY2U5MWM2OTk5MDdiZjMyN2M0ZGRiODUzMDk0MTJkMzkzOSJ9fX0=" + @Suppress("MaxLineLength") private const val REVIVE_STONE_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjZhNzZjYzIyZTdjMmFiOWM1NDBkMTI0NGVhZGJhNTgxZjVkZDllMThmOWFkYWNmMDUyODBhNWI0OGI4ZjYxOCJ9fX0K" + @Suppress("MaxLineLength") private const val PREMIUM_FLESH_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWE3NWU4YjA0NGM3MjAxYTRiMmU4NTZiZTRmYzMxNmE1YWFlYzY2NTc2MTY5YmFiNTg3MmE4ODUzNGI4MDI1NiJ9fX0K" + @Suppress("MaxLineLength") private const val ABILITY_ORB_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTAxZTA0MGNiMDFjZjJjY2U0NDI4MzU4YWUzMWQyZTI2NjIwN2M0N2NiM2FkMTM5NzA5YzYyMDEzMGRjOGFkNCJ9fX0=" + @Suppress("MaxLineLength") private const val SUPPORT_ORB_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTMxYTRmYWIyZjg3ZGI1NDMzMDEzNjUxN2I0NTNhYWNiOWQ3YzBmZTc4NDMwMDcwOWU5YjEwOWNiYzUxNGYwMCJ9fX0=" + @Suppress("MaxLineLength") private const val DAMAGE_ORB_TEXTURE = "eyJ0aW1lc3RhbXAiOjE1NzQ5NTEzMTkwNDQsInByb2ZpbGVJZCI6IjE5MjUyMWI0ZWZkYjQyNWM4OTMxZjAyYTg0OTZlMTFiIiwicHJvZmlsZU5hbWUiOiJTZXJpYWxpemFibGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiODZkYTJlMjQzYzA1ZGMwODk4YjBjYzVkM2U2NDg3NzE3MzE3N2UwYTIzOTQ0MjVjZWMxMDAyNTljYjQ1MjYifX19" + @Suppress("MaxLineLength") private const val HEALER_FAIRY_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt index 3968a3d18a87..17eca4a58cfa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt @@ -21,6 +21,7 @@ object DungeonRankTabListColor { * REGEX-TEST: §8[§r§9319§r§8] §r§bEmpa_ §r§7α §r§f(§r§dMage XXXIV§r§f) * REGEX-TEST: §8[§r§5393§r§8] §r§c[§r§fYOUTUBE§r§c] Remittal§r§f §r§7Σ§r§7♲ §r§f(§r§dMage XL§r§f) */ + @Suppress("MaxLineLength") private val pattern by patternGroup.pattern( "rank", "^(?:§.)*(?\\[(?:§.)*\\d+(?:§.)*]) (?(?:§.)*\\[(?:§.)*[^]]+(?:§.)*])? ?(?\\S+) (?[^(]*)\\((?:§.)*(?\\S+) (?[CLXVI]+)(?:§.)*\\)(?:§.)*$" diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt index 14e359c29114..69b8ab077f6f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt @@ -1,7 +1,6 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager @@ -15,37 +14,23 @@ object TerracottaPhase { private val config get() = SkyHanniMod.feature.dungeon.terracottaPhase - private var inTerracottaPhase = false - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!isEnabled()) return - - if (event.message == "§c[BOSS] Sadan§r§f: So you made it all the way here... Now you wish to defy me? Sadan?!") { - inTerracottaPhase = true - } - - if (event.message == "§c[BOSS] Sadan§r§f: ENOUGH!") { - inTerracottaPhase = false - } - } - @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { - if (isActive() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) { + if (isEnabled() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) { event.cancel() } } @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { - if (isActive() && config.hideParticles) { + if (isEnabled() && config.hideParticles) { event.cancel() } } - private fun isActive() = isEnabled() && inTerracottaPhase - private fun isEnabled() = - DungeonAPI.inDungeon() && DungeonAPI.inBossRoom && DungeonAPI.getCurrentBoss() == DungeonFloor.F6 + DungeonAPI.inDungeon() && + DungeonAPI.inBossRoom && + DungeonAPI.getCurrentBoss() == DungeonFloor.F6 && + DungeonBossAPI.bossPhase == DungeonBossAPI.DungeonBossPhase.F6_TERRACOTTA } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalInfo.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalInfo.kt new file mode 100644 index 000000000000..bd7b8a4ee7a6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalInfo.kt @@ -0,0 +1,52 @@ +package at.hannibal2.skyhanni.features.dungeon.floor7 + +import at.hannibal2.skyhanni.features.dungeon.DungeonBossAPI +import at.hannibal2.skyhanni.utils.LorenzVec + +private typealias BossPhase = DungeonBossAPI.DungeonBossPhase + +enum class TerminalInfo(val location: LorenzVec, val phase: BossPhase, val text: String) { + P1_TERMINAL_1(LorenzVec(111, 113, 73), BossPhase.F7_GOLDOR_1, "Terminal"), + P1_TERMINAL_2(LorenzVec(111, 119, 79), BossPhase.F7_GOLDOR_1, "Terminal"), + P1_TERMINAL_3(LorenzVec(89, 112, 92), BossPhase.F7_GOLDOR_1, "Terminal"), + P1_TERMINAL_4(LorenzVec(89, 122, 101), BossPhase.F7_GOLDOR_1, "Terminal"), + P1_LEVER_1(LorenzVec(106, 124, 113), BossPhase.F7_GOLDOR_1, "Lever"), + P1_LEVER_2(LorenzVec(94, 124, 113), BossPhase.F7_GOLDOR_1, "Lever"), + P1_DEVICE(LorenzVec(110, 119, 93), BossPhase.F7_GOLDOR_1, "Device"), + + P2_TERMINAL_1(LorenzVec(68, 109, 121), BossPhase.F7_GOLDOR_2, "Terminal"), + P2_TERMINAL_2(LorenzVec(59, 120, 122), BossPhase.F7_GOLDOR_2, "Terminal"), + P2_TERMINAL_3(LorenzVec(47, 109, 121), BossPhase.F7_GOLDOR_2, "Terminal"), + P2_TERMINAL_4(LorenzVec(40, 124, 122), BossPhase.F7_GOLDOR_2, "Terminal"), + P2_TERMINAL_5(LorenzVec(39, 108, 143), BossPhase.F7_GOLDOR_2, "Terminal"), + P2_LEVER_1(LorenzVec(23, 132, 138), BossPhase.F7_GOLDOR_2, "Lever"), + P2_LEVER_2(LorenzVec(27, 124, 127), BossPhase.F7_GOLDOR_2, "Lever"), + P2_DEVICE(LorenzVec(60, 131, 142), BossPhase.F7_GOLDOR_2, "Device"), + + P3_TERMINAL_1(LorenzVec(-3, 109, 112), BossPhase.F7_GOLDOR_3, "Terminal"), + P3_TERMINAL_2(LorenzVec(-3, 119, 93), BossPhase.F7_GOLDOR_3, "Terminal"), + P3_TERMINAL_3(LorenzVec(19, 123, 93), BossPhase.F7_GOLDOR_3, "Terminal"), + P3_TERMINAL_4(LorenzVec(-3, 109, 77), BossPhase.F7_GOLDOR_3, "Terminal"), + P3_LEVER_1(LorenzVec(14, 122, 55), BossPhase.F7_GOLDOR_3, "Lever"), + P3_LEVER_2(LorenzVec(2, 122, 55), BossPhase.F7_GOLDOR_3, "Lever"), + P3_DEVICE(LorenzVec(-2, 119, 77), BossPhase.F7_GOLDOR_3, "Device"), + + P4_TERMINAL_1(LorenzVec(41, 109, 29), BossPhase.F7_GOLDOR_4, "Terminal"), + P4_TERMINAL_2(LorenzVec(44, 121, 29), BossPhase.F7_GOLDOR_4, "Terminal"), + P4_TERMINAL_3(LorenzVec(67, 109, 29), BossPhase.F7_GOLDOR_4, "Terminal"), + P4_TERMINAL_4(LorenzVec(72, 115, 48), BossPhase.F7_GOLDOR_4, "Terminal"), + P4_LEVER_1(LorenzVec(84, 121, 34), BossPhase.F7_GOLDOR_4, "Lever"), + P4_LEVER_2(LorenzVec(86, 128, 46), BossPhase.F7_GOLDOR_4, "Lever"), + P4_DEVICE(LorenzVec(63, 126, 35), BossPhase.F7_GOLDOR_4, "Device"), + ; + + var highlight: Boolean = true + + companion object { + fun resetTerminals() = entries.forEach { it.highlight = true } + + fun getClosestTerminal(input: LorenzVec): TerminalInfo? { + return entries.filter { it.highlight }.minByOrNull { it.location.distance(input) } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalWaypoints.kt new file mode 100644 index 000000000000..f8479507a402 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/floor7/TerminalWaypoints.kt @@ -0,0 +1,56 @@ +package at.hannibal2.skyhanni.features.dungeon.floor7 + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.features.dungeon.DungeonBossAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.player.EntityPlayerMP +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object TerminalWaypoints { + + private val config get() = SkyHanniMod.feature.dungeon + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + + for (term in TerminalInfo.entries) { + if (!term.highlight || !term.phase.isCurrent()) continue + event.drawWaypointFilled(term.location, LorenzColor.GREEN.toColor(), seeThroughBlocks = true) + event.drawDynamicText(term.location, term.text, 1.0) + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + TerminalInfo.resetTerminals() + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!inBoss()) return + + val playerName = DungeonBossAPI.goldorTerminalPattern.matchMatcher(event.message) { + group("playerName") + } ?: return + + val playerEntity = EntityUtils.getEntities().find { it.name == playerName } ?: return + val terminal = TerminalInfo.getClosestTerminal(playerEntity.getLorenzVec()) + terminal?.highlight = false + } + + private fun inBoss() = DungeonAPI.inBossRoom && DungeonAPI.isOneOf("F7", "M7") + + private fun isEnabled() = inBoss() && config.terminalWaypoints +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalQuickStart.kt b/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalQuickStart.kt index 2257772c8f3c..fe7a73d09053 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalQuickStart.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalQuickStart.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.event.carnival import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.events.EntityClickEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -34,7 +35,7 @@ object CarnivalQuickStart { private var lastChat = SimpleTimeMark.farPast() private var lastClicked = SimpleTimeMark.farPast() - @SubscribeEvent + @HandleEvent fun onEntityClick(event: EntityClickEvent) { if (!isEnabled()) return if (lastChat.passedSince() > 5.0.seconds) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalReminder.kt index d77861872d6d..024d1446451c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/carnival/CarnivalReminder.kt @@ -49,6 +49,7 @@ object CarnivalReminder { /** REGEX-TEST: §e[NPC] §aCarnival Leader§f: §rYou've already claimed your §aCarnival Tickets §ffor §btoday§f, but I'm happy to answer any questions you might have. */ + @Suppress("MaxLineLength") private val alreadyClaimedPattern by repoGroup.pattern( "already", "§e\\[NPC\\] §aCarnival Leader§f: §rYou've already claimed your §aCarnival Tickets §ffor §btoday§f, but I'm happy to answer any questions you might have.", diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt index 2f3d19c24cb5..3316d966d020 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.BurrowGuessEvent import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent @@ -57,7 +59,8 @@ object DianaFixChat { errorCounter++ if (errorCounter == 1) { if (successfulCounter < 5) { - ChatUtils.chat("Could not find Diana Guess using sound and particles, please try again. (Was this a funny sound easter egg?)") + ChatUtils.chat("Could not find Diana Guess using sound and particles, " + + "please try again. (Was this a funny sound easter egg?)") } return } @@ -102,7 +105,7 @@ object DianaFixChat { } } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.HUB) fun onItemClick(event: ItemClickEvent) { if (!isEnabled()) return if (event.clickType != ClickType.RIGHT_CLICK) return 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 fb90de9e118e..cd9f48b62c25 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 @@ -139,7 +139,9 @@ object DianaProfitTracker { tryHide(event) } - if (message == "§6§lRARE DROP! §r§eYou dug out a §r§9Griffin Feather§r§e!" || message == "§eFollow the arrows to find the §r§6treasure§r§e!") { + if (message == "§6§lRARE DROP! §r§eYou dug out a §r§9Griffin Feather§r§e!" || + message == "§eFollow the arrows to find the §r§6treasure§r§e!" + ) { BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() tryHide(event) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 57cc77df583e..64b33c93418f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -1,6 +1,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.EntityMovementData import at.hannibal2.skyhanni.data.IslandType @@ -358,7 +359,7 @@ object GriffinBurrowHelper { event.move(2, "diana", "event.diana") } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.HUB) fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index 80d6ea0e0df9..a082dfaac6b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -93,20 +93,25 @@ object GriffinBurrowParticleFinder { private enum class ParticleType(val check: S2APacketParticles.() -> Boolean) { EMPTY({ - particleType == net.minecraft.util.EnumParticleTypes.CRIT_MAGIC && particleCount == 4 && particleSpeed == 0.01f && xOffset == 0.5f && yOffset == 0.1f && zOffset == 0.5f + particleType == net.minecraft.util.EnumParticleTypes.CRIT_MAGIC && + particleCount == 4 && particleSpeed == 0.01f && xOffset == 0.5f && yOffset == 0.1f && zOffset == 0.5f }), MOB({ - particleType == net.minecraft.util.EnumParticleTypes.CRIT && particleCount == 3 && particleSpeed == 0.01f && xOffset == 0.5f && yOffset == 0.1f && zOffset == 0.5f + particleType == net.minecraft.util.EnumParticleTypes.CRIT && + particleCount == 3 && particleSpeed == 0.01f && xOffset == 0.5f && yOffset == 0.1f && zOffset == 0.5f }), TREASURE({ - particleType == net.minecraft.util.EnumParticleTypes.DRIP_LAVA && particleCount == 2 && particleSpeed == 0.01f && xOffset == 0.35f && yOffset == 0.1f && zOffset == 0.35f + particleType == net.minecraft.util.EnumParticleTypes.DRIP_LAVA && + particleCount == 2 && particleSpeed == 0.01f && xOffset == 0.35f && yOffset == 0.1f && zOffset == 0.35f }), FOOTSTEP({ - particleType == net.minecraft.util.EnumParticleTypes.FOOTSTEP && particleCount == 1 && particleSpeed == 0.0f && xOffset == 0.05f && yOffset == 0.0f && zOffset == 0.05f + particleType == net.minecraft.util.EnumParticleTypes.FOOTSTEP && + particleCount == 1 && particleSpeed == 0.0f && xOffset == 0.05f && yOffset == 0.0f && zOffset == 0.05f }), ENCHANT({ - particleType == net.minecraft.util.EnumParticleTypes.ENCHANTMENT_TABLE && particleCount == 5 && particleSpeed == 0.05f && xOffset == 0.5f && yOffset == 0.4f && zOffset == 0.5f + particleType == net.minecraft.util.EnumParticleTypes.ENCHANTMENT_TABLE && + particleCount == 5 && particleSpeed == 0.05f && xOffset == 0.5f && yOffset == 0.4f && zOffset == 0.5f }); companion object { @@ -165,7 +170,7 @@ object GriffinBurrowParticleFinder { return true } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.HUB) fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return if (!config.burrowsSoopyGuess) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 2d0e2a809e81..96f18ecd8ab4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -53,10 +53,20 @@ object InquisitorWaypointShare { /** * REGEX-TEST: §9Party §8> UserName§f: §rA MINOS INQUISITOR has spawned near [Foraging Island ] at Coords 1 2 3 */ + @Suppress("MaxLineLength") private val partyInquisitorCheckerPattern by patternGroup.pattern( "party.inquisitorchecker", "(?§9Party §8> )?(?.+)§f: §rA MINOS INQUISITOR has spawned near \\[(?.*)] at Coords (?[^ ]+) (?[^ ]+) (?[^ ]+)" ) + + /** + * REGEX-TEST: §9Party §8> §b[MVP§9+§b] _088§f: §rx: 86, y: 73, z: -29 I dug up an inquisitor come over here! + */ + private val odinPattern by patternGroup.pattern( + "party.odin", + "(?§9Party §8> )?(?.+)§f: §rx: (?[^ ]+), y: (?[^ ]+), z: (?[^ ]+) I dug up an inquisitor come over here!" + ) + private val diedPattern by patternGroup.pattern( "died", "(?§9Party §8> )?(?.*)§f: §rInquisitor dead!" @@ -237,6 +247,11 @@ object InquisitorWaypointShare { event.cancel() } } + odinPattern.matchMatcher(message) { + if (detectFromChat()) { + event.cancel() + } + } partyOnlyCoordsPattern.matchMatcher(message) { if (detectFromChat()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt index 35016eda3740..477371ec2107 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt @@ -136,6 +136,7 @@ object SoopyGuessBurrow { } } + @Suppress("MaxLineLength") private fun solveEquationThing(x: LorenzVec, y: LorenzVec): LorenzVec { val a = (-y.x * x.y * x.x - y.y * x.y * x.z + y.y * x.y * x.x + x.y * x.z * y.z + x.x * x.z * y.x - x.x * x.z * y.z) / (x.y * y.x - x.y * y.z + x.x * y.z - y.x * x.z + y.y * x.z - y.y * x.x) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index 6d201e57edcd..ead632ae6b0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -520,9 +520,9 @@ object HoppityCollectionStats { } // bugfix for some weird potential user errors (e.g. if users play on alpha and get rabbits) - fun clearSavedRabbits() { + fun resetSavedRabbits() { loggedRabbits.clear() - ChatUtils.chat("Cleared saved rabbit data.") + ChatUtils.chat("Reset saved rabbit data.") } fun hasFoundRabbit(rabbit: String): Boolean = loggedRabbits.containsKey(rabbit) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index bef61bfbf5db..92dbd9dcba8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -208,7 +208,7 @@ object HoppityEggLocator { lastParticlePosition = null } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onItemClick(event: ItemClickEvent) { if (!isEnabled()) return val item = event.itemInHand ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index 9b9276420efe..23f76c74d29f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -102,7 +102,8 @@ object HoppityEggsCompactChat { val showDupeRarity = rarityConfig.let { it == RarityType.BOTH || it == RarityType.DUPE } val timeStr = if (config.showDuplicateTime) ", §a+§b$timeFormatted§7" else "" - "$mealNameFormat! §7Duplicate ${if (showDupeRarity) "$lastRarity " else ""}$lastName$dupeNumberFormat §7(§6+$format Chocolate§7$timeStr)" + "$mealNameFormat! §7Duplicate ${if (showDupeRarity) "$lastRarity " else ""}" + + "$lastName$dupeNumberFormat §7(§6+$format Chocolate§7$timeStr)" } else if (newRabbit) { val showNewRarity = rarityConfig.let { it == RarityType.BOTH || it == RarityType.NEW } "$mealNameFormat! §d§lNEW ${if (showNewRarity) "$lastRarity " else ""}$lastName §7($lastProfit§7)" 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 4a536465c28f..41d5142d8ca4 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 @@ -205,7 +205,8 @@ object HoppityEventSummary { val parsedInt: Int? = if (it.size == 1) it[0].toIntOrNull() else null - val availableYearsFormat = "§eHoppity Event Stats are available for the following years:§r\n${statsYearFormatList.joinToString("§e, ") { it }}" + val availableYearsFormat = + "§eHoppity Event Stats are available for the following years:§r\n${statsYearFormatList.joinToString("§e, ") { it }}" if (parsedInt == null) { if (HoppityAPI.isHoppityEvent()) { 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 new file mode 100644 index 000000000000..47ab47a38240 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/NucleusBarriersBox.kt @@ -0,0 +1,81 @@ +package at.hannibal2.skyhanni.features.event.hoppity + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.features.misc.IslandAreas +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.drawFilledBoundingBox_nea +import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock +import net.minecraft.util.AxisAlignedBB +import net.minecraft.util.BlockPos +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object NucleusBarriersBox { + private val config get() = SkyHanniMod.feature.mining.crystalHighlighter + + private var inNucleus = false + + private enum class Crystal(val color: LorenzColor, val boundingBox: AxisAlignedBB) { + AMBER( + LorenzColor.GOLD, + AxisAlignedBB( + BlockPos(474.0, 124.0, 524.0), + BlockPos(485.0, 111.0, 535.0), + ).expandBlock(), + ), + AMETHYST( + LorenzColor.DARK_PURPLE, + AxisAlignedBB( + BlockPos(474.0, 124.0, 492.0), + BlockPos(485.0, 111.0, 503.0), + ).expandBlock(), + ), + TOPAZ( + LorenzColor.YELLOW, + AxisAlignedBB( + BlockPos(508.0, 124.0, 473.0), + BlockPos(519.0, 111.0, 484.0), + ).expandBlock(), + ), + JADE( + LorenzColor.GREEN, + AxisAlignedBB( + BlockPos(542.0, 124.0, 492.0), + BlockPos(553.0, 111.0, 503.0), + ).expandBlock(), + ), + SAPPHIRE( + LorenzColor.BLUE, + AxisAlignedBB( + BlockPos(542.0, 124.0, 524.0), + BlockPos(553.0, 111.0, 535.0), + ).expandBlock(), + ), + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + inNucleus = IslandAreas.currentAreaName == "Crystal Nucleus" + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + + Crystal.entries.forEach { crystal -> + event.drawFilledBoundingBox_nea( + crystal.boundingBox, + crystal.color.addOpacity(config.opacity), + renderRelativeToCamera = false, + ) + } + } + + private fun isEnabled() = + IslandType.CRYSTAL_HOLLOWS.isInIsland() && (HoppityAPI.isHoppityEvent() || !config.onlyDuringHoppity) && config.enabled && inNucleus +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt index 8250b023db10..7f0b208e7976 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt @@ -29,7 +29,10 @@ object EasterEggWaypoints { if (!isEnabled()) return val message = event.message - if (message.startsWith("§a§lYou found an Easter Egg! §r") || message == "§aYou have received the §bsuper reward§a!" || message == "§cYou already found this egg!") { + if (message.startsWith("§a§lYou found an Easter Egg! §r") || + message == "§aYou have received the §bsuper reward§a!" || + message == "§cYou already found this egg!" + ) { val egg = EasterEgg.entries.minByOrNull { it.waypoint.distanceSqToPlayer() }!! egg.found = true if (closest == egg) { 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 19e0399ad269..b39a26c4f54b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/ReminderUtils.kt @@ -11,7 +11,8 @@ object ReminderUtils { // TODO: add arachne fight, add slayer boss spawned, add dragon fight fun isBusy(ignoreFarmingContest: Boolean = false): Boolean = - (DungeonAPI.inDungeon() && !DungeonAPI.completed) || LorenzUtils.inKuudraFight || (FarmingContestAPI.inContest && !ignoreFarmingContest) || + (DungeonAPI.inDungeon() && !DungeonAPI.completed) || + LorenzUtils.inKuudraFight || (FarmingContestAPI.inContest && !ignoreFarmingContest) || RiftAPI.inRift() || IslandType.DARK_AUCTION.isInIsland() || IslandType.MINESHAFT.isInIsland() || IslandType.NONE.isInIsland() || IslandType.UNKNOWN.isInIsland() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt index 514d330a4bee..c25974292321 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt @@ -27,6 +27,8 @@ object ShowFishingItemName { private var itemsOnGround = TimeLimitedCache(750.milliseconds) // Taken from Skytils + // TODO? Move to repo + @Suppress("MaxLineLength") private val cheapCoins = setOf( "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM4MDcxNzIxY2M1YjRjZDQwNmNlNDMxYTEzZjg2MDgzYTg5NzNlMTA2NGQyZjg4OTc4Njk5MzBlZTZlNTIzNyJ9fX0=", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGZhMDg3ZWI3NmU3Njg3YTgxZTRlZjgxYTdlNjc3MjY0OTk5MGY2MTY3Y2ViMGY3NTBhNGM1ZGViNmM0ZmJhZCJ9fX0=", diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt index b84ee2970b0d..3ddb00d37050 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt @@ -26,6 +26,8 @@ import java.awt.Color object ThunderSparksHighlight { private val config get() = SkyHanniMod.feature.fishing.thunderSpark + // TODO: Move to repo + @Suppress("MaxLineLength") private const val TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTY0MzUwNDM3MjI1NiwKICAicHJvZmlsZUlkIiA6ICI2MzMyMDgwZTY3YTI0Y2MxYjE3ZGJhNzZmM2MwMGYxZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJUZWFtSHlkcmEiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2IzMzI4ZDNlOWQ3MTA0MjAzMjI1NTViMTcyMzkzMDdmMTIyNzBhZGY4MWJmNjNhZmM1MGZhYTA0YjVjMDZlMSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" private val sparks = mutableListOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GoldenFishTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GoldenFishTimer.kt index b7c67034feab..dd023a7fadf3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GoldenFishTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GoldenFishTimer.kt @@ -93,6 +93,8 @@ object GoldenFishTimer { handle() } + // TODO: Move to repo + @Suppress("MaxLineLength") private const val GOLDEN_FISH_SKULL_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTY0MzgzMTA2MDE5OCwKICAicHJvZmlsZUlkIiA6ICJiN2ZkYmU2N2NkMDA0NjgzYjlmYTllM2UxNzczODI1NCIsCiAgInByb2ZpbGVOYW1lIiA6ICJDVUNGTDE0IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEyMGNmM2MwYTQwZmM2N2UwZTVmZTBjNDZiMGFlNDA5YWM3MTAzMGE3NjU2ZGExN2IxMWVkMDAxNjQ1ODg4ZmUiCiAgICB9CiAgfQp9" private val goldenFishSkullItem by lazy { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt index 290c5427bb6e..9403120eb382 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -75,7 +75,8 @@ enum class CropType( if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM if (itemName == "Seeds") return WHEAT return entries.firstOrNull { - it.cropName.equals(itemName, ignoreCase = true) || it.simpleName.equals(itemName, ignoreCase = true) + it.cropName.equals(itemName, ignoreCase = true) || + it.simpleName.equals(itemName, ignoreCase = true) } } 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 55898266e440..a6331db11af9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -54,6 +54,7 @@ object FarmingFortuneDisplay { "collection", "§7You have §6\\+(?\\d{1,3})☘ .*", ) + @Suppress("MaxLineLength") private val tooltipFortunePattern by patternGroup.pattern( "tooltip.new", "^§7Farming Fortune: §a\\+(?[\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(?\\d+)\\))?(?: §d\\(\\+(?\\d+)\\))?\$", 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 4e80bdbea678..460b112540c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -189,12 +189,18 @@ object GardenAPI { addItemStack(crop.icon.copy(), highlight = highlight, scale = scale) } - fun hideExtraGuis() = ComposterOverlay.inInventory || AnitaMedalProfit.inInventory || - SkyMartCopperPrice.inInventory || FarmingContestAPI.inInventory || VisitorAPI.inInventory || - FFGuideGUI.isInGui() || ChocolateShopPrice.inInventory || ChocolateFactoryAPI.inChocolateFactory || - ChocolateFactoryAPI.chocolateFactoryPaused || HoppityCollectionStats.inInventory - - fun clearCropSpeed() { + fun hideExtraGuis() = ComposterOverlay.inInventory || + AnitaMedalProfit.inInventory || + SkyMartCopperPrice.inInventory || + FarmingContestAPI.inInventory || + VisitorAPI.inInventory || + FFGuideGUI.isInGui() || + ChocolateShopPrice.inInventory || + ChocolateFactoryAPI.inChocolateFactory || + ChocolateFactoryAPI.chocolateFactoryPaused || + HoppityCollectionStats.inInventory + + fun resetCropSpeed() { storage?.cropsPerSecond?.clear() GardenBestCropTime.reset() updateGardenTool() @@ -213,10 +219,8 @@ object GardenAPI { private var lastLocation: LorenzVec? = null - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.GARDEN) fun onBlockClick(event: BlockClickEvent) { - if (!inGarden()) return - val blockState = event.getBlockState val cropBroken = blockState.getCropType() ?: return if (cropBroken.multiplier == 1 && blockState.isBabyCrop()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index 127ee3f305a1..3c2ca657813d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -29,6 +29,7 @@ object GardenCropMilestoneFix { * REGEX-TEST: Cocoa Beans 31: §r§a68% * REGEX-TEST: Potato 32: §r§a97.7% */ + @Suppress("MaxLineLength") private val tabListPattern by patternGroup.pattern( "tablist", " (?Wheat|Carrot|Potato|Pumpkin|Sugar Cane|Melon|Cactus|Cocoa Beans|Mushroom|Nether Wart) (?\\d+): §r§a(?.*)%" 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 d0a386272a1c..1b201b5aa5af 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -565,7 +565,8 @@ object GardenNextJacobContest { newContests[timeMark + contestDuration] = FarmingContest(timeMark + contestDuration, crops) } } else { - ChatUtils.chat("This year's contests aren't available to fetch automatically yet, please load them from your calendar or wait 10 minutes.") + ChatUtils.chat("This year's contests aren't available to fetch automatically yet, " + + "please load them from your calendar or wait 10 minutes.") ChatUtils.clickableChat( "Click here to open your calendar!", onClick = { HypixelCommands.calendar() }, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt index 8700e49425be..54e37332a6a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt @@ -86,8 +86,10 @@ object ToolTooltipTweaks { val cropString = if (hiddenFortune != 0.0) " §6[+${hiddenFortune.roundToInt()}]" else "" val fortuneLine = when (config.cropTooltipFortune) { - CropTooltipFortuneEntry.DEFAULT -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString" - CropTooltipFortuneEntry.SHOW -> "§7Farming Fortune: §a+${displayedFortune.formatStat()}$ffdString$reforgeString$cropString" + CropTooltipFortuneEntry.DEFAULT -> "§7Farming Fortune: " + + "§a+${displayedFortune.formatStat()}$ffdString$reforgeString" + CropTooltipFortuneEntry.SHOW -> "§7Farming Fortune: " + + "§a+${displayedFortune.formatStat()}$ffdString$reforgeString$cropString" else -> "§7Farming Fortune: §a+${totalFortune.formatStat()}$ffdString$reforgeString$cropString" } iterator.set(fortuneLine) 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 87306744e4a8..81ae0c96ff85 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 @@ -160,7 +160,8 @@ object CropMoneyDisplay { } val bazaarData = internalName.getBazaarData() val price = - if (LorenzUtils.noTradeMode || bazaarData == null) internalName.getNpcPrice() / 160 else (bazaarData.instantBuyPrice + bazaarData.sellOfferPrice) / 320 + if (LorenzUtils.noTradeMode || bazaarData == null) internalName.getNpcPrice() / 160 + else (bazaarData.instantBuyPrice + bazaarData.sellOfferPrice) / 320 extraDicerCoins = 60 * 60 * GardenCropSpeed.getRecentBPS() * dicerDrops * price } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index 3da9945b59d9..640661bd9797 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -360,12 +360,9 @@ object FarmingWeightDisplay { ) } - private fun isEnabled() = ( - config.display && ( - OutsideSbFeature.FARMING_WEIGHT.isSelected() && !LorenzUtils.inSkyBlock - ) || - (LorenzUtils.inSkyBlock && (GardenAPI.inGarden() || config.showOutsideGarden)) - ) + private fun isEnabled() = config.display && (outsideEnabled() || inGardenEnabled()) + private fun outsideEnabled() = OutsideSbFeature.FARMING_WEIGHT.isSelected() && !LorenzUtils.inSkyBlock + private fun inGardenEnabled() = (LorenzUtils.inSkyBlock && GardenAPI.inGarden()) || config.showOutsideGarden private fun isEtaEnabled() = config.overtakeETA 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 e8b2d55e4310..f3701c61a5e9 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 @@ -387,6 +387,13 @@ object CaptureFarmingGear { } } + fun onResetGearCommand() { + val storage = GardenAPI.storage?.fortune ?: return + ChatUtils.chat("Resets farming items") + storage.farmingItems.clear() + storage.outdatedItems.clear() + } + @SubscribeEvent fun onConfigUpdaterMigratorConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(48, "#profile.garden.fortune.carrotFortune", "#profile.garden.fortune.carrolyn.CARROT") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index 3771dd112db7..8912bd4d1618 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -5,6 +5,8 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.CropPage import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.OverviewPage import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.UpgradePage +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.guide.GuideGUI import at.hannibal2.skyhanni.utils.guide.GuideTab import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -20,6 +22,15 @@ class FFGuideGUI : GuideGUI(FortuneGuidePage.OVERVI companion object { + @JvmStatic + fun onCommand() { + if (!LorenzUtils.inSkyBlock) { + ChatUtils.userError("Join SkyBlock to open the fortune guide!") + } else { + open() + } + } + fun isInGui() = Minecraft.getMinecraft().currentScreen is FFGuideGUI fun open() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt index 3ca75b1793b0..d4e3933ce074 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt @@ -29,9 +29,8 @@ object GardenPlotMenuHighlighting { val list = mutableListOf() val plot = GardenPlotAPI.plots.find { it.inventorySlot == slot.slotIndex } ?: continue - val (pestsEnabled, spraysEnabled, locksEnabled, currentEnabled, pastesEnabled) = PlotStatusType.entries.map { - it in config.deskPlotStatusTypes - } + val (pestsEnabled, spraysEnabled, locksEnabled, currentEnabled, pastesEnabled) = + PlotStatusType.entries.map { it in config.deskPlotStatusTypes } if (plot.pests >= 1 && pestsEnabled) list.add(PlotStatusType.PESTS) if (plot.currentSpray != null && spraysEnabled) list.add(PlotStatusType.SPRAYS) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt index 690592d52184..68c9e632376e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt @@ -123,7 +123,8 @@ object PestFinder { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEnabled()) return if (!config.showPlotInWorld) return - if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand() && (PestAPI.lastTimeVacuumHold.passedSince() > config.showBorderForSeconds.seconds)) return + if (config.onlyWithVacuum && !PestAPI.hasVacuumInHand() && + (PestAPI.lastTimeVacuumHold.passedSince() > config.showBorderForSeconds.seconds)) return val playerLocation = event.exactPlayerEyeLocation() val visibility = config.visibilityType diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt index ff9af9cff523..bd8636b9ff86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.garden.pests import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent @@ -33,7 +35,7 @@ object PestParticleLine { private var lastPestTrackerUse = SimpleTimeMark.farPast() private val locations = mutableListOf>() - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.GARDEN) fun onItemClick(event: ItemClickEvent) { if (!isEnabled()) return if (PestAPI.hasVacuumInHand()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt index 6056c054eac9..33c9dbea2f57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt @@ -48,7 +48,7 @@ object PestParticleWaypoint { private var isPointingToPest = false private var color: Color? = null - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.GARDEN) fun onItemClick(event: ItemClickEvent) { if (!isEnabled()) return if (PestAPI.hasVacuumInHand()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt index 8cafd5260a1a..1524084546dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt @@ -32,6 +32,7 @@ object GardenVisitorCompactChat { * REGEX-TEST: §7§8+§d1,241 Gemstone Powder * REGEX-TEST: §7§8+§2Crystal Hollows Pass */ + @Suppress("MaxLineLength") private val visitorRewardPattern by patternGroup.pattern( "visitorreward", "^ {4}(?:(?:§.)+\\+)?(?:(?§.)(?[\\d,]+(?:\\.?(?:\\d)?k)?)x? )?(?:(?(?:§.)+)?(?.*?))(?: (?:(?:§.)?)?x(?\\d+))?\$" diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 1d5907d85284..641ad717e403 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -582,7 +582,9 @@ object GardenVisitorFeatures { } } - if ((config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH) && entity is EntityLivingBase) { + if ((config.highlightStatus == HighlightMode.COLOR || config.highlightStatus == HighlightMode.BOTH) && + entity is EntityLivingBase + ) { val color = visitor.status.color if (color != -1) { RenderLivingEntityHelper.setEntityColor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLines.kt similarity index 96% rename from src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsManager.kt rename to src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLines.kt index c4f6498498a4..bae687e9c827 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStatsLines.kt @@ -26,10 +26,10 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardEl private val hideEmptyLines get() = informationFilteringConfig.hideEmptyLines -enum class ChunkedStatsManager( +enum class ChunkedStatsLines( private val displayPair: () -> String, - val showWhen: () -> Boolean, - val showIsland: () -> Boolean, + private val showWhen: () -> Boolean, + private val showIsland: () -> Boolean, private val configLine: String, ) { PURSE( @@ -92,7 +92,7 @@ enum class ChunkedStatsManager( companion object { - private var currentIslandStats = listOf() + private var currentIslandStats = listOf() fun getChunkedStats() = buildList { currentIslandStats.forEach { stat -> 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 8f6f7f8ac12d..26ca6f143091 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 @@ -238,7 +238,7 @@ object CustomScoreboard { add("Custom Scoreboard disabled.") } else { add("Custom Scoreboard Lines:") - ScoreboardEntry.entries.forEach { entry -> + ScoreboardConfigElement.entries.forEach { entry -> add( " ${entry.name.firstLetterUppercase()} - " + "island: ${entry.element.showIsland()} - " + @@ -246,7 +246,7 @@ object CustomScoreboard { "${entry.element.getLines().map { it.display }}", ) } - allUnknownLines.toSet().takeIfNotEmpty()?.let { set -> + allUnknownLines.takeIfNotEmpty()?.let { set -> add("Recent Unknown Lines:") set.forEach { add(" ${it.line}") } } @@ -254,6 +254,15 @@ object CustomScoreboard { } } + @JvmStatic + fun resetAppearance() { + with(config.scoreboardEntries) { + get().clear() + get().addAll(ScoreboardConfigElement.defaultOption) + notifyObservers() + } + } + private fun isEnabled() = (LorenzUtils.inSkyBlock || (OutsideSbFeature.CUSTOM_SCOREBOARD.isSelected() && LorenzUtils.onHypixel)) && config.enabled.get() diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardConfigFix.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardConfigFix.kt index f181aed1e6c4..f6dfb1d69446 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardConfigFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardConfigFix.kt @@ -53,12 +53,12 @@ object CustomScoreboardConfigFix { event.transform(37, EVENT_ENTRIES_KEY) { it.asJsonArray.apply { - add(JsonPrimitive(ScoreboardEventEntry.QUEUE.name)) + add(JsonPrimitive(ScoreboardConfigEventElement.QUEUE.name)) } } event.transform(40, EVENT_ENTRIES_KEY) { element -> - replaceElements(element, listOf("HOT_DOG_CONTEST", "EFFIGIES"), ScoreboardEventEntry.RIFT.name) + replaceElements(element, listOf("HOT_DOG_CONTEST", "EFFIGIES"), ScoreboardConfigEventElement.RIFT.name) } event.move(43, "$ALIGNMENT_KEY.alignRight", "$ALIGNMENT_KEY.horizontalAlignment") { @@ -76,14 +76,14 @@ object CustomScoreboardConfigFix { event.transform(50, EVENT_ENTRIES_KEY) { it.asJsonArray.apply { - add(JsonPrimitive(ScoreboardEventEntry.ANNIVERSARY.name)) - add(JsonPrimitive(ScoreboardEventEntry.CARNIVAL.name)) + add(JsonPrimitive(ScoreboardConfigEventElement.ANNIVERSARY.name)) + add(JsonPrimitive(ScoreboardConfigEventElement.CARNIVAL.name)) } } event.transform(51, EVENT_ENTRIES_KEY) { it.asJsonArray.apply { - add(JsonPrimitive(ScoreboardEventEntry.NEW_YEAR.name)) + add(JsonPrimitive(ScoreboardConfigEventElement.NEW_YEAR.name)) } } @@ -92,7 +92,7 @@ object CustomScoreboardConfigFix { } event.transform(58, EVENT_ENTRIES_KEY) { element -> - replaceElements(element, listOf("GARDEN_CLEAN_UP", "GARDEN_PASTING"), ScoreboardEventEntry.GARDEN.name) + replaceElements(element, listOf("GARDEN_CLEAN_UP", "GARDEN_PASTING"), ScoreboardConfigEventElement.GARDEN.name) } listOf("customTitle", "customFooter").forEach { key -> event.transform(58, "$TITLE_AND_FOOTER_KEY.$key") { diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEntry.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt similarity index 97% rename from src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEntry.kt rename to src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt index 96524b791ed7..4d8e94b7a7ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEntry.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigElement.kt @@ -27,7 +27,6 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardEl import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementProfile import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementPurse import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementQuiver -import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElement import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementSlayer import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementSoulflow import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementTime @@ -36,7 +35,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardEl import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementUnknown import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementVisiting -enum class ScoreboardEntry(val element: ScoreboardElement) { +enum class ScoreboardConfigElement(val element: ScoreboardElement) { TITLE(ScoreboardElementTitle), PROFILE(ScoreboardElementProfile), PURSE(ScoreboardElementPurse), diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEventEntry.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigEventElement.kt similarity index 97% rename from src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEventEntry.kt rename to src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigEventElement.kt index 7838ccd59f00..aff6013465aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEventEntry.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardConfigEventElement.kt @@ -30,13 +30,13 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.events.ScoreboardEven /** * This enum contains all the lines that either are events or other lines that are so rare/not often seen that they - * don't fit in the normal [ScoreboardEntry] enum. + * don't fit in the normal [ScoreboardConfigElement] enum. * * We for example have the [ScoreboardEventVoting] Event, while this is clearly not an event, I don't consider them as normal lines * because they are visible for a maximum of like 1 minute every 5 days and ~12 hours. */ -enum class ScoreboardEventEntry(val event: ScoreboardEvent) { +enum class ScoreboardConfigEventElement(val event: ScoreboardEvent) { VOTING(ScoreboardEventVoting), SERVER_CLOSE(ScoreboardEventServerClose), DUNGEONS(ScoreboardEventDungeons), diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt index 085f1e3660f3..cf08642172d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt @@ -123,6 +123,7 @@ object ScoreboardPattern { "solo", "§3§lSolo", ) + @Suppress("MaxLineLength") val teammatesPattern by dungeonSb.pattern( "teammates", "(?:§.)*(?\\[\\w]) (?:§.)*(?\\w{2,16}) ((?:§.)*(?\\[Lvl?(?[\\w,.]+)?]?)|(?:§.)*(?[\\w,.]+)(?:§.)*.?)", 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 c8e60adc929e..a91d8c5e8a71 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 @@ -256,6 +256,7 @@ object UnknownLinesHandler { } private fun warn(line: String, reason: String) { + if (!CustomScoreboard.config.unknownLinesWarning) return ErrorManager.logErrorWithData( // line included in chat message to not cache a previous message Exception(line), diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementChunkedStats.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementChunkedStats.kt index 4ff72752cd96..e30274fd9f4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementChunkedStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementChunkedStats.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard.elements -import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsManager.Companion.getChunkedStats -import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsManager.Companion.shouldShowChunkedStats -import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsManager.Companion.showChunkedStatsIsland +import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.getChunkedStats +import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.shouldShowChunkedStats +import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.showChunkedStatsIsland import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.chunkedConfig // internal, widget and scoreboard diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementParty.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementParty.kt index 3c524d389f78..81c584cb0ec3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementParty.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/elements/ScoreboardElementParty.kt @@ -17,7 +17,7 @@ object ScoreboardElementParty : ScoreboardElement() { if (partyConfig.showPartyLeader) PartyAPI.partyLeader?.let { leader -> add(" §7- §f$leader §e♚") } PartyAPI.partyMembers - .take(partyConfig.maxPartyList) + .take(partyConfig.maxPartyList.get()) .apply { if (partyConfig.showPartyLeader) remove(PartyAPI.partyLeader) } .forEach { add(" §7- §f$it") 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 f8a16bf50b0b..8af1fe056829 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -563,7 +563,8 @@ object HideNotClickableItems { val bazaarInventory = BazaarApi.inBazaarInventory val auctionHouseInventory = - chestName == "Co-op Auction House" || chestName == "Auction House" || chestName == "Create BIN Auction" || chestName == "Create Auction" + chestName == "Co-op Auction House" || chestName == "Auction House" || + chestName == "Create BIN Auction" || chestName == "Create Auction" if (!bazaarInventory && !auctionHouseInventory) return false showGreenLine = true 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 40eb8c4b335b..0184e5265794 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -298,10 +298,8 @@ object ItemDisplayOverlayFeatures { } } - if (BESTIARY_LEVEL.isSelected() && (chestName.contains("Bestiary ➜") || chestName.contains("Fishing ➜")) && - lore.any { - it.contains("Deaths: ") - } + if (BESTIARY_LEVEL.isSelected() && (chestName.contains("Bestiary ➜") || + chestName.contains("Fishing ➜")) && lore.any { it.contains("Deaths: ") } ) { lore.matchFirst(bestiaryStackPattern) { val tier = (group("tier").romanToDecimalIfNecessary() - 1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt index c95950a85dcd..35e14f898660 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt @@ -175,9 +175,8 @@ class SkyblockGuideHighlightFeature private constructor( "travel", "Core ➜ Fast Travels Unlocked", taskOnlyCompleteOncePattern, - { - HypixelCommands.wiki("MUSEUM_TRAVEL_SCROLL") - }, // The items do not have proper internal names and using the fact that all travel scrolls lead to the same wiki page + // The items do not have proper internal names and using the fact that all travel scrolls lead to the same wiki page + { HypixelCommands.wiki("MUSEUM_TRAVEL_SCROLL") }, openWikiTooltip ) SkyblockGuideHighlightFeature( @@ -252,6 +251,7 @@ class SkyblockGuideHighlightFeature private constructor( SkyblockGuideHighlightFeature( { skyblockGuideConfig.menuGuide }, "tasks.skill", "Skill Related Tasks", categoryProgressPattern ) + @Suppress("MaxLineLength") SkyblockGuideHighlightFeature( { skyblockGuideConfig.collectionGuide }, "collections", 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 bb4eeaedb20c..9c890aa56dc3 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 @@ -104,6 +104,7 @@ object ChocolateFactoryStrayTracker { /** * REGEX-TEST: §7You caught a stray §9Fish the Rabbit§7! §7You have already found §9Fish the §9Rabbit§7, so you received §655,935,257 §6Chocolate§7! */ + @Suppress("MaxLineLength") private val fishTheRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern( "stray.fish", "§7You caught a stray (?§.)Fish the Rabbit§7! §7You have already found (?:§.)?Fish the (?:§.)?Rabbit§7, so you received §6(?[\\d,]*) (?:§6)?Chocolate§7!", diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentationTableAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentationTableAPI.kt index 4965a988324e..be0f08a5bafc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentationTableAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentationTableAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.inventory.experimentationtable import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -169,8 +170,10 @@ object ExperimentationTableAPI { * REGEX-TEST: §dGuardian * REGEX-TEST: §9Guardian§e */ - val petNamePattern by patternGroup.pattern( + private val petNamePattern by patternGroup.pattern( "guardianpet", "§[956d]Guardian.*", ) + + fun hasGuardianPet(): Boolean = petNamePattern.matches(PetAPI.currentPet) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt index ac1e8105ef25..79f0304f433f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.inventory.experimentationtable import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ItemAddManager @@ -164,7 +165,7 @@ object ExperimentsProfitTracker { } } - @SubscribeEvent + @HandleEvent fun onItemClick(event: ItemClickEvent) { if (isEnabled() && event.clickType == ClickType.RIGHT_CLICK) { val item = event.itemInHand ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/GuardianReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/GuardianReminder.kt index 32157adf7ebe..03748c5d5d5a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/GuardianReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/GuardianReminder.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.features.inventory.experimentationtable import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -12,7 +11,6 @@ import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils @@ -31,7 +29,6 @@ object GuardianReminder { private val config get() = SkyHanniMod.feature.inventory.experimentationTable private var lastInventoryOpen = SimpleTimeMark.farPast() - private var lastWarn = SimpleTimeMark.farPast() private var lastErrorSound = SimpleTimeMark.farPast() @SubscribeEvent @@ -44,10 +41,7 @@ object GuardianReminder { } private fun warn() { - if (ExperimentationTableAPI.petNamePattern.matches(PetAPI.currentPet)) return - - if (lastWarn.passedSince() < 5.seconds) return - lastWarn = SimpleTimeMark.now() + if (ExperimentationTableAPI.hasGuardianPet()) return ChatUtils.clickToActionOrDisable( "Use a §9§lGuardian Pet §efor more Exp in the Experimentation Table.", @@ -62,6 +56,7 @@ object GuardianReminder { if (!isEnabled()) return if (InventoryUtils.openInventoryName() != "Experimentation Table") return if (lastInventoryOpen.passedSince() > 2.seconds) return + if (ExperimentationTableAPI.hasGuardianPet()) return val gui = Minecraft.getMinecraft().currentScreen as? GuiContainer ?: return sendTitle(gui.width, gui.height) 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 81477957e4cd..5923433d1b36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.itemabilities import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.itemability.FireVeilWandConfig.DisplayEntry import at.hannibal2.skyhanni.data.ClickType @@ -39,9 +40,8 @@ object FireVeilWandParticles { } } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onItemClick(event: ItemClickEvent) { - if (!LorenzUtils.inSkyBlock) return if (event.clickType != ClickType.RIGHT_CLICK) return val internalName = event.itemInHand?.getInternalName() diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt index 68f9798c309b..6bc24f055ada 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt @@ -52,6 +52,8 @@ enum class ItemAbility( ROYAL_PIGEON(5), WAND_OF_STRENGTH(10), TACTICAL_INSERTION(20), + TOTEM_OF_CORRUPTION(20), + ENRAGER(20), // doesn't have a sound ENDER_BOW("Ender Warp", 5, "Ender Bow"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index 7715f7456055..fb15bd703a44 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ActionBarUpdateEvent import at.hannibal2.skyhanni.events.ItemClickEvent @@ -54,12 +55,14 @@ object ItemAbilityCooldown { private var lastAbility = "" private var items = mapOf>() private var abilityItems = mapOf>() + private val recentItemsInHand = InventoryUtils.recentItemsInHand.values private val WEIRD_TUBA = "WEIRD_TUBA".asInternalName() private val WEIRDER_TUBA = "WEIRDER_TUBA".asInternalName() private val VOODOO_DOLL_WILTED = "VOODOO_DOLL_WILTED".asInternalName() private val WARNING_FLARE = "WARNING_FLARE".asInternalName() private val ALERT_FLARE = "ALERT_FLARE".asInternalName() private val SOS_FLARE = "SOS_FLARE".asInternalName() + private val TOTEM_OF_CORRUPTION = "TOTEM_OF_CORRUPTION".asInternalName() @SubscribeEvent @@ -191,20 +194,30 @@ object ItemAbilityCooldown { event.soundName == "mob.zombie.remedy" && event.pitch == 1.8888888f && event.volume == 0.7f -> { ItemAbility.TACTICAL_INSERTION.activate(null, 17_000) } + // Totem of Corruption + event.soundName == "random.wood_click" && event.pitch == 0.84126985f && event.volume == 0.5f -> { + if (TOTEM_OF_CORRUPTION in recentItemsInHand) { + ItemAbility.TOTEM_OF_CORRUPTION.sound() + } + } + // Enrager + event.soundName == "mob.enderdragon.growl" && event.pitch == 0.4920635f && event.volume == 2.0f -> { + ItemAbility.ENRAGER.sound() + } + // Blaze Slayer Flares event.soundName == "fireworks.launch" && event.pitch == 1.0f && event.volume == 3.0f -> { - val recent = InventoryUtils.recentItemsInHand.values - if (WARNING_FLARE in recent || ALERT_FLARE in recent) { + if (WARNING_FLARE in recentItemsInHand || ALERT_FLARE in recentItemsInHand) { ItemAbility.ALERT_FLARE.sound() } - if (SOS_FLARE in recent) { + if (SOS_FLARE in recentItemsInHand) { ItemAbility.SOS_FLARE.sound() } } } } - @SubscribeEvent + @HandleEvent fun onItemClick(event: ItemClickEvent) { if (AshfangFreezeCooldown.isCurrentlyFrozen()) return handleItemClick(event.itemInHand) 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 a1d8f43a8d5b..68fc72669070 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt @@ -97,7 +97,8 @@ object DeepCavernsGuide { if (it.displayName != "§aObsidian Sanctuary") { if (!show) { start() - ChatUtils.chat("Automatically enabling Deep Caverns Guide, helping you find the way to the bottom of the Deep Caverns and the path to Rhys.") + ChatUtils.chat("Automatically enabling Deep Caverns Guide, " + + "helping you find the way to the bottom of the Deep Caverns and the path to Rhys.") } } } 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 0012ed8b0ef8..2d7487ddcb15 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.mining import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.model.Graph @@ -484,7 +485,7 @@ object TunnelsMaps { nextSpotKey(event) } - @SubscribeEvent + @HandleEvent fun onItemClick(event: ItemClickEvent) { if (!isEnabled() || !config.leftClickPigeon) return if (event.clickType != ClickType.LEFT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt index 15d46c0466a3..f11838683909 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt @@ -22,6 +22,7 @@ enum class MiningEventType( val eventName: String, private val shortName: String, val defaultLength: Duration, + // TODO change to LorenzColor private val colorCode: Char, val dwarvenSpecific: Boolean, iconInput: Renderable, @@ -68,14 +69,18 @@ enum class MiningEventType( }, ), + + @Suppress("MaxLineLength") GOBLIN_RAID( "GOBLIN RAID", "Raid", 5.minutes, 'c', true, - ItemUtils.createSkull( + ItemUtils.createSkull( // TODO: Move skull texture to repo "Goblin", "32518c29-6127-3c71-b2a7-be4c3251e76f", "ewogICJ0aW1lc3RhbXAiIDogMTYwNzQ2NDg4MTMwOCwKICAicHJvZmlsZUlkIiA6ICJhMmY4MzQ1OTVjODk0YTI3YWRkMzA0OTcxNmNhOTEwYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJiUHVuY2giLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTcyODUwOTA2YjdmMGQ5NTJjMGU1MDgwNzNjYzQzOWZkMzM3NGNjZjViODg5YzA2ZjdlOGQ5MGNjMGNjMjU1YyIKICAgIH0KICB9Cn0=", ), ), + + @Suppress("MaxLineLength") BETTER_TOGETHER( "BETTER TOGETHER", "Better", 18.minutes, 'd', false, object : Renderable { @@ -86,7 +91,7 @@ enum class MiningEventType( val steveHead = Renderable.itemStack(Items.skull.toItemStack(3), 0.36) val alexHead = Renderable.itemStack( - ItemUtils.createSkull( + ItemUtils.createSkull( // TODO: Move skull texture to repo "Alex", "6ab43178-89fd-4905-97f6-0f67d9d76fd9", "fRBfVNlIWW6cL478st/8NsNEHVxjvwQDp4+MbKbFj1tPZvxXgpIXRaQsLeDl/0+E4tipPKNANAbmqj9EKAVx3b3gDqLLrTTk/NfuH2RD3I5ppzio8w5oYk1022SopaayGBP4+kuwktDHzlR8IgAUb1RiavldKp+TGRdCbqw8vHHBm9pnuOePzTOOADQgdanRj98bOcfIXe69tSS/VHxDe9tkpYFPkQR8zsJcjUxf+nS83iFU9CW9lKtQlyoU6/BPbHFILvcR1KDR5Imj7GJe2OJefghI6OqtHNZP2tzkia2IDU0Yc4ikwC+7yN3i6I3Do4G3gTtCZVfNXiSdFyU9nCMyBxggTaG9zaljZpN0BynG4FzYMujIVgeNa6FLqwoaFT0iELW2w9JgJFgyVlaDKEqMSGyxgqtcQMPBuvCwMFFjeFd2EhtfTjQ4hcpva+NXXoYPP7yfTk/0DErNZV2dUTasekar8lH6U58B7ECNxDUwcon4z7sSO5mdlPJoiT7zllgpwQn5NUPaxZxaKkGdUIFEGzjmBfnCmk6MOqzi05Rr18wnkdic9hz/fIzzTMhn9mbMG6VF9eBkE4mNu1K5jai6II5Mz9BV49U0ZcA874N1VHpJpQE6762TYv+u7ICTRIOf2LD9wEgu3py/nX+IHma5j22ClUtXH3hYdZmHg+s=\",Value:\"ewogICJ0aW1lc3RhbXAiIDogMTcxMTY1OTI2NDg1NSwKICAicHJvZmlsZUlkIiA6ICI2YWI0MzE3ODg5ZmQ0OTA1OTdmNjBmNjdkOWQ3NmZkOSIsCiAgInByb2ZpbGVOYW1lIiA6ICJNSEZfQWxleCIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84M2NlZTVjYTZhZmNkYjE3MTI4NWFhMDBlODA0OWMyOTdiMmRiZWJhMGVmYjhmZjk3MGE1Njc3YTFiNjQ0MDMyIiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0=", @@ -108,17 +113,24 @@ enum class MiningEventType( "RAFFLE", "Raffle", 160.seconds, - '6', - true, - Items.name_tag.toItemStack().overrideId("MINING_RAFFLE_TICKET"), + colorCode = '6', + dwarvenSpecific = true, + iconInput = Items.name_tag.toItemStack().overrideId("MINING_RAFFLE_TICKET"), + ), + MITHRIL_GOURMAND( + "MITHRIL GOURMAND", + "Gourmand", 10.minutes, + colorCode = 'b', + dwarvenSpecific = true, + iconInput = Items.dye.toItemStack(6).overrideId("MITHRIL_GOURMAND") ), - MITHRIL_GOURMAND("MITHRIL GOURMAND", "Gourmand", 10.minutes, 'b', true, Items.dye.toItemStack(6).overrideId("MITHRIL_GOURMAND")), ; constructor( eventName: String, shortName: String, defaultLength: Duration, + // TODO change to LorenzColor colorCode: Char, dwarvenSpecific: Boolean, iconInput: ItemStack, diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseTracker.kt index bc5e324401bb..cb2c3cfe487f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseTracker.kt @@ -147,5 +147,8 @@ object CorpseTracker { } fun isEnabled() = - LorenzUtils.inSkyBlock && config.enabled && (IslandType.MINESHAFT.isInIsland() || (!config.onlyInMineshaft && MiningAPI.inGlacialTunnels())) + LorenzUtils.inSkyBlock && config.enabled && ( + IslandType.MINESHAFT.isInIsland() || + (!config.onlyInMineshaft && MiningAPI.inGlacialTunnels()) + ) } 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 c7d7bb5042e6..a9dc3dce34df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.minion import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.ClickType @@ -121,7 +122,7 @@ object MinionFeatures { } } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onEntityClick(event: EntityClickEvent) { if (!enableWithHub()) return if (event.clickType != ClickType.RIGHT_CLICK) return @@ -129,7 +130,7 @@ object MinionFeatures { lastClickedEntity = event.clickedEntity?.getLorenzVec() ?: return } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onBlockClick(event: BlockClickEvent) { if (!enableWithHub()) return if (event.clickType != ClickType.RIGHT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt index 7efce2fcdae5..b43625ed2769 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CarryTracker.kt @@ -276,7 +276,8 @@ object CarryTracker { ), onClick = { HypixelCommands.partyChat( - "$customerName Carry: already paid: ${paidFormat.removeColor()}, " + "still missing: ${missingFormat.removeColor()}", + "$customerName Carry: already paid: ${paidFormat.removeColor()}, " + + "still missing: ${missingFormat.removeColor()}", ) }, ), diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt index d12953b98006..8a47da6f72e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt @@ -41,6 +41,7 @@ object HideFarEntities { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && (!(GardenAPI.inGarden() && config.excludeGarden) && !(DungeonAPI.inDungeon() && config.excludeDungeon)) + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && + (!(GardenAPI.inGarden() && config.excludeGarden) && !(DungeonAPI.inDungeon() && config.excludeDungeon)) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt index 36bfb3fb78aa..c07ab7de45fc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt @@ -19,6 +19,8 @@ object LesserOrbHider { private val config get() = SkyHanniMod.feature.misc private val hiddenEntities = CollectionUtils.weakReferenceList() + // TODO: Move to repo + @Suppress("MaxLineLength") private const val LESSER_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjgzMjM2NjM5NjA3MDM2YzFiYTM5MWMyYjQ2YTljN2IwZWZkNzYwYzhiZmEyOTk2YTYwNTU1ODJiNGRhNSJ9fX0=" 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 83f45e535d5c..8fcc8fd8779d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -96,6 +96,7 @@ object NonGodPotEffectDisplay { // todo : cleanup and add support for poison candy I, and add support for splash / other formats @SubscribeEvent + @Suppress("MaxLineLength") fun onChat(event: LorenzChatEvent) { if (event.message == "§aYou cleared all of your active effects!") { effectDuration.clear() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt index 990f1a8b74e9..c9ad14620610 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt @@ -25,12 +25,16 @@ object ParticleHider { } val type = event.type - if (SkyHanniMod.feature.misc.particleHiders.hideCloseRedstoneParticles && type == EnumParticleTypes.REDSTONE && distanceToPlayer < 2) { + if (SkyHanniMod.feature.misc.particleHiders.hideCloseRedstoneParticles && + type == EnumParticleTypes.REDSTONE && distanceToPlayer < 2 + ) { event.cancel() return } - if (SkyHanniMod.feature.misc.particleHiders.hideFireballParticles && (type == EnumParticleTypes.SMOKE_NORMAL || type == EnumParticleTypes.SMOKE_LARGE)) { + if (SkyHanniMod.feature.misc.particleHiders.hideFireballParticles && + (type == EnumParticleTypes.SMOKE_NORMAL || type == EnumParticleTypes.SMOKE_LARGE) + ) { for (entity in EntityUtils.getEntities()) { val distance = entity.getLorenzVec().distance(event.location) if (distance < 5) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt index 093c7d80ed3c..ca735ce2c8ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt @@ -1,23 +1,21 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.WorldClickEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull -import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object PrivateIslandNoPickaxeAbility { private val config get() = SkyHanniMod.feature.mining - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.PRIVATE_ISLAND) fun onClick(event: WorldClickEvent) { - if (!IslandType.PRIVATE_ISLAND.isInIsland()) return if (!config.privateIslandNoPickaxeAbility) return if (event.clickType != ClickType.RIGHT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 0463257496f0..8b6697a41af8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.misc.EstimatedItemValueConfig import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -39,7 +40,7 @@ import kotlin.math.roundToLong @SkyHanniModule object EstimatedItemValue { - val config get() = SkyHanniMod.feature.inventory.estimatedItemValues + val config: EstimatedItemValueConfig get() = SkyHanniMod.feature.inventory.estimatedItemValues private var display = emptyList>() private val cache = mutableMapOf>>() private var lastToolTipTime = 0L @@ -90,13 +91,14 @@ object EstimatedItemValue { currentlyShowing = checkCurrentlyVisible() if (!currentlyShowing) return - // TODO add "is debug enabled" check once users notice this easteregg - if (Keyboard.KEY_RIGHT.isKeyClicked()) { - EstimatedItemValueCalculator.starChange += 1 - cache.clear() - } else if (Keyboard.KEY_LEFT.isKeyClicked()) { - EstimatedItemValueCalculator.starChange -= 1 - cache.clear() + if (SkyHanniMod.feature.dev.debug.enabled) { + if (Keyboard.KEY_RIGHT.isKeyClicked()) { + EstimatedItemValueCalculator.starChange += 1 + cache.clear() + } else if (Keyboard.KEY_LEFT.isKeyClicked()) { + EstimatedItemValueCalculator.starChange -= 1 + cache.clear() + } } config.itemPriceDataPos.renderStringsAndItems(display, posLabel = "Estimated Item Value") 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 fb1ce6b4488f..15c55e02e7fc 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 @@ -72,6 +72,7 @@ object EstimatedItemValueCalculator { private val kuudraSets = listOf("AURORA", "CRIMSON", "TERROR", "HOLLOW", "FERVOR") var starChange = 0 + get() = if (SkyHanniMod.feature.dev.debug.enabled) field else 0 private val additionalCostFunctions = listOf( ::addAttributeCost, @@ -449,7 +450,7 @@ object EstimatedItemValueCalculator { var totalStars = stack.getDungeonStarCount() ?: stack.getStarCount() ?: 0 starChange.takeIf { it != 0 }?.let { - list.add("change: $it") + list.add("[Debug] added stars: $it") totalStars += it } 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 84d86615da3d..9f2d2ac595d4 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 @@ -68,7 +68,10 @@ class GuiOptionEditorUpdateCheck(option: ProcessedOption) : GuiOptionEditor(opti override fun mouseInput(x: Int, y: Int, width: Int, mouseX: Int, mouseY: Int): Boolean { val width = width - 20 - if (Mouse.getEventButtonState() && (mouseX - getButtonPosition(width) - x) in (0..button.width) && (mouseY - 10 - y) in (0..button.height)) { + if (Mouse.getEventButtonState() && + (mouseX - getButtonPosition(width) - x) in (0..button.width) && + (mouseY - 10 - y) in (0..button.height) + ) { when (UpdateManager.updateState) { UpdateManager.UpdateState.AVAILABLE -> UpdateManager.queueUpdate() UpdateManager.UpdateState.QUEUED -> {} 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 9948d5eeb973..1f9b2e66ffa7 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 @@ -174,4 +174,28 @@ object UpdateManager { } private var potentialUpdate: PotentialUpdate? = null + + fun updateCommand(args: Array) { + val currentStream = SkyHanniMod.feature.about.updateStream.get() + val arg = args.firstOrNull() ?: "current" + val updateStream = when { + arg.equals("(?i)(?:full|release)s?".toRegex()) -> UpdateStream.RELEASES + arg.equals("(?i)(?:beta|latest)s?".toRegex()) -> UpdateStream.BETA + else -> currentStream + } + + val switchingToBeta = updateStream == UpdateStream.BETA && (currentStream != UpdateStream.BETA || !UpdateManager.isCurrentlyBeta()) + if (switchingToBeta) { + ChatUtils.clickableChat( + "Are you sure you want to switch to beta? These versions may be less stable.", + onClick = { + UpdateManager.checkUpdate(true, updateStream) + }, + "§eClick to confirm!", + oneTimeClick = true, + ) + } else { + UpdateManager.checkUpdate(true, updateStream) + } + } } 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 b8de2eca6bd9..fb2f72bed4a6 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 @@ -4,10 +4,12 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.GuiRenderUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.KeyboardManager +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SoundUtils @@ -63,6 +65,16 @@ open class VisualWordGui : GuiScreen() { companion object { + @JvmStatic + fun onCommand() { + if (!LorenzUtils.onHypixel) { + ChatUtils.userError("You need to join Hypixel to use this feature!") + } else { + if (sbeConfigPath.exists()) drawImport = true + SkyHanniMod.screenToOpen = VisualWordGui() + } + } + fun isInGui() = Minecraft.getMinecraft().currentScreen is VisualWordGui var sbeConfigPath = File("." + File.separator + "config" + File.separator + "SkyblockExtras.cfg") var drawImport = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt deleted file mode 100644 index 9c152e1432dd..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt +++ /dev/null @@ -1,124 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.ashfang - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy -import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import net.minecraft.entity.EntityLivingBase -import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.entity.monster.EntityBlaze -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -@SkyHanniModule -object AshfangBlazes { - - private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang - - private val blazeColor = mutableMapOf() - private var blazeArmorStand = mapOf() - - private var nearAshfang = false - - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!isEnabled()) return - - checkNearAshfang() - - if (nearAshfang) { - for (entity in EntityUtils.getEntities() - .filter { it !in blazeColor.keys }) { - val list = entity.getAllNameTagsWith(2, "Ashfang") - if (list.size == 1) { - val armorStand = list[0] - val color = when { - armorStand.name.contains("Ashfang Follower") -> LorenzColor.DARK_GRAY - armorStand.name.contains("Ashfang Underling") -> LorenzColor.RED - armorStand.name.contains("Ashfang Acolyte") -> LorenzColor.BLUE - else -> { - blazeArmorStand = blazeArmorStand.editCopy { - remove(entity) - } - continue - } - } - blazeArmorStand = blazeArmorStand.editCopy { - this[entity] = armorStand - } - entity setBlazeColor color - } - } - } - } - - @SubscribeEvent - fun onEntityHealthUpdate(event: EntityHealthUpdateEvent) { - if (!isEnabled()) return - - val entityId = event.entity.entityId - if (entityId !in blazeArmorStand.keys.map { it.entityId }) return - - if (event.health % 10_000_000 != 0) { - blazeArmorStand = blazeArmorStand.editCopy { - keys.removeIf { it.entityId == entityId } - } - } - } - - private fun checkNearAshfang() { - nearAshfang = EntityUtils.getEntities().any { it.name.contains("Ashfang") } - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { - if (!isEnabled()) return - if (!config.hide.fullNames) return - - val entity = event.entity - if (entity !is EntityArmorStand) return - if (!entity.hasCustomName()) return - if (entity.isDead) return - if (entity in blazeArmorStand.values) { - event.cancel() - } - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - blazeColor.clear() - blazeArmorStand = emptyMap() - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "ashfang.nextResetCooldown", "crimsonIsle.ashfang.nextResetCooldown") - event.move(2, "ashfang.highlightBlazes", "crimsonIsle.ashfang.highlightBlazes") - event.move(2, "ashfang.hideNames", "crimsonIsle.ashfang.hide.fullNames") - } - - private fun isEnabled(): Boolean { - return IslandType.CRIMSON_ISLE.isInIsland() && DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) - } - - private infix fun EntityBlaze.setBlazeColor(color: LorenzColor) { - blazeColor[this] = color - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - this, - color.toColor().withAlpha(40), - ) { isEnabled() && config.highlightBlazes } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt deleted file mode 100644 index de4db8f833da..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt +++ /dev/null @@ -1,71 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.ashfang - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture -import at.hannibal2.skyhanni.utils.LocationUtils -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.drawString -import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -@SkyHanniModule -object AshfangBlazingSouls { - - private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang.blazingSouls - - private const val TEXTURE = - "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODI4N2IzOTdkYWY5NTE2YTBiZDc2ZjVmMWI3YmY5Nzk1MTVkZjNkNWQ4MzNlMDYzNWZhNjhiMzdlZTA4MjIxMiJ9fX0=" - private val souls = mutableListOf() - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - - EntityUtils.getEntities() - .filter { it !in souls && it.hasSkullTexture(TEXTURE) } - .forEach { souls.add(it) } - } - - @SubscribeEvent - fun onRenderWorld(event: LorenzRenderWorldEvent) { - if (!isEnabled()) return - - val color = config.color.toChromaColor() - - val playerLocation = LocationUtils.playerLocation() - for (orb in souls) { - if (orb.isDead) continue - val orbLocation = orb.getLorenzVec() - event.drawWaypointFilled(orbLocation.add(-0.5, 1.25, -0.5), color, extraSize = -0.15) - if (orbLocation.distance(playerLocation) < 10) { - // TODO find way to dynamically change color - event.drawString(orbLocation.up(2.5), "§bBlazing Soul") - } - } - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - souls.clear() - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "ashfang.blazingSouls", "crimsonIsle.ashfang.blazingSouls.enabled") - event.move(2, "ashfang.blazingSoulsColor", "crimsonIsle.ashfang.blazingSouls.color") - } - - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt index 68684ef49ece..07cf723fa6f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt @@ -1,14 +1,10 @@ package at.hannibal2.skyhanni.features.nether.ashfang -import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format @@ -19,47 +15,35 @@ import kotlin.time.Duration.Companion.seconds @SkyHanniModule object AshfangFreezeCooldown { - private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang + private val config get() = AshfangManager.config private val cryogenicBlastPattern by RepoPattern.pattern( "ashfang.freeze.cryogenic", - "§cAshfang Follower's Cryogenic Blast hit you for .* damage!" + "§cAshfang Follower's Cryogenic Blast hit you for .* damage!", ) - private var lastHit = SimpleTimeMark.farPast() + private var unfrozenTime = SimpleTimeMark.farPast() + private val duration = 3.seconds @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - - val message = event.message - cryogenicBlastPattern.matchMatcher(message) { - lastHit = SimpleTimeMark.now() - } + if (cryogenicBlastPattern.matches(event.message)) unfrozenTime = SimpleTimeMark.now() + duration } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return + if (!isCurrentlyFrozen()) return - val passedSince = lastHit.passedSince() - val maxDuration = 3.seconds - val duration = maxDuration - passedSince - if (duration > 0.seconds) { - val format = duration.format(showMilliSeconds = true) - config.freezeCooldownPos.renderString( - "§cAshfang Freeze: §a$format", - posLabel = "Ashfang Freeze Cooldown" - ) - } + val format = unfrozenTime.timeUntil().format(showMilliSeconds = true) + config.freezeCooldownPos.renderString( + "§cAshfang Freeze: §a$format", + posLabel = "Ashfang Freeze Cooldown", + ) } - fun isCurrentlyFrozen(): Boolean { - val passedSince = lastHit.passedSince() - val maxDuration = 3.seconds - val duration = maxDuration - passedSince - return duration > 0.seconds - } + fun isCurrentlyFrozen() = unfrozenTime.isInFuture() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { @@ -67,6 +51,5 @@ object AshfangFreezeCooldown { event.move(2, "ashfang.freezeCooldownPos", "crimsonIsle.ashfang.freezeCooldownPos") } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.freezeCooldown && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) + private fun isEnabled() = AshfangManager.active && config.freezeCooldown } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt deleted file mode 100644 index 1eaa1dd5e921..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt +++ /dev/null @@ -1,75 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.ashfang - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture -import at.hannibal2.skyhanni.utils.LocationUtils -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils -import at.hannibal2.skyhanni.utils.RenderUtils.drawString -import at.hannibal2.skyhanni.utils.SpecialColor -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color - -@SkyHanniModule -object AshfangGravityOrbs { - - private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang.gravityOrbs - - private const val TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV" + - "0L3RleHR1cmUvMWE2OWNjZjdhZDkwNGM5YTg1MmVhMmZmM2Y1YjRlMjNhZGViZjcyZWQxMmQ1ZjI0Yjc4Y2UyZDQ0YjRhMiJ9fX0=" - private val orbs = mutableListOf() - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - - EntityUtils.getEntities() - .filter { it !in orbs && it.hasSkullTexture(TEXTURE) } - .forEach { orbs.add(it) } - } - - @SubscribeEvent - fun onRenderWorld(event: LorenzRenderWorldEvent) { - if (!isEnabled()) return - - val color = Color(SpecialColor.specialToChromaRGB(config.color), true) - val playerLocation = LocationUtils.playerLocation() - for (orb in orbs) { - if (orb.isDead) continue - val orbLocation = orb.getLorenzVec() - val center = orbLocation.add(-0.5, -2.0, -0.5) - RenderUtils.drawCylinderInWorld(color, center.x, center.y, center.z, 3.5f, 4.5f, event.partialTicks) - - if (orbLocation.distance(playerLocation) < 15) { - // TODO find way to dynamically change color - event.drawString(orbLocation.up(2.5), "§cGravity Orb") - } - } - } - - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - orbs.clear() - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(1, "ashfang.gravityOrbs", "ashfang.gravityOrbs.enabled") - event.move(1, "ashfang.gravityOrbsColor", "ashfang.gravityOrbs.color") - - event.move(2, "ashfang.gravityOrbs", "crimsonIsle.ashfang.gravityOrbs") - } - - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt deleted file mode 100644 index 606f7d17f8bc..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt +++ /dev/null @@ -1,34 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.ashfang - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.entity.EntityLivingBase -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -@SkyHanniModule -object AshfangHideDamageIndicator { - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { - if (!isEnabled()) return - - if (DamageIndicatorManager.isDamageSplash(event.entity)) { - event.cancel() - } - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "ashfang.hideDamageSplash", "crimsonIsle.ashfang.hide.damageSplash") - } - - private fun isEnabled() = - LorenzUtils.inSkyBlock && SkyHanniMod.feature.crimsonIsle.ashfang.hide.damageSplash && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt deleted file mode 100644 index 4c228a436f66..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt +++ /dev/null @@ -1,60 +0,0 @@ -package at.hannibal2.skyhanni.features.nether.ashfang - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -@SkyHanniModule -object AshfangHideParticles { - - private var nearAshfang = false - - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!LorenzUtils.inSkyBlock) return - - nearAshfang = DamageIndicatorManager.getDistanceTo(BossType.NETHER_ASHFANG) < 40 - } - - @SubscribeEvent - fun onReceiveParticle(event: ReceiveParticleEvent) { - if (isEnabled()) { - event.cancel() - } - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!isEnabled()) return - - val entity = event.entity - if (entity is EntityArmorStand) { - for (stack in entity.inventory) { - if (stack == null) continue - val name = stack.name - if (name == "§aFairy Souls") continue - if (name == "Glowstone") { - event.cancel() - } - } - } - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "ashfang.hideParticles", "crimsonIsle.ashfang.hide.particles") - } - - private fun isEnabled() = - LorenzUtils.inSkyBlock && SkyHanniMod.feature.crimsonIsle.ashfang.hide.particles && nearAshfang -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt new file mode 100644 index 000000000000..4e40ed77cc64 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHider.kt @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ItemUtils.name +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object AshfangHider { + + private val config get() = AshfangManager.config.hide + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { + if (!AshfangManager.active || !config.damageSplash) return + + if (DamageIndicatorManager.isDamageSplash(event.entity)) { + event.cancel() + } + } + + @SubscribeEvent + fun onReceiveParticle(event: ReceiveParticleEvent) { + if (!AshfangManager.active || !config.particles) return + event.cancel() + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!AshfangManager.active || !config.particles) return + val entity = event.entity as? EntityArmorStand ?: return + if (entity.inventory.any { it?.name == "Glowstone" }) event.cancel() + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "ashfang.hideDamageSplash", "crimsonIsle.ashfang.hide.damageSplash") + event.move(2, "ashfang.hideParticles", "crimsonIsle.ashfang.hide.particles") + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlights.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlights.kt new file mode 100644 index 000000000000..312cfc469cfb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlights.kt @@ -0,0 +1,106 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent +import at.hannibal2.skyhanni.events.entity.EntityLeaveWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ColorUtils +import at.hannibal2.skyhanni.utils.ColorUtils.getExtendedColorCode +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.drawCylinderInWorld +import at.hannibal2.skyhanni.utils.RenderUtils.drawString +import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object AshfangHighlights { + + private val config get() = AshfangManager.config + + private const val BLAZING_SOUL = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODI4N2IzOTdkYWY5NTE2YTBiZDc2ZjVmMWI3YmY5Nzk1MTVkZjNkNWQ4MzNlMDYzNWZhNjhiMzdlZTA4MjIxMiJ9fX0=" + private const val GRAVITY_ORB = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWE2OWNjZjdhZDkwNGM5YTg1MmVhMmZmM2Y1YjRlMjNhZGViZjcyZWQxMmQ1ZjI0Yjc4Y2UyZDQ0YjRhMiJ9fX0=" + private val blazingSouls = mutableSetOf() + private val gravityOrbs = mutableSetOf() + private const val MAX_DISTANCE = 15.0 + + @HandleEvent(onlyOnSkyblock = true, onlyOnIsland = IslandType.CRIMSON_ISLE) + fun onEntityJoin(event: EntityEnterWorldEvent) { + if (!AshfangManager.active) return + val entity = event.entity + DelayedRun.runNextTick { + when { + entity.hasSkullTexture(BLAZING_SOUL) -> blazingSouls += entity + entity.hasSkullTexture(GRAVITY_ORB) -> gravityOrbs += entity + } + } + } + + @HandleEvent(onlyOnSkyblock = true, onlyOnIsland = IslandType.CRIMSON_ISLE) + fun onEntityLeave(event: EntityLeaveWorldEvent) { + blazingSouls -= event.entity + gravityOrbs -= event.entity + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!AshfangManager.active) return + + if (config.blazingSouls.enabled) { + val color = config.blazingSouls.color.toChromaColor() + blazingSouls.forEach { + val location = event.exactLocation(it) + event.drawWaypointFilled(location.add(-0.5, 1.25, -0.5), color, extraSize = -0.15) + event.drawBlendedColorString(location, "Blazing Soul") + } + } + + if (config.gravityOrbs.enabled) { + val color = config.gravityOrbs.color.toChromaColor() + gravityOrbs.forEach { + val location = event.exactLocation(it) + event.drawCylinderInWorld(color, location.add(-0.5, -2.0, -0.5), 3.5f, 4.5f) + event.drawBlendedColorString(location, "Gravity Orb") + } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + blazingSouls.clear() + gravityOrbs.clear() + } + + private fun LorenzRenderWorldEvent.drawBlendedColorString(location: LorenzVec, text: String) { + val distance = location.distanceToPlayer() + if (distance < MAX_DISTANCE) { + val colorCode = getColorCode(distance) + drawString(location.add(y = 2.5), colorCode + text) + } + } + + private fun getColorCode(distance: Double): String = + ColorUtils.blendRGB(LorenzColor.GREEN.toColor(), LorenzColor.RED.toColor(), distance / MAX_DISTANCE).getExtendedColorCode() + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "ashfang.blazingSouls", "crimsonIsle.ashfang.blazingSouls.enabled") + event.move(2, "ashfang.blazingSoulsColor", "crimsonIsle.ashfang.blazingSouls.color") + + event.move(1, "ashfang.gravityOrbs", "ashfang.gravityOrbs.enabled") + event.move(1, "ashfang.gravityOrbsColor", "ashfang.gravityOrbs.color") + event.move(2, "ashfang.gravityOrbs", "crimsonIsle.ashfang.gravityOrbs") + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangManager.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangManager.kt new file mode 100644 index 000000000000..edf7dbd6489d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangManager.kt @@ -0,0 +1,93 @@ +package at.hannibal2.skyhanni.features.nether.ashfang + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.crimsonisle.ashfang.AshfangConfig +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.mob.Mob +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha +import at.hannibal2.skyhanni.utils.EntityUtils.isAtFullHealth +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.MobUtils.mob +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds + +@SkyHanniModule +object AshfangManager { + + val config: AshfangConfig get() = SkyHanniMod.feature.crimsonIsle.ashfang + + private val ashfangMobs = mutableSetOf() + var ashfang: Mob? = null + private set + var lastSpawnTime = SimpleTimeMark.farPast() + private set + + val active get() = ashfang != null + + @SubscribeEvent + fun onMobSpawn(event: MobEvent.Spawn.SkyblockMob) { + if (!IslandType.CRIMSON_ISLE.isInIsland()) return + val mob = event.mob + val color = when (mob.name) { + "Ashfang Follower" -> LorenzColor.DARK_GRAY + "Ashfang Underling" -> LorenzColor.RED + "Ashfang Acolyte" -> LorenzColor.BLUE + "Ashfang" -> { + ashfang = mob + return + } + + else -> return + } + ashfangMobs += mob + if (config.highlightBlazes) mob.highlight(color.toColor().addAlpha(40)) + } + + @SubscribeEvent + fun onMobFirstSeen(event: MobEvent.FirstSeen.SkyblockMob) { + if (!IslandType.CRIMSON_ISLE.isInIsland()) return + if (!event.mob.name.contains("Ashfang ")) return + if (lastSpawnTime.passedSince() < 10.seconds) return + lastSpawnTime = SimpleTimeMark.now() + } + + @SubscribeEvent + fun onMobDeSpawn(event: MobEvent.DeSpawn.SkyblockMob) { + val mob = event.mob + ashfangMobs -= mob + if (ashfang == mob) { + ashfang = null + if (mob.isInRender()) lastSpawnTime = SimpleTimeMark.farPast() + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { + if (!active || !config.hide.fullNames) return + val mob = event.entity.mob ?: return + if (mob !in ashfangMobs) return + if (mob.baseEntity.isAtFullHealth()) event.cancel() + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + lastSpawnTime = SimpleTimeMark.farPast() + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(2, "ashfang.nextResetCooldown", "crimsonIsle.ashfang.nextResetCooldown") + event.move(2, "ashfang.highlightBlazes", "crimsonIsle.ashfang.highlightBlazes") + event.move(2, "ashfang.hideNames", "crimsonIsle.ashfang.hide.fullNames") + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt index c555ec6d29f3..b77301edc06d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -1,61 +1,33 @@ package at.hannibal2.skyhanni.features.nether.ashfang -import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.features.combat.damageindicator.BossType -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils.format -import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @SkyHanniModule object AshfangNextResetCooldown { - private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang - private var spawnTime = SimpleTimeMark.farPast() - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - - if (EntityUtils.getEntities().any { - it.posY > 145 && (it.name.contains("§c§9Ashfang Acolyte§r") || it.name.contains("§c§cAshfang Underling§r")) - } - ) { - spawnTime = SimpleTimeMark.now() - } - } + private val config get() = AshfangManager.config + private val ashfangResetTime = 46.1.seconds @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!isEnabled()) return - if (spawnTime.isFarPast()) return + if (AshfangManager.lastSpawnTime.isFarPast()) return + val nextSpawn = AshfangManager.lastSpawnTime + ashfangResetTime - val passedSince = spawnTime.passedSince() - if (passedSince < 46.1.seconds) { - val format = passedSince.format(TimeUnit.SECOND, showMilliSeconds = true) - config.nextResetCooldownPos.renderString( - "§cAshfang next reset in: §a$format", - posLabel = "Ashfang Reset Cooldown" - ) - } else { - spawnTime = SimpleTimeMark.farPast() - } - } + val format = if (nextSpawn.isInPast()) "§aNow!" + else "§b${nextSpawn.timeUntil().format(TimeUnit.SECOND, showMilliSeconds = true)}" - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { - spawnTime = SimpleTimeMark.farPast() + config.nextResetCooldownPos.renderString( + "§cAshfang next reset in: $format", + posLabel = "Ashfang Reset Cooldown", + ) } @SubscribeEvent @@ -64,8 +36,5 @@ object AshfangNextResetCooldown { event.move(2, "ashfang.nextResetCooldownPos", "crimsonIsle.ashfang.nextResetCooldownPos") } - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && config.nextResetCooldown && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) - } + private fun isEnabled() = AshfangManager.active && config.nextResetCooldown } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt index 50c6593fb9d2..99c94d63a1df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt @@ -94,6 +94,7 @@ object VoltHighlighter { DOING_LIGHTNING, } + @Suppress("MaxLineLength") private fun getVoltState(itemStack: ItemStack): VoltState { return when (itemStack.getSkullTexture()) { // TODO: Move these textures to the repo diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt index 516ecfd90805..d3fbefa999a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/WoodenButtonsHelper.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.dreadfarm +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandGraphs import at.hannibal2.skyhanni.data.jsonobjects.repo.RiftWoodenButtonsJson @@ -105,7 +106,7 @@ object WoodenButtonsHelper { } } - @SubscribeEvent + @HandleEvent fun onBlockClick(event: BlockClickEvent) { if (!checkButtons()) return @@ -115,7 +116,7 @@ object WoodenButtonsHelper { } } - @SubscribeEvent + @HandleEvent fun onItemClick(event: ItemClickEvent) { if (!checkButtons()) return if (event.clickType != ClickType.RIGHT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt index 63a4e35cb750..08079849e11e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent @@ -22,7 +24,7 @@ object LivingCaveLivingMetalHelper { private var pair: Pair? = null private var startTime = 0L - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return if (event.clickType == ClickType.LEFT_CLICK) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt index 89e5d556b2b4..ec382a5d42ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt @@ -115,7 +115,9 @@ object DanceRoomHelper { @SubscribeEvent fun onPlaySound(event: PlaySoundEvent) { if (!isEnabled() || !inRoom) return - if ((event.soundName == "random.burp" && event.volume == 0.8f) || (event.soundName == "random.levelup" && event.pitch == 1.8412699f && event.volume == 1.0f)) { + if ((event.soundName == "random.burp" && event.volume == 0.8f) || + (event.soundName == "random.levelup" && event.pitch == 1.8412699f && event.volume == 1.0f) + ) { index = 0 found = false countdown = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt index c08594c26ea9..aab8c0caff0f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt @@ -26,9 +26,11 @@ object VerminHighlighter { private val checkedEntities = TimeLimitedSet(1.minutes) - // TODO repo + // TODO: Move to repo + @Suppress("MaxLineLength") private const val FLY_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTMwYWMxZjljNjQ5Yzk5Y2Q2MGU0YmZhNTMzNmNjMTg1MGYyNzNlYWI5ZjViMGI3OTQwZDRkNGQ3ZGM4MjVkYyJ9fX0=" + @Suppress("MaxLineLength") private const val SPIDER_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTY1MDU1NjEzMTkxNywKICAicHJvZmlsZUlkIiA6ICI0ODI5MmJkMjI1OTc0YzUwOTZiMTZhNjEyOGFmMzY3NSIsCiAgInByb2ZpbGVOYW1lIiA6ICJLVVJPVE9ZVEIyOCIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZmRmNjJkNGUwM2NhNTk0YzhjZDIxZGQxNzUzMjdmMWNmNzdjNGJjMDU3YTA5NTk2MDNkODNhNjhiYTI3MDA4IgogICAgfQogIH0KfQ==" 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 637fdfd15e1d..7b88b09ed857 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 @@ -89,7 +89,9 @@ object KloonHacking { slot highlight if (correctButton) LorenzColor.GREEN else LorenzColor.RED continue } - if (slot.slotIndex > i * 9 + 8 && slot.slotIndex < i * 9 + 18 && slot.stack!!.displayName.removeColor() == correctButtons[i]) { + if (slot.slotIndex > i * 9 + 8 && slot.slotIndex < i * 9 + 18 && + slot.stack!!.displayName.removeColor() == correctButtons[i] + ) { slot highlight LorenzColor.YELLOW } if (slot.slotIndex == i * 9 + 17) { 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 a89698596a74..7a58c5d51113 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 @@ -18,6 +18,9 @@ object RiftLarva { private val config get() = RiftAPI.config.area.wyldWoods.larvas private var hasHookInHand = false + + // TODO: Move to repo + @Suppress("MaxLineLength") private const val LARVA_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTgzYjMwZTlkMTM1YjA1MTkwZWVhMmMzYWM2MWUyYWI1NWEyZDgxZTFhNThkYmIyNjk4M2ExNDA4MjY2NCJ9fX0=" 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 555e5968c8e7..452d3edb0bb7 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 @@ -19,6 +19,9 @@ object RiftOdonata { private val config get() = RiftAPI.config.area.wyldWoods.odonata private var hasBottleInHand = false + + // TODO: Move to repo + @Suppress("MaxLineLength") private const val ODONATA_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWZkODA2ZGVmZGZkZjU5YjFmMjYwOWM4ZWUzNjQ2NjZkZTY2MTI3YTYyMzQxNWI1NDMwYzkzNThjNjAxZWY3YyJ9fX0=" private val emptyBottle by lazy { "EMPTY_ODONATA_BOTTLE".asInternalName() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt index 9e92b0807129..e32fd46a79d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt @@ -23,6 +23,7 @@ object CruxTalismanDisplay { private val config get() = RiftAPI.config.cruxTalisman + @Suppress("MaxLineLength") private val progressPattern by RepoPattern.pattern( "rift.everywhere.crux.progress", ".*(?§[0-9a-z][IV1-4-]+)\\s+(?§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?§[0-9a-z](?:§[0-9a-z])?MAXED|§[0-9a-z]\\d+§[0-9a-z]/§[0-9a-z]\\d+).*" 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 10be4a54abd9..a4068438f056 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 @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.rift.everywhere import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.mob.MobData @@ -155,7 +156,7 @@ object PunchcardHighlight { RenderLivingEntityHelper.removeEntityColor(entity) } - fun clearList() { + fun onResetCommand() { playerList.clear() playerQueue.clear() if (config.reverse.get()) { @@ -169,9 +170,8 @@ object PunchcardHighlight { } } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) fun onPunch(event: EntityClickEvent) { - if (!RiftAPI.inRift()) return val entity = event.clickedEntity if (entity !is AbstractClientPlayer) return if (entity.isNPC()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index 022a808d0afc..9cc9e19734b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -72,7 +72,8 @@ object ShowMotesNpcSellPrice { val burgerText = if (burgerStacks > 0) "(${burgerStacks}x≡) " else "" val size = itemStack.stackSize if (size > 1) { - event.toolTip.add("§6NPC price: $burgerText§d${baseMotes.addSeparators()} Motes §7($size x §d${(baseMotes / size).addSeparators()} Motes§7)") + event.toolTip.add("§6NPC price: $burgerText§d${baseMotes.addSeparators()} Motes " + + "§7($size x §d${(baseMotes / size).addSeparators()} Motes§7)") } else { event.toolTip.add("§6NPC price: $burgerText§d${baseMotes.addSeparators()} Motes") } 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 ffee3eda4656..ccc1ac1c1573 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -320,8 +320,11 @@ object SkillProgress { val xpInfo = skillXPInfoMap[activeSkill] ?: return@buildList val skillInfoLast = oldSkillInfoMap[activeSkill] ?: return@buildList oldSkillInfoMap[activeSkill] = skillInfo - val level = - if (config.overflowConfig.enableInEtaDisplay.get() || config.customGoalConfig.enableInETADisplay) skillInfo.overflowLevel else skillInfo.level + val level = if (config.overflowConfig.enableInEtaDisplay.get() || config.customGoalConfig.enableInETADisplay) { + skillInfo.overflowLevel + } else { + skillInfo.level + } val useCustomGoalLevel = skillInfo.customGoalLevel != 0 && skillInfo.customGoalLevel > skillInfo.overflowLevel && customGoalConfig.enableInETADisplay diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt index 8c1d3f618c29..e616deda48f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt @@ -56,7 +56,8 @@ object SkillTooltip { if (line.contains(bar)) { val progress = (skillInfo.overflowCurrentXp.toDouble() / skillInfo.overflowCurrentXpMax) val progressBar = StringUtils.progressBar(progress) - iterator.set("$progressBar §e${skillInfo.overflowCurrentXp.addSeparators()}§6/§e${skillInfo.overflowCurrentXpMax.addSeparators()}") + iterator.set("$progressBar §e${skillInfo.overflowCurrentXp.addSeparators()}§6/" + + "§e${skillInfo.overflowCurrentXpMax.addSeparators()}") iterator.add("") } } 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 acd37e9d5c14..defde1cf2b73 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -246,7 +246,7 @@ object SlayerProfitTracker { fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled - fun clearProfitCommand(args: Array) { + fun resetCommand() { if (itemLogCategory == "") { ChatUtils.userError( "No current slayer data found! " + diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 162675486946..c879c202b42d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent @@ -148,7 +149,7 @@ object SlayerQuestWarning { return getSlayerData().lastSlayerType == slayerType } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onItemClick(event: ItemClickEvent) { val internalName = event.itemInHand?.getInternalNameOrNull() diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index df7ab69d907a..87ceb82424e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -1,8 +1,10 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent @@ -63,9 +65,11 @@ object VampireSlayerFeatures { private val username get() = EntityUtils.getEntities().firstOrNull()?.name ?: error("own player is null") - // TODO: Add to repo + // TODO: Move to repo + @Suppress("MaxLineLength") private const val BLOOD_ICHOR_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAzNDA5MjNhNmRlNDgyNWExNzY4MTNkMTMzNTAzZWZmMTg2ZGIwODk2ZTMyYjY3MDQ5MjhjMmEyYmY2ODQyMiJ9fX0=" + @Suppress("MaxLineLength") private const val KILLER_SPRING_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzdmN2E3YmM4YWM4NmYyM2NhN2JmOThhZmViNzY5NjAyMjdlMTgzMmZlMjA5YTMwMjZmNmNlYjhiZGU3NGY1NCJ9fX0=" private var nextClawSend = 0L @@ -203,7 +207,7 @@ object VampireSlayerFeatures { return toChromaColor().withAlpha(config.withAlpha) } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.THE_RIFT) fun onEntityClick(event: EntityClickEvent) { if (!isEnabled()) return if (event.clickType != ClickType.LEFT_CLICK) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 8a5b5f727193..2f01af9033cc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.config.features.slayer.blaze.BlazeHellionConfig.FirstDaggerEntry @@ -202,7 +203,7 @@ object BlazeSlayerDaggerHelper { return LorenzUtils.inSkyBlock && config.daggers } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return if (clientSideClicked) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index 684d06cd4ba2..9b03ebbeb2f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -48,6 +48,9 @@ object EndermanSlayerFeatures { private val nukekubiSkulls = mutableSetOf() private var sittingBeacon = mapOf() private val logger = LorenzLogger("slayer/enderman") + + // TODO: Move to repo + @Suppress("MaxLineLength") private const val NUKEKUBI_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=" diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinWorld.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinWorld.java new file mode 100644 index 000000000000..1569416d4e20 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinWorld.java @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.mixins.transformers; + +import at.hannibal2.skyhanni.data.EntityData; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +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.Collection; + +@Mixin(World.class) +public class MixinWorld { + + @Inject(method = "unloadEntities", at = @At("HEAD")) + private void unloadEntities(Collection entityCollection, CallbackInfo ci) { + for (Entity entity : entityCollection) EntityData.despawnEntity(entity); + } + + @Inject(method = "onEntityRemoved", at = @At("HEAD")) + private void onEntityRemoved(Entity entityIn, CallbackInfo ci) { + EntityData.despawnEntity(entityIn); + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index fa6537046fc8..ae9b5e45b285 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -306,9 +306,9 @@ object SkyHanniDebugsAndTests { private var lastManualContestDataUpdate = SimpleTimeMark.farPast() - fun clearContestData() { + fun resetContestData() { if (lastManualContestDataUpdate.passedSince() < 30.seconds) { - ChatUtils.userError("§cYou already cleared Jacob's Contest data recently!") + ChatUtils.userError("§cYou already reset Jacob's Contest data recently!") return } lastManualContestDataUpdate = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt index 9b3cec0a09b3..b599fcc90f7c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent @@ -52,7 +53,7 @@ object WorldEdit { return text } - @SubscribeEvent + @HandleEvent fun onBlockClick(event: BlockClickEvent) { if (!isEnabled()) return if (event.itemInHand?.getItemId() != "WOOD_AXE") return @@ -105,7 +106,8 @@ object WorldEdit { } when (it.firstOrNull()) { null, "help" -> { - ChatUtils.chat("Use a wood axe and left/right click to select a region in the world. Then use /shworldedit copy or /shworldedit reset.") + ChatUtils.chat("Use a wood axe and left/right click to select a region in the world. " + + "Then use /shworldedit copy or /shworldedit reset.") } "copy" -> { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index e2251f49c69d..4cecc1c00568 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -297,9 +297,7 @@ object CollectionUtils { } fun takeColumn(start: Int, end: Int, startColumn: Int, endColumn: Int, rowSize: Int = 9) = - generateSequence(start) { - it + 1 - }.map { + generateSequence(start) { it + 1 }.map { (it / (endColumn - startColumn)) * rowSize + (it % (endColumn - startColumn)) + startColumn }.takeWhile { it <= end } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt index 7b941aebedc3..52b1eb68da40 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt @@ -8,7 +8,7 @@ object ColorUtils { fun String.toChromaColor() = Color(toChromaColorInt(), true) fun String.toChromaColorInt() = SpecialColor.specialToChromaRGB(this) - fun String.getFirstColorCode() = this.takeIf { it.firstOrNull() == '§' }?.getOrNull(1) + fun String.getFirstColorCode() = takeIf { it.firstOrNull() == '§' }?.getOrNull(1) fun getRed(color: Int) = color shr 16 and 0xFF @@ -24,6 +24,8 @@ object ColorUtils { (start.blue * (1 - percent) + end.blue * percent).toInt(), ) + fun Color.getExtendedColorCode(hasAlpha: Boolean = false): String = ExtendedChatColor(rgb, hasAlpha).toString() + /** Darkens a color by a [factor]. The lower the [factor], the darker the color. */ fun Color.darker(factor: Double = 0.7) = Color( (red * factor).toInt().coerceIn(0, 255), @@ -34,7 +36,8 @@ object ColorUtils { val TRANSPARENT_COLOR = Color(0, 0, 0, 0) - fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) + @Deprecated("Don't use int colors", ReplaceWith("this.addAlpha()")) + fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (rgb and 0x00ffffff) fun Color.addAlpha(alpha: Int): Color = Color(red, green, blue, alpha) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 59799ff3d1fd..c5eb95fc892a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -181,7 +181,10 @@ object EntityUtils { fun getAllEntities(): Sequence = Minecraft.getMinecraft().theWorld?.getAllEntities()?.let { if (Minecraft.getMinecraft() .isOnMainThread() - ) it else it.toMutableList() // TODO: while i am here, i want to point out that copying the entity list does not constitute proper synchronization, but *does* make crashes because of it rarer. + ) it + // TODO: while i am here, i want to point out that copying the entity list does not constitute proper synchronization, + // but *does* make crashes because of it rarer. + else it.toMutableList() }?.asSequence()?.filterNotNull() ?: emptySequence() fun getAllTileEntities(): Sequence = Minecraft.getMinecraft()?.theWorld?.loadedTileEntityList?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ExtendedChatColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/ExtendedChatColor.kt index f4a64017d55b..e4cb2f448161 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ExtendedChatColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ExtendedChatColor.kt @@ -4,7 +4,7 @@ import java.awt.Color class ExtendedChatColor( val rgb: Int, - val hasAlpha: Boolean, + val hasAlpha: Boolean = false, ) { override fun toString(): String { val stringBuilder = StringBuilder() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 14241f314a32..47bdb3976441 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -768,6 +768,15 @@ object RenderUtils { GlStateManager.popMatrix() } + fun LorenzRenderWorldEvent.drawCylinderInWorld( + color: Color, + location: LorenzVec, + radius: Float, + height: Float, + ) { + drawCylinderInWorld(color, location.x, location.y, location.z, radius, height, partialTicks) + } + fun drawCylinderInWorld( color: Color, x: Double, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 2e507989699b..b273b5f09991 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -76,6 +76,7 @@ object UtilsPatterns { "(?:§5§o)?§7Cost.*", ) + @Suppress("MaxLineLength") val timeAmountPattern by patternGroup.pattern( "time.amount", "(?:(?\\d+) ?y(?:\\w* ?)?)?(?:(?\\d+) ?d(?:\\w* ?)?)?(?:(?\\d+) ?h(?:\\w* ?)?)?(?:(?\\d+) ?m(?:\\w* ?)?)?(?:(?\\d+) ?s(?:\\w* ?)?)?", diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 94f0bc16eff1..c7c66084e045 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -260,7 +260,16 @@ interface Renderable { val isInNeuSettings = openGui.startsWith("io.github.moulberry.notenoughupdates.") val result = - isGuiScreen && isGuiPositionEditor && inMenu && isNotInSignAndOnSlot && isConfigScreen && !isInNeuPv && !isInSkytilsPv && !neuFocus && !isInSkytilsSettings && !isInNeuSettings + isGuiScreen && + isGuiPositionEditor && + inMenu && + isNotInSignAndOnSlot && + isConfigScreen && + !isInNeuPv && + !isInSkytilsPv && + !neuFocus && + !isInSkytilsSettings && + !isInNeuSettings if (debug) { if (!result) { @@ -614,7 +623,12 @@ interface Renderable { override val horizontalAlign = content.horizontalAlign override val verticalAlign = content.verticalAlign - val searchWidth get() = (Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchPrefix + textInput.editTextWithAlwaysCarriage()) * scale).toInt() + 1 + val searchWidth: Int + get() { + val fontRenderer = Minecraft.getMinecraft().fontRendererObj + val string = searchPrefix + textInput.editTextWithAlwaysCarriage() + return (fontRenderer.getStringWidth(string) * scale).toInt() + 1 + } init { textInput.registerToEvent(key) { 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 abdf15b1c100..57a5852a3a81 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -101,7 +101,9 @@ object RepoPatternManager { val previousOwner = exclusivity[key] if (previousOwner != owner && previousOwner != null && !previousOwner.transient) { if (!config.tolerateDuplicateUsage) - crash("Non unique access to regex at \"$key\". First obtained by ${previousOwner.ownerClass} / ${previousOwner.property}, tried to use at ${owner.ownerClass} / ${owner.property}") + crash("Non unique access to regex at \"$key\". " + + "First obtained by ${previousOwner.ownerClass} / ${previousOwner.property}, " + + "tried to use at ${owner.ownerClass} / ${owner.property}") } else { exclusivity[key] = owner } @@ -119,7 +121,9 @@ object RepoPatternManager { } val previousParentOwner = previousParentOwnerMutable - if (previousParentOwner != null && previousParentOwner != parentKeyHolder && !(previousParentOwner.shares && previousParentOwner.parent == parentKeyHolder)) { + if (previousParentOwner != null && previousParentOwner != parentKeyHolder && + !(previousParentOwner.shares && previousParentOwner.parent == parentKeyHolder) + ) { if (!config.tolerateDuplicateUsage) crash( "Non unique access to array regex at \"$parent\"." + " First obtained by ${previousParentOwner.ownerClass} / ${previousParentOwner.property}," + diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt index 2addca5c0aa9..ff691fd53696 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt @@ -151,7 +151,10 @@ class SkyHanniBucketedItemTracker, BucketedData : BucketedItemTracke onClick = { if (KeyboardManager.isModifierKeyDown()) { data.removeItem(data.getSelectedBucket(), internalName) - ChatUtils.chat("Removed $cleanName §efrom $name${if (data.getSelectedBucket() != null) " (${data.getSelectedBucket()})" else ""}") + ChatUtils.chat("Removed $cleanName §efrom $name" + + if (data.getSelectedBucket() != null) " (${data.getSelectedBucket()})" + else "" + ) } else { modify { it.toggleItemHide(data.getSelectedBucket(), internalName)