Skip to content

Commit

Permalink
Merge branch 'beta' into feature/election-viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Oct 13, 2024
2 parents 5d462dd + c5915be commit 08e2546
Show file tree
Hide file tree
Showing 125 changed files with 1,649 additions and 1,241 deletions.
7 changes: 7 additions & 0 deletions .live-plugins/module/plugin.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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) {
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,7 +59,7 @@ class SkyHanniMod {

SkyHanniEvents.init(modules)

Commands.init()
RegisterCommandsEvent.post()

PreInitFinishedEvent().post()
}
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,14 @@ object SkillAPI {
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(), matcher.group("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
Expand Down Expand Up @@ -468,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
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/config/ConfigGuiManager.kt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -18,4 +19,16 @@ object ConfigGuiManager {
}
SkyHanniMod.screenToOpen = GuiScreenElementWrapper(editor)
}

fun onCommand(args: Array<String>) {
if (args.isNotEmpty()) {
if (args[0].lowercase() == "gui") {
GuiEditManager.openGuiPositionEditor(hotkeyReminder = true)
} else {
openConfigGui(args.joinToString(" "))
}
} else {
openConfigGui()
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> = emptyList()
private var autoComplete: ((Array<String>) -> List<String>) = { listOf() }
private var callback: (Array<String>) -> Unit = {}

fun callback(callback: (Array<String>) -> Unit) {
this.callback = callback
}

fun autoComplete(autoComplete: (Array<String>) -> List<String>) {
this.autoComplete = autoComplete
}

fun toSimpleCommand() = SimpleCommand(name.lowercase(), aliases, callback, autoComplete)
}

Original file line number Diff line number Diff line change
@@ -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!",
)
}
Loading

0 comments on commit 08e2546

Please sign in to comment.