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