diff --git a/.editorconfig b/.editorconfig index 0c2021243d7c..e2edaad54308 100644 --- a/.editorconfig +++ b/.editorconfig @@ -21,13 +21,37 @@ max_line_length = 120 # Java Files [*.java] # Java files should not use wildcard imports -ij_java_names_count_to_use_import_on_demand = 999 -ij_java_class_count_to_use_import_on_demand = 999 -ij_java_packages_to_use_import_on_demand = +ij_java_names_count_to_use_import_on_demand = 2147483647 +ij_java_class_count_to_use_import_on_demand = 2147483647 +ij_java_packages_to_use_import_on_demand = 2147483647 [*.kt] +ktlint_code_style = intellij_idea + # Kotlin files should not use wildcard imports -ij_kotlin_name_count_to_use_star_import = 999 -ij_kotlin_name_count_to_use_star_import_for_members = 999 -ij_kotlin_packages_to_use_import_on_demand = +ij_kotlin_name_count_to_use_star_import = 2147483647 +ij_kotlin_name_count_to_use_star_import_for_members = 2147483647 ij_kotlin_enum_constants_wrap = split_into_lines +ij_kotlin_allow_trailing_comma_on_call_site = true +ij_kotlin_allow_trailing_comma = true +ktlint_standard_chain-wrapping = always + +ktlint_standard_multiline-if-else = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_no-single-line-block-comment = disabled +ktlint_standard_no-blank-line-before-rbrace = disabled +ktlint_standard_no-consecutive-blank-lines = disabled +ktlint_standard_no-empty-first-line-in-method-block = disabled +ktlint_standard_comment-spacing = disabled +ktlint_standard_string-template = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_standard_context-receiver-wrapping = disabled +ktlint_standard_multiline-expression-wrapping = false +ktlint_standard_string-template-indent = disabled +ktlint_standard_no-trailing-spaces = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_wrapping = enabled + +ktlint_standard_no-wildcard-imports = enabled +ktlint_standard_function-expression-body = disabled \ No newline at end of file diff --git a/.github/workflows/check-style.yaml b/.github/workflows/check-style.yaml new file mode 100644 index 000000000000..ff172208f8bc --- /dev/null +++ b/.github/workflows/check-style.yaml @@ -0,0 +1,16 @@ +name: check-style +on: + - pull_request +jobs: + ktlint: + name: Check Style + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + name: Checkout code + - name: ktlint + uses: ScaCap/action-ktlint@master + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-check diff --git a/.idea/dictionaries/default_user.xml b/.idea/dictionaries/default_user.xml index dcb32b1cd09d..c195bb1f4d61 100644 --- a/.idea/dictionaries/default_user.xml +++ b/.idea/dictionaries/default_user.xml @@ -27,12 +27,14 @@ cadycous carrolyn cata + cavespider chestplate chocolatefactory chronomatron chumcap coflnet coords + craftable cropie crosshair deathmite @@ -42,7 +44,9 @@ derpy despawn dicer + dragontail dreadfarm + dungeoneering dwarven egglocator einary @@ -73,9 +77,12 @@ hypixel hypixel's ichor + igrupan + igrupan's ingame inquis inquistiors + internalname interp itemstack jawbus @@ -89,6 +96,7 @@ kismets kloon kuudra + kuudra's laggy lapis larvas @@ -120,14 +128,17 @@ nukekebi nukekubi odger + odger's odonata odonatas opengenerowmenu opti oruo packmaster + perkpocalypse pickblock pickonimbus + plhlegblast preinitialization procs pyrochaos @@ -141,6 +152,7 @@ riftstalker robotron sadan + scatha sethome shcopytranslation shcropstartlocation @@ -165,6 +177,7 @@ sprayonator stillgore superboom + supercraft supercrafting superlite superpairs diff --git a/.live-plugins/event/plugin.kts b/.live-plugins/event/plugin.kts new file mode 100644 index 000000000000..d012154b881f --- /dev/null +++ b/.live-plugins/event/plugin.kts @@ -0,0 +1,76 @@ +import com.intellij.codeInspection.LocalQuickFix +import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.codeInspection.ProblemHighlightType +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElementVisitor +import liveplugin.registerInspection +import org.jetbrains.kotlin.idea.base.utils.fqname.fqName +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection +import org.jetbrains.kotlin.idea.util.AnnotationModificationHelper +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.nj2k.postProcessing.type +import org.jetbrains.kotlin.psi.KtNamedFunction +import org.jetbrains.kotlin.psi.KtVisitorVoid +import org.jetbrains.kotlin.psi.psiUtil.isPublic +import org.jetbrains.kotlin.types.typeUtil.supertypes + +// depends-on-plugin org.jetbrains.kotlin + +val skyhanniEvent = "at.hannibal2.skyhanni.api.event.SkyHanniEvent" +val handleEvent = "HandleEvent" + +registerInspection(HandleEventInspectionKotlin()) + +class HandleEventInspectionKotlin : AbstractKotlinInspection() { + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { + + val visitor = object : KtVisitorVoid() { + override fun visitNamedFunction(function: KtNamedFunction) { + val hasEventAnnotation = function.annotationEntries.any { it.shortName!!.asString() == handleEvent } + val isEvent = function.valueParameters.firstOrNull()?.type()?.supertypes() + ?.any { it.fqName?.asString() == skyhanniEvent } ?: false + + if (isEvent && !hasEventAnnotation && function.valueParameters.size == 1 && function.isPublic) { + holder.registerProblem( + function, + "Event handler function should be annotated with @HandleEvent", + HandleEventQuickFix() + ) + } else if (!isEvent && hasEventAnnotation) { + holder.registerProblem( + function, + "Function should not be annotated with @HandleEvent if it does not take a SkyHanniEvent", + ProblemHighlightType.GENERIC_ERROR + ) + } + } + } + + return visitor + } + + override fun getDisplayName() = "Event handler function should be annotated with @HandleEvent" + override fun getShortName() = "HandleEventInspection" + override fun getGroupDisplayName() = "SkyHanni" + override fun isEnabledByDefault() = true +} + +class HandleEventQuickFix : LocalQuickFix { + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { + val function = descriptor.psiElement as KtNamedFunction + AnnotationModificationHelper.addAnnotation( + function, + FqName("at.hannibal2.skyhanni.api.event.HandleEvent"), + null, + null, + { null }, + " ", + null + ) + } + + override fun getName() = "Annotate with @HandleEvent" + + override fun getFamilyName() = name +} diff --git a/.live-plugins/module/plugin.kts b/.live-plugins/module/plugin.kts new file mode 100644 index 000000000000..286160a9ba8a --- /dev/null +++ b/.live-plugins/module/plugin.kts @@ -0,0 +1,101 @@ +import com.intellij.codeInspection.LocalQuickFix +import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.codeInspection.ProblemHighlightType +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElementVisitor +import liveplugin.registerInspection +import liveplugin.show +import org.jetbrains.kotlin.idea.base.utils.fqname.fqName +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection +import org.jetbrains.kotlin.idea.util.AnnotationModificationHelper +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.nj2k.postProcessing.type +import org.jetbrains.kotlin.psi.* + +// depends-on-plugin org.jetbrains.kotlin + +val forgeEvent = "SubscribeEvent" +val handleEvent = "HandleEvent" +val skyHanniModule = "SkyHanniModule" + +val patternGroup = "at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGroup" +val pattern = "java.util.regex.Pattern" + +registerInspection(ModuleInspectionKotlin()) + +fun isEvent(function: KtNamedFunction): Boolean { + return function.annotationEntries.any { + it.shortName!!.asString() == handleEvent || it.shortName!!.asString() == forgeEvent + } +} + +fun isRepoPattern(property: KtProperty): Boolean { + val type = property.type()?.fqName?.asString() ?: return false + if (type == patternGroup) return true + if (type == pattern && property.hasDelegate()) return true + return false +} + +class ModuleInspectionKotlin : AbstractKotlinInspection() { + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { + + val visitor = object : KtVisitorVoid() { + + override fun visitClass(klass: KtClass) { + val hasAnnotation = klass.annotationEntries.any { it.shortName?.asString() == skyHanniModule } + + if (hasAnnotation) { + holder.registerProblem( + klass.nameIdentifier!!, + "@SkyHanniModule can only be applied to objects", + ProblemHighlightType.GENERIC_ERROR + ) + } + } + + override fun visitObjectDeclaration(declaration: KtObjectDeclaration) { + if (declaration.isCompanion()) return + val hasAnnotation = declaration.annotationEntries.any { it.shortName?.asString() == skyHanniModule } + if (hasAnnotation) return + + val hasSkyHanniEvents = declaration.body!!.functions.any { function -> isEvent(function) } + val hasRepoPatterns = declaration.body!!.properties.any { property -> isRepoPattern(property) } + if (!hasSkyHanniEvents && !hasRepoPatterns) return + + holder.registerProblem( + declaration, + "Module should have a @SkyHanniModule annotation", + ModuleQuickFix() + ) + } + } + + return visitor + } + + override fun getDisplayName() = "Modules should have a @SkyHanniModule annotation" + override fun getShortName() = "SkyHanniModuleInspection" + override fun getGroupDisplayName() = "SkyHanni" + override fun isEnabledByDefault() = true +} + +class ModuleQuickFix : LocalQuickFix { + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { + val obj = descriptor.psiElement as KtObjectDeclaration + AnnotationModificationHelper.addAnnotation( + obj, + FqName("at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule"), + null, + null, + { null }, + " ", + null + ) + show("Annotation applied, make sure SkyHanniMod isn't still loading this module") + } + + override fun getName() = "Annotate with @SkyHanniModule" + + override fun getFamilyName() = name +} diff --git a/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/ModuleProcessor.kt b/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/ModuleProcessor.kt index bc7d262b49d5..99d7904d0b33 100644 --- a/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/ModuleProcessor.kt +++ b/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/ModuleProcessor.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.skyhannimodule +import com.google.devtools.ksp.getClassDeclarationByName +import com.google.devtools.ksp.getDeclaredFunctions import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.Dependencies import com.google.devtools.ksp.processing.KSPLogger @@ -8,13 +10,24 @@ import com.google.devtools.ksp.processing.SymbolProcessor import com.google.devtools.ksp.symbol.ClassKind import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration +import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.validate import java.io.OutputStreamWriter class ModuleProcessor(private val codeGenerator: CodeGenerator, private val logger: KSPLogger) : SymbolProcessor { + // TODO remove once all events are migrated to SkyHanniEvent + private var skyHanniEvent: KSType? = null + private var minecraftForgeEvent: KSType? = null + private val warnings = mutableListOf() + override fun process(resolver: Resolver): List { + skyHanniEvent = + resolver.getClassDeclarationByName("at.hannibal2.skyhanni.api.event.SkyHanniEvent")?.asStarProjectedType() + minecraftForgeEvent = resolver.getClassDeclarationByName("net.minecraftforge.fml.common.eventhandler.Event") + ?.asStarProjectedType() + val symbols = resolver.getSymbolsWithAnnotation(SkyHanniModule::class.qualifiedName!!).toList() val validSymbols = symbols.mapNotNull { validateSymbol(it) } @@ -41,10 +54,42 @@ class ModuleProcessor(private val codeGenerator: CodeGenerator, private val logg return null } + // TODO remove once all events are migrated to SkyHanniEvent + val className = symbol.qualifiedName?.asString() ?: "unknown" + + for (function in symbol.getDeclaredFunctions()) { + if (function.annotations.any { it.shortName.asString() == "SubscribeEvent" }) { + val firstParameter = function.parameters.firstOrNull()?.type?.resolve()!! + if (!minecraftForgeEvent!!.isAssignableFrom(firstParameter)) { + warnings.add("Function in $className must have an event assignable from $minecraftForgeEvent because it is annotated with @SubscribeEvent") + } + } + + if (function.annotations.any { it.shortName.asString() == "HandleEvent" }) { + val firstParameter = function.parameters.firstOrNull()?.type?.resolve()!! + if (!skyHanniEvent!!.isAssignableFrom(firstParameter)) { + warnings.add("Function in $className must have an event assignable from $skyHanniEvent because it is annotated with @HandleEvent") + } + } + } + return symbol } + //TODO remove when KMixins added as it contains KSP annotation helpers. + private fun isDevAnnotation(klass: KSClassDeclaration): Boolean { + val annotation = klass.annotations.find { it.shortName.asString() == "SkyHanniModule" } ?: return false + return annotation.arguments.find { it.name?.asString() == "devOnly" }?.value as? Boolean ?: false + } + + // TODO use Kotlin Poet once KMixins is merged private fun generateFile(symbols: List) { + + if (warnings.isNotEmpty()) { + warnings.forEach { logger.warn(it) } + error("${warnings.size} errors related to event annotations found, please fix them before continuing. Click on the kspKotlin build log for more information.") + } + val dependencies = symbols.mapNotNull { it.containingFile }.toTypedArray() val deps = Dependencies(true, *dependencies) @@ -53,13 +98,18 @@ class ModuleProcessor(private val codeGenerator: CodeGenerator, private val logg OutputStreamWriter(file).use { it.write("package at.hannibal2.skyhanni.skyhannimodule\n\n") it.write("object LoadedModules {\n") - it.write(" val modules: List = listOf(\n") + it.write(" val isDev: Boolean = at.hannibal2.skyhanni.utils.system.PlatformUtils.isDevEnvironment\n") + it.write(" val modules: List = buildList {\n") symbols.forEach { symbol -> - it.write(" ${symbol.qualifiedName!!.asString()},\n") + if (isDevAnnotation(symbol)) { + it.write(" if (isDev) add(${symbol.qualifiedName!!.asString()})\n") + } else { + it.write(" add(${symbol.qualifiedName!!.asString()})\n") + } } - it.write(" )\n") + it.write(" }\n") it.write("}\n") } diff --git a/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/SkyHanniModule.kt b/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/SkyHanniModule.kt index cb6b0eae4c48..c854a572ce65 100644 --- a/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/SkyHanniModule.kt +++ b/annotation-processors/src/main/kotlin/at/hannibal2/skyhanni/skyhannimodule/SkyHanniModule.kt @@ -2,4 +2,9 @@ package at.hannibal2.skyhanni.skyhannimodule @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.SOURCE) -annotation class SkyHanniModule +annotation class SkyHanniModule( + /** + * If the module will only be loaded in a development environment. + */ + val devOnly: Boolean = false, +) diff --git a/build.gradle.kts b/build.gradle.kts index 1ef16722dbae..3b48bab11116 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.26.Beta.6" +version = "0.26.Beta.8" val gitHash by lazy { val baos = ByteArrayOutputStream() @@ -133,10 +133,6 @@ dependencies { implementation("net.hypixel:mod-api:0.3.1") } -ksp { - arg("symbolProcessor", "at.hannibal2.skyhanni.loadmodule.LoadModuleProvider") -} - configurations.getByName("minecraftNamed").dependencies.forEach { shot.applyTo(it as HasConfigurableAttributes<*>) } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 48144d882fdf..0c94c43cdfa3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -72,6 +72,9 @@ raven (https://github.com/hannibal002/SkyHanni/pull/1738) + Wand of Strength cooldown is now displayed. - saga (https://github.com/hannibal002/SkyHanni/pull/1948) + The cooldown displayed is for the buff, not the item usage. ++ Added Favorite Power Stones. - saga (https://github.com/hannibal002/SkyHanni/pull/2002) + + Highlighted in the Thaumaturgy inventory. + + Shift-click to add/remove them. #### Fishing Features @@ -112,6 +115,7 @@ + Added an option for a compacted Dicer RNG Drop Tracker Display. - Jordyrat (https://github.com/hannibal002/SkyHanni/pull/1735) + Also shortened the default display. ++ Minor GUI improvements in /ff. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/873) #### Hoppity Event Improvements @@ -126,6 +130,8 @@ maxime-bodifee (https://github.com/hannibal002/SkyHanni/pull/1926) + Adjusted and added Rabbit Uncle & Dog Keybinds. - raven (https://github.com/hannibal002/SkyHanni/pull/1907) + Added a distinct sound for the special stray rabbit. - HiZe (https://github.com/hannibal002/SkyHanni/pull/1913) ++ Added collected egg location API import. - appable (https://github.com/hannibal002/SkyHanni/pull/1972) + + Open your NEU profile viewer and click the chat message to load data. #### Mining Improvements @@ -155,6 +161,9 @@ + Improved Bazaar re-buy order helper to also search in the Bazaar upon chat message click. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1946) + Clarified the maximum clicks message for experiments. - Luna (https://github.com/hannibal002/SkyHanni/pull/1963) ++ Improved Attribute Prices in Estimated Item Value. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2020) + + Ignoring irrelevant attributes (Resistance, Speed, Experience, etc). + + No longer counting attribute combos or single attribute prices when cheaper than the base item price. #### Fishing Improvements @@ -166,6 +175,10 @@ + Reduced the frequency of Diana sound guess hints while the feature is working correctly. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1954) +#### Crimson Isle + ++ Crimson Isle Reputation Helper now warns when the Faction Quest Widget is disabled in the tab list. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1977) + #### Misc Improvements + Added a toggle for 24-hour time. - seraid (https://github.com/hannibal002/SkyHanni/pull/1804) @@ -176,6 +189,8 @@ Empa (https://github.com/hannibal002/SkyHanni/pull/1875) + Updated /shclearminiondata to remove only bugged minions nearby, not all minions. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1951) ++ Added information about the current Perkopocalypse Mayor's perks to the Custom Scoreboard. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2003) ++ Added support for Fancy Contributors in nametags. - Empa (https://github.com/hannibal002/SkyHanni/pull/1687) ### Fixes @@ -193,6 +208,7 @@ + Fixed a typo in Tunnels Maps. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1883) + Fixed error with SkyMall with Titanium buff. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1967) + Fixed swapped mining event display icons. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1958) ++ Fixed Area Walls being broken in Nucleus. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1994) #### Garden Fixes @@ -201,6 +217,10 @@ raven (https://github.com/hannibal002/SkyHanni/pull/1849) + Fixed /shcropgoal not working with double-name crops (wart, cocoa, cane). - L3Cache (https://github.com/hannibal002/SkyHanni/pull/1970) ++ Fixed Garden Visitor Drop Statistics not tracking new data. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1976) + + This may also fix the display not showing up. ++ Fixed Non-Craftable Items breaking the Visitor Shopping List. - jani/hannibal2/nea (https://github.com/hannibal002/SkyHanni/pull/2019) ++ Fixed stats in visitor inventory not showing under certain circumstances. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2018) #### Chocolate Factory & Hoppity Hunt Fixes @@ -230,12 +250,14 @@ + Fixed typo in /shclearkismet command. - fahr-plan (https://github.com/hannibal002/SkyHanni/pull/1912) + Fixed 'viewrecipe' lowercase not working. - Obsidian + hannibal2 (https://github.com/hannibal002/SkyHanni/pull/1939) ++ Fixed rare cases where queued /gfs didn't work. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1999) #### Fishing Fixes + Fixed Thunder and Jawbus not being highlighted by Highlight Rare Sea Creatures. - Empa (https://github.com/hannibal002/SkyHanni/pull/1858) + Fixed Trophy Fish Display not working for stranded players. - HiZe (https://github.com/hannibal002/SkyHanni/pull/1966) ++ Fixed Sea Creature highlight not working when the damage indicator was enabled. - Empa (https://github.com/hannibal002/SkyHanni/pull/1985) #### Performance Fixes @@ -267,6 +289,12 @@ CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1920) + Fixed the GUI editor opening unintentionally. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1973) + Fixed movable hotbar conflicts with some mods. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1965) ++ Fixed crashes caused by tooltips. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1986) ++ Fixed config reset on encountering unknown enum values in the config. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1990) ++ Config no longer resets when an incorrect value is entered. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Config no longer resets when downgrading versions. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Fixed accidental hiding of boss bars. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1980) ++ Fixed Account Upgrade Reminder feature with simultaneous account and profile upgrades. - appable (https://github.com/hannibal002/SkyHanni/pull/2007) ### Technical Details @@ -289,6 +317,33 @@ + Added unit test for repo pattern lists. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1733) + Added RepoPattern.exclusiveGroup. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1733) + Reserves a key namespace, that is only accessible from this group. ++ Increased usage of seconds passed. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1899) ++ Refactored /ff. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/873) ++ Added Perkopocalypse Mayor to MayorAPI. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2003) ++ Created FmlEventApi to hold Forge events before dispatching them as SkyHanniEvents. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1986) ++ Ensured correct config version when downgrading the mod. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1990) ++ Changed CachedItemData to use SimpleTimeMark. - nea (https://github.com/hannibal002/SkyHanni/pull/2006) + + This is done via an in-Kotlin delegate constructor, since calling functions with default arguments that have an inline class type from Java is not stable. ++ Added SimpleStringTypeAdapter. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Added SkippingTypeAdapterFactory. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Cleaned up ConfigManager. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Moved json package inside the utils package. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1979) ++ Added Tab Widget abstraction. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1150) ++ Added EntityDisplayNameEvent. - Empa (https://github.com/hannibal002/SkyHanni/pull/1687) ++ Make build fail when event functions have wrong annotation. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2024) ++ Begin transitioning to the new event system. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2023) ++ Added custom event bus. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/2008) + + Added live plugin to show when an event method is missing its annotation. ++ Changed Java to Kotlin for repository files. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1543) ++ Made in-game date display use a pattern instead of repository. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1543) ++ All /gfs calls go through gfs API now. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1999) ++ Made ItemHoverEvent be called earlier. - Vixid (https://github.com/hannibal002/SkyHanni/pull/2018) ++ Removed deprecated bazaar variables. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1987) ++ Removed another deprecated function. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1956) ++ Used event.cancel() over event.isCanceled = true for LorenzEvents. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1915) ++ Converted classes to objects, then used annotation. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1982) ++ Added annotations to objects. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1974) ++ Added module plugin. - ThatGravyBoat (https://github.com/hannibal002/SkyHanni/pull/1974) ## Version 0.25 @@ -1841,7 +1896,7 @@ + For better maintainability and automatic beta changelog creation. + Use less forge events throughout the mod to reduce possible crashes. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1085) -+ Fix entity click not being canceled - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1072) ++ Fix entity click not being cancelled - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1072) + Cleanup ItemClickData. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/1072) + Fixes minecraft bug where text that is bold can render weirdly. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/1126) @@ -2199,7 +2254,7 @@ + Auto-fixing plots marked as pests when killing all pests without SkyHanni earlier. - hannibal2 + Fixed error message that nearest pests cannot get removed properly. - hannibal2 + Fixed grammar in Jacob Contest chat messages. - Alexia Luna -+ Fixed rarity error for items thrown around when using Sprayanator. - hannibal2 ++ Fixed rarity error for items thrown around when using Sprayonator. - hannibal2 + Added cooldown to Garden Warp Commands. - Empa + Fixed the detection of Anita and Jacob visitors. - hannibal2 + Fixed the pets menu detection for /ff. - martimavocado @@ -2483,7 +2538,7 @@ + Show a Title when a pest spawns. - hannibal2 + Show the time since the last pest spawned in your garden. - hannibal2 + Option to only show the time while holding vacuum in the hand. -+ Show the pests that are attracted when changing the selected material of the Sprayanator. - hannibal2 ++ Show the pests that are attracted when changing the selected material of the Sprayonator. - hannibal2 + Added Garden only commands /home, /barn and /tp, and hotkeys. - hannibal2 + Showing a better plot name in the scoreboard. Updates faster and doesn't hide when pests are spawned. - hannibal2 + Show a display with all known pest locations. - hannibal2 @@ -2569,7 +2624,7 @@ + Added Waypoints for 2023 Lobby Presents. - walker + Added New Year Cake Reminder. - hannibal2 -#### Stranded Featuers +#### Stranded Features + Highlights NPCs in the stranded menu that are placeable but havent been placed. - walker @@ -2672,7 +2727,7 @@ + Added toggle to hide autopet messages. - CalMWolfs + Not only Slayer, also Fishing and Diana item drops will now show in chat & title when over a custom defined price. - hannibal2 -+ Added Support to read Badlion sendcoords format. - Cad ++ Added Support to read BadLion sendcoords format. - Cad + Added an option to not show cooldown when ability is ready. - Obsidian + Added an option to highlight dungeon perm/vc parties. - Cad + Added Glowing Mush Mixin support to the Non-God Pod display. - jani @@ -2699,7 +2754,7 @@ + Show a text around the new year that the calendar is not loaded for the next Jacob Contest. - hannibal2 + Fixed visitor reward item refuse inconsistencies. - hannibal2 + Fixed wrong base 100ff calculations in the farming fortune needed display. - Alexia Luna -+ Fixed showing Sprayanator plot grid overlay outside garden. - HiZe ++ Fixed showing Sprayonator plot grid overlay outside garden. - HiZe + Fixed an error message in the composter inventory when hovering over some items. - hannibal2 + Correctly load the plot names of locked plots from inventory. - hannibal2 + Fixed the boosted crop not being highlighted during contest participation. - Alexia Luna @@ -2773,7 +2828,7 @@ + Fixed the city project time remaining "soon!" error. - hannibal2 + Fixed Slayer Profit Tracker display and price problems with Wisp's Ice Flavored Water Potion. - hannibal2 + Fixed an error message when closing the wheat minion in the Hub. - Thunderblade73 -+ Fixed locraw sending outside Hypixel. - walker ++ Fixed /locraw sending outside Hypixel. - walker + Fixed finished city project still reminding and suggests buying items. - hannibal2 + Open the city project inventory once again to fix warnings correctly. + Fixed kick alert triggering instantly. - Alexia Luna @@ -2826,7 +2881,7 @@ + Added test command /shsendtitle - Cad + Saving bingo goal data into the config. - hannibal2 + Added WorldEdit region selection preview support. - nea - + Command /shworldedit and rigth/left clicking with a wood axe work. + + Command /shworldedit and right/left clicking with a wood axe work. + Fixed error message in the "/shconfig set" command. - Thunderblade73 + Add a check for the SkyHanni repository ID in publish. - walker + Cleanup getItemsInOpenChest. - walker @@ -3057,7 +3112,7 @@ #### Events -+ Highlight Jerries during the Jerrypoclaypse. - Erymanthus ++ Highlight Jerries during the Jerrypocalypse. - Erymanthus + Show waypoints for Baskets of the Halloween Event in the main Hypixel lobby. - Erymanthus + Thanks Tobbbb for the coordinates! + Support for hiding basket waypoints once you have clicked on them. - hannibal2 @@ -3257,7 +3312,7 @@ + Fixed the leftStronghold area not getting detected. - hannibal2 + Fixed error message with Ashfang Blazes. - hannibal2 + Fixed crash with pet exp tooltip. - hannibal2 -+ Fixed dungeoneering showing as 0 in the skill menu. - hannibal2 ++ Fixed Dungeoneering showing as 0 in the skill menu. - hannibal2 + Fixed showing minion level as 101 in some menus. - hannibal2 #### Config @@ -3322,7 +3377,7 @@ + **King Talisman Helper** + Show kings you have not talked to yet, and when the next missing king will appear. + **Harp Keybinds** - NetheriteMiner - + In Melodys Harp, press buttons with your number row on the keyboard instead of clicking. + + In Melody's Harp, press buttons with your number row on the keyboard instead of clicking. + **Ender Node Tracker** - pretz + Tracks items and profit obtained from mining ender nodes and killing normal endermen. + **Fishing timer** now works in **Crystal Hollows** as well. (Worm fishing) @@ -4232,7 +4287,7 @@ + Add two more chat filter categories: Powder Mining and Winter Gifts. + Add catacombs class level color to party finder. + Add wishing compass uses amount display. -+ Saves missing items from canceled buy orders to clipboard for faster re-entry. ++ Saves missing items from cancelled buy orders to clipboard for faster re-entry. + Adds a visual highlight to the Croesus inventory that show what chests have not yet been opened. ### Removals diff --git a/docs/FEATURES.md b/docs/FEATURES.md index bf1ab853f127..6e549a1cfab0 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -203,6 +203,9 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Option to remove enchant descriptions. + Option to change enchant formatting. + Also parses tooltips from /show. ++ Favorite Power Stones. - saga (https://github.com/hannibal002/SkyHanni/pull/2002) + + Highlighted in the Thaumaturgy inventory. + + Shift-click to add/remove them.
@@ -277,7 +280,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Showing colors in the order inventory for outbid or fully bought/sold items. + Best Sell Method (Calculating the difference between instant-selling or using sell order for a selected bazaar item) -+ Saves missing items from canceled buy orders to clipboard for faster re-entry. ++ Saves missing items from cancelled buy orders to clipboard for faster re-entry. + Update Timer showing when the next api data update happens. + Price Website button. - hannibal2 + Adds a button to the bazaar product inventory that will open the item page in skyblock.bz. @@ -669,7 +672,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. + Show a Title when a pest spawns. - hannibal2 + Show the time since the last pest spawned in your garden. - hannibal2 + Option to only show the time while holding vacuum in the hand. -+ Show the pests that are attracted when changing the selected material of the Sprayanator. - hannibal2 ++ Show the pests that are attracted when changing the selected material of the Sprayonator. - hannibal2 + Garden only commands /home, /barn and /tp, and hotkeys. - hannibal2 + Showing a better plot name in the scoreboard. Updates faster and doesn't hide when pests are spawned. - hannibal2 + Show a display with all known pest locations. - hannibal2 @@ -854,7 +857,7 @@ Use `/sh` or `/skyhanni` to open the SkyHanni config in game. -+ Highlight Jerries during the Jerrypoclaypse. - Erymanthus ++ Highlight Jerries during the Jerrypocalypse. - Erymanthus + Show waypoints for Baskets of the Halloween Event in the main Hypixel lobby. - Erymanthus + Thanks Tobbbb for the coordinates! + Support for hiding basket waypoints once you have clicked on them. - hannibal2 diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index a3143ee36ac3..dde349f04b3e 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -1,485 +1,31 @@ package at.hannibal2.skyhanni -import at.hannibal2.skyhanni.api.CollectionAPI -import at.hannibal2.skyhanni.api.DataWatcherAPI -import at.hannibal2.skyhanni.api.GetFromSackAPI -import at.hannibal2.skyhanni.api.SkillAPI +import at.hannibal2.skyhanni.api.event.SkyHanniEvents 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.data.ActionBarData -import at.hannibal2.skyhanni.data.ActionBarStatsData -import at.hannibal2.skyhanni.data.BitsAPI -import at.hannibal2.skyhanni.data.BlockData -import at.hannibal2.skyhanni.data.BossbarData -import at.hannibal2.skyhanni.data.CropAccessoryData -import at.hannibal2.skyhanni.data.EntityMovementData -import at.hannibal2.skyhanni.data.EventCounter -import at.hannibal2.skyhanni.data.FameRanks -import at.hannibal2.skyhanni.data.FixedRateTimerManager -import at.hannibal2.skyhanni.data.FriendAPI -import at.hannibal2.skyhanni.data.GardenComposterUpgradesData -import at.hannibal2.skyhanni.data.GardenCropMilestones -import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix -import at.hannibal2.skyhanni.data.GardenCropUpgrades -import at.hannibal2.skyhanni.data.GuiData -import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.data.GuildAPI -import at.hannibal2.skyhanni.data.HighlightOnHoverSlot -import at.hannibal2.skyhanni.data.HotmData import at.hannibal2.skyhanni.data.HypixelData -import at.hannibal2.skyhanni.data.ItemAddManager -import at.hannibal2.skyhanni.data.ItemClickData -import at.hannibal2.skyhanni.data.ItemTipHelper -import at.hannibal2.skyhanni.data.LocationFixData -import at.hannibal2.skyhanni.data.MaxwellAPI -import at.hannibal2.skyhanni.data.MayorAPI -import at.hannibal2.skyhanni.data.MinecraftData -import at.hannibal2.skyhanni.data.MiningAPI import at.hannibal2.skyhanni.data.OtherInventoryData -import at.hannibal2.skyhanni.data.OwnInventoryData -import at.hannibal2.skyhanni.data.PartyAPI -import at.hannibal2.skyhanni.data.PetAPI -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.data.PurseAPI -import at.hannibal2.skyhanni.data.QuiverAPI -import at.hannibal2.skyhanni.data.RenderData -import at.hannibal2.skyhanni.data.SackAPI -import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.data.ScreenData import at.hannibal2.skyhanni.data.SkillExperience -import at.hannibal2.skyhanni.data.SlayerAPI -import at.hannibal2.skyhanni.data.TitleData -import at.hannibal2.skyhanni.data.TitleManager -import at.hannibal2.skyhanni.data.TrackerManager -import at.hannibal2.skyhanni.data.bazaar.HypixelBazaarFetcher -import at.hannibal2.skyhanni.data.hypixel.chat.PlayerChatManager -import at.hannibal2.skyhanni.data.hypixel.chat.PlayerNameFormatter import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.JacobContestsJson import at.hannibal2.skyhanni.data.jsonobjects.local.KnownFeaturesJson import at.hannibal2.skyhanni.data.jsonobjects.local.VisualWordsJson -import at.hannibal2.skyhanni.data.mob.MobData -import at.hannibal2.skyhanni.data.mob.MobDebug -import at.hannibal2.skyhanni.data.mob.MobDetection -import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.data.repo.RepoManager import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.PreInitFinishedEvent -import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper -import at.hannibal2.skyhanni.features.bingo.BingoAPI -import at.hannibal2.skyhanni.features.bingo.CompactBingoChat -import at.hannibal2.skyhanni.features.bingo.MinionCraftHelper -import at.hannibal2.skyhanni.features.bingo.card.BingoCardDisplay -import at.hannibal2.skyhanni.features.bingo.card.BingoCardReader -import at.hannibal2.skyhanni.features.bingo.card.BingoCardTips -import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper -import at.hannibal2.skyhanni.features.chat.ArachneChatMessageHider -import at.hannibal2.skyhanni.features.chat.ChatFilter -import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage -import at.hannibal2.skyhanni.features.chat.CompactSplashPotionMessage -import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages -import at.hannibal2.skyhanni.features.chat.RareDropMessages -import at.hannibal2.skyhanni.features.chat.SkyblockXPInChat +import at.hannibal2.skyhanni.events.utils.PreInitFinishedEvent import at.hannibal2.skyhanni.features.chat.Translator -import at.hannibal2.skyhanni.features.chat.WatchdogHider -import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter -import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatModifier -import at.hannibal2.skyhanni.features.chroma.ChromaManager -import at.hannibal2.skyhanni.features.combat.BestiaryData -import at.hannibal2.skyhanni.features.combat.FerocityDisplay -import at.hannibal2.skyhanni.features.combat.FlareDisplay -import at.hannibal2.skyhanni.features.combat.HideDamageSplash -import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager -import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter -import at.hannibal2.skyhanni.features.combat.mobs.AreaMiniBossFeatures -import at.hannibal2.skyhanni.features.combat.mobs.AshfangMinisNametagHider -import at.hannibal2.skyhanni.features.combat.mobs.MobHighlight -import at.hannibal2.skyhanni.features.combat.mobs.SpawnTimers -import at.hannibal2.skyhanni.features.commands.PartyChatCommands -import at.hannibal2.skyhanni.features.commands.PartyCommands -import at.hannibal2.skyhanni.features.commands.SendCoordinatedCommand -import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand -import at.hannibal2.skyhanni.features.commands.WarpIsCommand -import at.hannibal2.skyhanni.features.commands.WikiManager -import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete -import at.hannibal2.skyhanni.features.commands.tabcomplete.PlayerTabComplete -import at.hannibal2.skyhanni.features.commands.tabcomplete.TabComplete -import at.hannibal2.skyhanni.features.commands.tabcomplete.WarpTabComplete -import at.hannibal2.skyhanni.features.cosmetics.ArrowTrail -import at.hannibal2.skyhanni.features.cosmetics.CosmeticFollowingLine -import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker -import at.hannibal2.skyhanni.features.dungeon.DungeonAPI -import at.hannibal2.skyhanni.features.dungeon.DungeonArchitectFeatures -import at.hannibal2.skyhanni.features.dungeon.DungeonBossHideDamageSplash -import at.hannibal2.skyhanni.features.dungeon.DungeonBossMessages -import at.hannibal2.skyhanni.features.dungeon.DungeonChatFilter -import at.hannibal2.skyhanni.features.dungeon.DungeonCleanEnd -import at.hannibal2.skyhanni.features.dungeon.DungeonCopilot -import at.hannibal2.skyhanni.features.dungeon.DungeonDeathCounter -import at.hannibal2.skyhanni.features.dungeon.DungeonFinderFeatures -import at.hannibal2.skyhanni.features.dungeon.DungeonHideItems -import at.hannibal2.skyhanni.features.dungeon.DungeonHighlightClickedBlocks -import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder -import at.hannibal2.skyhanni.features.dungeon.DungeonMilestonesDisplay -import at.hannibal2.skyhanni.features.dungeon.DungeonRankTabListColor -import at.hannibal2.skyhanni.features.dungeon.DungeonShadowAssassinNotification -import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines -import at.hannibal2.skyhanni.features.dungeon.DungeonsRaceGuide -import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite -import at.hannibal2.skyhanni.features.dungeon.TerracottaPhase -import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures -import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList -import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper -import at.hannibal2.skyhanni.features.event.diana.DianaAPI -import at.hannibal2.skyhanni.features.event.diana.DianaFixChat -import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker -import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper -import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder -import at.hannibal2.skyhanni.features.event.diana.GriffinPetWarning -import at.hannibal2.skyhanni.features.event.diana.HighlightInquisitors -import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare -import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker -import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow -import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionData -import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats -import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggDisplayManager -import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggLocator -import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager -import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsShared -import at.hannibal2.skyhanni.features.event.hoppity.HoppityNpc -import at.hannibal2.skyhanni.features.event.jerry.HighlightJerries -import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker -import at.hannibal2.skyhanni.features.event.lobby.waypoints.christmas.PresentWaypoints -import at.hannibal2.skyhanni.features.event.lobby.waypoints.easter.EasterEggWaypoints -import at.hannibal2.skyhanni.features.event.lobby.waypoints.halloween.BasketWaypoints -import at.hannibal2.skyhanni.features.event.spook.TheGreatSpook -import at.hannibal2.skyhanni.features.event.winter.JyrreTimer -import at.hannibal2.skyhanni.features.event.winter.NewYearCakeReminder -import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter -import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder -import at.hannibal2.skyhanni.features.fame.CityProjectFeatures -import at.hannibal2.skyhanni.features.fishing.ChumBucketHider -import at.hannibal2.skyhanni.features.fishing.FishingAPI -import at.hannibal2.skyhanni.features.fishing.FishingBaitWarnings -import at.hannibal2.skyhanni.features.fishing.FishingHookDisplay -import at.hannibal2.skyhanni.features.fishing.FishingTimer -import at.hannibal2.skyhanni.features.fishing.IsFishingDetection -import at.hannibal2.skyhanni.features.fishing.SeaCreatureFeatures -import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager -import at.hannibal2.skyhanni.features.fishing.SeaCreatureMessageShortener -import at.hannibal2.skyhanni.features.fishing.SharkFishCounter -import at.hannibal2.skyhanni.features.fishing.ShowFishingItemName -import at.hannibal2.skyhanni.features.fishing.ThunderSparksHighlight -import at.hannibal2.skyhanni.features.fishing.TotemOfCorruption -import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker -import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker -import at.hannibal2.skyhanni.features.fishing.trophy.GeyserFishing -import at.hannibal2.skyhanni.features.fishing.trophy.OdgerWaypoint -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishDisplay -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishFillet -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishMessages -import at.hannibal2.skyhanni.features.garden.AnitaMedalProfit -import at.hannibal2.skyhanni.features.garden.AtmosphericFilterDisplay -import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay -import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.GardenCropMilestoneFix -import at.hannibal2.skyhanni.features.garden.GardenLevelDisplay -import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest -import at.hannibal2.skyhanni.features.garden.GardenOptimalSpeed -import at.hannibal2.skyhanni.features.garden.GardenPlotAPI -import at.hannibal2.skyhanni.features.garden.GardenPlotBorders -import at.hannibal2.skyhanni.features.garden.GardenWarpCommands -import at.hannibal2.skyhanni.features.garden.GardenYawAndPitch -import at.hannibal2.skyhanni.features.garden.SensitivityReducer -import at.hannibal2.skyhanni.features.garden.ToolTooltipTweaks -import at.hannibal2.skyhanni.features.garden.composter.ComposterDisplay -import at.hannibal2.skyhanni.features.garden.composter.ComposterInventoryNumbers -import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay -import at.hannibal2.skyhanni.features.garden.composter.GardenComposterInventoryFeatures -import at.hannibal2.skyhanni.features.garden.contest.FarmingContestAPI -import at.hannibal2.skyhanni.features.garden.contest.JacobContestFFNeededDisplay -import at.hannibal2.skyhanni.features.garden.contest.JacobContestStatsSummary -import at.hannibal2.skyhanni.features.garden.contest.JacobContestTimeNeeded -import at.hannibal2.skyhanni.features.garden.contest.JacobFarmingContestsInventory -import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker -import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay -import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter -import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay -import at.hannibal2.skyhanni.features.garden.farming.GardenBestCropTime -import at.hannibal2.skyhanni.features.garden.farming.GardenBurrowingSporesNotifier -import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay -import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed -import at.hannibal2.skyhanni.features.garden.farming.GardenCustomKeybinds -import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation -import at.hannibal2.skyhanni.features.garden.farming.WildStrawberryDyeNotification -import at.hannibal2.skyhanni.features.garden.farming.WrongFungiCutterWarning -import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneAPI -import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneCreator -import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneFeatures -import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear -import at.hannibal2.skyhanni.features.garden.inventory.AnitaExtraFarmingFortune -import at.hannibal2.skyhanni.features.garden.inventory.GardenCropMilestoneInventory -import at.hannibal2.skyhanni.features.garden.inventory.GardenInventoryNumbers -import at.hannibal2.skyhanni.features.garden.inventory.GardenInventoryTooltipOverflow -import at.hannibal2.skyhanni.features.garden.inventory.LogBookStats -import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice -import at.hannibal2.skyhanni.features.garden.inventory.plots.GardenNextPlotPrice -import at.hannibal2.skyhanni.features.garden.inventory.plots.GardenPlotIcon -import at.hannibal2.skyhanni.features.garden.inventory.plots.GardenPlotMenuHighlighting -import at.hannibal2.skyhanni.features.garden.pests.PestAPI -import at.hannibal2.skyhanni.features.garden.pests.PestFinder -import at.hannibal2.skyhanni.features.garden.pests.PestParticleLine -import at.hannibal2.skyhanni.features.garden.pests.PestParticleWaypoint -import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker -import at.hannibal2.skyhanni.features.garden.pests.PestSpawn -import at.hannibal2.skyhanni.features.garden.pests.PestSpawnTimer -import at.hannibal2.skyhanni.features.garden.pests.SprayDisplay -import at.hannibal2.skyhanni.features.garden.pests.SprayFeatures -import at.hannibal2.skyhanni.features.garden.pests.StereoHarmonyDisplay -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorDropStatistics -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorFeatures -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorSupercraft -import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorTimer -import at.hannibal2.skyhanni.features.garden.visitor.HighlightVisitorsOutsideOfGarden -import at.hannibal2.skyhanni.features.garden.visitor.NPCVisitorFix -import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI -import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener -import at.hannibal2.skyhanni.features.garden.visitor.VisitorRewardWarning -import at.hannibal2.skyhanni.features.gui.MovableHotBar -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard -import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern -import at.hannibal2.skyhanni.features.gui.quiver.QuiverDisplay -import at.hannibal2.skyhanni.features.gui.quiver.QuiverWarning -import at.hannibal2.skyhanni.features.inventory.AuctionOutbidWarning -import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter -import at.hannibal2.skyhanni.features.inventory.ChestValue -import at.hannibal2.skyhanni.features.inventory.DojoRankDisplay -import at.hannibal2.skyhanni.features.inventory.HarpFeatures -import at.hannibal2.skyhanni.features.inventory.HeldTimeInLore -import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems -import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks -import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures -import at.hannibal2.skyhanni.features.inventory.ItemStars -import at.hannibal2.skyhanni.features.inventory.MaxPurseItems -import at.hannibal2.skyhanni.features.inventory.PowerStoneGuideFeatures -import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures -import at.hannibal2.skyhanni.features.inventory.RngMeterInventory -import at.hannibal2.skyhanni.features.inventory.SackDisplay -import at.hannibal2.skyhanni.features.inventory.ShiftClickBrewing -import at.hannibal2.skyhanni.features.inventory.ShiftClickEquipment -import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell -import at.hannibal2.skyhanni.features.inventory.SkyblockGuideHighlightFeature -import at.hannibal2.skyhanni.features.inventory.StatsTuning -import at.hannibal2.skyhanni.features.inventory.SuperCraftFeatures -import at.hannibal2.skyhanni.features.inventory.SuperpairsClicksAlert -import at.hannibal2.skyhanni.features.inventory.UltraRareBookAlert -import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseCopyUnderbidPrice -import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseOpenPriceWebsite -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarBestSellMethod -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarCancelledBuyOrderClipboard -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarOpenPriceWebsite -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarOrderHelper -import at.hannibal2.skyhanni.features.inventory.bazaar.CraftMaterialsFromBazaar -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryBarnManager -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryCustomReminder -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryDataLoader -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryInventory -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryKeybinds -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryShortcut -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStats -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTimeTowerManager -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltip -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryTooltipCompact -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryUpgradeWarning -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice -import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayHelper -import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints -import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer -import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles -import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown -import at.hannibal2.skyhanni.features.mining.ColdOverlay -import at.hannibal2.skyhanni.features.mining.DeepCavernsGuide -import at.hannibal2.skyhanni.features.mining.GoldenGoblinHighlight -import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs -import at.hannibal2.skyhanni.features.mining.HotmFeatures -import at.hannibal2.skyhanni.features.mining.KingTalismanHelper -import at.hannibal2.skyhanni.features.mining.MiningCommissionsBlocksColor -import at.hannibal2.skyhanni.features.mining.MiningNotifications -import at.hannibal2.skyhanni.features.mining.TunnelsMaps -import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore -import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsWalls -import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventDisplay -import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker -import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker -import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI -import at.hannibal2.skyhanni.features.mining.fossilexcavator.GlacitePowderFeatures -import at.hannibal2.skyhanni.features.mining.fossilexcavator.ProfitPerExcavation -import at.hannibal2.skyhanni.features.mining.fossilexcavator.solver.FossilSolverDisplay -import at.hannibal2.skyhanni.features.mining.glacitemineshaft.CorpseLocator -import at.hannibal2.skyhanni.features.mining.glacitemineshaft.MineshaftWaypoints -import at.hannibal2.skyhanni.features.mining.mineshaft.CorpseAPI -import at.hannibal2.skyhanni.features.mining.mineshaft.MineshaftCorpseProfitPer -import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker -import at.hannibal2.skyhanni.features.minion.InfernoMinionFeatures -import at.hannibal2.skyhanni.features.minion.MinionCollectLogic -import at.hannibal2.skyhanni.features.minion.MinionFeatures -import at.hannibal2.skyhanni.features.minion.MinionXp -import at.hannibal2.skyhanni.features.misc.AuctionHousePriceComparison -import at.hannibal2.skyhanni.features.misc.BetterSignEditing -import at.hannibal2.skyhanni.features.misc.BetterWikiFromMenus -import at.hannibal2.skyhanni.features.misc.BrewingStandOverlay -import at.hannibal2.skyhanni.features.misc.ButtonOnPause import at.hannibal2.skyhanni.features.misc.CollectionTracker -import at.hannibal2.skyhanni.features.misc.ContributorManager -import at.hannibal2.skyhanni.features.misc.CopyPlaytime -import at.hannibal2.skyhanni.features.misc.CurrentPetDisplay -import at.hannibal2.skyhanni.features.misc.CustomTextBox -import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider -import at.hannibal2.skyhanni.features.misc.FixGhostEntities -import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls -import at.hannibal2.skyhanni.features.misc.HideArmor -import at.hannibal2.skyhanni.features.misc.HideFarEntities -import at.hannibal2.skyhanni.features.misc.InGameDateDisplay -import at.hannibal2.skyhanni.features.misc.InWaterDisplay -import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows -import at.hannibal2.skyhanni.features.misc.LesserOrbHider -import at.hannibal2.skyhanni.features.misc.LockMouseLook -import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager -import at.hannibal2.skyhanni.features.misc.MiscFeatures -import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay -import at.hannibal2.skyhanni.features.misc.NoBitsWarning -import at.hannibal2.skyhanni.features.misc.NonGodPotEffectDisplay -import at.hannibal2.skyhanni.features.misc.ParticleHider -import at.hannibal2.skyhanni.features.misc.PartyMemberOutlines -import at.hannibal2.skyhanni.features.misc.PatcherSendCoordinates -import at.hannibal2.skyhanni.features.misc.PetCandyUsedDisplay -import at.hannibal2.skyhanni.features.misc.PetExpTooltip -import at.hannibal2.skyhanni.features.misc.PetItemDisplay -import at.hannibal2.skyhanni.features.misc.PocketSackInASackDisplay -import at.hannibal2.skyhanni.features.misc.PrivateIslandNoPickaxeAbility -import at.hannibal2.skyhanni.features.misc.QuickModMenuSwitch -import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals -import at.hannibal2.skyhanni.features.misc.RestorePieceOfWizardPortalLore -import at.hannibal2.skyhanni.features.misc.ServerRestartTitle -import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration -import at.hannibal2.skyhanni.features.misc.TabWidgetSettings -import at.hannibal2.skyhanni.features.misc.TimeFeatures -import at.hannibal2.skyhanni.features.misc.TpsCounter -import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList -import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader -import at.hannibal2.skyhanni.features.misc.compacttablist.TabListRenderer -import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager -import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue -import at.hannibal2.skyhanni.features.misc.items.EstimatedWardrobePrice -import at.hannibal2.skyhanni.features.misc.items.GlowingDroppedItems -import at.hannibal2.skyhanni.features.misc.items.enchants.EnchantParser -import at.hannibal2.skyhanni.features.misc.limbo.LimboPlaytime -import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker -import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures -import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadCompactName -import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadInventoryNumber -import at.hannibal2.skyhanni.features.misc.trevor.TrevorFeatures -import at.hannibal2.skyhanni.features.misc.trevor.TrevorSolver -import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker -import at.hannibal2.skyhanni.features.misc.update.UpdateManager -import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords -import at.hannibal2.skyhanni.features.nether.MatriarchHelper -import at.hannibal2.skyhanni.features.nether.PabloHelper -import at.hannibal2.skyhanni.features.nether.SulphurSkitterBox -import at.hannibal2.skyhanni.features.nether.VolcanoExplosivityDisplay -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazes -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazingSouls -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangHideDamageIndicator -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangHideParticles -import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown -import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper -import at.hannibal2.skyhanni.features.rift.RiftAPI -import at.hannibal2.skyhanni.features.rift.area.colosseum.BlobbercystsHighlight -import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftAgaricusCap -import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftWiltedBerberisHelper -import at.hannibal2.skyhanni.features.rift.area.dreadfarm.VoltHighlighter -import at.hannibal2.skyhanni.features.rift.area.livingcave.LivingCaveDefenseBlocks -import at.hannibal2.skyhanni.features.rift.area.livingcave.LivingCaveLivingMetalHelper -import at.hannibal2.skyhanni.features.rift.area.livingcave.LivingMetalSuitProgress -import at.hannibal2.skyhanni.features.rift.area.mirrorverse.DanceRoomHelper -import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftLavaMazeParkour -import at.hannibal2.skyhanni.features.rift.area.mirrorverse.RiftUpsideDownParkour -import at.hannibal2.skyhanni.features.rift.area.mirrorverse.TubulatorParkour -import at.hannibal2.skyhanni.features.rift.area.stillgorechateau.RiftBloodEffigies -import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminHighlighter -import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker -import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonHacking -import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftLarva -import at.hannibal2.skyhanni.features.rift.area.wyldwoods.RiftOdonata -import at.hannibal2.skyhanni.features.rift.area.wyldwoods.ShyCruxWarnings -import at.hannibal2.skyhanni.features.rift.everywhere.CruxTalismanDisplay -import at.hannibal2.skyhanni.features.rift.everywhere.EnigmaSoulWaypoints -import at.hannibal2.skyhanni.features.rift.everywhere.HighlightRiftGuide -import at.hannibal2.skyhanni.features.rift.everywhere.RiftHorsezookaHider -import at.hannibal2.skyhanni.features.rift.everywhere.RiftTimer -import at.hannibal2.skyhanni.features.rift.everywhere.motes.RiftMotesOrb -import at.hannibal2.skyhanni.features.rift.everywhere.motes.ShowMotesNpcSellPrice -import at.hannibal2.skyhanni.features.skillprogress.SkillProgress -import at.hannibal2.skyhanni.features.skillprogress.SkillTooltip -import at.hannibal2.skyhanni.features.slayer.HideMobNames -import at.hannibal2.skyhanni.features.slayer.SlayerBossSpawnSoon -import at.hannibal2.skyhanni.features.slayer.SlayerItemsOnGround -import at.hannibal2.skyhanni.features.slayer.SlayerMiniBossFeatures -import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker -import at.hannibal2.skyhanni.features.slayer.SlayerQuestWarning -import at.hannibal2.skyhanni.features.slayer.SlayerRngMeterDisplay -import at.hannibal2.skyhanni.features.slayer.VampireSlayerFeatures -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning -import at.hannibal2.skyhanni.features.slayer.blaze.FirePillarDisplay -import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper -import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerFeatures -import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerHideParticles -import at.hannibal2.skyhanni.features.stranded.HighlightPlaceableNpcs -import at.hannibal2.skyhanni.features.summonings.SummoningMobManager -import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName -import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.skyhannimodule.LoadedModules -import at.hannibal2.skyhanni.test.HighlightMissingRepoItems -import at.hannibal2.skyhanni.test.PacketTest -import at.hannibal2.skyhanni.test.ParkourWaypointSaver -import at.hannibal2.skyhanni.test.ShowItemUuid import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests -import at.hannibal2.skyhanni.test.TestBingo -import at.hannibal2.skyhanni.test.TestCopyBestiaryValues -import at.hannibal2.skyhanni.test.TestCopyRngMeterValues -import at.hannibal2.skyhanni.test.TestExportTools -import at.hannibal2.skyhanni.test.TestShowSlotNumber -import at.hannibal2.skyhanni.test.WorldEdit import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.test.command.TrackParticlesCommand -import at.hannibal2.skyhanni.test.command.TrackSoundsCommand import at.hannibal2.skyhanni.test.hotswap.HotswapSupport -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.EntityOutlineRenderer -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.KeyboardManager -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging -import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded -import at.hannibal2.skyhanni.utils.TabListData -import at.hannibal2.skyhanni.utils.UtilsPatterns -import at.hannibal2.skyhanni.utils.renderables.RenderableTooltips -import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternManager import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -502,7 +48,7 @@ import org.apache.logging.log4j.Logger clientSideOnly = true, useMetadata = true, guiFactory = "at.hannibal2.skyhanni.config.ConfigGuiForgeInterop", - version = "0.26.Beta.6", + version = "0.26.Beta.8", ) class SkyHanniMod { @@ -516,481 +62,23 @@ class SkyHanniMod { LoadedModules.modules.forEach { loadModule(it) } // data - loadModule(PlayerChatManager()) - loadModule(PlayerNameFormatter()) loadModule(HypixelData()) - loadModule(LocationFixData) - loadModule(DungeonAPI) - loadModule(ScoreboardData()) - loadModule(SeaCreatureFeatures()) - loadModule(SeaCreatureManager()) - loadModule(MobData()) - loadModule(MobDetection()) - loadModule(EntityMovementData) - loadModule(TestExportTools) - loadModule(ItemClickData()) -// loadModule(Year300RaffleEvent) - loadModule(MinecraftData) - loadModule(TitleManager()) - loadModule(ItemTipHelper()) - loadModule(RenderLivingEntityHelper()) loadModule(SkillExperience()) - loadModule(OtherInventoryData) - loadModule(TabListData) - loadModule(RenderData()) - loadModule(GardenCropMilestones) - loadModule(GardenCropMilestonesCommunityFix) - loadModule(MovableHotBar()) - loadModule(GardenCropUpgrades) - loadModule(VisitorListener()) - loadModule(VisitorRewardWarning()) - loadModule(OwnInventoryData()) - loadModule(ScreenData) - loadModule(HighlightVisitorsOutsideOfGarden()) - loadModule(GuiEditManager()) - loadModule(GetFromSackAPI) - loadModule(UpdateManager) - loadModule(CropAccessoryData) - loadModule(GardenComposterUpgradesData()) - loadModule(ActionBarStatsData) - loadModule(GardenCropMilestoneInventory()) - loadModule(GardenCropSpeed) - loadModule(GardenWarpCommands()) - loadModule(ProfileStorageData) - loadModule(TitleData()) - loadModule(BlockData()) - loadModule(DefaultConfigFeatures) - loadModule(EntityOutlineRenderer) - loadModule(KeyboardManager) - loadModule(AdvancedPlayerList) - loadModule(ItemAddManager()) - loadModule(BingoCardReader()) - loadModule(DeepCavernsGuide()) - loadModule(DungeonsRaceGuide()) - loadModule(GardenBestCropTime()) - loadModule(ActionBarData) - loadModule(TrackerManager) - loadModule(ScoreboardPattern) - loadModule(UtilsPatterns) - loadModule(GuiData) - loadModule(BossbarData) - loadModule(EntityUtils) - loadModule(ChatUtils) - loadModule(FixedRateTimerManager()) - loadModule(ChromaManager) - loadModule(TabWidget) - loadModule(HotmData) - loadModule(ContributorManager) - loadModule(TabComplete) - loadModule(HypixelBazaarFetcher) - loadModule(EventCounter) - - // APIs - loadModule(BazaarApi()) - loadModule(GardenAPI) - loadModule(GardenPlotAPI) - loadModule(DataWatcherAPI()) - loadModule(CollectionAPI) - loadModule(FarmingContestAPI) - loadModule(HighlightOnHoverSlot) - loadModule(FriendAPI) - loadModule(PartyAPI) - loadModule(GuildAPI) - loadModule(SlayerAPI) - loadModule(PurseAPI) - loadModule(RiftAPI) - loadModule(SackAPI) - loadModule(BingoAPI) - loadModule(FameRanks) - loadModule(FishingAPI) - loadModule(MaxwellAPI) - loadModule(QuiverAPI) - loadModule(BitsAPI) - loadModule(MayorAPI) - loadModule(SkillAPI) - loadModule(VisitorAPI) - loadModule(KuudraAPI) - loadModule(PetAPI) - loadModule(IsFishingDetection) - loadModule(LorenzUtils) - loadModule(NEUItems) - loadModule(PestAPI) - loadModule(MiningAPI) - loadModule(FossilExcavatorAPI) - loadModule(ChocolateFactoryAPI) - loadModule(RenderableTooltips) - loadModule(DianaAPI) // features - loadModule(BazaarOrderHelper()) - loadModule(AuctionsHighlighter) - loadModule(ChatFilter()) - loadModule(PlayerChatModifier()) - loadModule(DungeonChatFilter()) - loadModule(HideNotClickableItems()) - loadModule(ItemDisplayOverlayFeatures) - loadModule(CurrentPetDisplay()) - loadModule(HideFarEntities()) - loadModule(ExpOrbsOnGroundHider()) - loadModule(BetterWikiFromMenus()) - loadModule(DamageIndicatorManager()) - loadModule(ItemAbilityCooldown()) - loadModule(DungeonHighlightClickedBlocks()) - loadModule(DungeonMilestonesDisplay) - loadModule(DungeonDeathCounter()) - loadModule(DungeonCleanEnd()) - loadModule(TunnelsMaps()) - loadModule(DungeonBossMessages()) - loadModule(DungeonBossHideDamageSplash()) - loadModule(UniqueGiftingOpportunitiesFeatures) - loadModule(UniqueGiftCounter) - loadModule(TrophyFishManager) - loadModule(TrophyFishFillet()) - loadModule(TrophyFishMessages()) - loadModule(GeyserFishing()) - loadModule(BazaarBestSellMethod()) - loadModule(ShiftClickBrewing()) - loadModule(BazaarOpenPriceWebsite()) - loadModule(AuctionHouseCopyUnderbidPrice()) - loadModule(AuctionHouseOpenPriceWebsite()) - loadModule(AnvilCombineHelper()) - loadModule(SeaCreatureMessageShortener()) - loadModule(AshfangFreezeCooldown) - loadModule(AshfangNextResetCooldown()) - loadModule(CrystalHollowsWalls()) - loadModule(SummoningSoulsName()) - loadModule(AshfangGravityOrbs()) - loadModule(AshfangBlazingSouls()) - loadModule(AshfangBlazes()) - loadModule(AshfangHideParticles()) - loadModule(AshfangHideDamageIndicator()) - loadModule(ItemStars()) - loadModule(MinionFeatures) - loadModule(TimeFeatures()) - loadModule(RngMeterInventory()) - loadModule(WikiManager) - loadModule(SendCoordinatedCommand()) - loadModule(WarpIsCommand()) - loadModule(ViewRecipeCommand) - loadModule(PartyCommands) - loadModule(PartyChatCommands) - loadModule(SummoningMobManager()) - loadModule(SkyblockXPInChat()) - loadModule(AreaMiniBossFeatures()) - loadModule(MobHighlight()) - loadModule(ChocolateFactoryDataLoader) - loadModule(ChocolateFactoryBarnManager) - loadModule(ChocolateFactoryShortcut()) - loadModule(ChocolateFactoryInventory) - loadModule(ChocolateFactoryStats) - loadModule(ChocolateFactoryTooltipCompact) - loadModule(ChocolateFactoryTimeTowerManager) - loadModule(ChocolateFactoryTooltip) - loadModule(ChocolateFactoryKeybinds) - loadModule(ChocolateShopPrice) - loadModule(ChocolateFactoryUpgradeWarning) - loadModule(ChocolateFactoryCustomReminder) - loadModule(HoppityNpc) - loadModule(HoppityEggsManager) - loadModule(HoppityEggLocator) - loadModule(HoppityEggsShared) - loadModule(HoppityEggDisplayManager) - loadModule(HoppityCollectionData) - loadModule(HoppityCollectionStats) - loadModule(SpawnTimers()) - loadModule(MarkedPlayerManager()) - loadModule(SlayerMiniBossFeatures()) - loadModule(PlayerDeathMessages()) - loadModule(HighlightDungeonDeathmite()) - loadModule(DungeonHideItems()) - loadModule(DungeonCopilot()) - loadModule(DungeonArchitectFeatures()) - loadModule(EndermanSlayerFeatures()) - loadModule(FireVeilWandParticles()) - loadModule(HideMobNames()) - loadModule(HideDamageSplash()) - loadModule(FerocityDisplay()) - loadModule(FlareDisplay) - loadModule(InGameDateDisplay()) - loadModule(ThunderSparksHighlight()) - loadModule(BlazeSlayerDaggerHelper()) - loadModule(HellionShieldHelper()) - loadModule(BlazeSlayerFirePitsWarning()) - loadModule(BlazeSlayerClearView()) - loadModule(FirePillarDisplay()) - loadModule(EndermanSlayerHideParticles()) - loadModule(PlayerChatFilter()) - loadModule(HideArmor()) - loadModule(SlayerQuestWarning()) - loadModule(StatsTuning()) - loadModule(NonGodPotEffectDisplay()) - loadModule(SoopyGuessBurrow()) - loadModule(HotmFeatures()) - loadModule(DianaProfitTracker) - loadModule(DianaFixChat()) - loadModule(MythologicalCreatureTracker) - loadModule(ShiftClickNPCSell) - loadModule(HighlightJerries()) - loadModule(TheGreatSpook()) - loadModule(GriffinBurrowHelper) - loadModule(AllBurrowsList) - loadModule(GriffinBurrowParticleFinder) - loadModule(BurrowWarpHelper()) loadModule(CollectionTracker()) - loadModule(HighlightBonzoMasks) - loadModule(BazaarCancelledBuyOrderClipboard()) - loadModule(CompactSplashPotionMessage()) - loadModule(CroesusChestTracker()) - loadModule(CompactBingoChat()) - loadModule(BrewingStandOverlay()) - loadModule(FishingTimer()) - loadModule(MatriarchHelper()) - loadModule(LesserOrbHider()) - loadModule(FishingHookDisplay()) loadModule(CrimsonIsleReputationHelper(this)) - loadModule(SkyblockGuideHighlightFeature) - loadModule(SharkFishCounter()) - loadModule(PowerStoneGuideFeatures()) - loadModule(OdgerWaypoint()) - loadModule(TrophyFishDisplay) - loadModule(TiaRelayHelper()) - loadModule(TiaRelayWaypoints()) - loadModule(BasketWaypoints()) - loadModule(EasterEggWaypoints()) - loadModule(BingoCardDisplay()) - loadModule(BingoNextStepHelper()) - loadModule(MinionCraftHelper()) - loadModule(TpsCounter()) - loadModule(ParticleHider()) - loadModule(MiscFeatures) - loadModule(ReplaceRomanNumerals()) - loadModule(GardenPlotMenuHighlighting()) - loadModule(SkyMartCopperPrice()) - loadModule(GardenVisitorFeatures) - loadModule(GardenVisitorSupercraft()) - loadModule(NPCVisitorFix) - loadModule(GardenInventoryNumbers()) - loadModule(GardenVisitorTimer()) - loadModule(MinionXp()) - loadModule(GardenNextPlotPrice()) - loadModule(GardenCropMilestoneDisplay) - loadModule(GardenCustomKeybinds) - loadModule(ChickenHeadTimer()) - loadModule(FossilSolverDisplay) - loadModule(ExcavatorProfitTracker()) - loadModule(ProfitPerExcavation()) - loadModule(GlacitePowderFeatures()) - loadModule(MineshaftCorpseProfitPer()) - loadModule(MineshaftWaypoints) - loadModule(CorpseLocator) - loadModule(CorpseAPI()) - loadModule(GardenOptimalSpeed()) - loadModule(GardenLevelDisplay()) loadModule(FarmingWeightDisplay()) - loadModule(DicerRngDropTracker) - loadModule(PrivateIslandNoPickaxeAbility()) - loadModule(CropMoneyDisplay) - loadModule(JacobFarmingContestsInventory()) - loadModule(GardenNextJacobContest) - loadModule(WrongFungiCutterWarning()) - loadModule(ArmorDropTracker) - loadModule(FarmingLaneAPI) - loadModule(FarmingLaneFeatures) - loadModule(FarmingLaneCreator) - loadModule(JoinCrystalHollows()) - loadModule(CrystalHollowsNamesInCore()) - loadModule(GardenVisitorColorNames) - loadModule(TeleportPadCompactName()) - loadModule(AnitaMedalProfit()) - loadModule(AtmosphericFilterDisplay()) - loadModule(AnitaExtraFarmingFortune()) - loadModule(ComposterDisplay()) - loadModule(GardenComposterInventoryFeatures()) - loadModule(MinionCollectLogic()) - loadModule(BetterSignEditing()) - loadModule(PatcherSendCoordinates()) - loadModule(PetItemDisplay()) - loadModule(EstimatedItemValue) - loadModule(EstimatedWardrobePrice()) - loadModule(ComposterInventoryNumbers()) - loadModule(FarmingFortuneDisplay) - loadModule(ToolTooltipTweaks()) - loadModule(CropSpeedMeter()) - loadModule(AshfangMinisNametagHider()) - loadModule(TeleportPadInventoryNumber()) - loadModule(ComposterOverlay) - loadModule(DiscordRPCManager) - loadModule(GardenCropMilestoneFix()) - loadModule(GardenBurrowingSporesNotifier()) - loadModule(WildStrawberryDyeNotification()) - loadModule(JacobContestFFNeededDisplay()) - loadModule(JacobContestTimeNeeded()) - loadModule(JacobContestStatsSummary()) - loadModule(GardenYawAndPitch()) - loadModule(MovementSpeedDisplay()) - loadModule(ChumBucketHider()) - loadModule(InquisitorWaypointShare) - loadModule(TrevorFeatures) - loadModule(TrevorSolver) - loadModule(TrevorTracker) - loadModule(BingoCardTips()) - loadModule(GardenVisitorDropStatistics) - loadModule(CaptureFarmingGear) - loadModule(SackDisplay) - loadModule(GardenStartLocation) - loadModule(PetCandyUsedDisplay()) - loadModule(ServerRestartTitle) - loadModule(CityProjectFeatures()) - loadModule(GardenPlotIcon) - loadModule(GardenPlotBorders) - loadModule(LogBookStats()) - loadModule(PocketSackInASackDisplay()) - loadModule(ShowFishingItemName()) - loadModule(WarpTabComplete) - loadModule(PlayerTabComplete) - loadModule(GetFromSacksTabComplete) - loadModule(SlayerProfitTracker) - loadModule(FishingProfitTracker) - loadModule(SeaCreatureTracker) - loadModule(SlayerItemsOnGround()) - loadModule(RestorePieceOfWizardPortalLore()) - loadModule(QuickModMenuSwitch) - loadModule(ArachneChatMessageHider()) - loadModule(ShowItemUuid()) - loadModule(FrozenTreasureTracker) - loadModule(MiningEventDisplay) - loadModule(MiningCommissionsBlocksColor) - loadModule(SlayerRngMeterDisplay()) - loadModule(GhostCounter) - loadModule(RiftTimer()) - loadModule(HighlightRiftGuide()) - loadModule(ShyCruxWarnings()) - loadModule(RiftLarva()) - loadModule(VoltHighlighter()) - loadModule(RiftOdonata()) - loadModule(RiftAgaricusCap()) - loadModule(KloonHacking()) - loadModule(EnigmaSoulWaypoints) - loadModule(DungeonLividFinder) - loadModule(CruxTalismanDisplay) - loadModule(DanceRoomHelper) - loadModule(TubulatorParkour()) - loadModule(CustomTextBox()) - loadModule(RiftUpsideDownParkour()) - loadModule(RiftLavaMazeParkour()) - loadModule(HighlightMiningCommissionMobs()) - loadModule(ShowMotesNpcSellPrice()) - loadModule(LivingMetalSuitProgress()) - loadModule(VampireSlayerFeatures) - loadModule(BlobbercystsHighlight()) - loadModule(LivingCaveDefenseBlocks()) - loadModule(LivingCaveLivingMetalHelper()) - loadModule(RiftMotesOrb()) - loadModule(ChestValue()) - loadModule(SlayerBossSpawnSoon()) - loadModule(RiftBloodEffigies) - loadModule(RiftWiltedBerberisHelper()) - loadModule(RiftHorsezookaHider()) - loadModule(GriffinPetWarning()) - loadModule(BestiaryData) - loadModule(KingTalismanHelper()) - loadModule(HarpFeatures) - loadModule(EnderNodeTracker) - loadModule(CompactBestiaryChatMessage()) - loadModule(WatchdogHider()) - loadModule(AuctionHousePriceComparison()) - loadModule(AccountUpgradeReminder()) - loadModule(PetExpTooltip()) loadModule(Translator()) - loadModule(CosmeticFollowingLine()) - loadModule(SuperpairsClicksAlert()) - loadModule(UltraRareBookAlert) - loadModule(PowderTracker) - loadModule(ModifyVisualWords) - loadModule(TabListReader) - loadModule(TabListRenderer) - loadModule(GlowingDroppedItems()) - loadModule(DungeonTeammateOutlines()) - loadModule(DungeonRankTabListColor()) - loadModule(TerracottaPhase()) - loadModule(VolcanoExplosivityDisplay()) - loadModule(FixNEUHeavyPearls()) - loadModule(QuickCraftFeatures()) - loadModule(SkyBlockKickDuration()) - loadModule(LimboTimeTracker) - loadModule(PartyMemberOutlines()) - loadModule(ArrowTrail()) - loadModule(ShiftClickEquipment()) - loadModule(LockMouseLook) - loadModule(SensitivityReducer) - loadModule(DungeonFinderFeatures()) - loadModule(GoldenGoblinHighlight()) - loadModule(TabWidgetSettings()) - loadModule(EnchantParser) - loadModule(PabloHelper()) - loadModule(FishingBaitWarnings()) - loadModule(CustomScoreboard()) - loadModule(RepoPatternManager) - loadModule(PestSpawn()) - loadModule(PestSpawnTimer) - loadModule(PestFinder) - loadModule(PestParticleWaypoint()) - loadModule(StereoHarmonyDisplay()) - loadModule(PestParticleLine()) - loadModule(SprayFeatures()) - loadModule(DojoRankDisplay()) - loadModule(SprayDisplay()) - loadModule(HighlightPlaceableNpcs()) - loadModule(PresentWaypoints()) - loadModule(MiningEventTracker()) - loadModule(InWaterDisplay) - loadModule(MiningNotifications) - loadModule(JyrreTimer()) - loadModule(TotemOfCorruption()) - loadModule(NewYearCakeReminder()) - loadModule(SulphurSkitterBox()) - loadModule(HighlightInquisitors()) - loadModule(VerminTracker) - loadModule(VerminHighlighter()) - loadModule(SkillProgress) - loadModule(GardenInventoryTooltipOverflow()) - loadModule(SkillTooltip()) - loadModule(MaxPurseItems()) - loadModule(SuperCraftFeatures) - loadModule(HeldTimeInLore) - loadModule(InfernoMinionFeatures()) - loadModule(LimboPlaytime) - loadModule(CopyPlaytime) - loadModule(RareDropMessages()) - loadModule(CraftMaterialsFromBazaar()) - loadModule(DungeonShadowAssassinNotification()) - loadModule(PestProfitTracker) - loadModule(NoBitsWarning) - loadModule(ColdOverlay()) - loadModule(QuiverDisplay()) - loadModule(QuiverWarning()) - loadModule(AuctionOutbidWarning) // test stuff loadModule(SkyHanniDebugsAndTests()) - loadModule(FixGhostEntities) - loadModule(TrackSoundsCommand) - loadModule(TrackParticlesCommand) - loadModule(ButtonOnPause()) - loadModule(PacketTest) - loadModule(TestBingo) - loadModule(TestCopyRngMeterValues) - loadModule(TestCopyBestiaryValues) - loadModule(HighlightMissingRepoItems()) - loadModule(ParkourWaypointSaver()) - loadModule(TestShowSlotNumber()) - loadModule(SkyHanniDebugsAndTests) - loadModule(WorldEdit) - loadModule(MobDebug()) + + SkyHanniEvents.init(modules) Commands.init() - PreInitFinishedEvent().postAndCatch() + PreInitFinishedEvent().post() } @Mod.EventHandler @@ -1011,7 +99,7 @@ class SkyHanniMod { loadedClasses.clear() } - private val loadedClasses = mutableSetOf() + private val loadedClasses = mutableSetOf() fun loadModule(obj: Any) { if (!loadedClasses.add(obj.javaClass.name)) throw IllegalStateException("Module ${obj.javaClass.name} is already loaded") diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 22e22c423e71..3e7e1f7bf964 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.CollectionUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,6 +20,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object CollectionAPI { private val patternGroup = RepoPattern.group("data.collection.api") private val counterPattern by patternGroup.pattern( @@ -87,7 +89,7 @@ object CollectionAPI { @SubscribeEvent fun onItemAdd(event: ItemAddEvent) { val internalName = event.internalName - val (_, amount) = NEUItems.getMultiplier(internalName) + val amount = NEUItems.getPrimitiveMultiplier(internalName).amount if (amount > 1) return // TODO add support for replenish (higher collection than actual items in inv) diff --git a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt index 4eb107554791..94931dd8caf8 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.api import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DataWatcherAPI { +@SkyHanniModule +object DataWatcherAPI { private val DATA_VALUE_CUSTOM_NAME = 2 diff --git a/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt b/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt new file mode 100644 index 000000000000..c2b1571f4792 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/FmlEventApi.kt @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.api + +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import net.minecraftforge.event.entity.EntityJoinWorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.network.FMLNetworkEvent + +@SkyHanniModule +object FmlEventApi { + + @SubscribeEvent + fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + ClientDisconnectEvent().post() + } + + @SubscribeEvent + fun onEntityJoinWorld(event: EntityJoinWorldEvent) { + EntityEnterWorldEvent(event.entity).post() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt index 98160a372fa4..7f69e7318c31 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.isCommand @@ -31,6 +32,7 @@ import java.util.Deque import java.util.LinkedList import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GetFromSackAPI { private val config get() = SkyHanniMod.feature.inventory.gfs @@ -58,7 +60,7 @@ object GetFromSackAPI { text: String = "§lCLICK HERE§r§e to grab §ax${item.amount} §9${item.itemName}§e from sacks!", ) = ChatUtils.clickableChat(text, onClick = { - HypixelCommands.getFromSacks(item.internalName.asString(), item.amount) + getFromSack(item) }) fun getFromSlotClickedSackItems(items: List, slotIndex: Int) = addToInventory(items, slotIndex) @@ -89,7 +91,8 @@ object GetFromSackAPI { if (!LorenzUtils.inSkyBlock) return if (queue.isNotEmpty() && lastTimeOfCommand.passedSince() >= minimumDelay) { val item = queue.poll() - HypixelCommands.getFromSacks(item.internalName.asString().replace('-', ':'), item.amount) + // TODO find a better workaround + ChatUtils.sendMessageToServer("/gfs ${item.internalName.asString().replace('-', ':')} ${item.amount}") lastTimeOfCommand = ChatUtils.getTimeWhenNewlyQueuedMessageGetsExecuted() } } @@ -105,7 +108,7 @@ object GetFromSackAPI { if (event.clickedButton != 1) return // filter none right clicks addToQueue(inventoryMap[event.slotId] ?: return) inventoryMap.remove(event.slotId) - event.isCanceled = true + event.cancel() } @SubscribeEvent @@ -128,11 +131,11 @@ object GetFromSackAPI { queuedHandler(replacedEvent) bazaarHandler(replacedEvent) if (replacedEvent.isCanceled) { - event.isCanceled = true + event.cancel() return } if (replacedEvent !== event) { - event.isCanceled = true + event.cancel() ChatUtils.sendMessageToServer(replacedEvent.message) } } @@ -150,7 +153,7 @@ object GetFromSackAPI { CommandResult.WRONG_AMOUNT -> ChatUtils.userError("Invalid amount!") CommandResult.INTERNAL_ERROR -> {} } - event.isCanceled = true + event.cancel() } private fun bazaarHandler(event: MessageSendToServerEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt index 842b9ec84d38..5c9c3017a7e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevel import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevelExact import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getSkillInfo import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.xpRequiredForLevel +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -39,6 +40,7 @@ import java.util.LinkedList import java.util.regex.Matcher import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object SkillAPI { private val patternGroup = RepoPattern.group("api.skilldisplay") private val skillPercentPattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/CancellableSkyHanniEvent.kt b/src/main/java/at/hannibal2/skyhanni/api/event/CancellableSkyHanniEvent.kt new file mode 100644 index 000000000000..048630b84942 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/CancellableSkyHanniEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.api.event + +abstract class CancellableSkyHanniEvent : SkyHanniEvent(), SkyHanniEvent.Cancellable diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt new file mode 100644 index 000000000000..cfc8e63b87a8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt @@ -0,0 +1,134 @@ +package at.hannibal2.skyhanni.api.event + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +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 + + var invokeCount: Long = 0L + private set + + constructor(event: Class) : this( + (event.name.split(".").lastOrNull() ?: event.name).replace("$", "."), + GenericSkyHanniEvent::class.java.isAssignableFrom(event) + ) + + 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 + + var errors = 0 + + for (listener in listeners) { + if (!shouldInvoke(event, listener)) continue + try { + listener.invoker.accept(event) + } catch (throwable: Throwable) { + errors++ + if (errors <= 3) { + val errorName = throwable::class.simpleName ?: "error" + val message = "Caught an $errorName in ${listener.name} at $name: ${throwable.message}" + ErrorManager.logErrorWithData(throwable, message, ignoreErrorCache = onError != null) + } + onError?.invoke(throwable) + } + if (event.isCancelled && !canReceiveCancelled) break + } + + if (errors > 3) { + val hiddenErrors = errors - 3 + ChatUtils.chat( + Text.text( + "§c[SkyHanni/${SkyHanniMod.version}] $hiddenErrors more errors in $name are hidden!" + ) + ) + } + return event.isCancelled + } + + private fun shouldInvoke(event: SkyHanniEvent, listener: Listener): Boolean { + if (SkyHanniEvents.isDisabledInvoker(listener.name)) return false + if (listener.options.onlyOnSkyblock && !LorenzUtils.inSkyBlock) return false + if (listener.options.onlyOnIsland != IslandType.ANY && !listener.options.onlyOnIsland.isInIsland()) return false + if (event.isCancelled && !listener.options.receiveCancelled) return false + if ( + event is GenericSkyHanniEvent<*> && + listener.generic != null && + !listener.generic.isAssignableFrom(event.type) + ) { + return false + } + return true + } + + private class Listener( + val name: String, + val invoker: Consumer, + val options: HandleEvent, + val generic: Class<*>? + ) +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/GenericSkyHanniEvent.kt b/src/main/java/at/hannibal2/skyhanni/api/event/GenericSkyHanniEvent.kt new file mode 100644 index 000000000000..1b761e1ae637 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/GenericSkyHanniEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.api.event + +abstract class GenericSkyHanniEvent(val type: Class) : SkyHanniEvent(), SkyHanniEvent.Cancellable diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt b/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt new file mode 100644 index 000000000000..39b047a6e1de --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/HandleEvent.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.api.event + +import at.hannibal2.skyhanni.data.IslandType + +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FUNCTION) +annotation class HandleEvent( + /** + * If the event should only be received while on SkyBlock. + */ + val onlyOnSkyblock: Boolean = false, + + /** + * If the event should only be received while on a specific skyblock island. + */ + val onlyOnIsland: IslandType = IslandType.ANY, + + /** + * The priority of when the event will be called, lower priority will be called first, see the companion object. + */ + val priority: Int = 0, + + /** + * If the event is cancelled & receiveCancelled is true, then the method will still invoke. + */ + val receiveCancelled: Boolean = false, +) { + + companion object { + const val HIGHEST = -2 + const val HIGH = -1 + const val LOW = 1 + const val LOWEST = 2 + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvent.kt b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvent.kt new file mode 100644 index 000000000000..4f3685c8bdff --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvent.kt @@ -0,0 +1,19 @@ +package at.hannibal2.skyhanni.api.event + +abstract class SkyHanniEvent protected constructor() { + + var isCancelled: Boolean = false + private set + + fun post() = SkyHanniEvents.getEventHandler(javaClass).post(this) + + fun post(onError: (Throwable) -> Unit = {}) = SkyHanniEvents.getEventHandler(javaClass).post(this, onError) + + interface Cancellable { + + fun cancel() { + val event = this as SkyHanniEvent + event.isCancelled = true + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt new file mode 100644 index 000000000000..e3dff201485b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/event/SkyHanniEvents.kt @@ -0,0 +1,64 @@ +package at.hannibal2.skyhanni.api.event + +import at.hannibal2.skyhanni.data.MinecraftData +import at.hannibal2.skyhanni.data.jsonobjects.repo.DisabledEventsJson +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.lang.reflect.Method + +@SkyHanniModule +object SkyHanniEvents { + + private val handlers: MutableMap, EventHandler<*>> = mutableMapOf() + private var disabledHandlers = emptySet() + private var disabledHandlerInvokers = emptySet() + + fun init(instances: List) { + instances.forEach { instance -> + instance.javaClass.declaredMethods.forEach { + registerMethod(it, instance) + } + } + handlers.values.forEach { it.freeze() } + } + + @Suppress("UNCHECKED_CAST") + fun getEventHandler(event: Class): EventHandler = handlers.getOrPut(event) { + EventHandler(event) + } as EventHandler + + fun isDisabledHandler(handler: String): Boolean = handler in disabledHandlers + fun isDisabledInvoker(invoker: String): Boolean = invoker in disabledHandlerInvokers + + @Suppress("UNCHECKED_CAST") + private fun registerMethod(method: Method, instance: Any) { + if (method.parameterCount != 1) return + 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) + } + + @SubscribeEvent + fun onRepoLoad(event: RepositoryReloadEvent) { + val data = event.getConstant("DisabledEvents") + disabledHandlers = data.disabledHandlers + disabledHandlerInvokers = data.disabledInvokers + } + + @SubscribeEvent + fun onDebug(event: DebugDataCollectEvent) { + event.title("Events") + event.addIrrelevant { + handlers.values.toMutableList() + .filter { it.invokeCount > 0 } + .sortedWith(compareBy({ -it.invokeCount }, { it.name })) + .forEach { + add("- ${it.name} (${it.invokeCount} ${it.invokeCount / (MinecraftData.totalTicks / 20)}/s)") + } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index 19ef97ec1a83..1e7684de8626 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.json.BaseGsonBuilder +import at.hannibal2.skyhanni.utils.system.PlatformUtils import com.google.gson.Gson import com.google.gson.GsonBuilder import com.google.gson.JsonObject @@ -128,7 +129,7 @@ class ConfigManager { } val configLink = field.getAnnotation(ConfigLink::class.java) if (configLink == null) { - if (LorenzUtils.isInDevEnvironment()) { + if (PlatformUtils.isDevEnvironment) { var name = "${field.declaringClass.name}.${field.name}" name = name.replace("at.hannibal2.skyhanni.config.", "") if (name !in ignoredMissingConfigLinks) { @@ -176,7 +177,7 @@ class ConfigManager { val jsonObject = lenientGson.fromJson(bufferedReader.readText(), JsonObject::class.java) val newJsonObject = ConfigUpdaterMigrator.fixConfig(jsonObject) val run = { lenientGson.fromJson(newJsonObject, defaultValue.javaClass) } - if (LorenzUtils.isInDevEnvironment()) { + if (PlatformUtils.isDevEnvironment) { try { run() } catch (e: Throwable) { diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index b7fd4838b5b9..b674c382a16a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 47 + const val CONFIG_VERSION = 49 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null @@ -111,6 +111,7 @@ object ConfigUpdaterMigrator { val lastVersion = (config["lastVersion"] as? JsonPrimitive)?.asIntOrNull ?: -1 if (lastVersion > CONFIG_VERSION) { logger.log("Attempted to downgrade config version") + config.add("lastVersion", JsonPrimitive(CONFIG_VERSION)) return config } if (lastVersion == CONFIG_VERSION) return config 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 bd6cc8efea41..89980d349925 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -371,17 +371,11 @@ object Commands { "Disables/enables the rendering of all skyhanni guis." ) { SkyHanniDebugsAndTests.toggleRender() } registerCommand( - "shcarrot", - "Toggles receiving the 12 fortune from carrots" - ) { CaptureFarmingGear.reverseCarrotFortune() } - registerCommand( - "shpumpkin", - "Toggles receiving the 12 fortune from pumpkins" - ) { CaptureFarmingGear.reversePumpkinFortune() } - registerCommand( - "shcocoabeans", - "Toggles receiving the 12 fortune from cocoa beans" - ) { CaptureFarmingGear.reverseCocoaBeansFortune() } + "shcarrolyn", + "Toggels if the specified crops effect is active from carrolyn" + ) { + CaptureFarmingGear.handelCarrolyn(it) + } registerCommand( "shrepostatus", "Shows the status of all the mods constants" diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index 4378fe36e7b8..e0e8c28a5d60 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -20,9 +20,9 @@ package at.hannibal2.skyhanni.config.core.config.gui import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsX +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsY +import at.hannibal2.skyhanni.data.GuiEditManager.getDummySize import at.hannibal2.skyhanni.data.OtherInventoryData import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer import at.hannibal2.skyhanni.utils.GuiRenderUtils diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java index 095c3733ca6b..b477d23297a6 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/SkyMartConfig.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; @@ -23,4 +24,26 @@ public class SkyMartConfig { @Expose @ConfigLink(owner = SkyMartConfig.class, field = "copperPrice") public Position copperPricePos = new Position(211, 132, false, true); + + @Expose + @ConfigOption(name = "Overlay Price", desc = "Toggle for Bazaar 'sell order' vs 'instant sell' price in copper price overlay.") + @ConfigEditorDropdown + public OverlayPriceTypeEntry overlayPriceType = OverlayPriceTypeEntry.INSTANT_SELL; + + public enum OverlayPriceTypeEntry { + INSTANT_SELL("Instant Sell"), + SELL_ORDER("Sell Order"), + ; + private final String str; + + + OverlayPriceTypeEntry(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java index 3d714199bad3..02cdae33a033 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/visitor/VisitorConfig.java @@ -37,6 +37,12 @@ public class VisitorConfig { @FeatureToggle public boolean notificationChat = true; + @Expose + @ConfigOption(name = "Compact Chat", desc = "Compact reward summary messages when you accept an offer.") + @ConfigEditorBoolean + @FeatureToggle + public boolean compactRewardChat = false; + @Expose @ConfigOption(name = "Notification Title", desc = "Show a title when a new visitor is visiting your island.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java index 0dbc4da0f382..ed6abdc7cf2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java @@ -14,4 +14,10 @@ public class MayorConfig { @ConfigOption(name = "Show Time till next mayor", desc = "Show the time till the next mayor is elected.") @ConfigEditorBoolean public boolean showTimeTillNextMayor = true; + + @Expose + // TODO: Same Toggle toggles ministers + @ConfigOption(name = "Show Extra Mayor", desc = "Show the Perkacolypse Mayor without their perks.") + @ConfigEditorBoolean + public boolean showExtraMayor = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 872fb8ad6ba1..f20643cc323b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -3,6 +3,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.HasLegacyId; import at.hannibal2.skyhanni.config.features.inventory.chocolatefactory.ChocolateFactoryConfig; +import at.hannibal2.skyhanni.config.features.inventory.customwardrobe.CustomWardrobeConfig; import at.hannibal2.skyhanni.config.features.inventory.helper.HelperConfig; import at.hannibal2.skyhanni.config.features.itemability.ItemAbilityConfig; import at.hannibal2.skyhanni.config.features.misc.EstimatedItemValueConfig; @@ -49,6 +50,10 @@ public class InventoryConfig { @Category(name = "Item Abilities", desc = "Stuff about item abilities.") public ItemAbilityConfig itemAbilities = new ItemAbilityConfig(); + @Expose + @Category(name = "Custom Wardrobe", desc = "New Wardrobe Look.") + public CustomWardrobeConfig customWardrobe = new CustomWardrobeConfig(); + @Expose @Category(name = "Chocolate Factory", desc = "Features to help you master the Chocolate Factory idle game.") public ChocolateFactoryConfig chocolateFactory = new ChocolateFactoryConfig(); @@ -93,16 +98,13 @@ public class InventoryConfig { @Accordion public GetFromSackConfig gfs = new GetFromSackConfig(); + @Expose @ConfigOption(name = "Pocket Sack-In-A-Sack", desc = "") @Accordion - @Expose public PocketSackInASackConfig pocketSackInASack = new PocketSackInASackConfig(); @Expose - @ConfigOption( - name = "Item Number", - desc = "Showing the item number as a stack size for these items." - ) + @ConfigOption(name = "Item Number", desc = "Showing the item number as a stack size for these items.") @ConfigEditorDraggableList public List itemNumberAsStackSize = new ArrayList<>(Arrays.asList( NEW_YEAR_CAKE, @@ -168,10 +170,10 @@ public String toString() { public boolean vacuumBagCap = true; @Expose - @ConfigOption( - name = "Quick Craft Confirmation", + @ConfigOption(name = "Quick Craft Confirmation", desc = "Require Ctrl+Click to craft items that aren't often quick crafted " + - "(e.g. armor, weapons, accessories). Sack items can be crafted normally." + "(e.g. armor, weapons, accessories). " + + "Sack items can be crafted normally." ) @ConfigEditorBoolean @FeatureToggle @@ -190,28 +192,31 @@ public String toString() { public boolean anvilCombineHelper = false; @Expose - @ConfigOption(name = "Item Stars", - desc = "Show a compact star count in the item name for all items.") + @ConfigOption(name = "Item Stars", desc = "Show a compact star count in the item name for all items.") @ConfigEditorBoolean @FeatureToggle public boolean itemStars = false; @Expose - @ConfigOption(name = "Missing Tasks", - desc = "Highlight missing tasks in the SkyBlock Level Guide inventory.") + @ConfigOption(name = "Missing Tasks", desc = "Highlight missing tasks in the SkyBlock Level Guide inventory.") // TODO move( , "inventory.highlightMissingSkyBlockLevelGuide", "inventory.skyblockGuideConfig.highlightMissingSkyBlockLevelGuide") @ConfigEditorBoolean @FeatureToggle public boolean highlightMissingSkyBlockLevelGuide = true; @Expose - @ConfigOption(name = "Power Stone Guide", - desc = "Highlight missing power stones, show their total bazaar price, and allows to open the bazaar when clicking on the items in the Power Stone Guide.") + @ConfigOption(name = "Power Stone Guide", desc = "Highlight missing power stones, show their total bazaar price, and allows to open the bazaar when clicking on the items in the Power Stone Guide.") // TODO move( , "inventory.powerStoneGuide", "inventory.skyblockGuideConfig.powerStoneGuide") @ConfigEditorBoolean @FeatureToggle public boolean powerStoneGuide = true; + @Expose + @ConfigOption(name = "Favorite Power Stone", desc = "Shows your favorite power stones. You can add/remove them by shift clicking a Power Stone.") + @ConfigEditorBoolean + @FeatureToggle + public boolean favoritePowerStone = false; + @Expose @ConfigOption(name = "Shift Click Equipment", desc = "Makes normal clicks to shift clicks in equipment inventory.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index 50230a6ae960..ae36b2a5128e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -98,6 +98,12 @@ public class ChocolateFactoryConfig { @FeatureToggle public boolean showDuplicateTime = false; + @Expose + @ConfigOption(name = "Stray Rabbit Time", desc = "Show the production time of chocolate gained from stray rabbits.") + @ConfigEditorBoolean + @FeatureToggle + public boolean showStrayTime = false; + @Expose @ConfigOption(name = "Time Tower Usage Warning", desc = "Notification when you have a new time tower usage available and " + "continuously warn when your time tower is full.") @@ -174,6 +180,15 @@ public class ChocolateFactoryConfig { @FeatureToggle public boolean highlightRabbitsWithRequirement = false; + @Expose + @ConfigOption( + name = "Show Missing Location Rabbits", + desc = "Shows which in which locations you have not yet found enough egg locations to unlock the rabbit for that location." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean showLocationRequirementsRabbitsInHoppityStats = false; + @Expose @ConfigOption(name = "Only Requirement Not Met", desc = "Only highlight the rabbits you don't have the requirement for.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/ColorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/ColorConfig.java new file mode 100644 index 000000000000..20f9282542b3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/ColorConfig.java @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.config.features.inventory.customwardrobe; + +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class ColorConfig { + + @Expose + @ConfigOption(name = "Background", desc = "Color of the GUI background.") + @ConfigEditorColour + public String backgroundColor = "0:127:0:0:0"; + + @Expose + @ConfigOption(name = "Equipped", desc = "Color of the currently equipped wardrobe slot.") + @ConfigEditorColour + public String equippedColor = "0:127:85:255:85"; + + @Expose + @ConfigOption(name = "Favorite", desc = "Color of the wardrobe slots that have been added as favorites.") + @ConfigEditorColour + public String favoriteColor = "0:127:255:85:85"; + + @Expose + @ConfigOption(name = "Same Page", desc = "Color of wardrobe slots in the same page.") + @ConfigEditorColour + public String samePageColor = "0:127:94:108:255"; + + @Expose + @ConfigOption(name = "Other Page", desc = "Color of wardrobe slots in another page.") + @ConfigEditorColour + public String otherPageColor = "0:127:0:0:0"; + + @Expose + @ConfigOption(name = "Top Outline", desc = "Color of the top of the outline when hovered.") + @ConfigEditorColour + public String topBorderColor = "0:255:255:200:0"; + + @Expose + @ConfigOption(name = "Bottom Outline", desc = "Color of the bottom of the outline when hovered.") + @ConfigEditorColour + public String bottomBorderColor = "0:255:255:0:0"; + +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java new file mode 100644 index 000000000000..a4ea69badb20 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/CustomWardrobeConfig.java @@ -0,0 +1,54 @@ +package at.hannibal2.skyhanni.config.features.inventory.customwardrobe; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.Accordion; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +public class CustomWardrobeConfig { + + @Expose + @ConfigOption(name = "Enable", desc = "Enables the Custom Wardrobe GUI.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Follow mouse", desc = "Players follow the movement of the mouse.") + @ConfigEditorBoolean + public boolean eyesFollowMouse = true; + + @Expose + @ConfigOption(name = "Hide Empty Slots", desc = "Hides wardrobe slots with no armor.") + @ConfigEditorBoolean + public boolean hideEmptySlots = false; + + @Expose + @ConfigOption(name = "Hide Locked Slots", desc = "Hides locked wardrobe slots.") + @ConfigEditorBoolean + public boolean hideLockedSlots = false; + + @Expose + public boolean onlyFavorites = false; + + @Expose + @ConfigOption(name = "Estimated Value", desc = "Show a §2$ §7sign you can hover to see the wardrobe slot value.") + @ConfigEditorBoolean + public boolean estimatedValue = true; + + @Expose + @ConfigOption(name = "Loading text", desc = "Shows a \"§cLoading...\" §7text when the wardrobe page hasn't fully loaded in yet.") + @ConfigEditorBoolean + public boolean loadingText = true; + + @Expose + @ConfigOption(name = "Colors", desc = "Change the color settings.") + @Accordion + public ColorConfig color = new ColorConfig(); + + @Expose + @ConfigOption(name = "Spacing", desc = "") + @Accordion + public SpacingConfig spacing = new SpacingConfig(); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/SpacingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/SpacingConfig.java new file mode 100644 index 000000000000..363a9a6a70bf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/customwardrobe/SpacingConfig.java @@ -0,0 +1,145 @@ +package at.hannibal2.skyhanni.config.features.inventory.customwardrobe; + +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class SpacingConfig { + + @Expose + @ConfigOption(name = "Global Scale", desc = "Controls the scale of the entirety of the wardrobe.") + @ConfigEditorSlider( + minValue = 30, + maxValue = 200, + minStep = 1 + ) + public Property globalScale = Property.of(100); + + @Expose + @ConfigOption(name = "Outline Thickness", desc = "How thick the outline of the hovered slot is.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 15, + minStep = 1 + ) + public Property outlineThickness = Property.of(5); + + @Expose + @ConfigOption(name = "Outline Blur", desc = "Amount of blur of the outline.") + @ConfigEditorSlider( + minValue = 0f, + maxValue = 1f, + minStep = 0.1f + ) + public Property outlineBlur = Property.of(0.5f); + + @Expose + @ConfigOption(name = "Slot Width", desc = "Width of the wardrobe slots.") + @ConfigEditorSlider( + minValue = 30, + maxValue = 100, + minStep = 1 + ) + public Property slotWidth = Property.of(75); + + @Expose + @ConfigOption(name = "Slot Height", desc = "Height of the wardrobe slots.") + @ConfigEditorSlider( + minValue = 60, + maxValue = 200, + minStep = 1 + ) + public Property slotHeight = Property.of(140); + + @Expose + @ConfigOption(name = "Player Scale", desc = "Scale of the players.") + @ConfigEditorSlider( + minValue = 0, + maxValue = 100, + minStep = 1 + ) + public Property playerScale = Property.of(75); + + @Expose + @ConfigOption(name = "Slots per Row", desc = "Max amount of wardrobe slots per row.") + @ConfigEditorSlider( + minValue = 5, + maxValue = 18, + minStep = 1 + ) + public Property maxPlayersPerRow = Property.of(9); + + @Expose + @ConfigOption(name = "Slots Horizontal Spacing", desc = "How much space horizontally between wardrobe slots.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 20, + minStep = 1 + ) + public Property horizontalSpacing = Property.of(3); + + @Expose + @ConfigOption(name = "Slots Vertical Spacing", desc = "How much space vertically between wardrobe slots.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 20, + minStep = 1 + ) + public Property verticalSpacing = Property.of(3); + + @Expose + @ConfigOption(name = "Slots & Buttons Spacing", desc = "How much vertical space there is between wardrobe slots and the buttons.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 40, + minStep = 1 + ) + public Property buttonSlotsVerticalSpacing = Property.of(10); + + @Expose + @ConfigOption(name = "Button Horizontal Spacing", desc = "How much space horizontally between buttons.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 40, + minStep = 1 + ) + public Property buttonHorizontalSpacing = Property.of(10); + + @Expose + @ConfigOption(name = "Button Vertical Spacing", desc = "How much space vertically between buttons.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 40, + minStep = 1 + ) + public Property buttonVerticalSpacing = Property.of(10); + + @Expose + @ConfigOption(name = "Button Width", desc = "Width of the buttons.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 60, + minStep = 1 + ) + public Property buttonWidth = Property.of(50); + + @Expose + @ConfigOption(name = "Button Height", desc = "Height of the buttons.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 60, + minStep = 1 + ) + public Property buttonHeight = Property.of(20); + + @Expose + @ConfigOption(name = "Background Padding", desc = "Space between the edges of the background and the slots.") + @ConfigEditorSlider( + minValue = 1, + maxValue = 20, + minStep = 1 + ) + public Property backgroundPadding = Property.of(10); + +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java index 79238b29f1c3..2f277d92500b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/PowderTrackerConfig.java @@ -45,11 +45,6 @@ public class PowderTrackerConfig { @ConfigEditorBoolean public boolean onlyWhenPowderGrinding = false; - @Expose - @ConfigOption(name = "Great Explorer", desc = "Enable this if your Great Explorer perk is maxed.") - @ConfigEditorBoolean - public boolean greatExplorerMaxed = false; - @Expose @ConfigOption( name = "Text Format", diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index c390e7feb247..536ac1e5269c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -199,7 +199,7 @@ public class MiscConfig { public boolean restorePieceOfWizardPortalLore = true; @Expose - @ConfigOption(name = "Account Upgrade Reminder", desc = "Remind you to claim account upgrades when complete.") + @ConfigOption(name = "Account Upgrade Reminder", desc = "Remind you to claim community shop account and profile upgrades when complete.") @ConfigEditorBoolean @FeatureToggle public boolean accountUpgradeReminder = true; @@ -266,6 +266,12 @@ public class MiscConfig { @FeatureToggle public boolean replaceRomanNumerals = false; + @Expose + @ConfigOption(name = "Unknown Perkpocalypse Mayor Warning", desc = "Show a warning when the Unknown Perkpocalypse Mayor is unknown.") + @ConfigEditorBoolean + @FeatureToggle + public boolean unknownPerkpocalypseMayorWarning = true; + @ConfigOption(name = "Hide Far Entities", desc = "") @Accordion @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java index e30f62946263..171cb82b1b38 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/PlayerSpecificStorage.java @@ -1,7 +1,10 @@ package at.hannibal2.skyhanni.config.storage; import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal; +import at.hannibal2.skyhanni.features.fame.UpgradeReminder; +import at.hannibal2.skyhanni.utils.GenericWrapper; import at.hannibal2.skyhanni.utils.NEUInternalName; +import at.hannibal2.skyhanni.utils.SimpleTimeMark; import com.google.gson.annotations.Expose; import java.util.ArrayList; @@ -23,13 +26,10 @@ public class PlayerSpecificStorage { public Integer gardenCommunityUpgrade = -1; @Expose - public long nextCityProjectParticipationTime = 0L; + public SimpleTimeMark nextCityProjectParticipationTime = GenericWrapper.getSimpleTimeMark(SimpleTimeMark.farPast()).getIt(); @Expose - public String currentAccountUpgrade = null; - - @Expose - public long nextAccountUpgradeCompletionTime = -1L; + public UpgradeReminder.CommunityShopUpgrade communityShopAccountUpgrade = null; @Expose public List guildMembers = new ArrayList<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index d88ccb315313..e037b80a63f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker; import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats; import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker; +import at.hannibal2.skyhanni.features.fame.UpgradeReminder; import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker; import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; @@ -27,6 +28,7 @@ import at.hannibal2.skyhanni.features.garden.pests.PestProfitTracker; import at.hannibal2.skyhanni.features.garden.pests.VinylType; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; +import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI; import at.hannibal2.skyhanni.features.mining.fossilexcavator.ExcavatorProfitTracker; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; @@ -34,8 +36,10 @@ import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal; import at.hannibal2.skyhanni.features.skillprogress.SkillType; import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker; +import at.hannibal2.skyhanni.utils.GenericWrapper; import at.hannibal2.skyhanni.utils.LorenzVec; import at.hannibal2.skyhanni.utils.NEUInternalName; +import at.hannibal2.skyhanni.utils.SimpleTimeMark; import com.google.gson.annotations.Expose; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; @@ -48,6 +52,10 @@ public class ProfileSpecificStorage { + private static SimpleTimeMark SimpleTimeMarkFarPast() { + return GenericWrapper.getSimpleTimeMark(SimpleTimeMark.farPast()).getIt(); + } + @Expose public String currentPet = ""; @@ -83,10 +91,10 @@ public static class ChocolateFactoryStorage { public int timeTowerLevel = 0; @Expose - public long currentTimeTowerEnds = 0; + public SimpleTimeMark currentTimeTowerEnds = SimpleTimeMarkFarPast(); @Expose - public long nextTimeTower = 0; + public SimpleTimeMark nextTimeTower = SimpleTimeMarkFarPast(); @Expose public int currentTimeTowerUses = -1; @@ -101,20 +109,21 @@ public static class ChocolateFactoryStorage { public boolean hasMuRabbit = false; @Expose - public long bestUpgradeAvailableAt = 0; + public SimpleTimeMark bestUpgradeAvailableAt = SimpleTimeMarkFarPast(); @Expose public long bestUpgradeCost = 0; @Expose - public long lastDataSave = 0; + public SimpleTimeMark lastDataSave = SimpleTimeMarkFarPast(); @Expose public PositionChange positionChange = new PositionChange(); public static class PositionChange { @Expose - public Long lastTime = null; + @Nullable + public SimpleTimeMark lastTime = null; @Expose public int lastPosition = -1; @@ -130,10 +139,13 @@ public static class PositionChange { public String targetName = null; @Expose - public Map rabbitCounts = new HashMap(); + public Map rabbitCounts = new HashMap<>(); @Expose - public Map> collectedEggLocations = new HashMap(); + public Map locationRabbitRequirements = new HashMap<>(); + + @Expose + public Map> collectedEggLocations = new HashMap<>(); @Expose public Integer hoppityShopYearOpened = null; @@ -151,6 +163,9 @@ public static class MaxwellPowerStorage { @Expose public List tunings = new ArrayList<>(); + + @Expose + public List favoritePowers = new ArrayList<>(); } @Expose @@ -175,7 +190,8 @@ public static class BitsStorage { public int bitsAvailable = -1; @Expose - public Long boosterCookieExpiryTime = null; + @Nullable + public SimpleTimeMark boosterCookieExpiryTime = null; } @Expose @@ -186,6 +202,7 @@ public static class MinionConfig { @Expose public String displayName = ""; + // TODO use SimpleTimeMark @Expose public long lastClicked = -1; @@ -204,7 +221,8 @@ public String toString() { public static class BeaconPowerStorage { @Expose - public Long beaconPowerExpiryTime = null; + @Nullable + public SimpleTimeMark beaconPowerExpiryTime = null; @Expose public String boostedStat = null; @@ -259,16 +277,16 @@ public static class GardenStorage { public DicerRngDropTracker.Data dicerDropTracker = new DicerRngDropTracker.Data(); @Expose - public long informedAboutLowMatter = 0; + public SimpleTimeMark informedAboutLowMatter = SimpleTimeMarkFarPast(); @Expose - public long informedAboutLowFuel = 0; + public SimpleTimeMark informedAboutLowFuel = SimpleTimeMarkFarPast(); @Expose public long visitorInterval = 15 * 60_000L; @Expose - public long nextSixthVisitorArrival = 0; + public SimpleTimeMark nextSixthVisitorArrival = SimpleTimeMarkFarPast(); @Expose public ArmorDropTracker.Data armorDropTracker = new ArmorDropTracker.Data(); @@ -370,26 +388,20 @@ public static class Fortune { public int plotsUnlocked = -1; @Expose - public long cakeExpiring = -1L; + public SimpleTimeMark cakeExpiring = null; @Expose - public boolean carrotFortune = false; - - @Expose - public boolean pumpkinFortune = false; - - @Expose - public boolean cocoaBeansFortune = false; + public Map carrolyn = new HashMap<>(); @Expose public Map farmingItems = new HashMap<>(); } @Expose - public long composterEmptyTime = 0; + public SimpleTimeMark composterEmptyTime = SimpleTimeMarkFarPast(); @Expose - public long lastComposterEmptyWarningTime = 0; + public SimpleTimeMark lastComposterEmptyWarningTime = SimpleTimeMarkFarPast(); @Expose public GardenStorage.FarmingWeightConfig farmingWeight = new GardenStorage.FarmingWeightConfig(); @@ -557,7 +569,7 @@ public static class DungeonStorage { public Map bosses = new HashMap<>(); @Expose - public List runs = CroesusChestTracker.Companion.generateMaxChestAsList(); + public List runs = CroesusChestTracker.generateMaxChestAsList(); public static class DungeonRunInfo { @@ -607,10 +619,25 @@ public static class DianaStorage { public DianaProfitTracker.Data dianaProfitTracker = new DianaProfitTracker.Data(); @Expose - // TODO renmae + // TODO rename public MythologicalCreatureTracker.Data mythologicalMobTracker = new MythologicalCreatureTracker.Data(); } @Expose public Map skillData = new HashMap<>(); + + @Expose + public WardrobeStorage wardrobe = new WardrobeStorage(); + + public static class WardrobeStorage { + @Expose + public Map data = new HashMap<>(); + + @Expose + @Nullable + public Integer currentSlot = null; + } + + @Expose + public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt index 74617e9b3c38..1cef0be01b3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt @@ -2,10 +2,12 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.ActionBarUpdateEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ActionBarData { private var actionBar = "" diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt index fc7480729823..b2145db767c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.ActionBarUpdateEvent import at.hannibal2.skyhanni.events.ActionBarValueUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -37,6 +38,7 @@ enum class ActionBarStatsData(@Language("RegExp") rawPattern: String) { var value: String = "" private set + @SkyHanniModule companion object { init { diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 18d3ee1f9098..c7c8925c7b00 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.BitsUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -16,7 +17,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace import at.hannibal2.skyhanni.utils.TimeUtils @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.days +@SkyHanniModule object BitsAPI { private val profileStorage get() = ProfileStorageData.profileSpecific?.bits private val playerStorage get() = SkyHanniMod.feature.storage @@ -47,12 +48,12 @@ object BitsAPI { } var cookieBuffTime: SimpleTimeMark? - get() = profileStorage?.boosterCookieExpiryTime?.asTimeMark() + get() = profileStorage?.boosterCookieExpiryTime private set(value) { - profileStorage?.boosterCookieExpiryTime = value?.toMillis() + profileStorage?.boosterCookieExpiryTime = value } - private const val defaultcookiebits = 4800 + private const val defaultCookieBits = 4800 private val bitsDataGroup = RepoPattern.group("data.bits") @@ -193,7 +194,7 @@ object BitsAPI { } boosterCookieAte.matchMatcher(message) { - bitsAvailable += (defaultcookiebits * (currentFameRank?.bitsMultiplier ?: return)).toInt() + bitsAvailable += (defaultCookieBits * (currentFameRank?.bitsMultiplier ?: return)).toInt() val cookieTime = cookieBuffTime cookieBuffTime = if (cookieTime == null) SimpleTimeMark.now() + 4.days else cookieTime + 4.days sendBitsAvailableGainedEvent() @@ -306,7 +307,9 @@ object BitsAPI { fun hasCookieBuff() = cookieBuffTime?.isInFuture() ?: false - private fun sendBitsGainEvent(difference: Int) = BitsUpdateEvent.BitsGain(bits, bitsAvailable, difference).postAndCatch() + private fun sendBitsGainEvent(difference: Int) = + BitsUpdateEvent.BitsGain(bits, bitsAvailable, difference).postAndCatch() + private fun sendBitsSpentEvent() = BitsUpdateEvent.BitsSpent(bits, bitsAvailable).postAndCatch() private fun sendBitsAvailableGainedEvent() = BitsUpdateEvent.BitsAvailableGained(bits, bitsAvailable).postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt index 32a2ee17d032..0dcc1714e1a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BlockData.kt @@ -1,28 +1,25 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.network.play.server.S22PacketMultiBlockChange import net.minecraft.network.play.server.S23PacketBlockChange -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BlockData { +@SkyHanniModule +object BlockData { - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onBlockReceivePacket(event: PacketEvent.ReceiveEvent) { - - @Suppress("USELESS_ELVIS") - val packet = event.packet ?: return - - if (packet is S23PacketBlockChange) { - val blockPos = packet.blockPosition ?: return - val blockState = packet.blockState ?: return + @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true) + fun onBlockReceivePacket(event: PacketReceivedEvent) { + if (event.packet is S23PacketBlockChange) { + val blockPos = event.packet.blockPosition ?: return + val blockState = event.packet.blockState ?: return ServerBlockChangeEvent(blockPos, blockState).postAndCatch() - } else if (packet is S22PacketMultiBlockChange) { - for (block in packet.changedBlocks) { + } else if (event.packet is S22PacketMultiBlockChange) { + for (block in event.packet.changedBlocks) { ServerBlockChangeEvent(block.pos, block.blockState).postAndCatch() } } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt b/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt index 75ad8df9bc51..77daa26011a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt @@ -3,9 +3,11 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.BossbarUpdateEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.entity.boss.BossStatus import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object BossbarData { private var bossbar: String? = null private var previousServerBossbar = "" diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index ef032f6fc360..965b4af578b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -1,9 +1,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.chat.ChatFilterGui import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils @@ -11,10 +12,10 @@ import at.hannibal2.skyhanni.utils.IdentityCharacteristics import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.ReflectionUtils.getClassInstance -import at.hannibal2.skyhanni.utils.ReflectionUtils.getModContainer import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.chat.Text.send +import at.hannibal2.skyhanni.utils.system.PlatformUtils.getModInstance import net.minecraft.client.Minecraft import net.minecraft.client.gui.ChatLine import net.minecraft.client.gui.GuiNewChat @@ -76,17 +77,17 @@ object ChatManager { val hoverExtraInfo: List = listOf(), ) - @SubscribeEvent - fun onSendMessageToServerPacket(event: PacketEvent.SendEvent) { + @HandleEvent + fun onSendMessageToServerPacket(event: PacketSentEvent) { val packet = event.packet as? C01PacketChatMessage ?: return val message = packet.message val component = ChatComponentText(message) val originatingModCall = event.findOriginatingModCall() - val originatingModContainer = originatingModCall?.getClassInstance()?.getModContainer() + val originatingModContainer = originatingModCall?.getClassInstance()?.getModInstance() val hoverInfo = listOf( "§7Message created by §a${originatingModCall?.toString() ?: "§cprobably minecraft"}", - "§7Mod id: §a${originatingModContainer?.modId}", + "§7Mod id: §a${originatingModContainer?.id}", "§7Mod name: §a${originatingModContainer?.name}" ) val stackTrace = @@ -108,7 +109,7 @@ object ChatManager { originatingModContainer ).postAndCatch() ) { - event.isCanceled = true + event.cancel() messageHistory[IdentityCharacteristics(component)] = result.copy(actionKind = ActionKind.OUTGOING_BLOCKED) } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index f9a9107a6ce7..d1923a938dfb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropAccessory import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object CropAccessoryData { private val accessoryBagNamePattern by RepoPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt index 318ac465a3f5..c8e90fd279f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt @@ -1,12 +1,13 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent 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.PacketEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth @@ -57,8 +58,8 @@ object EntityData { maxHealthMap.clear() } - @SubscribeEvent - fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) { + @HandleEvent + fun onHealthUpdatePacket(event: PacketReceivedEvent) { val packet = event.packet if (packet !is S1CPacketEntityMetadata) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt index 277ffb5deaa0..92a36b62363d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EntityMovementData.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWarpEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec @@ -15,6 +16,7 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object EntityMovementData { private val warpingPattern by RepoPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt index 28f1e254b3b7..6e308c18965f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -9,6 +10,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object EventCounter { private val config get() = SkyHanniMod.feature.dev.debug diff --git a/src/main/java/at/hannibal2/skyhanni/data/FameRanks.kt b/src/main/java/at/hannibal2/skyhanni/data/FameRanks.kt index 663e2b9703e6..750f1294390e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FameRanks.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FameRanks.kt @@ -2,8 +2,10 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.data.jsonobjects.repo.FameRankJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object FameRanks { var fameRanks = emptyMap() private set @@ -13,7 +15,7 @@ object FameRanks { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val ranks = event.getConstant("FameRank") - fameRanks = ranks.fame_rank.values.map { FameRank(it.name, it.fame_required, it.bits_multiplier, it.votes) } + fameRanks = ranks.fameRank.values.map { FameRank(it.name, it.fameRequired, it.bitsMultiplier, it.votes) } .associateBy { it.name } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/FixedRateTimerManager.kt b/src/main/java/at/hannibal2/skyhanni/data/FixedRateTimerManager.kt index a0125d35ee1a..4d825b2e9b9d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FixedRateTimerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FixedRateTimerManager.kt @@ -1,11 +1,13 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import kotlin.concurrent.fixedRateTimer -class FixedRateTimerManager { +@SkyHanniModule +object FixedRateTimerManager { private var totalSeconds = 0 init { diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index 875229d1cadc..1abe31736214 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson import at.hannibal2.skyhanni.data.jsonobjects.local.FriendsJson.PlayerFriends.Friend import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -15,6 +16,7 @@ import net.minecraft.util.ChatStyle import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.UUID +@SkyHanniModule object FriendAPI { private val patternGroup = RepoPattern.group("data.friends") private val removedFriendPattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt index 19943ad05f9c..18093b880b86 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.data.model.ComposterUpgrade import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenComposterUpgradesData { +@SkyHanniModule +object GardenComposterUpgradesData { @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index 5100a042d13a..5e236c4c5f64 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil.formatLong @@ -16,16 +17,17 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenCropMilestones { private val patternGroup = RepoPattern.group("data.garden.milestone") private val cropPattern by patternGroup.pattern( "crop", - "§7Harvest §f(?.*) §7on .*" + "§7Harvest §f(?.*) §7on .*", ) val totalPattern by patternGroup.pattern( "total", - "§7Total: §a(?.*)" + "§7Total: §a(?.*)", ) private val config get() = GardenAPI.config.cropMilestones @@ -65,9 +67,10 @@ object GardenCropMilestones { add(" §r§7§8+§d2 SkyHanni User Luck") } + val cropName = crop.cropName val messages = listOf( "§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r", - " §r§b§lGARDEN MILESTONE §3${crop.cropName} §8$oldLevel➜§3$newLevel§r", + " §r§b§lGARDEN MILESTONE §3$cropName §8$oldLevel➜§3$newLevel§r", if (goalReached) listOf( "", @@ -78,13 +81,16 @@ object GardenCropMilestones { "", " §r§a§lREWARDS§r", rewards.joinToString("\n"), - "§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r" + "§r§3§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬§r", ) chat(messages.joinToString("\n"), false) - if (goalReached) - chat("§e§lYou have reached your milestone goal of §b§l${customGoalLevel} §e§lin the §b§l${crop.cropName} §e§lcrop!", false) + val message = "§e§lYou have reached your milestone goal of §b§l$customGoalLevel " + + "§e§lin the §b§l$cropName §e§lcrop!" + if (goalReached) { + chat(message, false) + } SoundUtils.createSound("random.levelup", 1f, 1f).playSound() } @@ -179,6 +185,6 @@ object GardenCropMilestones { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - cropMilestoneData = event.getConstant("Garden").crop_milestones + cropMilestoneData = event.getConstant("Garden").cropMilestones } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt index 7b2819570fd1..691a3c8e262b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter @@ -25,10 +26,11 @@ import kotlinx.coroutines.launch import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenCropMilestonesCommunityFix { private val amountPattern by RepoPattern.pattern( "data.garden.milestonefix.amount", - ".*§e(?.*)§6/§e(?.*)" + ".*§e(?.*)§6/§e(?.*)", ) private var showWrongData = false @@ -37,7 +39,7 @@ object GardenCropMilestonesCommunityFix { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - val map = data.crop_milestone_community_help ?: return + val map = data.cropMilestoneCommunityHelp for ((key, value) in map) { if (key == "show_wrong_data") { showWrongData = value @@ -65,7 +67,7 @@ object GardenCropMilestonesCommunityFix { ChatUtils.chat( "Found §c${data.size} §ewrong crop milestone steps in the menu! " + "Correct data got put into clipboard. " + - "Please share it on the §bSkyHanni Discord §ein the channel §b#share-data§e." + "Please share it on the §bSkyHanni Discord §ein the channel §b#share-data§e.", ) OSUtils.copyToClipboard("```${data.joinToString("\n")}```") } else { @@ -91,8 +93,8 @@ object GardenCropMilestonesCommunityFix { // debug("crop: $crop") // debug("realTier: $realTier") - val guessNextMax = GardenCropMilestones.getCropsForTier(realTier + 1, crop) - GardenCropMilestones.getCropsForTier(realTier, crop) -// debug("guessNextMax: ${guessNextMax.addSeparators()}") + val guessNextMax = nextMax(realTier, crop) + // debug("guessNextMax: ${guessNextMax.addSeparators()}") val nextMax = amountPattern.matchMatcher(next) { group("max").formatLong() } ?: return @@ -112,7 +114,7 @@ object GardenCropMilestonesCommunityFix { // debug("$crop total offf by: ${totalOffBy.addSeparators()}") } -// fun debug(message: String) { + // fun debug(message: String) { // if (SkyHanniMod.feature.dev.debug.enabled) { // println(message) // } @@ -160,7 +162,7 @@ object GardenCropMilestonesCommunityFix { } private fun tryFix(crop: CropType, tier: Int, amount: Int): Boolean { - val guessNextMax = GardenCropMilestones.getCropsForTier(tier + 1, crop) - GardenCropMilestones.getCropsForTier(tier, crop) + val guessNextMax = nextMax(tier, crop) if (guessNextMax.toInt() == amount) return false GardenCropMilestones.cropMilestoneData = GardenCropMilestones.cropMilestoneData.editCopy { fix(crop, this, tier, amount) @@ -168,6 +170,9 @@ object GardenCropMilestonesCommunityFix { return true } + private fun nextMax(tier: Int, crop: CropType): Long = + GardenCropMilestones.getCropsForTier(tier + 1, crop) - GardenCropMilestones.getCropsForTier(tier, crop) + private fun fix(crop: CropType, map: MutableMap>, tier: Int, amount: Int) { map[crop] = map[crop]!!.editCopy { this[tier] = amount diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt index 35a8787918da..5728ce5024f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NumberUtil.formatInt @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenCropUpgrades { private val patternGroup = RepoPattern.group("garden.cropupgrades") diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt index c0cd463658fe..782f3224a95b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiData.kt @@ -1,9 +1,12 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.NEURenderEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import io.github.moulberry.notenoughupdates.NEUApi @@ -13,26 +16,26 @@ import net.minecraftforge.client.event.GuiOpenEvent import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent import org.lwjgl.input.Keyboard +@SkyHanniModule object GuiData { - var preDrawEventCanceled = false + var preDrawEventCancelled = false @SubscribeEvent(priority = EventPriority.HIGH) fun onNeuRenderEvent(event: NEURenderEvent) { - if (preDrawEventCanceled) event.cancel() + if (preDrawEventCancelled) event.cancel() } @SubscribeEvent(priority = EventPriority.HIGH) fun onClick(event: GuiContainerEvent.SlotClickEvent) { - if (preDrawEventCanceled) event.cancel() + if (preDrawEventCancelled) event.cancel() } @SubscribeEvent(priority = EventPriority.HIGH) fun onGuiClick(event: GuiScreenEvent.MouseInputEvent.Pre) { - if (preDrawEventCanceled) event.isCanceled = true + if (preDrawEventCancelled) event.isCanceled = true } @SubscribeEvent(priority = EventPriority.HIGH) @@ -41,31 +44,31 @@ object GuiData { Keyboard.KEY_ESCAPE to it.keyBindInventory.keyCode } if (escKey.isKeyHeld() || invKey.isKeyHeld()) return - if (preDrawEventCanceled) event.isCanceled = true + if (preDrawEventCancelled) event.isCanceled = true } @SubscribeEvent fun onInventoryClose(event: InventoryCloseEvent) { DelayedRun.runNextTick { if (Minecraft.getMinecraft().currentScreen !is GuiChest) { - preDrawEventCanceled = false + preDrawEventCancelled = false } } } @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - preDrawEventCanceled = false + preDrawEventCancelled = false } - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { - preDrawEventCanceled = false + @HandleEvent + fun onDisconnect(event: ClientDisconnectEvent) { + preDrawEventCancelled = false } @SubscribeEvent(priority = EventPriority.LOW) fun onGuiOpen(event: GuiOpenEvent) { - if (preDrawEventCanceled) { + if (preDrawEventCancelled) { NEUApi.setInventoryButtonsToDisabled() } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 38da02e08b88..9f249ee7a04f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.GuiPositionMovedEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign @@ -31,10 +32,15 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class GuiEditManager { +@SkyHanniModule +object GuiEditManager { private var lastHotkeyPressed = SimpleTimeMark.farPast() + private var currentPositions = TimeLimitedCache(15.seconds) + private var currentBorderSize = mutableMapOf>() + private var lastMovedGui: String? = null + @SubscribeEvent fun onKeyClick(event: LorenzKeyPressEvent) { if (event.keyCode != SkyHanniMod.feature.gui.keyBindOpen) return @@ -71,77 +77,70 @@ class GuiEditManager { } } - companion object { - - private var currentPositions = TimeLimitedCache(15.seconds) - private var currentBorderSize = mutableMapOf>() - private var lastMovedGui: String? = null - - @JvmStatic - fun add(position: Position, posLabel: String, x: Int, y: Int) { - var name = position.internalName - if (name == null) { - name = if (posLabel == "none") "none " + UUID.randomUUID() else posLabel - position.internalName = name - } - currentPositions[name] = position - currentBorderSize[posLabel] = Pair(x, y) + @JvmStatic + fun add(position: Position, posLabel: String, x: Int, y: Int) { + var name = position.internalName + if (name == null) { + name = if (posLabel == "none") "none " + UUID.randomUUID() else posLabel + position.internalName = name } + currentPositions[name] = position + currentBorderSize[posLabel] = Pair(x, y) + } - private var lastHotkeyReminded = SimpleTimeMark.farPast() - - @JvmStatic - fun openGuiPositionEditor(hotkeyReminder: Boolean) { - SkyHanniMod.screenToOpen = GuiPositionEditor( - currentPositions.values().toList(), - 2, - Minecraft.getMinecraft().currentScreen as? GuiContainer + private var lastHotkeyReminded = SimpleTimeMark.farPast() + + @JvmStatic + fun openGuiPositionEditor(hotkeyReminder: Boolean) { + SkyHanniMod.screenToOpen = GuiPositionEditor( + currentPositions.values().toList(), + 2, + Minecraft.getMinecraft().currentScreen as? GuiContainer + ) + if (hotkeyReminder && lastHotkeyReminded.passedSince() > 30.minutes) { + lastHotkeyReminded = SimpleTimeMark.now() + ChatUtils.chat( + "§eTo edit hidden GUI elements:\n" + + " §7- §e1. Set a key in /sh edit.\n" + + " §7- §e2. Click that key while the GUI element is visible." ) - if (hotkeyReminder && lastHotkeyReminded.passedSince() > 30.minutes) { - lastHotkeyReminded = SimpleTimeMark.now() - ChatUtils.chat( - "§eTo edit hidden GUI elements:\n" + - " §7- §e1. Set a key in /sh edit.\n" + - " §7- §e2. Click that key while the GUI element is visible." - ) - } } + } - @JvmStatic - fun renderLast() { - if (!isInGui()) return - if (!SkyHanniDebugsAndTests.globalRender) return + @JvmStatic + fun renderLast() { + if (!isInGui()) return + if (!SkyHanniDebugsAndTests.globalRender) return - GlStateManager.translate(0f, 0f, 200f) + GlStateManager.translate(0f, 0f, 200f) - GuiRenderEvent.GuiOverlayRenderEvent().postAndCatch() + GuiRenderEvent.GuiOverlayRenderEvent().postAndCatch() - GlStateManager.pushMatrix() - GlStateManager.enableDepth() - GuiRenderEvent.ChestGuiOverlayRenderEvent().postAndCatch() - GlStateManager.popMatrix() + GlStateManager.pushMatrix() + GlStateManager.enableDepth() + GuiRenderEvent.ChestGuiOverlayRenderEvent().postAndCatch() + GlStateManager.popMatrix() - GlStateManager.translate(0f, 0f, -200f) - } + GlStateManager.translate(0f, 0f, -200f) + } - fun isInGui() = Minecraft.getMinecraft().currentScreen is GuiPositionEditor + fun isInGui() = Minecraft.getMinecraft().currentScreen is GuiPositionEditor - fun Position.getDummySize(random: Boolean = false): Vector2i { - if (random) return Vector2i(5, 5) - val (x, y) = currentBorderSize[internalName] ?: return Vector2i(1, 1) - return Vector2i((x * effectiveScale).toInt(), (y * effectiveScale).toInt()) - } + fun Position.getDummySize(random: Boolean = false): Vector2i { + if (random) return Vector2i(5, 5) + val (x, y) = currentBorderSize[internalName] ?: return Vector2i(1, 1) + return Vector2i((x * effectiveScale).toInt(), (y * effectiveScale).toInt()) + } - fun Position.getAbsX() = getAbsX0(getDummySize(true).x) + fun Position.getAbsX() = getAbsX0(getDummySize(true).x) - fun Position.getAbsY() = getAbsY0(getDummySize(true).y) + fun Position.getAbsY() = getAbsY0(getDummySize(true).y) - fun GuiProfileViewer.anyTextBoxFocused() = - this.getPropertiesWithType().any { it.focus } + fun GuiProfileViewer.anyTextBoxFocused() = + this.getPropertiesWithType().any { it.focus } - fun handleGuiPositionMoved(guiName: String) { - lastMovedGui = guiName - } + fun handleGuiPositionMoved(guiName: String) { + lastMovedGui = guiName } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt index f4273e745e17..541eb323cf8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GuildAPI { private var inGuildMessage = false diff --git a/src/main/java/at/hannibal2/skyhanni/data/HighlightOnHoverSlot.kt b/src/main/java/at/hannibal2/skyhanni/data/HighlightOnHoverSlot.kt index 9e99fdbae7c1..c5aa22e66fd7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HighlightOnHoverSlot.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HighlightOnHoverSlot.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -10,6 +11,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object HighlightOnHoverSlot { val currentSlots = mutableMapOf, List>() diff --git a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt index 841e39c17920..8c6db7df0de5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf @@ -42,188 +43,289 @@ enum class HotmData( val rewardFun: ((Int) -> (Map)), ) { - MINING_SPEED("Mining Speed", + MINING_SPEED( + "Mining Speed", 50, { currentLevel -> (currentLevel + 2.0).pow(3) }, - { level -> mapOf(HotmReward.MINING_SPEED to level * 20.0) }), - MINING_FORTUNE("Mining Fortune", + { level -> mapOf(HotmReward.MINING_SPEED to level * 20.0) }, + ), + MINING_FORTUNE( + "Mining Fortune", 50, { currentLevel -> (currentLevel + 2.0).pow(3.05) }, - { level -> mapOf(HotmReward.MINING_FORTUNE to level * 5.0) }), - QUICK_FORGE("Quick Forge", + { level -> mapOf(HotmReward.MINING_FORTUNE to level * 5.0) }, + ), + QUICK_FORGE( + "Quick Forge", 20, { currentLevel -> (currentLevel + 2.0).pow(4) }, - { level -> mapOf(HotmReward.FORGE_TIME_DECREASE to 10.0 + (level * 0.5)) }), - TITANIUM_INSANIUM("Titanium Insanium", + { level -> mapOf(HotmReward.FORGE_TIME_DECREASE to 10.0 + (level * 0.5)) }, + ), + TITANIUM_INSANIUM( + "Titanium Insanium", 50, { currentLevel -> (currentLevel + 2.0).pow(3.1) }, - { level -> mapOf(HotmReward.TITANIUM_CHANCE to 2.0 + (level * 0.1)) }), - DAILY_POWDER("Daily Powder", + { level -> mapOf(HotmReward.TITANIUM_CHANCE to 2.0 + (level * 0.1)) }, + ), + DAILY_POWDER( + "Daily Powder", 100, { currentLevel -> 200.0 + (currentLevel * 18.0) }, - { level -> mapOf(HotmReward.DAILY_POWDER to (200.0 + ((level - 1.0) * 18.0)) * 2.0) }), - LUCK_OF_THE_CAVE("Luck of the Cave", + { level -> mapOf(HotmReward.DAILY_POWDER to (200.0 + ((level - 1.0) * 18.0)) * 2.0) }, + ), + LUCK_OF_THE_CAVE( + "Luck of the Cave", 45, { currentLevel -> (currentLevel + 2.0).pow(3.07) }, - { level -> mapOf(HotmReward.EXTRA_CHANCE_TRIGGER_RARE_OCCURRENCES to 5.0 + level) }), - CRYSTALLIZED("Crystallized", 30, { currentLevel -> (currentLevel + 2.0).pow(3.4) }, { level -> - mapOf( - HotmReward.MINING_SPEED to 20.0 + ((level - 1.0) * 6.0), - HotmReward.MINING_FORTUNE to 20.0 + ((level - 1.0) * 5.0) - ) - }), - EFFICIENT_MINER("Efficient Miner", + { level -> mapOf(HotmReward.EXTRA_CHANCE_TRIGGER_RARE_OCCURRENCES to 5.0 + level) }, + ), + CRYSTALLIZED( + "Crystallized", + 30, + { currentLevel -> (currentLevel + 2.0).pow(3.4) }, + { level -> + mapOf( + HotmReward.MINING_SPEED to 20.0 + ((level - 1.0) * 6.0), + HotmReward.MINING_FORTUNE to 20.0 + ((level - 1.0) * 5.0), + ) + }, + ), + EFFICIENT_MINER( + "Efficient Miner", 100, { currentLevel -> (currentLevel + 2.0).pow(2.6) }, - { level -> mapOf(HotmReward.AVERAGE_BLOCK_BREAKS to (10.0 + (level * 0.4)) * (1.0 + (level * 0.05))) }), - ORBITER("Orbiter", + { level -> mapOf(HotmReward.AVERAGE_BLOCK_BREAKS to (10.0 + (level * 0.4)) * (1.0 + (level * 0.05))) }, + ), + ORBITER( + "Orbiter", 80, { currentLevel -> (currentLevel + 1.0) * 70.0 }, - { level -> mapOf(HotmReward.CHANCE_EXTRA_XP_ORBS to 0.2 + (level * 0.01)) }), - SEASONED_MINEMAN("Seasoned Mineman", + { level -> mapOf(HotmReward.CHANCE_EXTRA_XP_ORBS to 0.2 + (level * 0.01)) }, + ), + SEASONED_MINEMAN( + "Seasoned Mineman", 100, { currentLevel -> (currentLevel + 2.0).pow(2.3) }, - { level -> mapOf(HotmReward.MINING_WISDOM to 5.0 + (level * 0.1)) }), - MOLE("Mole", + { level -> mapOf(HotmReward.MINING_WISDOM to 5.0 + (level * 0.1)) }, + ), + MOLE( + "Mole", 190, { currentLevel -> (currentLevel + 2.0).pow(2.2) }, - { level -> mapOf(HotmReward.AVERAGE_BLOCK_BREAKS to 1.0 + ((level + 9.0) * 0.05 * ((level + 8) % 20))) }), - PROFESSIONAL("Professional", + { level -> mapOf(HotmReward.AVERAGE_BLOCK_BREAKS to 1.0 + ((level + 9.0) * 0.05 * ((level + 8) % 20))) }, + ), + PROFESSIONAL( + "Professional", 140, { currentLevel -> (currentLevel + 2.0).pow(2.3) }, - { level -> mapOf(HotmReward.MINING_SPEED to 50.0 + (level * 5.0)) }), - LONESOME_MINER("Lonesome Miner", + { level -> mapOf(HotmReward.MINING_SPEED to 50.0 + (level * 5.0)) }, + ), + LONESOME_MINER( + "Lonesome Miner", 45, { currentLevel -> (currentLevel + 2.0).pow(3.07) }, - { level -> mapOf(HotmReward.COMBAT_STAT_BOOST to 5.0 + ((level - 1.0) * 0.5)) }), - GREAT_EXPLORER("Great Explorer", 20, { currentLevel -> (currentLevel + 2.0).pow(4.0) }, { level -> - mapOf( - HotmReward.CHANCE_OF_TREASURE_CHEST to (0.2 * (0.2 + 0.04 * (level - 1.0))), - HotmReward.LOCKS_OF_TREASURE_CHEST to 1 + level * 0.2 - ) - }), - FORTUNATE("Fortunate", + { level -> mapOf(HotmReward.COMBAT_STAT_BOOST to 5.0 + ((level - 1.0) * 0.5)) }, + ), + GREAT_EXPLORER( + "Great Explorer", + 20, + { currentLevel -> (currentLevel + 2.0).pow(4.0) }, + { level -> + mapOf( + HotmReward.CHANCE_OF_TREASURE_CHEST to (0.2 * (0.2 + 0.04 * (level - 1.0))), + HotmReward.LOCKS_OF_TREASURE_CHEST to 1 + level * 0.2, + ) + }, + ), + FORTUNATE( + "Fortunate", 20, { currentLevel -> (currentLevel + 1.0).pow(3.05) }, - { level -> mapOf(HotmReward.MINING_FORTUNE to 20.0 + (level * 4.0)) }), - POWDER_BUFF("Powder Buff", 50, { currentLevel -> (currentLevel + 1.0).pow(3.2) }, { level -> - mapOf( - HotmReward.MORE_MITHRIL_POWER to level.toDouble(), HotmReward.MORE_GEMSTONE_POWER to level.toDouble() - ) - }), - MINING_SPEED_II("Mining Speed II", + { level -> mapOf(HotmReward.MINING_FORTUNE to 20.0 + (level * 4.0)) }, + ), + POWDER_BUFF( + "Powder Buff", + 50, + { currentLevel -> (currentLevel + 1.0).pow(3.2) }, + { level -> + mapOf( + HotmReward.MORE_MITHRIL_POWER to level.toDouble(), + HotmReward.MORE_GEMSTONE_POWER to level.toDouble(), + ) + }, + ), + MINING_SPEED_II( + "Mining Speed II", 50, { currentLevel -> (currentLevel + 2.0).pow(3.2) }, - { level -> mapOf(HotmReward.MINING_SPEED to level * 40.0) }), - MINING_FORTUNE_II("Mining Fortune II", + { level -> mapOf(HotmReward.MINING_SPEED to level * 40.0) }, + ), + MINING_FORTUNE_II( + "Mining Fortune II", 50, { currentLevel -> (currentLevel + 2.0).pow(3.2) }, - { level -> mapOf(HotmReward.MINING_FORTUNE to level * 5.0) }), + { level -> mapOf(HotmReward.MINING_FORTUNE to level * 5.0) }, + ), // Static - MINING_MADNESS("Mining Madness", 1, { null }, { - mapOf( - HotmReward.MINING_SPEED to 50.0, HotmReward.MINING_FORTUNE to 50.0 - ) - }), + MINING_MADNESS( + "Mining Madness", + 1, + { null }, + { + mapOf( + HotmReward.MINING_SPEED to 50.0, + HotmReward.MINING_FORTUNE to 50.0, + ) + }, + ), SKY_MALL("Sky Mall", 1, { null }, { emptyMap() }), PRECISION_MINING("Precision Mining", 1, { null }, { mapOf(HotmReward.MINING_SPEED_BOOST to 30.0) }), - FRONT_LOADED("Front Loaded", 1, { null }, { - mapOf( - HotmReward.MINING_SPEED to 100.0, - HotmReward.MINING_FORTUNE to 100.0, - HotmReward.MORE_BASE_MITHRIL_POWER to 2.0, - HotmReward.MORE_BASE_GEMSTONE_POWER to 2.0 - ) - }), + FRONT_LOADED( + "Front Loaded", + 1, + { null }, + { + mapOf( + HotmReward.MINING_SPEED to 100.0, + HotmReward.MINING_FORTUNE to 100.0, + HotmReward.MORE_BASE_MITHRIL_POWER to 2.0, + HotmReward.MORE_BASE_GEMSTONE_POWER to 2.0, + ) + }, + ), STAR_POWDER("Star Powder", 1, { null }, { mapOf(HotmReward.MORE_MITHRIL_POWER to 300.0) }), GOBLIN_KILLER("Goblin Killer", 1, { null }, { emptyMap() }), // Abilities - PICKOBULUS("Pickobulus", 3, { null }, { level -> - mapOf( - HotmReward.ABILITY_RADIUS to ceil(level * 0.5) + 1.0, - HotmReward.ABILITY_COOLDOWN to 130.0 - 10.0 * level - ) - }), - MINING_SPEED_BOOST("Mining Speed Boost", 3, { null }, { level -> - mapOf( - HotmReward.ABILITY_DURATION to level + 1.0, HotmReward.ABILITY_COOLDOWN to 10.0 + 5.0 * level - ) - }), - VEIN_SEEKER("Vein Seeker", 3, { null }, { level -> - mapOf( - HotmReward.ABILITY_RADIUS to level + 1.0, - HotmReward.ABILITY_DURATION to 10.0 + 2.0 * level, - HotmReward.ABILITY_COOLDOWN to 60.0 - ) - }), - MANIAC_MINER("Maniac Miner", 3, { null }, { level -> - mapOf( - HotmReward.ABILITY_DURATION to 5.0 + level * 5.0, HotmReward.ABILITY_COOLDOWN to 60.0 - level - ) - }), + PICKOBULUS( + "Pickobulus", + 3, + { null }, + { level -> + mapOf( + HotmReward.ABILITY_RADIUS to ceil(level * 0.5) + 1.0, + HotmReward.ABILITY_COOLDOWN to 130.0 - 10.0 * level, + ) + }, + ), + MINING_SPEED_BOOST( + "Mining Speed Boost", + 3, + { null }, + { level -> + mapOf( + HotmReward.ABILITY_DURATION to level + 1.0, + HotmReward.ABILITY_COOLDOWN to 10.0 + 5.0 * level, + ) + }, + ), + VEIN_SEEKER( + "Vein Seeker", + 3, + { null }, + { level -> + mapOf( + HotmReward.ABILITY_RADIUS to level + 1.0, + HotmReward.ABILITY_DURATION to 10.0 + 2.0 * level, + HotmReward.ABILITY_COOLDOWN to 60.0, + ) + }, + ), + MANIAC_MINER( + "Maniac Miner", + 3, + { null }, + { level -> + mapOf( + HotmReward.ABILITY_DURATION to 5.0 + level * 5.0, + HotmReward.ABILITY_COOLDOWN to 60.0 - level, + ) + }, + ), PEAK_OF_THE_MOUNTAIN("Peak of the Mountain", 10, { null }, { emptyMap() }), // Mining V3 - DAILY_GRIND("Daily Grind", + DAILY_GRIND( + "Daily Grind", 100, { currentLevel -> 218.0 + (18.0 * (currentLevel - 2.0)) }, - { level -> mapOf(HotmReward.DAILY_POWDER to 50.0 * level) }), + { level -> mapOf(HotmReward.DAILY_POWDER to 50.0 * level) }, + ), DUST_COLLECTOR( "Dust Collector", 20, { currentLevel -> (currentLevel + 1.0).pow(4) }, - { level -> mapOf(HotmReward.FOSSIL_DUST to 1.0 * level) }), - WARM_HEARTED("Warm Hearted", + { level -> mapOf(HotmReward.FOSSIL_DUST to 1.0 * level) }, + ), + WARM_HEARTED( + "Warm Hearted", 50, { currentLevel -> floor((currentLevel + 1.0).pow(3.1)) }, - { level -> mapOf(HotmReward.COLD_RESISTANCE to 0.2 * level) }), + { level -> mapOf(HotmReward.COLD_RESISTANCE to 0.2 * level) }, + ), - STRONG_ARM("Strong Arm", + STRONG_ARM( + "Strong Arm", 100, { currentLevel -> floor((currentLevel + 1.0).pow(2.3)) }, - { level -> mapOf(HotmReward.MINING_SPEED to 5.0 * level) }), - NO_STONE_UNTURNED("No Stone Unturned", + { level -> mapOf(HotmReward.MINING_SPEED to 5.0 * level) }, + ), + NO_STONE_UNTURNED( + "No Stone Unturned", 50, { currentLevel -> floor((currentLevel + 1.0).pow(3.05)) }, - { level -> mapOf(HotmReward.UNKNOWN to 0.5 * level) }), + { level -> mapOf(HotmReward.UNKNOWN to 0.5 * level) }, + ), - SUB_ZERO_MINING("SubZero Mining", + SUB_ZERO_MINING( + "SubZero Mining", 100, { currentLevel -> floor((currentLevel + 1.0).pow(2.3)) }, - { level -> mapOf(HotmReward.MINING_FORTUNE to 1.0 * level) }), - SURVEYOR("Surveyor", + { level -> mapOf(HotmReward.MINING_FORTUNE to 1.0 * level) }, + ), + SURVEYOR( + "Surveyor", 20, { currentLevel -> (currentLevel + 1.0).pow(4) }, - { level -> mapOf(HotmReward.UNKNOWN to 0.75 * level) }), - EAGER_ADVENTURER("Eager Adventurer", + { level -> mapOf(HotmReward.UNKNOWN to 0.75 * level) }, + ), + EAGER_ADVENTURER( + "Eager Adventurer", 100, { currentLevel -> floor((currentLevel + 1.0).pow(2.3)) }, - { level -> mapOf(HotmReward.MINING_SPEED to 2.0 * level) }), + { level -> mapOf(HotmReward.MINING_SPEED to 2.0 * level) }, + ), - DEAD_MANS_CHEST("Dead Man's Chest", + DEAD_MANS_CHEST( + "Dead Man's Chest", 50, { currentLevel -> floor((currentLevel + 1.0).pow(3.2)) }, - { level -> mapOf(HotmReward.UNKNOWN to 1.0 * level) }), + { level -> mapOf(HotmReward.UNKNOWN to 1.0 * level) }, + ), - GIFTS_FROM_THE_DEPARTED("Gifts from the Departed", + GIFTS_FROM_THE_DEPARTED( + "Gifts from the Departed", 100, { currentLevel -> floor((currentLevel + 1.0).pow(2.45)) }, - { level -> mapOf(HotmReward.UNKNOWN to 0.2 * level) }), + { level -> mapOf(HotmReward.UNKNOWN to 0.2 * level) }, + ), EXCAVATOR( "Excavator", 50, { currentLevel -> (currentLevel + 1.0).pow(3) }, - { level -> mapOf(HotmReward.UNKNOWN to 0.5 * level) }), - RAGS_TO_RICHES("Rags to Riches", + { level -> mapOf(HotmReward.UNKNOWN to 0.5 * level) }, + ), + RAGS_TO_RICHES( + "Rags to Riches", 50, { currentLevel -> floor((currentLevel + 1.0).pow(3.05)) }, - { level -> mapOf(HotmReward.MINING_FORTUNE to 2.0 * level) }), + { level -> mapOf(HotmReward.MINING_FORTUNE to 2.0 * level) }, + ), KEEN_EYE("Keen Eye", 1, { null }, { emptyMap() }), MINESHAFT_MAYHEM("Mineshaft Mayhem", 1, { null }, { emptyMap() }), @@ -246,6 +348,9 @@ enum class HotmData( storage?.perks?.computeIfAbsent(this.name) { HotmTree.HotmPerk() }?.level = value } + val isMaxLevel: Boolean + get() = activeLevel >= maxLevel // >= to account for +1 from Blue Cheese + private fun blueEgg() = if (this != PEAK_OF_THE_MOUNTAIN && maxLevel != 1 && HotmAPI.isBlueEggActive) 1 else 0 var enabled: Boolean @@ -267,6 +372,8 @@ enum class HotmData( fun getReward() = rewardFun(activeLevel) + // TODO move all object functions into hotm api? + @SkyHanniModule companion object { val storage get() = ProfileStorageData.profileSpecific?.mining?.hotmTree @@ -275,49 +382,62 @@ enum class HotmData( listOf(PICKOBULUS, MINING_SPEED_BOOST, VEIN_SEEKER, MANIAC_MINER, HAZARDOUS_MINER, GEMSTONE_INFUSION) private val inventoryPattern by patternGroup.pattern( - "inventory", "Heart of the Mountain" + "inventory", + "Heart of the Mountain", ) private val levelPattern by patternGroup.pattern( - "perk.level", "§(?.)Level (?\\d+).*" + "perk.level", + "§(?.)Level (?\\d+).*", ) private val notUnlockedPattern by patternGroup.pattern( - "perk.notunlocked", "(§.)*Requires.*|.*Mountain!|(§.)*Click to unlock!|" + "perk.notunlocked", + "(§.)*Requires.*|.*Mountain!|(§.)*Click to unlock!|", ) private val enabledPattern by patternGroup.pattern( - "perk.enable", "§a§lENABLED|(§.)*SELECTED" + "perk.enable", + "§a§lENABLED|(§.)*SELECTED", ) private val disabledPattern by patternGroup.pattern( - "perk.disabled", "§c§lDISABLED|§7§eClick to select!" - ) // unused for now since the assumption is when enabled isn't found it is disabled, but the value might be useful in the future or for debugging + "perk.disabled", + "§c§lDISABLED|§7§eClick to select!", + ) // unused for now since the assumption is when enabled isn't found it is disabled, + // but the value might be useful in the future or for debugging private val resetChatPattern by patternGroup.pattern( - "reset.chat", "§aReset your §r§5Heart of the Mountain§r§a! Your Perks and Abilities have been reset." + "reset.chat", + "§aReset your §r§5Heart of the Mountain§r§a! Your Perks and Abilities have been reset.", ) private val heartItemPattern by patternGroup.pattern( - "inventory.heart", "§5Heart of the Mountain" + "inventory.heart", + "§5Heart of the Mountain", ) private val resetItemPattern by patternGroup.pattern( - "inventory.reset", "§cReset Heart of the Mountain" + "inventory.reset", + "§cReset Heart of the Mountain", ) private val heartTokensPattern by patternGroup.pattern( - "inventory.heart.token", "§7Token of the Mountain: §5(?\\d+)" + "inventory.heart.token", + "§7Token of the Mountain: §5(?\\d+)", ) private val resetTokensPattern by patternGroup.pattern( - "inventory.reset.token", "\\s+§8- §5(?\\d+) Token of the Mountain" + "inventory.reset.token", + "\\s+§8- §5(?\\d+) Token of the Mountain", ) private val skymallPattern by patternGroup.pattern( - "skymall", "(?:§eNew buff§r§r§r: §r§f|§8 ■ §7)(?.*)" + "skymall", + "(?:§eNew buff§r§r§r: §r§f|§8 ■ §7)(?.*)", ) private val mayhemChatPattern by patternGroup.pattern( - "mayhem", "§b§lMAYHEM! §r§7(?.*)" + "mayhem", + "§b§lMAYHEM! §r§7(?.*)", ) var inInventory = false @@ -447,20 +567,23 @@ enum class HotmData( } private val skyMallCurrentEffect by patternGroup.pattern( - "skymall.current", "§aYour Current Effect" + "skymall.current", + "§aYour Current Effect", ) private fun handelSkyMall(lore: List) { if (!SKY_MALL.enabled || !SKY_MALL.isUnlocked) HotmAPI.skymall = null else { - val index = (lore.indexOfFirstMatch(skyMallCurrentEffect) ?: run { - ErrorManager.logErrorStateWithData( - "Could not read the skymall effect from the hotm tree", - "skyMallCurrentEffect didn't match", - "lore" to lore - ) - return - }) + 1 + val index = ( + lore.indexOfFirstMatch(skyMallCurrentEffect) ?: run { + ErrorManager.logErrorStateWithData( + "Could not read the skymall effect from the hotm tree", + "skyMallCurrentEffect didn't match", + "lore" to lore, + ) + return + } + ) + 1 skymallPattern.matchMatcher(lore[index]) { val perk = group("perk") HotmAPI.skymall = SkymallPerk.entries.firstOrNull { it.itemPattern.matches(perk) } ?: run { @@ -468,7 +591,7 @@ enum class HotmData( "Could not read the skymall effect from the hotm tree", "no itemPattern matched", "lore" to lore, - "perk" to perk + "perk" to perk, ) null } @@ -526,7 +649,7 @@ enum class HotmData( "Could not read the skymall effect from chat", "no chatPattern matched", "chat" to event.message, - "perk" to perk + "perk" to perk, ) null } @@ -541,7 +664,7 @@ enum class HotmData( "Could not read the mayhem effect from chat", "no chatPattern matched", "chat" to event.message, - "perk" to perk + "perk" to perk, ) null } @@ -562,7 +685,8 @@ enum class HotmData( HotmAPI.Powder.entries.forEach { if (it.getStorage() == null) { ProfileStorageData.profileSpecific?.mining?.powder?.put( - it, ProfileSpecificStorage.MiningConfig.PowderStorage() + it, + ProfileSpecificStorage.MiningConfig.PowderStorage(), ) } } @@ -582,9 +706,11 @@ enum class HotmData( add("Mineshaft Mayhem: ${HotmAPI.mineshaftMayhem}") } event.title("HotM - Tree") - event.addIrrelevant(entries.filter { it.isUnlocked }.map { - "${if (it.enabled) "✔" else "✖"} ${it.printName}: ${it.activeLevel}" - }) + event.addIrrelevant( + entries.filter { it.isUnlocked }.map { + "${if (it.enabled) "✔" else "✖"} ${it.printName}: ${it.activeLevel}" + }, + ) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index dbf153c57c11..0e2f9af32842 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigManager.Companion.gson import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.HypixelJoinEvent @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.WidgetUpdateEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.rift.RiftAPI @@ -30,7 +32,6 @@ import com.google.gson.JsonObject import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent import kotlin.concurrent.thread import kotlin.time.Duration.Companion.seconds @@ -38,7 +39,8 @@ class HypixelData { private val patternGroup = RepoPattern.group("data.hypixeldata") private val islandNamePattern by patternGroup.pattern( - "islandname", "(?:§.)*(Area|Dungeon): (?:§.)*(?.*)" + "islandname", + "(?:§.)*(Area|Dungeon): (?:§.)*(?.*)", ) private var lastLocRaw = SimpleTimeMark.farPast() @@ -46,41 +48,52 @@ class HypixelData { companion object { private val patternGroup = RepoPattern.group("data.hypixeldata") private val serverIdScoreboardPattern by patternGroup.pattern( - "serverid.scoreboard", "§7\\d+/\\d+/\\d+ §8(?[mM])(?\\S+).*" + "serverid.scoreboard", + "§7\\d+/\\d+/\\d+ §8(?[mM])(?\\S+).*", ) private val serverIdTablistPattern by patternGroup.pattern( - "serverid.tablist", " Server: §r§8(?\\S+)" + "serverid.tablist", + " Server: §r§8(?\\S+)", ) private val lobbyTypePattern by patternGroup.pattern( - "lobbytype", "(?.*lobby)\\d+" + "lobbytype", + "(?.*lobby)\\d+", ) private val playerAmountPattern by patternGroup.pattern( - "playeramount", "^\\s*(?:§.)+Players (?:§.)+\\((?\\d+)\\)\\s*$" + "playeramount", + "^\\s*(?:§.)+Players (?:§.)+\\((?\\d+)\\)\\s*$", ) private val playerAmountCoopPattern by patternGroup.pattern( - "playeramount.coop", "^\\s*(?:§.)*Coop (?:§.)*\\((?\\d+)\\)\\s*$" + "playeramount.coop", + "^\\s*(?:§.)*Coop (?:§.)*\\((?\\d+)\\)\\s*$", ) private val playerAmountGuestingPattern by patternGroup.pattern( - "playeramount.guesting", "^\\s*(?:§.)*Guests (?:§.)*\\((?\\d+)\\)\\s*$" + "playeramount.guesting", + "^\\s*(?:§.)*Guests (?:§.)*\\((?\\d+)\\)\\s*$", ) /** * REGEX-TEST: §r§b§lParty §r§f(4) */ private val dungeonPartyAmountPattern by patternGroup.pattern( - "playeramount.dungeonparty", "^\\s*(?:§.)+Party (?:§.)+\\((?\\d+)\\)\\s*$" + "playeramount.dungeonparty", + "^\\s*(?:§.)+Party (?:§.)+\\((?\\d+)\\)\\s*$", ) private val soloProfileAmountPattern by patternGroup.pattern( - "solo.profile.amount", "^\\s*(?:§.)*Island\\s*$" + "solo.profile.amount", + "^\\s*(?:§.)*Island\\s*$", ) private val scoreboardVisitingAmoutPattern by patternGroup.pattern( - "scoreboard.visiting.amount", "\\s+§.✌ §.\\(§.(?\\d+)§./(?\\d+)\\)" + "scoreboard.visiting.amount", + "\\s+§.✌ §.\\(§.(?\\d+)§./(?\\d+)\\)", ) private val guestPattern by patternGroup.pattern( - "guesting.scoreboard", "SKYBLOCK GUEST" + "guesting.scoreboard", + "SKYBLOCK GUEST", ) private val scoreboardTitlePattern by patternGroup.pattern( - "scoreboard.title", "SK[YI]BLOCK(?: CO-OP| GUEST)?" + "scoreboard.title", + "SK[YI]BLOCK(?: CO-OP| GUEST)?", ) /** @@ -88,7 +101,8 @@ class HypixelData { * REGEX-TEST: §5ф §dWizard Tower */ private val skyblockAreaPattern by patternGroup.pattern( - "skyblock.area", "\\s*§(?7⏣|5ф) §(?.)(?.*)" + "skyblock.area", + "\\s*§(?7⏣|5ф) §(?.)(?.*)", ) var hypixelLive = false @@ -115,8 +129,13 @@ class HypixelData { // Data from locraw var locrawData: JsonObject? = null private var locraw: MutableMap = listOf( - "server", "gametype", "lobbyname", "lobbytype", "mode", "map" - ).associate { it to "" }.toMutableMap() + "server", + "gametype", + "lobbyname", + "lobbytype", + "mode", + "map", + ).associateWith { "" }.toMutableMap() val server get() = locraw["server"] ?: "" val gameType get() = locraw["gametype"] ?: "" @@ -147,7 +166,7 @@ class HypixelData { "Could not find server id", "islandType" to LorenzUtils.skyBlockIsland, "tablist" to TabListData.getTabList(), - "scoreboard" to ScoreboardData.sidebarLinesFormatted + "scoreboard" to ScoreboardData.sidebarLinesFormatted, ) } @@ -235,8 +254,8 @@ class HypixelData { skyBlockAreaWithSymbol = null } - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + @HandleEvent + fun onDisconnect(event: ClientDisconnectEvent) { hypixelLive = false hypixelAlpha = false skyBlock = false @@ -279,8 +298,8 @@ class HypixelData { } } - @SubscribeEvent // TODO rewrite everything in here + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) { // Modified from NEU. diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index ff185d5ae460..4d36c1c0182e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -26,6 +26,7 @@ enum class IslandType(val displayName: String) { MINESHAFT("Mineshaft"), NONE(""), + ANY(""), UNKNOWN("???"), ; diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt index 7025e17105cb..26658eee7cc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemAddManager.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SackChangeEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent import at.hannibal2.skyhanni.features.inventory.SuperCraftFeatures.craftedPattern +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -19,11 +20,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class ItemAddManager { +@SkyHanniModule +object ItemAddManager { enum class Source { ITEM_ADD, SACKS, - ; } private val ARCHFIEND_DICE = "ARCHFIEND_DICE".asInternalName() @@ -31,7 +32,7 @@ class ItemAddManager { private val diceRollChatPattern by RepoPattern.pattern( "data.itemmanager.diceroll", - "§eYour §r§(5|6High Class )Archfiend Dice §r§erolled a §r§.(?.)§r§e! Bonus: §r§.(?.*)❤" + "§eYour §r§(5|6High Class )Archfiend Dice §r§erolled a §r§.(?.)§r§e! Bonus: §r§.(?.*)❤", ) private var inSackInventory = false diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt index acd331cc8984..e7fa75331924 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.EntityClickEvent import at.hannibal2.skyhanni.events.ItemClickEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft @@ -11,14 +13,14 @@ import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraft.network.play.client.C07PacketPlayerDigging import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement import net.minecraft.network.play.client.C0APacketAnimation -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ItemClickData { +@SkyHanniModule +object ItemClickData { - @SubscribeEvent - fun onItemClickSend(event: PacketEvent.SendEvent) { + @HandleEvent + fun onItemClickSend(event: PacketSentEvent) { val packet = event.packet - event.isCanceled = when { + val cancelled = when { packet is C08PacketPlayerBlockPlacement -> { if (packet.placedBlockDirection != 255) { val position = packet.position.toLorenzVec() @@ -56,6 +58,10 @@ class ItemClickData { return } } + + if (cancelled) { + event.cancel() + } } /* @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt index 22d299f17e62..fbbd78e138ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ItemTipHelper.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderItemEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -16,7 +17,8 @@ import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ItemTipHelper { +@SkyHanniModule +object ItemTipHelper { @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { @@ -75,4 +77,4 @@ class ItemTipHelper { GlStateManager.enableLighting() GlStateManager.enableDepth() } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt index 728678824dc9..129e1cd956ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/LocationFixData.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.data.jsonobjects.repo.LocationFixJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object LocationFixData { private var locationFixes = mutableListOf() @@ -20,9 +22,9 @@ object LocationFixData { locationFixes.clear() for (fix in data.locationFixes.values) { - val island = IslandType.getByName(fix.island_name) + val island = IslandType.getByName(fix.islandName) val area = fix.a.axisAlignedTo(fix.b) - val realLocation = fix.real_location + val realLocation = fix.realLocation locationFixes.add(LocationFix(island, area, realLocation)) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt index cc9a6aa43931..56e3cdf42e78 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt @@ -7,6 +7,7 @@ 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.ScoreboardElement +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -27,6 +28,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern +@SkyHanniModule object MaxwellAPI { private val storage get() = ProfileStorageData.profileSpecific @@ -49,72 +51,78 @@ object MaxwellAPI { storage?.maxwell?.tunings = value ?: return } + var favoritePowers: List + get() = storage?.maxwell?.favoritePowers ?: listOf() + set(value) { + storage?.maxwell?.favoritePowers = value + } + private var powers = mutableListOf() private val patternGroup = RepoPattern.group("data.maxwell") private val chatPowerPattern by patternGroup.pattern( "chat.power", - "§eYou selected the §a(?.*) §e(power )?for your §aAccessory Bag§e!" + "§eYou selected the §a(?.*) §e(power )?for your §aAccessory Bag§e!", ) private val chatPowerUnlockedPattern by patternGroup.pattern( "chat.power.unlocked", - "§eYour selected power was set to (?:§r)*§a(?.*)(?:§r)*§e!" + "§eYour selected power was set to (?:§r)*§a(?.*)(?:§r)*§e!", ) private val inventoryPowerPattern by patternGroup.pattern( "inventory.power", - "§7Selected Power: §a(?.*)" + "§7Selected Power: §a(?.*)", ) private val inventoryMPPattern by patternGroup.pattern( "inventory.magicalpower", - "§7Magical Power: §6(?[\\d,]+)" + "§7Magical Power: §6(?[\\d,]+)", ) private val thaumaturgyGuiPattern by patternGroup.pattern( "gui.thaumaturgy", - "Accessory Bag Thaumaturgy" + "Accessory Bag Thaumaturgy", ) private val thaumaturgyStartPattern by patternGroup.pattern( "gui.thaumaturgy.start", - "§7Your tuning:" + "§7Your tuning:", ) private val thaumaturgyDataPattern by patternGroup.pattern( "gui.thaumaturgy.data", - "§(?.)\\+(?[^ ]+)(?.) (?.+)" + "§(?.)\\+(?[^ ]+)(?.) (?.+)", ) private val thaumaturgyMagicalPowerPattern by patternGroup.pattern( "gui.thaumaturgy.magicalpower", - "§7Total: §6(?[\\d.,]+) Magical Power" + "§7Total: §6(?[\\d.,]+) Magical Power", ) private val statsTuningGuiPattern by patternGroup.pattern( "gui.thaumaturgy.statstuning", - "Stats Tuning" + "Stats Tuning", ) private val statsTuningDataPattern by patternGroup.pattern( "thaumaturgy.statstuning", - "§7You have: .+ §7\\+ §(?.)(?[^ ]+) (?.)" + "§7You have: .+ §7\\+ §(?.)(?[^ ]+) (?.)", ) private val tuningAutoAssignedPattern by patternGroup.pattern( "tuningpoints.chat.autoassigned", - "§aYour §r§eTuning Points §r§awere auto-assigned as convenience!" + "§aYour §r§eTuning Points §r§awere auto-assigned as convenience!", ) private val yourBagsGuiPattern by patternGroup.pattern( "gui.yourbags", - "Your Bags" + "Your Bags", ) private val powerSelectedPattern by patternGroup.pattern( "gui.selectedpower", - "§aPower is selected!" + "§aPower is selected!", ) private val noPowerSelectedPattern by patternGroup.pattern( "gui.noselectedpower", - "(?:§.)*Visit Maxwell in the Hub to learn" + "(?:§.)*Visit Maxwell in the Hub to learn", ) private val accessoryBagStack by patternGroup.pattern( "stack.accessorybag", - "§.Accessory Bag" + "§.Accessory Bag", ) private val redstoneCollectionRequirementPattern by patternGroup.pattern( "collection.redstone.requirement", - "(?:§.)*Requires (?:§.)*Redstone Collection I+(?:§.)*\\." + "(?:§.)*Requires (?:§.)*Redstone Collection I+(?:§.)*\\.", ) fun isThaumaturgyInventory(inventoryName: String) = thaumaturgyGuiPattern.matches(inventoryName) @@ -130,7 +138,9 @@ object MaxwellAPI { if (tunings.isNullOrEmpty()) return val tuningsInScoreboard = ScoreboardElement.TUNING in CustomScoreboard.config.scoreboardEntries if (tuningsInScoreboard) { - ChatUtils.chat("Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.") + ChatUtils.chat( + "Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.", + ) } } } @@ -142,7 +152,7 @@ object MaxwellAPI { UnknownMaxwellPower("Unknown power: $power"), "Unknown power: $power", "power" to power, - "message" to message + "message" to message, ) } } @@ -178,7 +188,7 @@ object MaxwellAPI { } ?: ErrorManager.skyHanniError( "found no name in thaumaturgy", "stack name" to stack.name, - "line" to line + "line" to line, ) map.add(it) } @@ -210,7 +220,7 @@ object MaxwellAPI { "Unknown power: $displayName", "displayName" to displayName, "lore" to selectedPowerStack.getLore(), - noStackTrace = true + noStackTrace = true, ) } @@ -248,7 +258,10 @@ object MaxwellAPI { var foundMagicalPower = false for (line in stack.getLore()) { redstoneCollectionRequirementPattern.matchMatcher(line) { - ChatUtils.chat("Seems like you don't have the Requirement for the Accessory Bag yet, setting power to No Power and magical power to 0.") + ChatUtils.chat( + "Seems like you don't have the Requirement for the Accessory Bag yet, " + + "setting power to No Power and magical power to 0.", + ) currentPower = getPowerByNameOrNull("No Power") magicalPower = 0 return @@ -273,7 +286,7 @@ object MaxwellAPI { "Unknown power: ${stack.displayName}", "displayName" to stack.displayName, "lore" to stack.getLore(), - noStackTrace = true + noStackTrace = true, ) } } @@ -282,7 +295,7 @@ object MaxwellAPI { if (!foundMagicalPower) magicalPower = 0 } - private fun getPowerByNameOrNull(name: String) = powers.find { it == name } + fun getPowerByNameOrNull(name: String) = powers.find { it == name } private fun isEnabled() = LorenzUtils.inSkyBlock && storage != null diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt index 584d2291f8a9..0f9ab91574b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt @@ -2,55 +2,102 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.data.Mayor.Companion.getMayorFromPerk import at.hannibal2.skyhanni.data.Mayor.Companion.setAssumeMayor import at.hannibal2.skyhanni.data.Mayor.Companion.setAssumeMayorJson +import at.hannibal2.skyhanni.data.Perk.Companion.getPerkFromName import at.hannibal2.skyhanni.data.jsonobjects.other.MayorCandidate import at.hannibal2.skyhanni.data.jsonobjects.other.MayorElection import at.hannibal2.skyhanni.data.jsonobjects.other.MayorJson import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.CollectionUtils.put import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle +import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.SkyBlockTime +import at.hannibal2.skyhanni.utils.SkyBlockTime.Companion.SKYBLOCK_YEAR_MILLIS +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.json.fromJson import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration +import kotlin.time.Duration.Companion.hours +import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object MayorAPI { - val group = RepoPattern.group("mayorapi") + private val group = RepoPattern.group("mayorapi") + + // TODO: Add Regex-test val foxyExtraEventPattern by group.pattern( "foxy.extraevent", - "Schedules an extra §.(?.*) §.event during the year\\." + "Schedules an extra §.(?.*) §.event during the year\\.", ) - private val electionOver by group.pattern( + + /** + * REGEX-TEST: The election room is now closed. Clerk Seraphine is doing a final count of the votes... + */ + private val electionOverPattern by group.pattern( "election.over", - "§eThe election room is now closed\\. Clerk Seraphine is doing a final count of the votes\\.\\.\\." + "§eThe election room is now closed\\. Clerk Seraphine is doing a final count of the votes\\.\\.\\.", + ) + + /** + * REGEX-TEST: Calendar and Events + */ + private val calendarGuiPattern by group.pattern( + "calendar.gui", + "Calendar and Events", + ) + + /** + * REGEX-TEST: §dMayor Jerry + */ + private val jerryHeadPattern by group.pattern( + "jerry.head", + "§dMayor Jerry", + ) + + /** + * REGEX-TEST: §9Perkpocalypse Perks: + */ + private val perkpocalypsePerksPattern by group.pattern( + "perkpocalypse", + "§9Perkpocalypse Perks:", ) + var currentMayor: Mayor? = null + private set private var lastMayor: Mayor? = null + var jerryExtraMayor: Pair = null to SimpleTimeMark.farPast() + private set + var lastJerryExtraMayorReminder = SimpleTimeMark.farPast() - var lastUpdate = SimpleTimeMark.farPast() + private var lastUpdate = SimpleTimeMark.farPast() private var dispatcher = Dispatchers.IO private var rawMayorData: MayorJson? = null - var candidates = mapOf() - private set - var currentMayor: Mayor? = null - private set - var timeTillNextMayor = Duration.ZERO + private var candidates = mapOf() + + var nextMayorTimestamp = SimpleTimeMark.farPast() private set private const val ELECTION_END_MONTH = 3 // Late Spring @@ -75,23 +122,65 @@ object MayorAPI { checkHypixelAPI() getTimeTillNextMayor() } + + if (!LorenzUtils.inSkyBlock) return + if (jerryExtraMayor.first != null && jerryExtraMayor.second.isInPast() && Mayor.JERRY.isActive()) { + jerryExtraMayor = null to SimpleTimeMark.farPast() + ChatUtils.clickableChat( + "The Perkpocalypse Mayor has expired! Click here to update the new temporary Mayor.", + onClick = { HypixelCommands.calendar() }, + ) + } + val misc = SkyHanniMod.feature.misc + if (Mayor.JERRY.isActive() && jerryExtraMayor.first == null && misc.unknownPerkpocalypseMayorWarning) { + if (lastJerryExtraMayorReminder.passedSince() < 5.minutes) return + if (ReminderUtils.isBusy()) return + lastJerryExtraMayorReminder = SimpleTimeMark.now() + ChatUtils.clickableChat( + "The Perkpocalypse Mayor is not known! Click here to update the temporary Mayor.", + onClick = { HypixelCommands.calendar() }, + ) + } } @SubscribeEvent fun onChat(event: LorenzChatEvent) { - if (!LorenzUtils.onHypixel) return + if (!LorenzUtils.inSkyBlock) return - if (electionOver.matches(event.message)) { + if (electionOverPattern.matches(event.message)) { lastMayor = currentMayor currentMayor = Mayor.UNKNOWN } } + @SubscribeEvent + fun onInventory(event: InventoryFullyOpenedEvent) { + if (!LorenzUtils.inSkyBlock) return + + if (!calendarGuiPattern.matches(event.inventoryName)) return + + val stack: ItemStack = + event.inventoryItems.values.firstOrNull { jerryHeadPattern.matches(it.displayName) } ?: return + + val perk = stack.getLore().nextAfter({ perkpocalypsePerksPattern.matches(it) }) ?: return + // This is one Perk of the Perkpocalypse Mayor + val jerryMayor = getMayorFromPerk(getPerkFromName(perk.removeColor()) ?: return)?.addAllPerks() ?: return + + val lastMayorTimestamp = nextMayorTimestamp - SKYBLOCK_YEAR_MILLIS.milliseconds + + val expireTime = (1..21).map { lastMayorTimestamp + (6.hours * it) }.first { it.isInFuture() } + + ChatUtils.debug("Jerry Mayor found: ${jerryMayor.name} expiring at: ${expireTime.timeUntil()}") + + jerryExtraMayor = jerryMayor to expireTime + } + private fun calculateNextMayorTime(): SimpleTimeMark { - var mayorYear = SkyBlockTime.now().year + val now = SkyBlockTime.now() + var mayorYear = now.year // Check if either the month is already over or the day after 27th in the third month - if (SkyBlockTime.now().month > ELECTION_END_MONTH || (SkyBlockTime.now().day >= ELECTION_END_DAY && SkyBlockTime.now().month == ELECTION_END_MONTH)) { + if (now.month > ELECTION_END_MONTH || (now.day >= ELECTION_END_DAY && now.month == ELECTION_END_MONTH)) { // If so, the next mayor will be in the next year mayorYear++ } @@ -100,8 +189,7 @@ object MayorAPI { } private fun getTimeTillNextMayor() { - val nextMayorTime = calculateNextMayorTime() - timeTillNextMayor = nextMayorTime - SimpleTimeMark.now() + nextMayorTimestamp = calculateNextMayorTime() } private fun checkCurrentMayor() { @@ -160,7 +248,10 @@ object MayorAPI { add("Current Mayor: ${currentMayor?.name ?: "Unknown"}") add("Active Perks: ${currentMayor?.activePerks}") add("Last Update: $lastUpdate (${lastUpdate.passedSince()} ago)") - add("Time Till Next Mayor: $timeTillNextMayor") + add("Time Till Next Mayor: ${nextMayorTimestamp.timeUntil()}") + if (jerryExtraMayor.first != null) { + add("Jerry Mayor: ${jerryExtraMayor.first?.name} expiring at: ${jerryExtraMayor.second.timeUntil()}") + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt b/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt index 04c1464e0041..ccf74aec259a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.data.MayorAPI.currentMayor import at.hannibal2.skyhanni.data.MayorAPI.foxyExtraEventPattern import at.hannibal2.skyhanni.data.jsonobjects.other.MayorPerk import at.hannibal2.skyhanni.test.command.ErrorManager @@ -39,10 +40,20 @@ enum class Mayor( override fun toString() = mayorName + fun addAllPerks(): Mayor { + activePerks.addAll(perks) + perks.forEach { it.isActive = true } + return this + } + + fun isActive() = this == currentMayor + companion object { fun getMayorFromName(name: String): Mayor? = entries.firstOrNull { it.mayorName == name } + fun getMayorFromPerk(perk: Perk): Mayor? = entries.firstOrNull { it.perks.contains(perk) } + fun setAssumeMayorJson(name: String, perksJson: List): Mayor? { val mayor = getMayorFromName(name) if (mayor == null) { @@ -146,4 +157,8 @@ enum class Perk(val perkName: String) { ; var isActive = false + + companion object { + fun getPerkFromName(name: String): Perk? = entries.firstOrNull { it.perkName == name } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt index bc0f31e2f274..02768fc3d4bf 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MinecraftData.kt @@ -1,11 +1,13 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.ItemInHandChangeEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -19,12 +21,11 @@ import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent +@SkyHanniModule object MinecraftData { - @SubscribeEvent(receiveCanceled = true) - fun onSoundPacket(event: PacketEvent.ReceiveEvent) { - if (!LorenzUtils.inSkyBlock) return - + @HandleEvent(receiveCancelled = true, onlyOnSkyblock = true) + fun onSoundPacket(event: PacketReceivedEvent) { val packet = event.packet if (packet !is S29PacketSoundEffect) return @@ -35,7 +36,7 @@ object MinecraftData { packet.volume ).postAndCatch() ) { - event.isCanceled = true + event.cancel() } } @@ -44,10 +45,8 @@ object MinecraftData { LorenzWorldChangeEvent().postAndCatch() } - @SubscribeEvent(receiveCanceled = true) - fun onParticlePacketReceive(event: PacketEvent.ReceiveEvent) { - if (!LorenzUtils.inSkyBlock) return - + @HandleEvent(receiveCancelled = true, onlyOnSkyblock = true) + fun onParticlePacketReceive(event: PacketReceivedEvent) { val packet = event.packet if (packet !is S2APacketParticles) return @@ -61,7 +60,7 @@ object MinecraftData { packet.particleArgs, ).postAndCatch() ) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt index 0c28874aae23..edb79b89440b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -16,6 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.absoluteValue import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object MiningAPI { private val group = RepoPattern.group("data.miningapi") diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt index 776580602d95..02f3910196ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OtherInventoryData.kt @@ -1,17 +1,20 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.item.ItemStack import net.minecraft.network.play.server.S2DPacketOpenWindow import net.minecraft.network.play.server.S2EPacketCloseWindow import net.minecraft.network.play.server.S2FPacketSetSlot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object OtherInventoryData { private var currentInventory: Inventory? = null @@ -36,8 +39,8 @@ object OtherInventoryData { } } - @SubscribeEvent - fun onInventoryDataReceiveEvent(event: PacketEvent.ReceiveEvent) { + @HandleEvent + fun onInventoryDataReceiveEvent(event: PacketReceivedEvent) { val packet = event.packet if (packet is S2EPacketCloseWindow) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt index 2759f82b9d0c..6a855a06bcf6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/OwnInventoryData.kt @@ -1,13 +1,16 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils @@ -22,13 +25,13 @@ import net.minecraft.client.Minecraft import net.minecraft.network.play.client.C0EPacketClickWindow import net.minecraft.network.play.server.S0DPacketCollectItem import net.minecraft.network.play.server.S2FPacketSetSlot -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class OwnInventoryData { +@SkyHanniModule +object OwnInventoryData { private var itemAmounts = mapOf() private var dirty = false @@ -37,10 +40,8 @@ class OwnInventoryData { "§aMoved §r§e\\d* (?.*)§r§a from your Sacks to your inventory." ) - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onItemPickupReceivePacket(event: PacketEvent.ReceiveEvent) { - if (!LorenzUtils.inSkyBlock) return - + @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true, onlyOnSkyblock = true) + fun onItemPickupReceivePacket(event: PacketReceivedEvent) { val packet = event.packet if (packet is S2FPacketSetSlot || packet is S0DPacketCollectItem) { dirty = true @@ -57,9 +58,8 @@ class OwnInventoryData { } } - @SubscribeEvent - fun onClickEntity(event: PacketEvent.SendEvent) { - if (!LorenzUtils.inSkyBlock) return + @HandleEvent(onlyOnSkyblock = true) + fun onClickEntity(event: PacketSentEvent) { val packet = event.packet if (packet is C0EPacketClickWindow) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt index 5afdea70f9aa..ee2257545c8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PartyAPI.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.data.hypixel.chat.event.PartyChatEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.random.Random +@SkyHanniModule object PartyAPI { private val patternGroup = RepoPattern.group("data.party") diff --git a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt index 7339f9a2a1bb..5b65c8e23cca 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PetAPI.kt @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +@SkyHanniModule object PetAPI { private val patternGroup = RepoPattern.group("misc.pet") private val petMenuPattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 21f3d5b8c3ca..6db5913a7bb5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -22,6 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ProfileStorageData { var playerSpecific: PlayerSpecificStorage? = null diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index e09eb11d787e..5c7f94aed3ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.NumberUtil.million import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -13,6 +14,7 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object PurseAPI { private val patternGroup = RepoPattern.group("data.purse") val coinsPattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt index 51f9fb6be5b5..51240ecd3243 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt @@ -3,10 +3,11 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.data.jsonobjects.repo.ArrowTypeJson import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.QuiverUpdateEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -28,8 +29,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemBow import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -private var infinityQuiverLevelMultiplier = 0.03f +@SkyHanniModule object QuiverAPI { private val storage get() = ProfileStorageData.profileSpecific var currentArrow: ArrowType? @@ -273,7 +274,7 @@ object QuiverAPI { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (event.repeatSeconds(2)) { checkChestplate() diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt index f8e8f37dae27..0aae783575b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderData.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.utils.ConfigUtils import net.minecraft.client.Minecraft @@ -16,7 +17,8 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RenderData { +@SkyHanniModule +object RenderData { @SubscribeEvent fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index b4c203291adb..a2235608ec0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.SackDataUpdateEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity import at.hannibal2.skyhanni.features.inventory.SackDisplay +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -36,6 +37,7 @@ import com.google.gson.annotations.Expose import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object SackAPI { private val sackDisplayConfig get() = SkyHanniMod.feature.inventory.sackDisplay diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 7330317f297b..72abf6bab54f 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.data +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RegexUtils.matches import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S3CPacketUpdateScore @@ -13,66 +15,45 @@ import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ScoreboardData { - - companion object { - - private val minecraftColorCodesPattern = "(?i)[0-9a-fkmolnr]".toPattern() - - // TODO USE SH-REPO - private val splitIcons = listOf( - "\uD83C\uDF6B", - "\uD83D\uDCA3", - "\uD83D\uDC7D", - "\uD83D\uDD2E", - "\uD83D\uDC0D", - "\uD83D\uDC7E", - "\uD83C\uDF20", - "\uD83C\uDF6D", - "⚽", - "\uD83C\uDFC0", - "\uD83D\uDC79", - "\uD83C\uDF81", - "\uD83C\uDF89", - "\uD83C\uDF82", - "\uD83D\uDD2B", - ) - - fun formatLines(rawList: List): List { - val list = mutableListOf() - for (line in rawList) { - val separator = splitIcons.find { line.contains(it) } ?: continue - val split = line.split(separator) - val start = split[0] - var end = split[1] - // get last color code in start - val lastColorIndex = start.lastIndexOf('§') - val lastColor = if (lastColorIndex != -1 - && lastColorIndex + 1 < start.length - && (minecraftColorCodesPattern.matches(start[lastColorIndex + 1].toString())) - ) start.substring(lastColorIndex, lastColorIndex + 2) - else "" - - // remove first color code from end, when it is the same as the last color code in start - end = end.removePrefix(lastColor) - - list.add(start + end) - } +@SkyHanniModule +object ScoreboardData { - return list - } + var sidebarLinesFormatted: List = emptyList() - var sidebarLinesFormatted: List = emptyList() + private var sidebarLines: List = emptyList() // TODO rename to raw + var sidebarLinesRaw: List = emptyList() // TODO delete + var objectiveTitle = "" - var sidebarLines: List = emptyList() // TODO rename to raw - var sidebarLinesRaw: List = emptyList() // TODO delete - var objectiveTitle = "" - } + private var dirty = false + + private val minecraftColorCodesPattern = "(?i)[0-9a-fkmolnr]".toPattern() + + fun formatLines(rawList: List): List { + val list = mutableListOf() + for (line in rawList) { + val separator = splitIcons.find { line.contains(it) } ?: continue + val split = line.split(separator) + val start = split[0] + var end = split[1] + // get last color code in start + val lastColorIndex = start.lastIndexOf('§') + val lastColor = if (lastColorIndex != -1 + && lastColorIndex + 1 < start.length + && (minecraftColorCodesPattern.matches(start[lastColorIndex + 1].toString())) + ) start.substring(lastColorIndex, lastColorIndex + 2) + else "" - var dirty = false + // remove first color code from end, when it is the same as the last color code in start + end = end.removePrefix(lastColor) - @SubscribeEvent(receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + list.add(start + end) + } + + return list + } + + @HandleEvent(receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (event.packet is S3CPacketUpdateScore) { if (event.packet.objectiveName == "update") { dirty = true @@ -126,4 +107,23 @@ class ScoreboardData { ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName) } } + + // TODO USE SH-REPO + private val splitIcons = listOf( + "\uD83C\uDF6B", + "\uD83D\uDCA3", + "\uD83D\uDC7D", + "\uD83D\uDD2E", + "\uD83D\uDC0D", + "\uD83D\uDC7E", + "\uD83C\uDF20", + "\uD83C\uDF6D", + "⚽", + "\uD83C\uDFC0", + "\uD83D\uDC79", + "\uD83C\uDF81", + "\uD83C\uDF89", + "\uD83C\uDF82", + "\uD83D\uDD2B", + ) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt index 194983695f6f..2b64ed1ab33d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScreenData.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ScreenData { private var wasOpen = false diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index 3d3be9c3a3e4..93870b119b82 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent import at.hannibal2.skyhanni.features.slayer.SlayerType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -21,6 +22,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object SlayerAPI { private var nameCache = TimeLimitedCache, Pair>(1.minutes) diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt index fe776c8d0631..f8ad4f652fc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TitleData.kt @@ -1,21 +1,23 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.network.play.server.S45PacketTitle -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TitleData { +@SkyHanniModule +object TitleData { - @SubscribeEvent - fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) { + @HandleEvent + fun onReceiveCurrentShield(event: PacketReceivedEvent) { val packet = event.packet if (packet !is S45PacketTitle) return val message = packet.message ?: return val formattedText = message.formattedText if (TitleReceivedEvent(formattedText).postAndCatch()) { - event.isCanceled = true + event.cancel() } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt index af3683402391..95dbe1577f56 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TitleManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import io.github.notenoughupdates.moulconfig.internal.TextRenderUtils @@ -14,43 +15,41 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class TitleManager { +@SkyHanniModule +object TitleManager { - companion object { + private var originalText = "" + private var display = "" + private var endTime = SimpleTimeMark.farPast() + private var heightModifier = 1.8 + private var fontSizeModifier = 4f - private var originalText = "" - private var display = "" - private var endTime = SimpleTimeMark.farPast() - private var heightModifier = 1.8 - private var fontSizeModifier = 4f + fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) { + originalText = text + display = "§f$text" + endTime = SimpleTimeMark.now() + duration + heightModifier = height + fontSizeModifier = fontSize + } - fun sendTitle(text: String, duration: Duration, height: Double, fontSize: Float) { - originalText = text - display = "§f$text" - endTime = SimpleTimeMark.now() + duration - heightModifier = height - fontSizeModifier = fontSize + fun optionalResetTitle(condition: (String) -> Boolean) { + if (condition(originalText)) { + sendTitle("", 1.milliseconds, 1.8, 4f) } + } - fun optionalResetTitle(condition: (String) -> Boolean) { - if (condition(originalText)) { - sendTitle("", 1.milliseconds, 1.8, 4f) - } + fun command(args: Array) { + if (args.size < 4) { + ChatUtils.userError("Usage: /shsendtitle ") + return } - fun command(args: Array) { - if (args.size < 4) { - ChatUtils.userError("Usage: /shsendtitle ") - return - } + val duration = args[0].toInt().seconds + val height = args[1].toDouble() + val fontSize = args[2].toFloat() + val title = "§6" + args.drop(3).joinToString(" ").replace("&", "§") - val duration = args[0].toInt().seconds - val height = args[1].toDouble() - val fontSize = args[2].toFloat() - val title = "§6" + args.drop(3).joinToString(" ").replace("&", "§") - - sendTitle(title, duration, height, fontSize) - } + sendTitle(title, duration, height, fontSize) } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt index 70cd9cd343bc..482b590fe54b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt @@ -37,7 +37,7 @@ object ToolTipData { @JvmStatic fun onHover(stack: ItemStack, toolTip: MutableList) { - ItemHoverEvent(stack, toolTip).postAndCatch() + ItemHoverEvent(stack, toolTip).post() } var lastSlot: Slot? = null diff --git a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt index b59d31394920..ab5f9cc78c69 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/TrackerManager.kt @@ -5,11 +5,13 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ConfigUtils import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TrackerManager { private var hasChanged = false diff --git a/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt b/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt index 6ed9b8e6a8d1..dfbb0816418e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/bazaar/HypixelBazaarFetcher.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarData +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ChatUtils @@ -22,6 +23,7 @@ import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds // https://api.hypixel.net/#tag/SkyBlock/paths/~1v2~1skyblock~1bazaar/get +@SkyHanniModule object HypixelBazaarFetcher { private const val URL = "https://api.hypixel.net/v2/skyblock/bazaar" private const val HIDDEN_FAILED_ATTEMPTS = 3 @@ -61,7 +63,7 @@ object HypixelBazaarFetcher { private fun process(products: Map) = products.mapNotNull { (key, product) -> val internalName = NEUItems.transHypixelNameToInternalName(key) val sellOfferPrice = product.buySummary.minOfOrNull { it.pricePerUnit } ?: 0.0 - val insantBuyPrice = product.sellSummary.maxOfOrNull { it.pricePerUnit } ?: 0.0 + val instantBuyPrice = product.sellSummary.maxOfOrNull { it.pricePerUnit } ?: 0.0 if (product.quickStatus.isEmpty()) { return@mapNotNull null @@ -70,11 +72,10 @@ object HypixelBazaarFetcher { if (internalName.getItemStackOrNull() == null) { // Items that exist in Hypixel's Bazaar API, but not in NEU repo (not visible in the ingame bazaar). // Should only include Enchants - if (LorenzUtils.debug) - println("Unknown bazaar product: $key/$internalName") + if (LorenzUtils.debug) println("Unknown bazaar product: $key/$internalName") return@mapNotNull null } - internalName to BazaarData(internalName.itemName, sellOfferPrice, insantBuyPrice, product) + internalName to BazaarData(internalName.itemName, sellOfferPrice, instantBuyPrice, product) }.toMap() private fun BazaarQuickStatus.isEmpty(): Boolean = with(this) { @@ -102,7 +103,7 @@ object HypixelBazaarFetcher { userMessage, "fetchType" to fetchType, "failedAttepmts" to failedAttempts, - "rawResponse" to rawResponse + "rawResponse" to rawResponse, ) } } 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 023589e0f090..f8f8b4523541 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 @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.data.hypixel.chat.event.PlayerShowItemChatEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.PrivateMessageChatEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ComponentMatcher import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.intoSpan import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.matchStyledMatcher @@ -23,7 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent /** * Reading normal chat events, and splitting them up into many different player chat events, with all available extra information */ -class PlayerChatManager { +@SkyHanniModule +object PlayerChatManager { private val patternGroup = RepoPattern.group("data.chat.player") diff --git a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt index b617fd1185d6..94bc665b6202 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/hypixel/chat/PlayerNameFormatter.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.changeColor import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.matchStyledMatcher import at.hannibal2.skyhanni.utils.ComponentSpan @@ -34,7 +35,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent * Listening to the player chat events, and applying custom chat options to them. * E.g. part order, rank hider, etc */ -class PlayerNameFormatter { +@SkyHanniModule +object PlayerNameFormatter { private val config get() = SkyHanniMod.feature.chat.playerMessage private val patternGroup = RepoPattern.group("data.chat.player.name") diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/HotmTree.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/HotmTree.kt index 3c0118089203..b1635144a696 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/HotmTree.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/local/HotmTree.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.data.jsonobjects.local; +package at.hannibal2.skyhanni.data.jsonobjects.local import at.hannibal2.skyhanni.utils.json.fromJson import com.google.gson.Gson @@ -7,11 +7,11 @@ import com.google.gson.annotations.Expose class HotmTree { @Expose - val perks = mutableMapOf(); + val perks = mutableMapOf() fun deepCopy(): HotmTree { - val gson = Gson(); - val json = gson.toJson(this); + val gson = Gson() + val json = gson.toJson(this) return gson.fromJson(json) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/EliteBotJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/EliteBotJson.kt index 2f2543f5626b..5da9a9629fe7 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/EliteBotJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/EliteBotJson.kt @@ -7,7 +7,7 @@ import com.google.gson.annotations.SerializedName data class ElitePlayerWeightJson( @Expose val selectedProfileId: String, - @Expose val profiles: List + @Expose val profiles: List, ) data class WeightProfile( @@ -17,30 +17,30 @@ data class WeightProfile( @Expose val cropWeight: Map, @Expose val bonusWeight: Map, @Expose val uncountedCrops: Map, - @Expose val pests: Map + @Expose val pests: Map, ) data class EliteLeaderboardJson( - @Expose val data: EliteLeaderboard + @Expose val data: EliteLeaderboard, ) data class EliteLeaderboard( @Expose val rank: Int, @Expose val upcomingRank: Int, - @Expose val upcomingPlayers: List + @Expose val upcomingPlayers: List, ) data class UpcomingLeaderboardPlayer( @Expose @SerializedName("ign") val name: String, - @Expose @SerializedName("amount") val weight: Double + @Expose @SerializedName("amount") val weight: Double, ) data class EliteWeightsJson( @Expose val crops: Map, - @Expose val pests: PestWeightData + @Expose val pests: PestWeightData, ) data class PestWeightData( @Expose val brackets: Map, - @Expose @SerializedName("values") val pestWeights: Map> + @Expose @SerializedName("values") val pestWeights: Map>, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/HypixelPlayerApiJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/HypixelPlayerApiJson.kt index 47304433ab43..70a3529104eb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/HypixelPlayerApiJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/HypixelPlayerApiJson.kt @@ -2,36 +2,34 @@ package at.hannibal2.skyhanni.data.jsonobjects.other import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName -import javax.annotation.Nullable data class HypixelPlayerApiJson( - @Expose val profiles: List + @Expose val profiles: List, ) data class HypixelApiProfile( @Expose val members: Map, - @Expose @SerializedName("cute_name") val profileName: String + @Expose @SerializedName("cute_name") val profileName: String, ) data class HypixelApiPlayer( @Expose @SerializedName("trophy_fish") val trophyFish: HypixelApiTrophyFish, - @Expose val events: HypixelApiEvents + @Expose val events: HypixelApiEvents, ) data class HypixelApiEvents( - @Expose val easter: HypixelApiEasterEvent + @Expose val easter: HypixelApiEasterEvent, ) data class HypixelApiEasterEvent( - @Expose val rabbits: HypixelApiRabbits + @Expose val rabbits: HypixelApiRabbits, ) data class HypixelApiRabbits( - @Expose @SerializedName("collected_locations") - val collectedLocations: Map> + @Expose @SerializedName("collected_locations") val collectedLocations: Map>, ) data class HypixelApiTrophyFish( val totalCaught: Int, - val caught: Map + val caught: Map, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/SkyblockItemsDataJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/SkyblockItemsDataJson.kt index 0676a5e8eed9..65384848fbe1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/SkyblockItemsDataJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/SkyblockItemsDataJson.kt @@ -4,11 +4,11 @@ import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName data class SkyblockItemsDataJson( - @Expose val items: List + @Expose val items: List, ) data class SkyblockItemData( @Expose val id: String?, @Expose @SerializedName("npc_sell_price") val npcPrice: Double?, - @Expose @SerializedName("motes_sell_price") val motesPrice: Double? + @Expose @SerializedName("motes_sell_price") val motesPrice: Double?, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.java deleted file mode 100644 index a1122eec348a..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.java +++ /dev/null @@ -1,18 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class AnitaUpgradeCostsJson { - @Expose - public Map level_price; - - public static class Price { - @Expose - public Integer gold_medals; - - @Expose - public Integer jacob_tickets; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.kt new file mode 100644 index 000000000000..f4ced7e83b95 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/AnitaUpgradeCostsJson.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class AnitaUpgradeCostsJson( + @Expose @SerializedName("level_price") val levelPrice: Map, +) + +data class AnitaUpgradePrice( + @Expose @SerializedName("gold_medals") val goldMedals: Int, + @Expose @SerializedName("jacob_tickets") val jacobTickets: Int, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.java deleted file mode 100644 index c8038c49fc34..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.java +++ /dev/null @@ -1,19 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class ArmorDropsJson { - @Expose - public Map special_crops; - - public static class DropInfo { - @Expose - public String armor_type; - - @Expose - public List chance; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.kt new file mode 100644 index 000000000000..4441a37d5b78 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArmorDropsJson.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class ArmorDropsJson( + @Expose @SerializedName("special_crops") val specialCrops: Map, +) + +data class ArmorDropInfo( + @Expose @SerializedName("armor_type") val armorType: String, + @Expose val chance: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.java deleted file mode 100644 index 4173fa0a3425..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.java +++ /dev/null @@ -1,15 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class ArrowTypeJson { - @Expose - public Map arrows; - - public static class ArrowAttributes { - @Expose - public String arrow; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.kt new file mode 100644 index 000000000000..1d8d6e1cfb58 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ArrowTypeJson.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class ArrowTypeJson( + @Expose val arrows: Map, +) + +data class ArrowAttributes( + @Expose val arrow: String, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java deleted file mode 100644 index 15aadc2d47bc..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class BeltsJson { - @Expose - public Map belts; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.kt new file mode 100644 index 000000000000..2cc4d4fe39a7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class BeltsJson( + @Expose val belts: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java deleted file mode 100644 index f9e8406ebbcb..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class BingoJson { - @Expose - public Map bingo_tips; - - public static class BingoData { - @Expose - public String difficulty; - - @Expose - public List note; - - @Expose - public List guide; - - @Expose - public String found; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.kt new file mode 100644 index 000000000000..4078d917e8c1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoJson.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class BingoJson( + @Expose @SerializedName("bingo_tips") val bingoTips: Map, +) + +data class BingoData( + @Expose val difficulty: String, + @Expose val note: List, + @Expose val guide: List, + @Expose val found: String, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.java deleted file mode 100644 index 98f2a469547f..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class BingoRanksJson { - @Expose - public Map ranks; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.kt new file mode 100644 index 000000000000..598e94ee845e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BingoRanksJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class BingoRanksJson( + @Expose val ranks: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.java deleted file mode 100644 index 0ab0e52ff617..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.java +++ /dev/null @@ -1,35 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class CrimsonIsleReputationJson { - @Expose - public Map FISHING; - - @Expose - public Map RESCUE; - - @Expose - public Map FETCH; - - @Expose - public Map DOJO; - - @Expose - public Map MINIBOSS; - - @Expose - public Map KUUDRA; - - public static class ReputationQuest { - @Expose - public NEUInternalName item; - - @Expose - public List location; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.kt new file mode 100644 index 000000000000..c669a8eb3cc3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/CrimsonIsleReputationJson.kt @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose + +data class CrimsonIsleReputationJson( + @Expose val FISHING: Map, + @Expose val RESCUE: Map, + @Expose val FETCH: Map, + @Expose val DOJO: Map, + @Expose val MINIBOSS: Map, + @Expose val KUUDRA: Map, +) + +data class ReputationQuest( + @Expose val item: NEUInternalName, + @Expose val location: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.java deleted file mode 100644 index e7c167e5349b..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class DanceRoomInstructionsJson { - @Expose - public List instructions; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.kt new file mode 100644 index 000000000000..991f0a15f6be --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DanceRoomInstructionsJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class DanceRoomInstructionsJson( + @Expose val instructions: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java deleted file mode 100644 index 050601c3d642..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java +++ /dev/null @@ -1,11 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class DianaDrops { - @Expose - public List diana_drops; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDropsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDropsJson.kt new file mode 100644 index 000000000000..5bbdfde1d3fb --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDropsJson.kt @@ -0,0 +1,9 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class DianaDropsJson( + @Expose @SerializedName("diana_drops") val dianaDrops: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.java deleted file mode 100644 index 00a662768473..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.java +++ /dev/null @@ -1,31 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; - -import java.util.List; - -public class DicerDropsJson { - @Expose - public DicerType MELON; - - @Expose - public DicerType PUMPKIN; - - public static class DicerType { - @Expose - @SerializedName("total chance") - public Integer totalChance; - - @Expose - public List drops; - } - - public static class DropInfo { - @Expose - public Integer chance; - - @Expose - public List amount; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.kt new file mode 100644 index 000000000000..ef36a932335d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DicerDropsJson.kt @@ -0,0 +1,19 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +class DicerDropsJson( + @Expose val MELON: DicerType, + @Expose val PUMPKIN: DicerType, +) + +data class DicerType( + @Expose @SerializedName("total chance") val totalChance: Int, + @Expose val drops: List, +) + +data class DropInfo( + @Expose val chance: Int, + @Expose val amount: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledEventsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledEventsJson.kt new file mode 100644 index 000000000000..131ea5f3cdd8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledEventsJson.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class DisabledEventsJson( + @Expose val disabledHandlers: Set = emptySet(), + @Expose val disabledInvokers: Set = emptySet(), +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.java deleted file mode 100644 index 1099cf782ded..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class DisabledFeaturesJson { - @Expose - public Map features; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.kt new file mode 100644 index 000000000000..a393dfe9a2ee --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DisabledFeaturesJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class DisabledFeaturesJson( + @Expose val features: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.java deleted file mode 100644 index cd17d1744ef2..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.java +++ /dev/null @@ -1,20 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzVec; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class EnigmaSoulsJson { - @Expose - public Map> areas; - - public static class EnigmaPosition { - @Expose - public String name; - - @Expose - public LorenzVec position; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.kt new file mode 100644 index 000000000000..d26cd1aaacfc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EnigmaSoulsJson.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose + +data class EnigmaSoulsJson( + @Expose val areas: Map>, +) + +data class EnigmaPosition( + @Expose val name: String, + @Expose val position: LorenzVec, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.java deleted file mode 100644 index f59af9ffba45..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzVec; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class EventWaypointsJson { - - @Expose - public Map> presents; - - @Expose - public Map> presents_entrances; - - public static class Waypoint { - @Expose - public String name; - - //format: "x:y:z" - @Expose - public LorenzVec position; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.kt new file mode 100644 index 000000000000..604fc2f3e25d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/EventWaypointsJson.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class EventWaypointsJson( + @Expose val presents: Map>, + @Expose @SerializedName("presents_entrances") val presentsEntrances: Map>, +) + +data class EventWaypointData( + @Expose val name: String, + @Expose val position: LorenzVec, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.java deleted file mode 100644 index e060d55d19d3..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class FameRankJson { - @Expose - public Map fame_rank; - - public static class FameRank { - @Expose - public String name; - - @Expose - public int fame_required; - - @Expose - public double bits_multiplier; - - @Expose - public int votes; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.kt new file mode 100644 index 000000000000..59da76776f44 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FameRankJson.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class FameRankJson( + @Expose @SerializedName("fame_rank") val fameRank: Map, +) + +data class FameRank( + @Expose val name: String, + @Expose @SerializedName("fame_required") val fameRequired: Int, + @Expose @SerializedName("bits_multiplier") val bitsMultiplier: Double, + @Expose val votes: Int, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.java deleted file mode 100644 index 47f7fc0bb276..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class FishingProfitItemsJson { - @Expose - public Map> categories; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.kt new file mode 100644 index 000000000000..96956bc92f06 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/FishingProfitItemsJson.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose + +data class FishingProfitItemsJson( + @Expose val categories: Map>, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java deleted file mode 100644 index dd00add03ce1..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.java +++ /dev/null @@ -1,59 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.features.garden.CropType; -import at.hannibal2.skyhanni.utils.LorenzRarity; -import at.hannibal2.skyhanni.utils.LorenzVec; -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; - -public class GardenJson { - @Expose - public List garden_exp; - - @Expose - public Map> crop_milestones; - - @Expose - public Map crop_milestone_community_help; - - @Expose - public Map visitors; - - @Expose - public Map organic_matter; - - @Expose - public Map fuel; - - public static class GardenVisitor { - @Expose - public LorenzRarity rarity; - - @Expose - public LorenzRarity new_rarity; - - @Nullable - @Expose - public LorenzVec position; - - /** - * Formatted as follows: - * - If this visitor is a player, get the encoded skin value - * - If this visitor is a mob, get their mob class name - */ - @Nullable - @Expose - public String skinOrType; - - @Nullable - @Expose - public String mode; - - @Expose - public List need_items; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt new file mode 100644 index 000000000000..a6c7b84a27cf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt @@ -0,0 +1,26 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.utils.LorenzRarity +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class GardenJson( + @Expose @SerializedName("garden_exp") val gardenExp: List, + @Expose @SerializedName("crop_milestones") val cropMilestones: Map>, + @Expose @SerializedName("crop_milestone_community_help") val cropMilestoneCommunityHelp: Map, + @Expose val visitors: Map, + @Expose @SerializedName("organic_matter") val organicMatter: Map, + @Expose val fuel: Map, +) + +data class GardenVisitor( + @Expose val rarity: LorenzRarity, + @Expose @SerializedName("new_rarity") val newRarity: LorenzRarity?, + @Expose val position: LorenzVec?, + @Expose var skinOrType: String?, + @Expose val mode: String, + @Expose @SerializedName("need_items") val needItems: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.java deleted file mode 100644 index 8877e596e836..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.java +++ /dev/null @@ -1,30 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class HideNotClickableItemsJson { - @Expose - public MultiFilterJson hide_npc_sell; - - @Expose - public MultiFilterJson hide_in_storage; - - @Expose - public MultiFilterJson hide_player_trade; - - @Expose - public MultiFilterJson not_auctionable; - - @Expose - public SalvageFilter salvage; - - public static class SalvageFilter { - @Expose - public List armor; - - @Expose - public List items; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.kt new file mode 100644 index 000000000000..b8d0d7c28d1d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HideNotClickableItemsJson.kt @@ -0,0 +1,17 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class HideNotClickableItemsJson( + @Expose @SerializedName("hide_npc_sell") val hideNpcSell: MultiFilterJson, + @Expose @SerializedName("hide_in_storage") val hideInStorage: MultiFilterJson, + @Expose @SerializedName("hide_player_trade") val hidePlayerTrade: MultiFilterJson, + @Expose @SerializedName("not_auctionable") val notAuctionable: MultiFilterJson, + @Expose val salvage: SalvageFilter, +) + +data class SalvageFilter( + @Expose val armor: List, + @Expose val items: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/InfernoMinionFuelsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/InfernoMinionFuelsJson.kt index d6d3931c2d97..45b09dabfb21 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/InfernoMinionFuelsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/InfernoMinionFuelsJson.kt @@ -5,5 +5,5 @@ import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName data class InfernoMinionFuelsJson( - @Expose @SerializedName("inferno_minion_fuels") val minionFuels: List + @Expose @SerializedName("inferno_minion_fuels") val minionFuels: List, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java deleted file mode 100644 index 0efeeb9fd67e..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.java +++ /dev/null @@ -1,27 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class ItemsJson { - @Expose - public List crimson_armors; - - @Expose - public Map crimson_tiers; - - @Expose - public Map enchant_multiplier; - - @Expose - public List lava_fishing_rods; - - @Expose - public List water_fishing_rods; - - @Expose - public Map book_bundle_amount; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt new file mode 100644 index 000000000000..c70d0afa565e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ItemsJson.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class ItemsJson( + @Expose @SerializedName("crimson_armors") val crimsonArmors: List, + @Expose @SerializedName("crimson_tiers") val crimsonTiers: Map, + @Expose @SerializedName("enchant_multiplier") val enchantMultiplier: Map, + @Expose @SerializedName("lava_fishing_rods") val lavaFishingRods: List, + @Expose @SerializedName("water_fishing_rods") val waterFishingRods: List, + @Expose @SerializedName("book_bundle_amount") val bookBundleAmount: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.java deleted file mode 100644 index 0df76b4a9c05..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.java +++ /dev/null @@ -1,27 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzVec; -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class LocationFixJson { - - @Expose - public Map locationFixes; - - public static class LocationFix { - @Expose - public LorenzVec a; - - @Expose - public LorenzVec b; - - @Expose - public String island_name; - - @Expose - public String real_location; - } - -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.kt new file mode 100644 index 000000000000..c2662a02bbf9 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/LocationFixJson.kt @@ -0,0 +1,16 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class LocationFixJson( + @Expose val locationFixes: Map, +) + +data class LocationFix( + @Expose val a: LorenzVec, + @Expose val b: LorenzVec, + @Expose @SerializedName("island_name") val islandName: String, + @Expose @SerializedName("real_location") val realLocation: String, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.java deleted file mode 100644 index 6ac70abb69a9..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class MaxwellPowersJson { - @Expose - public List powers; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.kt new file mode 100644 index 000000000000..779960189131 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MaxwellPowersJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class MaxwellPowersJson( + @Expose val powers: MutableList, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.java deleted file mode 100644 index 44f66b8b86f9..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class MinionXPJson { - @Expose - public Map> minion_xp; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.kt new file mode 100644 index 000000000000..6a8aa199f7c1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MinionXPJson.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class MinionXPJson( + @Expose @SerializedName("minion_xp") val minionXp: Map>, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.java deleted file mode 100644 index cf0b0656d593..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ModGuiSwitcherJson { - - @Expose - public Map mods = new HashMap<>(); - - public static class Mod { - @Expose - public List description = new ArrayList<>(); - - @Expose - public String command = ""; - - @Expose - public List guiPath = new ArrayList<>(); - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.kt new file mode 100644 index 000000000000..7532608b7102 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ModGuiSwitcherJson.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class ModGuiSwitcherJson( + @Expose val mods: Map, +) + +data class OtherModInfo( + @Expose val description: List, + @Expose val command: String, + @Expose val guiPath: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.java deleted file mode 100644 index 0d0c0d6e1191..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class MultiFilterJson { - @Expose - public List equals; - - @Expose - public List startsWith; - - @Expose - public List endsWith; - - @Expose - public List contains; - - @Expose - public List containsWord; - - @Expose - public String description; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.kt new file mode 100644 index 000000000000..51279c498056 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/MultiFilterJson.kt @@ -0,0 +1,12 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class MultiFilterJson( + @Expose val equals: List, + @Expose val startsWith: List, + @Expose val endsWith: List, + @Expose val contains: List, + @Expose val containsWord: List, + @Expose val description: String, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.java deleted file mode 100644 index 0dd51143010d..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.java +++ /dev/null @@ -1,23 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzVec; -import com.google.gson.annotations.Expose; - -import java.util.ArrayList; -import java.util.List; - -public class ParkourJson { - @Expose - public List locations; - - @Expose - public List shortCuts = new ArrayList<>(); - - public static class ShortCut { - @Expose - public int from; - - @Expose - public int to; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.kt new file mode 100644 index 000000000000..686a33af1417 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ParkourJson.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose + +data class ParkourJson( + @Expose val locations: List, + @Expose val shortCuts: List = listOf(), +) + +data class ParkourShortCut( + @Expose val from: Int, + @Expose val to: Int, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.java deleted file mode 100644 index 708ac24e06aa..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class PlayerChatFilterJson { - @Expose - public List filters; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.kt new file mode 100644 index 000000000000..0749c53052fc --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/PlayerChatFilterJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class PlayerChatFilterJson( + @Expose val filters: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.java deleted file mode 100644 index ad94c374dc35..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.java +++ /dev/null @@ -1,11 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzVec; -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class RiftEffigiesJson { - @Expose - public List locations; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.kt new file mode 100644 index 000000000000..5cc121c1164b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RiftEffigiesJson.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzVec +import com.google.gson.annotations.Expose + +data class RiftEffigiesJson( + @Expose val locations: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.java deleted file mode 100644 index 3f8449fb6ac6..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.java +++ /dev/null @@ -1,33 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.LorenzRarity; -import com.google.gson.annotations.Expose; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.Map; - -public class SeaCreatureJson { - - public static Type TYPE = new TypeToken>() { - }.getType(); - - public static class Variant { - @Expose - public String chat_color; - @Expose - public Map sea_creatures; - } - - public static class SeaCreature { - @Expose - public String chat_message; - @Expose - public int fishing_experience; - @Expose - public Boolean rare; - @Expose - public LorenzRarity rarity; - } - -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.kt new file mode 100644 index 000000000000..c75efdac35c4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SeaCreatureJson.kt @@ -0,0 +1,23 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.LorenzRarity +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName +import com.google.gson.reflect.TypeToken +import java.lang.reflect.Type + +data class SeaCreatureJson( + @Expose @SerializedName("chat_color") val chatColor: String, + @Expose @SerializedName("sea_creatures") val seaCreatures: Map, +) { + companion object { + val TYPE: Type = object : TypeToken>() {}.type + } +} + +data class SeaCreatureInfo( + @Expose @SerializedName("chat_message") val chatMessage: String, + @Expose @SerializedName("fishing_experience") val fishingExperience: Int, + @Expose val rare: Boolean = false, + @Expose val rarity: LorenzRarity, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.java deleted file mode 100644 index f9c91bdfc124..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; - -import java.util.List; -import java.util.Map; - -public class SlayerProfitTrackerItemsJson { - @Expose - public Map> slayers; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.kt new file mode 100644 index 000000000000..118ee4795a89 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SlayerProfitTrackerItemsJson.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose + +data class SlayerProfitTrackerItemsJson( + @Expose val slayers: Map>, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/StackingEnchantsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/StackingEnchantsJson.kt index a663f6db8497..876ff946b6ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/StackingEnchantsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/StackingEnchantsJson.kt @@ -3,10 +3,10 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo import com.google.gson.annotations.Expose data class StackingEnchantsJson( - @Expose val enchants: Map + @Expose val enchants: Map, ) data class StackingEnchantData( @Expose val levels: List, - @Expose val statName: String + @Expose val statName: String, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TabListJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TabListJson.java deleted file mode 100644 index 2c475679e095..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TabListJson.java +++ /dev/null @@ -1,11 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class TabListJson { - - @Expose - public List sun_moon_symbols; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.java deleted file mode 100644 index c15adf1b89e9..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.java +++ /dev/null @@ -1,25 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; -import com.google.gson.annotations.Expose; - -import java.util.Map; - -public class TrophyFishJson { - @Expose - public Map trophy_fish; - - public static class TrophyFishInfo { - @Expose - public String displayName; - - @Expose - public String description; - - @Expose - public Integer rate; - - @Expose - public Map fillet; - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.kt new file mode 100644 index 000000000000..02079ed30bbf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/TrophyFishJson.kt @@ -0,0 +1,16 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName + +data class TrophyFishJson( + @Expose @SerializedName("trophy_fish") val trophyFish: Map, +) + +data class TrophyFishInfo( + @Expose val displayName: String, + @Expose val description: String, + @Expose val rate: Int?, + @Expose val fillet: Map, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.java deleted file mode 100644 index d2a4a0562ac8..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class VipVisitsJson { - @Expose - public List vipVisits; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.kt new file mode 100644 index 000000000000..1cc8b2602c81 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/VipVisitsJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class VipVisitsJson( + @Expose val vipVisits: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.java deleted file mode 100644 index ef81b052a462..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.java +++ /dev/null @@ -1,10 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class WarpsJson { - @Expose - public List warpCommands; -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.kt new file mode 100644 index 000000000000..0820f5b9c30f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/WarpsJson.kt @@ -0,0 +1,7 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo + +import com.google.gson.annotations.Expose + +data class WarpsJson( + @Expose val warpCommands: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuHoppityJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuHoppityJson.kt index 1c80f6ad3fda..ada6afaa122c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuHoppityJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuHoppityJson.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo.neu import com.google.gson.annotations.Expose data class NeuHoppityJson( - @Expose val hoppity: HoppityInfo + @Expose val hoppity: HoppityInfo, ) data class HoppityInfo( diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt index d63a9ae790a3..a2df8a095bc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt @@ -5,5 +5,5 @@ import com.google.gson.annotations.Expose data class NeuRNGScore( @Expose val catacombs: Map>, - @Expose val slayer: Map> + @Expose val slayer: Map>, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt index c450e391055e..8ebe2dea60fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo.neu; +package at.hannibal2.skyhanni.data.jsonobjects.repo.neu import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.NEUInternalName diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt index fe0ae5b495c2..481c4f76b91e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSacksJson.kt @@ -4,10 +4,10 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import com.google.gson.annotations.Expose data class NeuSacksJson( - @Expose val sacks: Map + @Expose val sacks: Map, ) data class SackInfo( @Expose val item: NEUInternalName, - @Expose val contents: List + @Expose val contents: List, ) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt index d8ac8c838583..ce50c4fe4108 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt @@ -4,5 +4,5 @@ import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName data class NeuSkillLevelJson( - @Expose @SerializedName("leveling_xp") val levelingXp: List + @Expose @SerializedName("leveling_xp") val levelingXp: List, ) 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 b8bf67f81505..59cacde87131 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.takeIfAllNotNull import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzLogger @@ -11,36 +12,35 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.TreeMap import at.hannibal2.skyhanni.data.mob.Mob.Type as MobType -class MobData { +@SkyHanniModule +object MobData { class MobSet : HashSet() { val entityList get() = this.flatMap { listOf(it.baseEntity) + (it.extraEntities) } } - companion object { - val players = MobSet() - val displayNPCs = MobSet() - val skyblockMobs = MobSet() - val summoningMobs = MobSet() - val special = MobSet() - val currentMobs = MobSet() + val players = MobSet() + val displayNPCs = MobSet() + val skyblockMobs = MobSet() + val summoningMobs = MobSet() + val special = MobSet() + val currentMobs = MobSet() - val entityToMob = mutableMapOf() + val entityToMob = mutableMapOf() - internal val currentEntityLiving = mutableSetOf() - internal val previousEntityLiving = mutableSetOf() + internal val currentEntityLiving = mutableSetOf() + internal val previousEntityLiving = mutableSetOf() - internal val retries = TreeMap() + internal val retries = TreeMap() - const val ENTITY_RENDER_RANGE_IN_BLOCKS = 80.0 // Entity DeRender after ~5 Chunks - const val DETECTION_RANGE = 22.0 - const val DISPLAY_NPC_DETECTION_RANGE = 24.0 // 24.0 + const val ENTITY_RENDER_RANGE_IN_BLOCKS = 80.0 // Entity DeRender after ~5 Chunks + const val DETECTION_RANGE = 22.0 + const val DISPLAY_NPC_DETECTION_RANGE = 24.0 // 24.0 - var externRemoveOfRetryAmount = 0 + var externRemoveOfRetryAmount = 0 - val logger = LorenzLogger("mob/detection") - } + val logger = LorenzLogger("mob/detection") internal enum class Result { Found, diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt index bb9eb7ac0560..03f6d64b60c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.dev.DebugMobConfig.HowToShow import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand.getMobInfo import at.hannibal2.skyhanni.utils.LocationUtils.getTopCenter import at.hannibal2.skyhanni.utils.LorenzColor @@ -16,7 +17,8 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityPlayerSP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MobDebug { +@SkyHanniModule +object MobDebug { private val config get() = SkyHanniMod.feature.dev.mobDebug.mobDetection 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 a521e23545ad..0c59a72ac1a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt @@ -1,8 +1,9 @@ package at.hannibal2.skyhanni.data.mob import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.mob.MobData.Companion.logger +import at.hannibal2.skyhanni.data.mob.MobData.logger import at.hannibal2.skyhanni.data.mob.MobFilter.isDisplayNPC import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer import at.hannibal2.skyhanni.data.mob.MobFilter.isSkyBlockMob @@ -10,7 +11,9 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.MobEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.drainForEach import at.hannibal2.skyhanni.utils.CollectionUtils.drainTo import at.hannibal2.skyhanni.utils.CollectionUtils.put @@ -31,17 +34,16 @@ import net.minecraft.network.play.server.S01PacketJoinGame import net.minecraft.network.play.server.S0CPacketSpawnPlayer import net.minecraft.network.play.server.S0FPacketSpawnMob import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.atomic.AtomicBoolean -private const val MAX_RETRIES = 20 * 5 -class MobDetection { +@SkyHanniModule +object MobDetection { - /* Unsupported "Mobs" + /* Unsupported Entities Nicked Players - Odanate + Odonata Silk Worm Fairy (in Dungeon) Totem of Corruption @@ -53,6 +55,8 @@ class MobDetection { Zee */ + private const val MAX_RETRIES = 20 * 5 + private val forceReset get() = !SkyHanniMod.feature.dev.mobDebug.enable private var shouldClear: AtomicBoolean = AtomicBoolean(false) @@ -308,8 +312,8 @@ class MobDetection { return true } - @SubscribeEvent - fun onEntitySpawnPacket(event: PacketEvent.ReceiveEvent) { + @HandleEvent + fun onEntitySpawnPacket(event: PacketReceivedEvent) { when (val packet = event.packet) { is S0FPacketSpawnMob -> addEntityUpdate(packet.entityID) is S0CPacketSpawnPlayer -> addEntityUpdate(packet.entityID) @@ -330,8 +334,8 @@ class MobDetection { allEntitiesViaPacketId.add(id) } - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + @HandleEvent + fun onDisconnect(event: ClientDisconnectEvent) { shouldClear.set(true) } 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 d459e2a9ef56..7a9711f208e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data.model import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.WidgetUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf @@ -353,6 +354,7 @@ enum class TabWidget( } } + @SkyHanniModule companion object { /** The index for the start of each Widget (inclusive) */ diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index aaaa1dd2ed73..f957b75ffb9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -6,17 +6,19 @@ import at.hannibal2.skyhanni.mixins.hooks.setValue import at.hannibal2.skyhanni.mixins.transformers.AccessorEventBus import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.system.PlatformUtils import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event import net.minecraftforge.fml.common.eventhandler.IEventListener +@Deprecated("Use SkyHanniEvent instead", ReplaceWith("")) abstract class LorenzEvent : Event() { private val eventName by lazy { this::class.simpleName!! } + @Deprecated("Use SkyHanniEvent instead", ReplaceWith("")) fun postAndCatch() = postAndCatchAndBlock {} companion object { @@ -26,9 +28,10 @@ abstract class LorenzEvent : Event() { return 0 } } - val isInGuardedEventHandler get() = eventHandlerDepth > 0 || LorenzUtils.isInDevEnvironment() + val isInGuardedEventHandler get() = eventHandlerDepth > 0 || PlatformUtils.isDevEnvironment } + @Deprecated("Use SkyHanniEvent instead", ReplaceWith("")) fun postAndCatchAndBlock( printError: Boolean = true, stopOnFirstError: Boolean = false, @@ -67,9 +70,10 @@ abstract class LorenzEvent : Event() { return listenerList.getListeners(accessorEventBus.busId) } + @Deprecated("Use SkyHanniEvent instead", ReplaceWith("")) fun postWithoutCatch() = MinecraftForge.EVENT_BUS.post(this) - // TODO let walker use this function for all 101 other uses + @Deprecated("Use SkyHanniEvent instead", ReplaceWith("")) fun cancel() { isCanceled = true } diff --git a/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt index 49e51a30b603..6aa07cb54ca0 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt @@ -1,11 +1,11 @@ package at.hannibal2.skyhanni.events -import net.minecraftforge.fml.common.ModContainer +import at.hannibal2.skyhanni.utils.system.ModInstance import net.minecraftforge.fml.common.eventhandler.Cancelable @Cancelable class MessageSendToServerEvent( val message: String, val splitMessage: List, - val originatingModContainer: ModContainer? + val originatingModContainer: ModInstance? ) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt deleted file mode 100644 index 961699a40275..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt +++ /dev/null @@ -1,47 +0,0 @@ -package at.hannibal2.skyhanni.events - -import net.minecraft.network.Packet -import net.minecraftforge.fml.common.eventhandler.Cancelable - -@Cancelable -/** - * Note: This event is async and may not be executed on the main minecraft thread. - */ -abstract class PacketEvent : LorenzEvent() { - - abstract val direction: Direction - abstract val packet: Packet<*> - - /** - * Note: This event is async and may not be executed on the main minecraft thread. - */ - data class ReceiveEvent(override val packet: Packet<*>) : PacketEvent() { - - override val direction = Direction.INBOUND - } - - /** - * Note: This event is async and may not be executed on the main minecraft thread. - */ - data class SendEvent(override val packet: Packet<*>) : PacketEvent() { - - override val direction = Direction.OUTBOUND - - fun findOriginatingModCall(skipSkyhanni: Boolean = false): StackTraceElement? { - val nonMinecraftOriginatingStack = Thread.currentThread().stackTrace - // Skip calls before the event is being called - .dropWhile { it.className != "net.minecraft.client.network.NetHandlerPlayClient" } - // Limit the remaining callstack until only the main entrypoint to hide the relauncher - .takeWhile { !it.className.endsWith(".Main") } - // Drop minecraft or skyhanni call frames - .dropWhile { it.className.startsWith("net.minecraft.") || (skipSkyhanni && it.className.startsWith("at.hannibal2.skyhanni.")) } - .firstOrNull() - return nonMinecraftOriginatingStack - } - } - - enum class Direction { - INBOUND, - OUTBOUND, - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/events/PreInitFinishedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PreInitFinishedEvent.kt deleted file mode 100644 index 8294b8bd7e0c..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/PreInitFinishedEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package at.hannibal2.skyhanni.events - -class PreInitFinishedEvent : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoCardUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoCardUpdateEvent.kt index f7406498b96c..de9a83214a85 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoCardUpdateEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoCardUpdateEvent.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.events.bingo -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent -class BingoCardUpdateEvent : LorenzEvent() +class BingoCardUpdateEvent : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt index b091c24f3cfc..06d392251f64 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/bingo/BingoGoalReachedEvent.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.events.bingo -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal -class BingoGoalReachedEvent(val goal: BingoGoal) : LorenzEvent() +class BingoGoalReachedEvent(val goal: BingoGoal) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/diana/InquisitorFoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/diana/InquisitorFoundEvent.kt index 9978c6f3c603..9061eaa72dd4 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/diana/InquisitorFoundEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/diana/InquisitorFoundEvent.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.events.diana -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent import net.minecraft.client.entity.EntityOtherPlayerMP -class InquisitorFoundEvent(val inquisitorEntity: EntityOtherPlayerMP) : LorenzEvent() +class InquisitorFoundEvent(val inquisitorEntity: EntityOtherPlayerMP) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/entity/EntityEnterWorldEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityEnterWorldEvent.kt new file mode 100644 index 000000000000..24b887165e60 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/entity/EntityEnterWorldEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.entity + +import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent +import net.minecraft.entity.Entity + +class EntityEnterWorldEvent(val entity: T) : GenericSkyHanniEvent(entity.javaClass) diff --git a/src/main/java/at/hannibal2/skyhanni/events/farming/FarmingLaneSwitchEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/farming/FarmingLaneSwitchEvent.kt deleted file mode 100644 index 3f78fd9c0e0c..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/events/farming/FarmingLaneSwitchEvent.kt +++ /dev/null @@ -1,6 +0,0 @@ -package at.hannibal2.skyhanni.events.farming - -import at.hannibal2.skyhanni.events.LorenzEvent -import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane - -class FarmingLaneSwitchEvent(val lane: FarmingLane?) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/fishing/TrophyFishCaughtEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/fishing/TrophyFishCaughtEvent.kt index 358b057bc422..46215c90e844 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/fishing/TrophyFishCaughtEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/fishing/TrophyFishCaughtEvent.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.events.fishing -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity // trophyFishName is NO Neu Internal Name -class TrophyFishCaughtEvent(val trophyFishName: String, val rarity: TrophyRarity) : LorenzEvent() +class TrophyFishCaughtEvent(val trophyFishName: String, val rarity: TrophyRarity) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/farming/FarmingLaneSwitchEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/farming/FarmingLaneSwitchEvent.kt new file mode 100644 index 000000000000..c2e5141351ce --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/farming/FarmingLaneSwitchEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.garden.farming + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent +import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLane + +class FarmingLaneSwitchEvent(val lane: FarmingLane?) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestSpawnEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestSpawnEvent.kt index 219516b9bd82..5c441a2deafd 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestSpawnEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestSpawnEvent.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.events.garden.pests -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent -class PestSpawnEvent(val amountPests: Int, val plotNames: List, val unknownAmount: Boolean) : LorenzEvent() +class PestSpawnEvent(val amountPests: Int, val plotNames: List, val unknownAmount: Boolean) : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestUpdateEvent.kt index 6f444fa86e4d..c4c299b1338f 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestUpdateEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/garden/pests/PestUpdateEvent.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.events.garden.pests -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent -class PestUpdateEvent : LorenzEvent() +class PestUpdateEvent : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt index 2b3041d62f88..1081f86473da 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt @@ -1,6 +1,13 @@ package at.hannibal2.skyhanni.events.item -import at.hannibal2.skyhanni.events.LorenzEvent +import at.hannibal2.skyhanni.api.event.SkyHanniEvent import net.minecraft.item.ItemStack -class ItemHoverEvent(val itemStack: ItemStack, val toolTip: List) : LorenzEvent() +class ItemHoverEvent(val itemStack: ItemStack, private val toolTip0: MutableList) : SkyHanniEvent() { + var toolTip + set(value) { + toolTip0.clear() + toolTip0.addAll(value) + } + get() = toolTip0 +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/minecraft/ClientDisconnectEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/minecraft/ClientDisconnectEvent.kt new file mode 100644 index 000000000000..6c7a5e8a1b4c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/minecraft/ClientDisconnectEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events.minecraft + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent + +class ClientDisconnectEvent : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketReceivedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketReceivedEvent.kt new file mode 100644 index 000000000000..bbb29acdd511 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketReceivedEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events.minecraft.packet + +import at.hannibal2.skyhanni.api.event.CancellableSkyHanniEvent +import net.minecraft.network.Packet + +class PacketReceivedEvent(val packet: Packet<*>) : CancellableSkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketSentEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketSentEvent.kt new file mode 100644 index 000000000000..b01bd94fbcb1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/minecraft/packet/PacketSentEvent.kt @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.events.minecraft.packet + +import at.hannibal2.skyhanni.api.event.CancellableSkyHanniEvent +import net.minecraft.client.network.NetHandlerPlayClient +import net.minecraft.network.Packet + +class PacketSentEvent(val network: NetHandlerPlayClient, val packet: Packet<*>) : CancellableSkyHanniEvent() { + fun findOriginatingModCall(skipSkyhanni: Boolean = false): StackTraceElement? { + val nonMinecraftOriginatingStack = Thread.currentThread().stackTrace + // Skip calls before the event is being called + .dropWhile { it.className != "net.minecraft.client.network.NetHandlerPlayClient" } + // Limit the remaining callstack until only the main entrypoint to hide the relauncher + .takeWhile { !it.className.endsWith(".Main") } + // Drop minecraft or skyhanni call frames + .dropWhile { + it.className.startsWith("net.minecraft.") || + (skipSkyhanni && it.className.startsWith("at.hannibal2.skyhanni.")) + } + .firstOrNull() + return nonMinecraftOriginatingStack + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/utils/PreInitFinishedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/utils/PreInitFinishedEvent.kt new file mode 100644 index 000000000000..1d52761ed2dd --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/utils/PreInitFinishedEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events.utils + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent + +class PreInitFinishedEvent : SkyHanniEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt index 9e9992ab1f7a..625ded34f838 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/anvil/AnvilCombineHelper.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.anvil import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.InventoryUtils.getLowerItems import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems @@ -13,7 +14,8 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AnvilCombineHelper { +@SkyHanniModule +object AnvilCombineHelper { @SubscribeEvent fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt index 008f35b72f75..5950f484d565 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoAPI.kt @@ -2,12 +2,14 @@ package at.hannibal2.skyhanni.features.bingo import at.hannibal2.skyhanni.config.storage.PlayerSpecificStorage.BingoSession import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoData import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoRanksJson import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -18,10 +20,11 @@ import java.time.LocalTime import java.time.OffsetDateTime import java.time.ZoneOffset +@SkyHanniModule object BingoAPI { private var ranks = mapOf() - private var data: Map = emptyMap() + private var data: Map = emptyMap() val bingoGoals get() = bingoStorage.goals val personalGoals get() = bingoGoals.values.filter { it.type == GoalType.PERSONAL } @@ -67,7 +70,7 @@ object BingoAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { ranks = event.getConstant("BingoRanks").ranks - data = event.getConstant("Bingo").bingo_tips + data = event.getConstant("Bingo").bingoTips } fun getRankFromScoreboard(text: String) = if (detectionPattern.matches(text)) getRank(text) else null @@ -82,7 +85,7 @@ object BingoAPI { fun getData(itemName: String) = data.filter { itemName.startsWith(it.key.split(" (Community Goal)")[0]) }.values.firstOrNull() - fun BingoGoal.getData(): BingoJson.BingoData? = if (type == GoalType.COMMUNITY) { + fun BingoGoal.getData(): BingoData? = if (type == GoalType.COMMUNITY) { getData(displayName) } else { data[displayName] diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt index a6a773bda657..39f069771345 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.bingo import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -9,7 +10,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CompactBingoChat { +@SkyHanniModule +object CompactBingoChat { private val config get() = SkyHanniMod.feature.event.bingo.compactChat 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 1ebbd901162a..c12bafc39ea3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.hasEnchantments import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -29,7 +30,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class MinionCraftHelper { +@SkyHanniModule +object MinionCraftHelper { private val config get() = SkyHanniMod.feature.event.bingo @@ -120,7 +122,7 @@ class MinionCraftHelper { if (!allIngredients.contains(rawId)) continue if (!isAllowed(allMinions, rawId)) continue - val (itemId, multiplier) = NEUItems.getMultiplier(rawId) + val (itemId, multiplier) = NEUItems.getPrimitiveMultiplier(rawId) val old = otherItems.getOrDefault(itemId, 0) otherItems[itemId] = old + item.stackSize * multiplier } @@ -131,7 +133,7 @@ class MinionCraftHelper { } private fun isAllowed(allMinions: List, internalName: NEUInternalName): Boolean { - val a = NEUItems.getMultiplier(internalName) + val primitiveStack = NEUItems.getPrimitiveMultiplier(internalName) for (minion in allMinions) { val recipes = NEUItems.getRecipes(minion) @@ -140,8 +142,8 @@ class MinionCraftHelper { val ingredientInternalName = ingredient.internalItemId.asInternalName() if (ingredientInternalName == internalName) return true - val b = NEUItems.getMultiplier(ingredientInternalName) - if (a.first == b.first && a.second < b.second) return true + val ingredientPrimitive = NEUItems.getPrimitiveMultiplier(ingredientInternalName) + if (primitiveStack.internalName == ingredientPrimitive.internalName && primitiveStack.amount < ingredientPrimitive.amount) return true } } } @@ -207,7 +209,7 @@ class MinionCraftHelper { } var allDone = true for ((rawId, need) in map) { - val (itemId, multiplier) = NEUItems.getMultiplier(rawId) + val (itemId, multiplier) = NEUItems.getPrimitiveMultiplier(rawId) val needAmount = need * multiplier val have = otherItems.getOrDefault(itemId, 0) val percentage = have.toDouble() / needAmount diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt index b00b88569bb7..94bd4f6dd8dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.bingo.card import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -9,6 +10,7 @@ import at.hannibal2.skyhanni.events.bingo.BingoCardUpdateEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.HypixelCommands @@ -27,45 +29,43 @@ import net.minecraft.client.gui.inventory.GuiInventory import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.days -class BingoCardDisplay { +@SkyHanniModule +object BingoCardDisplay { private var display = emptyList() private var hasHiddenPersonalGoals = false - companion object { + private const val MAX_PERSONAL_GOALS = 20 + private const val MAX_COMMUNITY_GOALS = 5 - private const val MAX_PERSONAL_GOALS = 20 - private const val MAX_COMMUNITY_GOALS = 5 + private val config get() = SkyHanniMod.feature.event.bingo.bingoCard + private var displayMode = 0 - private val config get() = SkyHanniMod.feature.event.bingo.bingoCard - private var displayMode = 0 + fun command() { + reload() + } - fun command() { - reload() - } + private fun reload() { + BingoAPI.bingoGoals.clear() + } - private fun reload() { - BingoAPI.bingoGoals.clear() + fun toggleCommand() { + if (!LorenzUtils.isBingoProfile) { + ChatUtils.userError("This command only works on a bingo profile!") + return } - - fun toggleCommand() { - if (!LorenzUtils.isBingoProfile) { - ChatUtils.userError("This command only works on a bingo profile!") - return - } - if (!config.enabled) { - ChatUtils.userError("Bingo Card is disabled in the config!") - return - } - toggleMode() + if (!config.enabled) { + ChatUtils.userError("Bingo Card is disabled in the config!") + return } + toggleMode() + } - private fun toggleMode() { - displayMode++ - if (displayMode == 3) { - displayMode = 0 - } + private fun toggleMode() { + displayMode++ + if (displayMode == 3) { + displayMode = 0 } } @@ -247,7 +247,7 @@ class BingoCardDisplay { private fun canEditDisplay() = Minecraft.getMinecraft().currentScreen is GuiInventory || InventoryUtils.openInventoryName() == "Bingo Card" - @SubscribeEvent + @HandleEvent fun onBingoCardUpdate(event: BingoCardUpdateEvent) { if (!config.enabled) return if (!LorenzUtils.isBingoProfile) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt index 1f84c11da110..b04a081eab56 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardReader.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.bingo.card import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoJson +import at.hannibal2.skyhanni.data.jsonobjects.repo.BingoData import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.bingo.BingoCardUpdateEvent @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType import at.hannibal2.skyhanni.features.bingo.card.goals.HiddenGoalData +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -22,7 +23,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration -class BingoCardReader { +@SkyHanniModule +object BingoCardReader { private val config get() = SkyHanniMod.feature.event.bingo.bingoCard private val patternGroup = RepoPattern.group("bingo.card") @@ -94,7 +96,7 @@ class BingoCardReader { } BingoAPI.lastBingoCardOpenTime = SimpleTimeMark.now() - BingoCardUpdateEvent().postAndCatch() + BingoCardUpdateEvent().post() } private fun bingoGoalDifference(bingoGoal: BingoGoal, new: Double) { @@ -160,9 +162,9 @@ class BingoCardReader { val goal = BingoAPI.personalGoals.firstOrNull { it.displayName == name } ?: return goal.done = true - BingoGoalReachedEvent(goal).postAndCatch() - BingoCardUpdateEvent().postAndCatch() + BingoGoalReachedEvent(goal).post() + BingoCardUpdateEvent().post() } - private fun BingoJson.BingoData.getDescriptionLine() = "§7" + note.joinToString(" ") + private fun BingoData.getDescriptionLine() = "§7" + note.joinToString(" ") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt index 3c88567af34d..abf8bbedc701 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardTips.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.bingo.BingoAPI.getData import at.hannibal2.skyhanni.features.bingo.card.goals.GoalType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BingoCardTips { +@SkyHanniModule +object BingoCardTips { private val config get() = SkyHanniMod.feature.event.bingo.bingoCard 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 b723a41c0ab2..427fbb902b71 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 @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.ObtainCrys import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.PartialProgressItemsStep import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.ProgressionStep import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps.SkillLevelStep +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils @@ -29,7 +30,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BingoNextStepHelper { +@SkyHanniModule +object BingoNextStepHelper { private val config get() = SkyHanniMod.feature.event.bingo.bingoCard private var dirty = true @@ -61,72 +63,69 @@ class BingoNextStepHelper { private val islands = mutableMapOf() private val rhysTaskName = "30x Enchanted Minerals (Redstone, Lapis Lazuli, Coal) (for Rhys)" - companion object { + private val finalSteps = mutableListOf() + private var currentSteps = emptyList() + var currentHelp = emptyList() - private val finalSteps = mutableListOf() - private var currentSteps = emptyList() - var currentHelp = emptyList() - - fun command() { - updateResult(true) - } + fun command() { + updateResult(true) + } - private fun updateResult(print: Boolean = false) { + private fun updateResult(print: Boolean = false) { + if (print) println() + currentSteps = listOf() + for (step in finalSteps) { + printRequirements(step, print) if (print) println() - currentSteps = listOf() - for (step in finalSteps) { - printRequirements(step, print) - if (print) println() - } - - currentHelp = drawDisplay(print) } - private fun drawDisplay(print: Boolean): MutableList { - val newCurrentHelp = mutableListOf() - newCurrentHelp.add("§6Bingo Step Helper:") + currentHelp = drawDisplay(print) + } - if (currentSteps.isEmpty()) { - newCurrentHelp.add("§cOpen the §e/bingo §ccard.") - } - for (currentStep in currentSteps) { - val text = getName(currentStep) - newCurrentHelp.add(" §7$text") - if (print) println(text) - } - if (print) println() - return newCurrentHelp - } + private fun drawDisplay(print: Boolean): MutableList { + val newCurrentHelp = mutableListOf() + newCurrentHelp.add("§6Bingo Step Helper:") - private fun printRequirements(step: NextStep, print: Boolean, parentDone: Boolean = false, depth: Int = 0) { - if (print) println(getName(step, parentDone, depth)) - var requirementsToDo = 0 - for (requirement in step.requirements) { - printRequirements(requirement, print, step.done || parentDone, depth + 1) - if (!requirement.done) { - requirementsToDo++ - } - } + if (currentSteps.isEmpty()) { + newCurrentHelp.add("§cOpen the §e/bingo §ccard.") + } + for (currentStep in currentSteps) { + val text = getName(currentStep) + newCurrentHelp.add(" §7$text") + if (print) println(text) + } + if (print) println() + return newCurrentHelp + } - if (!step.done && !parentDone && requirementsToDo == 0 && !currentSteps.contains(step)) { - currentSteps = currentSteps.editCopy { add(step) } + private fun printRequirements(step: NextStep, print: Boolean, parentDone: Boolean = false, depth: Int = 0) { + if (print) println(getName(step, parentDone, depth)) + var requirementsToDo = 0 + for (requirement in step.requirements) { + printRequirements(requirement, print, step.done || parentDone, depth + 1) + if (!requirement.done) { + requirementsToDo++ } } - private fun getName(step: NextStep, parentDone: Boolean = false, depth: Int = 0): String { - val prefix = " ".repeat(depth) + if (step.done) "[DONE] " else if (parentDone) "[done] " else "" - val suffix = if (step is ProgressionStep) progressDisplay(step) else "" - return prefix + step.displayName + suffix + if (!step.done && !parentDone && requirementsToDo == 0 && !currentSteps.contains(step)) { + currentSteps = currentSteps.editCopy { add(step) } } + } - private fun progressDisplay(step: ProgressionStep): String { - val having = step.amountHaving - return if (having > 0) { - val needed = step.amountNeeded - val percentage = LorenzUtils.formatPercentage(having.toDouble() / needed) - " $percentage (${having.addSeparators()}/${needed.addSeparators()})" - } else "" - } + private fun getName(step: NextStep, parentDone: Boolean = false, depth: Int = 0): String { + val prefix = " ".repeat(depth) + if (step.done) "[DONE] " else if (parentDone) "[done] " else "" + val suffix = if (step is ProgressionStep) progressDisplay(step) else "" + return prefix + step.displayName + suffix + } + + private fun progressDisplay(step: ProgressionStep): String { + val having = step.amountHaving + return if (having > 0) { + val needed = step.amountNeeded + val percentage = LorenzUtils.formatPercentage(having.toDouble() / needed) + " $percentage (${having.addSeparators()}/${needed.addSeparators()})" + } else "" } init { diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt index 1f2e7bf324af..5bf5b34489a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ArachneChatMessageHider.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ArachneChatMessageHider { +@SkyHanniModule +object ArachneChatMessageHider { private val config get() = SkyHanniMod.feature.chat private var hideArachneDeadMessage = false 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 1b4ae762caf3..f424b52a3cea 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils @@ -12,7 +13,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern -class ChatFilter { +@SkyHanniModule +object ChatFilter { private val generalConfig get() = SkyHanniMod.feature.chat private val config get() = SkyHanniMod.feature.chat.filterType diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt index b4b8b10eb3da..4c75cd7aeb37 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactBestiaryChatMessage.kt @@ -3,12 +3,14 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CompactBestiaryChatMessage { +@SkyHanniModule +object CompactBestiaryChatMessage { private var inBestiary = false private var bestiaryDescription = mutableListOf() 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 c8db2de703e3..7547ae6ab24b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/CompactSplashPotionMessage.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull @@ -9,7 +10,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CompactSplashPotionMessage { +@SkyHanniModule +object CompactSplashPotionMessage { private val config get() = SkyHanniMod.feature.chat.compactPotionMessages diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index 768e74854689..55c690199c4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PlayerDeathMessages { +@SkyHanniModule +object PlayerDeathMessages { private val lastTimePlayerSeen = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt index e4145c98fff6..8a0670e98d8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/RareDropMessages.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity import at.hannibal2.skyhanni.utils.RegexUtils.matchMatchers @@ -9,7 +10,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RareDropMessages { +@SkyHanniModule +object RareDropMessages { private val chatGroup = RepoPattern.group("pet.chatdrop") diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt index 190ddb493350..d0a08c86fd4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt @@ -3,10 +3,12 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ActionBarStatsData import at.hannibal2.skyhanni.events.ActionBarValueUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SkyblockXPInChat { +@SkyHanniModule +object SkyblockXPInChat { val config get() = SkyHanniMod.feature.chat.skyBlockXPInChat diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt index 11e51e6861f6..6e1b005040ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/WatchdogHider.kt @@ -4,33 +4,39 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class WatchdogHider { +@SkyHanniModule +object WatchdogHider { private var inWatchdog = false private var blockedLines = 0 private var startLineComponent: IChatComponent? = null + private const val START_LINE = "§f" + private const val ANNOUNCEMENT_LINE = "§4[WATCHDOG ANNOUNCEMENT]" + private const val END_LINE = "§c" + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.onHypixel || !SkyHanniMod.feature.chat.filterType.watchDog) return when (event.message) { - watchdogStartLine -> { + START_LINE -> { startLineComponent = event.chatComponent blockedLines = 0 } - watchdogAnnouncementLine -> { + ANNOUNCEMENT_LINE -> { ChatManager.retractMessage(startLineComponent, "watchdog") startLineComponent = null inWatchdog = true } - watchdogEndLine -> { + END_LINE -> { event.blockedReason = "watchdog" inWatchdog = false } @@ -46,17 +52,8 @@ class WatchdogHider { } } - companion object { - - private const val watchdogStartLine = "§f" - private const val watchdogAnnouncementLine = "§4[WATCHDOG ANNOUNCEMENT]" - private const val watchdogEndLine = "§c" - } - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(3, "chat.watchDog", "chat.filterType.watchDog") } } - - diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt index cb6f68c4dfda..23de5de6b97e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatFilter.kt @@ -2,26 +2,25 @@ package at.hannibal2.skyhanni.features.chat.playerchat import at.hannibal2.skyhanni.data.jsonobjects.repo.PlayerChatFilterJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.MultiFilter import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PlayerChatFilter { +@SkyHanniModule +object PlayerChatFilter { - companion object { + private val filters = mutableMapOf() - private val filters = mutableMapOf() - - fun shouldChatFilter(original: IChatComponent): Boolean { - val message = original.formattedText.lowercase() - for (filter in filters) { - filter.value.matchResult(message)?.let { - return true - } + fun shouldChatFilter(original: IChatComponent): Boolean { + val message = original.formattedText.lowercase() + for (filter in filters) { + filter.value.matchResult(message)?.let { + return true } - - return false } + + return false } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt index 52e95b3a12fa..7bcaea265db1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/playerchat/PlayerChatModifier.kt @@ -4,14 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.StringUtils.applyIfPossible import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent -import net.minecraft.util.ChatComponentText import net.minecraft.util.IChatComponent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PlayerChatModifier { +@SkyHanniModule +object PlayerChatModifier { private val config get() = SkyHanniMod.feature.chat.playerMessage private val patterns = mutableListOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaManager.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaManager.kt index dab2f2cf4f61..052cea4e45f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaManager.kt @@ -3,8 +3,10 @@ package at.hannibal2.skyhanni.features.chroma import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChromaManager { val config get() = SkyHanniMod.feature.gui.chroma diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 4b576a4b9298..864f4926db01 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -33,6 +34,7 @@ import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object BestiaryData { private val config get() = SkyHanniMod.feature.combat.bestiary diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt index bffc60e404e1..31b85ddd0b73 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FerocityDisplay.kt @@ -3,13 +3,16 @@ package at.hannibal2.skyhanni.features.combat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class FerocityDisplay { +@SkyHanniModule +object FerocityDisplay { + private val config get() = SkyHanniMod.feature.combat.ferocityDisplay /** diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt index 4dcadb3a53a6..5ed2cdb8ad05 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/FlareDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.EntityUtils @@ -30,6 +31,7 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object FlareDisplay { private val config get() = SkyHanniMod.feature.combat.flare diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt index acf4b607578c..215d4a0a3897 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/HideDamageSplash.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HideDamageSplash { +@SkyHanniModule +object HideDamageSplash { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { @@ -17,7 +19,7 @@ class HideDamageSplash { if (!SkyHanniMod.feature.combat.hideDamageSplash) return if (DamageIndicatorManager.isDamageSplash(event.entity)) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index ca761b580aa5..33bb20a5238d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.combat.damageindicator import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.BossCategory import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig.NameVisibility @@ -15,9 +16,11 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield -import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield +import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper.setHellionShield +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.CollectionUtils.put @@ -47,6 +50,7 @@ import com.google.gson.JsonArray import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.Entity import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand @@ -54,7 +58,6 @@ import net.minecraft.entity.monster.EntityEnderman import net.minecraft.entity.monster.EntityMagmaCube import net.minecraft.entity.monster.EntityZombie import net.minecraft.entity.passive.EntityWolf -import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.UUID @@ -62,7 +65,8 @@ import kotlin.math.max import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -class DamageIndicatorManager { +@SkyHanniModule +object DamageIndicatorManager { private var mobFinder: MobFinder? = null private val maxHealth = mutableMapOf() @@ -70,45 +74,42 @@ class DamageIndicatorManager { private val enderSlayerHitsNumberPattern = ".* §[5fd]§l(?\\d+) Hits?".toPattern() - companion object { + private var data = mapOf() + private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() - private var data = mapOf() - private val damagePattern = "[✧✯]?(\\d+[⚔+✧❤♞☄✷ﬗ✯]*)".toPattern() + fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } - fun isBoss(entity: EntityLivingBase) = data.values.any { it.entity == entity } + fun isDamageSplash(entity: EntityLivingBase): Boolean { + if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false + if (!entity.hasCustomName()) return false + if (entity.isDead) return false + val name = entity.customNameTag.removeColor().replace(",", "") - fun isDamageSplash(entity: EntityLivingBase): Boolean { - if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return false - if (!entity.hasCustomName()) return false - if (entity.isDead) return false - val name = entity.customNameTag.removeColor().replace(",", "") - - return damagePattern.matcher(name).matches() - } + return damagePattern.matcher(name).matches() + } - fun isBossSpawned(type: BossType) = data.entries.find { it.value.bossType == type } != null + fun isBossSpawned(type: BossType) = data.entries.find { it.value.bossType == type } != null - fun isBossSpawned(vararg types: BossType) = types.any { isBossSpawned(it) } + fun isBossSpawned(vararg types: BossType) = types.any { isBossSpawned(it) } - fun getDistanceTo(vararg types: BossType): Double { - val playerLocation = LocationUtils.playerLocation() - return data.values.filter { it.bossType in types } - .map { it.entity.getLorenzVec().distance(playerLocation) } - .let { list -> - if (list.isEmpty()) Double.MAX_VALUE else list.minOf { it } - } - } + fun getDistanceTo(vararg types: BossType): Double { + val playerLocation = LocationUtils.playerLocation() + return data.values.filter { it.bossType in types } + .map { it.entity.getLorenzVec().distance(playerLocation) } + .let { list -> + if (list.isEmpty()) Double.MAX_VALUE else list.minOf { it } + } + } - fun getNearestDistanceTo(location: LorenzVec): Double { - return data.values - .map { it.entity.getLorenzVec() } - .minOfOrNull { it.distance(location) } ?: Double.MAX_VALUE - } + fun getNearestDistanceTo(location: LorenzVec): Double { + return data.values + .map { it.entity.getLorenzVec() } + .minOfOrNull { it.distance(location) } ?: Double.MAX_VALUE + } - fun removeDamageIndicator(type: BossType) { - data = data.editCopy { - values.removeIf { it.bossType == type } - } + fun removeDamageIndicator(type: BossType) { + data = data.editCopy { + values.removeIf { it.bossType == type } } } @@ -849,8 +850,8 @@ class DamageIndicatorManager { return maxHealth.getOrDefault(entity.uniqueID!!, 0L) } - @SubscribeEvent - fun onEntityJoin(event: EntityJoinWorldEvent) { + @HandleEvent + fun onEntityJoin(event: EntityEnterWorldEvent) { mobFinder?.handleNewEntity(event.entity) } @@ -870,7 +871,7 @@ class DamageIndicatorManager { if (entityData != null) { if (config.hideDamageSplash) { - event.isCanceled = true + event.cancel() } if (entityData.bossType == BossType.DUMMY) { val uuid = entity.uniqueID @@ -887,7 +888,7 @@ class DamageIndicatorManager { if (name.contains("Overflux")) return if (name.contains("Mana Flux")) return if (name.contains("Radiant")) return - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index aa462726a9b1..dcc5b01dfcd3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.events.SackChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange @@ -31,6 +32,7 @@ import com.google.gson.annotations.Expose import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object EnderNodeTracker { private val config get() = SkyHanniMod.feature.combat.enderNodeTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index 4a4f94d49d8a..89fdc89ea1c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -23,7 +23,8 @@ import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatText import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.isUsingCTGhostCounter import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.preFormat import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.prettyTime -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -63,6 +64,7 @@ import java.util.Locale import kotlin.math.roundToInt import kotlin.math.roundToLong +@SkyHanniModule object GhostCounter { val config get() = SkyHanniMod.feature.combat.ghostCounter @@ -262,10 +264,10 @@ object GhostCounter { addAsSingletonList(etaFormatting.base.formatText(eta).formatText(killETA)) val rate = 0.12 * (1 + (avgMagicFind.toDouble() / 100)) - val sorrowValue = SORROW.getBazaarData()?.buyPrice?.toLong() ?: 0L + val sorrowValue = SORROW.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L val final: String = (killInterp * sorrowValue * (rate / 100)).toLong().addSeparators() - val plasmaValue = PLASMA.getBazaarData()?.buyPrice?.toLong() ?: 0L - val voltaValue = VOLTA.getBazaarData()?.buyPrice?.toLong() ?: 0L + val plasmaValue = PLASMA.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L + val voltaValue = VOLTA.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L var moneyMade: Long = 0 val priceMap = listOf( Triple("Sorrow", Option.SORROWCOUNT.getInt(), sorrowValue), diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt similarity index 91% rename from src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt rename to src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt index ac2496f1845f..2fee0577e8f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/SpawnTimers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/ArachneSpawnTimer.kt @@ -1,29 +1,31 @@ package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.network.play.server.S2APacketParticles import net.minecraft.util.EnumParticleTypes -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class SpawnTimers { +@SkyHanniModule +object ArachneSpawnTimer { private val config get() = SkyHanniMod.feature.combat.mobs @@ -78,9 +80,8 @@ class SpawnTimers { } } - // All this to detect "quickspawn" vs regular arachne spawn - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.SPIDER_DEN, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!saveNextTickParticles) return if (searchTime.passedSince() < 3.seconds) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt index f64467203cc0..5bdc521cd061 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AreaMiniBossFeatures.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth import at.hannibal2.skyhanni.utils.LocationUtils @@ -24,7 +25,8 @@ import net.minecraft.entity.passive.EntityWolf import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class AreaMiniBossFeatures { +@SkyHanniModule +object AreaMiniBossFeatures { private val config get() = SkyHanniMod.feature.combat.mobs private var lastSpawnTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt index dc05046ade82..55c3f7833316 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/AshfangMinisNametagHider.kt @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.features.combat.mobs import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangMinisNametagHider { +@SkyHanniModule +object AshfangMinisNametagHider { private val config get() = SkyHanniMod.feature.combat.mobs @@ -23,7 +25,7 @@ class AshfangMinisNametagHider { val name = entity.name if (name.contains("§cArachne's Brood§r")) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt index d5cc0ed9e548..af439d767702 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/mobs/MobHighlight.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith @@ -25,7 +26,8 @@ import net.minecraft.entity.monster.EntitySpider import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MobHighlight { +@SkyHanniModule +object MobHighlight { private val config get() = SkyHanniMod.feature.combat.mobs private var arachne: EntityLivingBase? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt index fca11b45a1a0..6b96024ed129 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.FriendAPI import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.data.hypixel.chat.event.PartyChatEvent import at.hannibal2.skyhanni.events.TabCompletionEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object PartyChatCommands { private val config get() = SkyHanniMod.feature.misc.partyCommands diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt index 3f25804653d7..c60c84ae5bf5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyCommands.kt @@ -6,10 +6,12 @@ import at.hannibal2.skyhanni.data.FriendAPI import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.HypixelCommands import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object PartyCommands { private val config get() = SkyHanniMod.feature.misc.commands diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt index 70b94c79525e..ba65fac3a77d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/SendCoordinatedCommand.kt @@ -1,17 +1,19 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LocationUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SendCoordinatedCommand { +@SkyHanniModule +object SendCoordinatedCommand { @SubscribeEvent fun onMessageSendToServer(event: MessageSendToServerEvent) { val message = event.message if (message.startsWith("/sendcoords")) { - event.isCanceled = true + event.cancel() val description = message.substringAfter("/sendcoords").trim() sendCoordinates(description) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt index cbdc626acd0b..e3d6a5713297 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.NEUItems @@ -9,6 +10,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ViewRecipeCommand { private val config get() = SkyHanniMod.feature.misc.commands @@ -32,7 +34,7 @@ object ViewRecipeCommand { group("item").uppercase().replace(" ", "_") } ?: return - event.isCanceled = true + event.cancel() HypixelCommands.viewRecipe(item) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt index 0401c0edb5f9..b78e6cf63123 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WarpIsCommand.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class WarpIsCommand { +@SkyHanniModule +object WarpIsCommand { @SubscribeEvent fun onMessageSendToServer(event: MessageSendToServerEvent) { @@ -14,7 +16,7 @@ class WarpIsCommand { if (!SkyHanniMod.feature.misc.commands.replaceWarpIs) return if (event.message.lowercase() == "/warp is") { - event.isCanceled = true + event.cancel() HypixelCommands.island() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt index bff80b930b29..b8e14d280588 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -16,6 +17,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.net.URLEncoder +@SkyHanniModule object WikiManager { private const val OFFICIAL_URL_PREFIX = "https://wiki.hypixel.net/" private const val OFFICIAL_SEARCH_PREFIX = "index.php?search=" @@ -36,7 +38,7 @@ object WikiManager { val message = event.message.lowercase() if (!(message.startsWith("/wiki"))) return - event.isCanceled = true + event.cancel() if (message == "/wiki") { sendWikiMessage() return diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt index 748a73ceba47..e199a47fd923 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt @@ -6,9 +6,11 @@ import at.hannibal2.skyhanni.data.FriendAPI import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.data.jsonobjects.repo.VipVisitsJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object PlayerTabComplete { private val config get() = SkyHanniMod.feature.misc.commands.tabComplete diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt index 49bde5993bea..602c4a3b9e10 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt @@ -3,9 +3,12 @@ package at.hannibal2.skyhanni.features.commands.tabcomplete import at.hannibal2.skyhanni.events.TabCompletionEvent import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand +import at.hannibal2.skyhanni.features.garden.fortuneguide.CarrolynTable import at.hannibal2.skyhanni.features.misc.CollectionTracker +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TabComplete { @SubscribeEvent @@ -28,6 +31,7 @@ object TabComplete { CollectionTracker.handleTabComplete(command)?.let { return it } PartyCommands.customTabComplete(command)?.let { return it } ViewRecipeCommand.customTabComplete(command)?.let { return it } + CarrolynTable.customTabComplete(command)?.let { return it } return null } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt index 4520aee0944d..6b067831892d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/WarpTabComplete.kt @@ -4,9 +4,11 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.jsonobjects.repo.WarpsJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.TabCompletionEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object WarpTabComplete { private val config get() = SkyHanniMod.feature.misc.commands.tabComplete diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt index ca641889a3d4..0f4d267f7f6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -20,7 +21,8 @@ import java.util.LinkedList import kotlin.time.DurationUnit import kotlin.time.toDuration -class ArrowTrail { +@SkyHanniModule +object ArrowTrail { private val config get() = SkyHanniMod.feature.gui.cosmetic.arrowTrail diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt index a2dab30cf7ce..34e962890553 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/CosmeticFollowingLine.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.LocationUtils @@ -20,7 +21,8 @@ import java.awt.Color import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class CosmeticFollowingLine { +@SkyHanniModule +object CosmeticFollowingLine { private val config get() = SkyHanniMod.feature.gui.cosmetic.followingLine diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt index b565c0210f71..801b4f800c95 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonChest +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -31,7 +32,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CroesusChestTracker { +@SkyHanniModule +object CroesusChestTracker { private val config get() = SkyHanniMod.feature.dungeon.chest @@ -49,10 +51,11 @@ class CroesusChestTracker { private val openedPattern by patternGroup.pattern("chest.state.opened", "§8Opened Chest:.*") private val unopenedPattern by patternGroup.pattern("chest.state.unopened", "§8No Chests Opened!") - private val kismetSlotId = 50 - private val emptySlotId = 22 - private val frontArrowSlotId = 53 - private val backArrowSlotId = 45 + private const val KISMET_SLOT = 50 + private const val EMPTY_SLOT = 22 + private const val FRONT_ARROW_SLOT = 53 + private const val BACK_ARROW_SLOT = 45 + private const val MAX_CHESTS = 60 private val kismetInternalName = "KISMET_FEATHER".asInternalName() @@ -67,6 +70,8 @@ class CroesusChestTracker { private var kismetAmountCache = 0 + private val croesusChests get() = ProfileStorageData.profileSpecific?.dungeons?.runs + @SubscribeEvent(priority = EventPriority.LOW) fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { if (!LorenzUtils.inSkyBlock) return @@ -119,7 +124,7 @@ class CroesusChestTracker { kismetAmountCache = getKismetAmount() } if (config.showUsedKismets) { - val kismetItem = event.inventoryItems[kismetSlotId] ?: return + val kismetItem = event.inventoryItems[KISMET_SLOT] ?: return if (config.showUsedKismets && kismetUsedPattern.matches(kismetItem.getLore().lastOrNull())) setKismetUsed() } @@ -155,8 +160,8 @@ class CroesusChestTracker { private fun pageSetup(event: InventoryFullyOpenedEvent) { inCroesusInventory = true pageSwitchable = true - croesusEmpty = croesusEmptyPattern.matches(event.inventoryItems[emptySlotId]?.name) - if (event.inventoryItems[backArrowSlotId]?.item != Items.arrow) { + croesusEmpty = croesusEmptyPattern.matches(event.inventoryItems[EMPTY_SLOT]?.name) + if (event.inventoryItems[BACK_ARROW_SLOT]?.item != Items.arrow) { currentPage = 0 } } @@ -177,19 +182,19 @@ class CroesusChestTracker { fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.showUsedKismets) return - if (chestInventory != null && event.slotId == kismetSlotId) { + if (chestInventory != null && event.slotId == KISMET_SLOT) { setKismetUsed() return } if (inCroesusInventory && !croesusEmpty) { if (event.slot == null) return when (event.slotId) { - frontArrowSlotId -> if (pageSwitchable && event.slot.stack.isArrow()) { + FRONT_ARROW_SLOT -> if (pageSwitchable && event.slot.stack.isArrow()) { pageSwitchable = false currentPage++ } - backArrowSlotId -> if (pageSwitchable && event.slot.stack.isArrow()) { + BACK_ARROW_SLOT -> if (pageSwitchable && event.slot.stack.isArrow()) { pageSwitchable = false currentPage-- } @@ -227,7 +232,7 @@ class CroesusChestTracker { if (event.floor == "E") return croesusChests?.add(0, DungeonRunInfo(event.floor)) currentRunIndex = 0 - if ((croesusChests?.size ?: 0) > maxChests) { + if ((croesusChests?.size ?: 0) > MAX_CHESTS) { croesusChests?.dropLast(1) } @@ -261,26 +266,21 @@ class CroesusChestTracker { private inline fun runSlots(slotId: Int, any: T) = croesusSlotMapToRun(slotId)?.getRun()?.let { it to any } - companion object { - val maxChests = 60 - - private val croesusChests get() = ProfileStorageData.profileSpecific?.dungeons?.runs - - fun resetChest() = croesusChests?.let { - it.clear() - it.addAll(generateMaxChest()) - ChatUtils.chat("Kismet State was cleared!") - } + fun resetChest() = croesusChests?.let { + it.clear() + it.addAll(generateMaxChest()) + ChatUtils.chat("Kismet State was cleared!") + } - fun generateMaxChest(): Sequence = generateSequence { DungeonRunInfo() }.take(maxChests) - fun generateMaxChestAsList(): List = generateMaxChest().toList() + @JvmStatic + fun generateMaxChestAsList(): List = generateMaxChest().toList() + private fun generateMaxChest(): Sequence = generateSequence { DungeonRunInfo() }.take(MAX_CHESTS) - fun getLastActiveChest(includeDungeonKey: Boolean = false): Int = - (croesusChests?.indexOfLast { - it.floor != null && - (it.openState == OpenedState.UNOPENED || (includeDungeonKey && it.openState == OpenedState.OPENED)) - } ?: -1) + 1 - } + fun getLastActiveChest(includeDungeonKey: Boolean = false): Int = + (croesusChests?.indexOfLast { + it.floor != null && + (it.openState == OpenedState.UNOPENED || (includeDungeonKey && it.openState == OpenedState.OPENED)) + } ?: -1) + 1 enum class OpenedState { UNOPENED, diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index 86def886ded9..8b852f1ccbcb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.TablistFooterUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -31,6 +32,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DungeonAPI { private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?.*)\\)".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonArchitectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonArchitectFeatures.kt index b5d2ac230dfc..662c366045b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonArchitectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonArchitectFeatures.kt @@ -1,18 +1,20 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.GetFromSackAPI import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacks import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class DungeonArchitectFeatures { +@SkyHanniModule +object DungeonArchitectFeatures { private val config get() = SkyHanniMod.feature.dungeon private val patternGroup = RepoPattern.group("dungeon.architectsdraft") @@ -40,16 +42,17 @@ class DungeonArchitectFeatures { } } + private val architectsFirstDraft = "ARCHITECT_FIRST_DRAFT".asInternalName().makePrimitiveStack() + private fun generateMessage(name: String, event: LorenzChatEvent) { val architectItemAmount = architectsFirstDraftItem.getAmountInSacks() if (architectItemAmount <= 0) return - ChatUtils.clickableChat( - "§c§lPUZZLE FAILED! §r§b$name §r§efailed a puzzle. \n" + - "§eClick here to get §5Architect's First Draft §7(§e${architectItemAmount}x left§7)", - { HypixelCommands.getFromSacks("ARCHITECT_FIRST_DRAFT", 1) }, - prefix = false + GetFromSackAPI.getFromChatMessageSackItems( + architectsFirstDraft, "§c§lPUZZLE FAILED! §r§b$name §r§efailed a puzzle. \n" + + "§eClick here to get §5Architect's First Draft §7(§e${architectItemAmount}x left§7)" ) + LorenzUtils.sendTitle("§c§lPUZZLE FAILED!", 3.seconds) event.blockedReason = "puzzle_fail" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt index 6f5a83a851cb..166faccc193b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -3,11 +3,13 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonBossHideDamageSplash { +@SkyHanniModule +object DungeonBossHideDamageSplash { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { @@ -16,7 +18,7 @@ class DungeonBossHideDamageSplash { if (!DungeonAPI.inBossRoom) return if (DamageIndicatorManager.isDamageSplash(event.entity)) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt index bed6cbefeb8d..62fccecaeb50 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt @@ -2,10 +2,12 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonBossMessages { +@SkyHanniModule +object DungeonBossMessages { private val config get() = SkyHanniMod.feature.chat private val bossPattern = "§([cd4])\\[BOSS] (.*)".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt index f63d3e96ef8a..a49369d83f74 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.chat.ChatConfig import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -10,7 +11,8 @@ import java.util.regex.Pattern private typealias MessageTypes = ChatConfig.DungeonMessageTypes -class DungeonChatFilter { +@SkyHanniModule +object DungeonChatFilter { private val config get() = SkyHanniMod.feature.chat diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt index e83916eeebf1..3b9f023d2e98 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -18,7 +19,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityGuardian import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonCleanEnd { +@SkyHanniModule +object DungeonCleanEnd { private val config get() = SkyHanniMod.feature.dungeon.cleanEnd private val catacombsPattern by RepoPattern.pattern( @@ -104,20 +106,20 @@ class DungeonCleanEnd { return } - event.isCanceled = true + event.cancel() } @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { if (shouldBlock()) { - event.isCanceled = true + event.cancel() } } @SubscribeEvent fun onPlaySound(event: PlaySoundEvent) { if (shouldBlock() && !chestsSpawned && event.soundName.startsWith("note.")) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt index 2651f14b3c61..11d749b668fa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonCopilot { +@SkyHanniModule +object DungeonCopilot { private val config get() = SkyHanniMod.feature.dungeon.dungeonCopilot diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt index a61d0c9865e4..4be042b4365f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt @@ -5,12 +5,14 @@ import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonDeathCounter { +@SkyHanniModule +object DungeonDeathCounter { private val config get() = SkyHanniMod.feature.dungeon private var display = "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt index 960ca8afcd91..d3a3692019f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -22,7 +23,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // TODO Remove all removeColor calls in this class. Deal with the color code in regex. -class DungeonFinderFeatures { +@SkyHanniModule +object DungeonFinderFeatures { private val config get() = SkyHanniMod.feature.dungeon.partyFinder // Repo group and patterns diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt index f100e9cfff17..9d2c531a5a93 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHideItems.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.EntityMoveEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture @@ -19,7 +20,8 @@ import net.minecraft.entity.item.EntityItem import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonHideItems { +@SkyHanniModule +object DungeonHideItems { private val config get() = SkyHanniMod.feature.dungeon.objectHider @@ -28,25 +30,25 @@ class DungeonHideItems { // TODO put in skull data repo part - private val soulWeaverHider = + private const val SOUL_WEAVER_HIDER = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmYyNGVkNjg3NTMwNGZhNGExZjBjNzg1YjJjYjZhNmE3MjU2M2U5ZjNlMjRlYTU1ZTE4MTc4NDUyMTE5YWE2NiJ9fX0=" - private val blessingTexture = + private const val BLESSING_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTkzZTIwNjg2MTc4NzJjNTQyZWNkYTFkMjdkZjRlY2U5MWM2OTk5MDdiZjMyN2M0ZGRiODUzMDk0MTJkMzkzOSJ9fX0=" - private val reviveStoneTexture = + private const val REVIVE_STONE_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjZhNzZjYzIyZTdjMmFiOWM1NDBkMTI0NGVhZGJhNTgxZjVkZDllMThmOWFkYWNmMDUyODBhNWI0OGI4ZjYxOCJ9fX0K" - private val premiumFleshTexture = + private const val PREMIUM_FLESH_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWE3NWU4YjA0NGM3MjAxYTRiMmU4NTZiZTRmYzMxNmE1YWFlYzY2NTc2MTY5YmFiNTg3MmE4ODUzNGI4MDI1NiJ9fX0K" - private val abilityOrbTexture = + private const val ABILITY_ORB_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTAxZTA0MGNiMDFjZjJjY2U0NDI4MzU4YWUzMWQyZTI2NjIwN2M0N2NiM2FkMTM5NzA5YzYyMDEzMGRjOGFkNCJ9fX0=" - private val supportOrbTexture = + private const val SUPPORT_ORB_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTMxYTRmYWIyZjg3ZGI1NDMzMDEzNjUxN2I0NTNhYWNiOWQ3YzBmZTc4NDMwMDcwOWU5YjEwOWNiYzUxNGYwMCJ9fX0=" - private val damageOrbTexture = + private const val DAMAGE_ORB_TEXTURE = "eyJ0aW1lc3RhbXAiOjE1NzQ5NTEzMTkwNDQsInByb2ZpbGVJZCI6IjE5MjUyMWI0ZWZkYjQyNWM4OTMxZjAyYTg0OTZlMTFiIiwicHJvZmlsZU5hbWUiOiJTZXJpYWxpemFibGUiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiODZkYTJlMjQzYzA1ZGMwODk4YjBjYzVkM2U2NDg3NzE3MzE3N2UwYTIzOTQ0MjVjZWMxMDAyNTljYjQ1MjYifX19" - private val healerFairyTexture = + private const val HEALER_FAIRY_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" private fun isSkeletonSkull(entity: EntityArmorStand): Boolean { @@ -63,11 +65,11 @@ class DungeonHideItems { if (entity is EntityItem) { val stack = entity.entityItem if (config.hideReviveStone && stack.cleanName() == "Revive Stone") { - event.isCanceled = true + event.cancel() } if (config.hideJournalEntry && stack.cleanName() == "Journal Entry") { - event.isCanceled = true + event.cancel() } } @@ -77,44 +79,44 @@ class DungeonHideItems { val skullTexture = head?.getSkullTexture() if (config.hideSuperboomTNT) { if (entity.name.startsWith("§9Superboom TNT")) { - event.isCanceled = true + event.cancel() } if (head != null && head.cleanName() == "Superboom TNT") { - event.isCanceled = true + event.cancel() hideParticles[entity] = System.currentTimeMillis() } } if (config.hideBlessing) { if (entity.name.startsWith("§dBlessing of ")) { - event.isCanceled = true + event.cancel() } - if (skullTexture == blessingTexture) { - event.isCanceled = true + if (skullTexture == BLESSING_TEXTURE) { + event.cancel() } } if (config.hideReviveStone) { if (entity.name == "§6Revive Stone") { - event.isCanceled = true + event.cancel() } - if (skullTexture == reviveStoneTexture) { - event.isCanceled = true + if (skullTexture == REVIVE_STONE_TEXTURE) { + event.cancel() hideParticles[entity] = System.currentTimeMillis() } } if (config.hidePremiumFlesh) { if (entity.name == "§9Premium Flesh") { - event.isCanceled = true + event.cancel() hideParticles[entity] = System.currentTimeMillis() } - if (skullTexture == premiumFleshTexture) { - event.isCanceled = true + if (skullTexture == PREMIUM_FLESH_TEXTURE) { + event.cancel() } } @@ -125,23 +127,23 @@ class DungeonHideItems { if (lastMove + 100 > System.currentTimeMillis()) { return } - event.isCanceled = true + event.cancel() } } if (config.hideHealerOrbs) { when { - entity.name.startsWith("§c§lDAMAGE §e") -> event.isCanceled = true - entity.name.startsWith("§c§lABILITY DAMAGE §e") -> event.isCanceled = true - entity.name.startsWith("§a§lDEFENSE §e") -> event.isCanceled = true + entity.name.startsWith("§c§lDAMAGE §e") -> event.cancel() + entity.name.startsWith("§c§lABILITY DAMAGE §e") -> event.cancel() + entity.name.startsWith("§a§lDEFENSE §e") -> event.cancel() } when (skullTexture) { - abilityOrbTexture, - supportOrbTexture, - damageOrbTexture, + ABILITY_ORB_TEXTURE, + SUPPORT_ORB_TEXTURE, + DAMAGE_ORB_TEXTURE, -> { - event.isCanceled = true + event.cancel() hideParticles[entity] = System.currentTimeMillis() return } @@ -150,15 +152,15 @@ class DungeonHideItems { if (config.hideHealerFairy) { // Healer Fairy texture is stored in id 0, not id 4 for some reasos. - if (entity.inventory[0]?.getSkullTexture() == healerFairyTexture) { - event.isCanceled = true + if (entity.inventory[0]?.getSkullTexture() == HEALER_FAIRY_TEXTURE) { + event.cancel() return } } if (config.hideSoulweaverSkulls) { - if (skullTexture == soulWeaverHider) { - event.isCanceled = true + if (skullTexture == SOUL_WEAVER_HIDER) { + event.cancel() return } } @@ -174,10 +176,10 @@ class DungeonHideItems { val distance = packetLocation.distance(armorStand.getLorenzVec()) if (distance < 2) { if (event.type == EnumParticleTypes.FIREWORKS_SPARK) { - event.isCanceled = true + event.cancel() } if (event.type == EnumParticleTypes.REDSTONE) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt index 9d030e528c80..16b5cb5f666a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.LorenzColor @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawString import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonHighlightClickedBlocks { +@SkyHanniModule +object DungeonHighlightClickedBlocks { private val blocks = mutableListOf() private var colorIndex = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index becbb896bbc3..989368595d97 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt @@ -28,6 +29,7 @@ import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DungeonLividFinder { private val config get() = SkyHanniMod.feature.dungeon.lividFinder @@ -117,7 +119,7 @@ object DungeonLividFinder { if (entity != livid && entity != lividArmorStand) { if (entity.name.contains("Livid")) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index 960a8053e44c..3f00775d9809 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object DungeonMilestonesDisplay { private val config get() = SkyHanniMod.feature.dungeon diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt index 15c6e14166a3..80a60ba4b8f1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.TabListLineRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.groupOrNull import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -10,7 +11,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.stripHypixelMessage import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonRankTabListColor { +@SkyHanniModule +object DungeonRankTabListColor { private val config get() = SkyHanniMod.feature.dungeon.tabList private val patternGroup = RepoPattern.group("dungeon.tablist") diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt index af5f21eaec34..d96e4559fbc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonShadowAssassinNotification.kt @@ -1,19 +1,22 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.TitleManager -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorWorldBoarderPacket +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraft.network.play.server.S44PacketWorldBorder -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class DungeonShadowAssassinNotification { +@SkyHanniModule +object DungeonShadowAssassinNotification { private val config get() = SkyHanniMod.feature.dungeon - @SubscribeEvent - fun onWorldBoarderChange(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.CATACOMBS) + fun onWorldBoarderChange(event: PacketReceivedEvent) { if (!isEnabled()) return if (DungeonAPI.dungeonFloor?.contains("3") == true && DungeonAPI.inBossRoom) return @@ -27,5 +30,5 @@ class DungeonShadowAssassinNotification { } } - private fun isEnabled() = DungeonAPI.inDungeon() && config.shadowAssassinJumpNotifier + private fun isEnabled() = config.shadowAssassinJumpNotifier } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt index 2575d4431dff..5f31a4dc5a89 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.gui.FontRenderer @@ -10,7 +11,8 @@ import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraft.scoreboard.Team import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonTeammateOutlines { +@SkyHanniModule +object DungeonTeammateOutlines { private val config get() = SkyHanniMod.feature.dungeon diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt index a5e11cbd071d..1a543749d7f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonsRaceGuide { +@SkyHanniModule +object DungeonsRaceGuide { private val config get() = SkyHanniMod.feature.dungeon.dungeonsRaceGuide private val raceActivePattern by RepoPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt index 6aba8843f63f..26b129dd9574 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/HighlightDungeonDeathmite.kt @@ -3,12 +3,14 @@ package at.hannibal2.skyhanni.features.dungeon import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.LorenzColor import net.minecraft.entity.monster.EntitySilverfish import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightDungeonDeathmite { +@SkyHanniModule +object HighlightDungeonDeathmite { @SubscribeEvent fun onEntityHealthUpdate(event: EntityMaxHealthUpdateEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt index 747331ad8a63..14e359c29114 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt @@ -5,11 +5,13 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TerracottaPhase { +@SkyHanniModule +object TerracottaPhase { private val config get() = SkyHanniMod.feature.dungeon.terracottaPhase @@ -31,14 +33,14 @@ class TerracottaPhase { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { if (isActive() && config.hideDamageSplash && DamageIndicatorManager.isDamageSplash(event.entity)) { - event.isCanceled = true + event.cancel() } } @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { if (isActive() && config.hideParticles) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt index d296680c03df..e24a66594edb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt @@ -1,14 +1,17 @@ package at.hannibal2.skyhanni.features.event import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.WinterAPI import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.isNPC @@ -20,12 +23,13 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.player.EntityPlayer -import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object UniqueGiftingOpportunitiesFeatures { private val playerList: MutableSet? @@ -71,16 +75,16 @@ object UniqueGiftingOpportunitiesFeatures { analyzeArmorStand(entity) } - @SubscribeEvent - fun onEntityJoinWorld(event: EntityJoinWorldEvent) { + @HandleEvent + fun onEntityJoinWorld(event: EntityEnterWorldEvent) { playerColor(event) val entity = event.entity as? EntityArmorStand ?: return analyzeArmorStand(entity) } - private fun playerColor(event: EntityJoinWorldEvent) { + private fun playerColor(event: EntityEnterWorldEvent) { if (event.entity is EntityOtherPlayerMP) { - val entity = event.entity as EntityOtherPlayerMP + val entity = event.entity if (entity.isNPC() || isIronman(entity) || isBingo(entity)) return RenderLivingEntityHelper.setEntityColor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt index 4e8bc060c86f..134e09d09b21 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/Year300RaffleEvent.kt @@ -20,6 +20,7 @@ import java.time.Instant import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +// @SkyHanniModule object Year300RaffleEvent { private val config get() = SkyHanniMod.feature.event.century diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt index 005d9b8f104e..40bc4a97fdff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/AllBurrowsList.kt @@ -3,7 +3,8 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.BurrowDetectEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object AllBurrowsList { private var list = listOf() private val config get() = SkyHanniMod.feature.event.diana.allBurrowsList @@ -32,9 +34,8 @@ object AllBurrowsList { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(1)) return val burrowLocations = burrowLocations ?: return val range = 5..70 diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index 11973f2c77f7..be8d77a6af3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.HypixelCommands @@ -18,7 +19,11 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class BurrowWarpHelper { +@SkyHanniModule +object BurrowWarpHelper { + + private val config get() = SkyHanniMod.feature.event.diana + var currentWarp: WarpPoint? = null private var lastWarpTime = SimpleTimeMark.farPast() private var lastWarp: WarpPoint? = null @@ -90,37 +95,31 @@ class BurrowWarpHelper { event.addData(list) } - companion object { - - private val config get() = SkyHanniMod.feature.event.diana - var currentWarp: WarpPoint? = null - - fun shouldUseWarps(target: LorenzVec, debug: MutableList? = null) { - debug?.add("target: ${target.printWithAccuracy(1)}") - val playerLocation = LocationUtils.playerLocation() - debug?.add("playerLocation: ${playerLocation.printWithAccuracy(1)}") - val warpPoint = getNearestWarpPoint(target) - debug?.add("warpPoint: ${warpPoint.displayName}") - - val playerDistance = playerLocation.distance(target) - debug?.add("playerDistance: ${playerDistance.round(1)}") - val warpDistance = warpPoint.distance(target) - debug?.add("warpDistance: ${warpDistance.round(1)}") - val difference = playerDistance - warpDistance - debug?.add("difference: ${difference.round(1)}") - val setWarpPoint = difference > 10 - debug?.add("setWarpPoint: $setWarpPoint") - currentWarp = if (setWarpPoint) warpPoint else null - } + fun shouldUseWarps(target: LorenzVec, debug: MutableList? = null) { + debug?.add("target: ${target.printWithAccuracy(1)}") + val playerLocation = LocationUtils.playerLocation() + debug?.add("playerLocation: ${playerLocation.printWithAccuracy(1)}") + val warpPoint = getNearestWarpPoint(target) + debug?.add("warpPoint: ${warpPoint.displayName}") + + val playerDistance = playerLocation.distance(target) + debug?.add("playerDistance: ${playerDistance.round(1)}") + val warpDistance = warpPoint.distance(target) + debug?.add("warpDistance: ${warpDistance.round(1)}") + val difference = playerDistance - warpDistance + debug?.add("difference: ${difference.round(1)}") + val setWarpPoint = difference > 10 + debug?.add("setWarpPoint: $setWarpPoint") + currentWarp = if (setWarpPoint) warpPoint else null + } - private fun getNearestWarpPoint(location: LorenzVec) = - WarpPoint.entries.filter { it.unlocked && !it.ignored() }.map { it to it.distance(location) } - .sorted().first().first + private fun getNearestWarpPoint(location: LorenzVec) = + WarpPoint.entries.filter { it.unlocked && !it.ignored() }.map { it to it.distance(location) } + .sorted().first().first - fun resetDisabledWarps() { - WarpPoint.entries.forEach { it.unlocked = true } - ChatUtils.chat("Reset disabled burrow warps.") - } + fun resetDisabledWarps() { + WarpPoint.entries.forEach { it.unlocked = true } + ChatUtils.chat("Reset disabled burrow warps.") } enum class WarpPoint( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt index f49376e37e1f..468c3ecbeaa8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt @@ -1,19 +1,20 @@ package at.hannibal2.skyhanni.features.event.diana +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.events.diana.InquisitorFoundEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.item.ItemStack -import net.minecraftforge.event.entity.EntityJoinWorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DianaAPI { private val spade by lazy { "ANCESTRAL_SPADE".asInternalName() } @@ -31,13 +32,10 @@ object DianaAPI { private fun hasSpadeInInventory() = InventoryUtils.getItemsInOwnInventory().any { it.isDianaSpade } - @SubscribeEvent - fun onJoinWorld(event: EntityJoinWorldEvent) { - if (!LorenzUtils.inSkyBlock) return - - val entity = event.entity - if (entity is EntityOtherPlayerMP && entity.name == "Minos Inquisitor") { - InquisitorFoundEvent(entity).postAndCatch() + @HandleEvent(onlyOnSkyblock = true) + fun onJoinWorld(event: EntityEnterWorldEvent) { + if (event.entity.name == "Minos Inquisitor") { + InquisitorFoundEvent(event.entity).post() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt index ad42aba24ce7..d88f5c017180 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaFixChat.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands @@ -15,7 +16,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class DianaFixChat { +@SkyHanniModule +object DianaFixChat { private val config get() = SkyHanniMod.feature.event.diana diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt index 71e9228e1b8a..9fe716328855 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt @@ -1,11 +1,12 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.jsonobjects.repo.DianaDrops +import at.hannibal2.skyhanni.data.jsonobjects.repo.DianaDropsJson import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.ItemAddEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils @@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DianaProfitTracker { private val config get() = SkyHanniMod.feature.event.diana.dianaProfitTracker @@ -52,12 +54,12 @@ object DianaProfitTracker { @Expose var burrowsDug: Long = 0 - override fun getDescription(timesDropped: Long): List { - val percentage = timesDropped.toDouble() / burrowsDug + override fun getDescription(timesGained: Long): List { + val percentage = timesGained.toDouble() / burrowsDug val perBurrow = LorenzUtils.formatPercentage(percentage.coerceAtMost(1.0)) return listOf( - "§7Dropped §e${timesDropped.addSeparators()} §7times.", + "§7Dropped §e${timesGained.addSeparators()} §7times.", "§7Your drop chance per burrow: §c$perBurrow", ) } @@ -146,7 +148,7 @@ object DianaProfitTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - allowedDrops = event.getConstant("DianaDrops").diana_drops + allowedDrops = event.getConstant("DianaDrops").dianaDrops } fun resetCommand() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 24bc891a8b98..6fe2870216c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.BlockUtils.isInLoadedChunk import at.hannibal2.skyhanni.utils.ChatUtils @@ -43,6 +44,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GriffinBurrowHelper { private val config get() = SkyHanniMod.feature.event.diana diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index f2fc89c5b032..80d6ea0e0df9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -1,14 +1,17 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.BurrowDetectEvent import at.hannibal2.skyhanni.events.BurrowDugEvent import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzVec @@ -17,11 +20,11 @@ import at.hannibal2.skyhanni.utils.TimeLimitedSet import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.init.Blocks import net.minecraft.network.play.server.S2APacketParticles -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GriffinBurrowParticleFinder { private val config get() = SkyHanniMod.feature.event.diana @@ -55,8 +58,8 @@ object GriffinBurrowParticleFinder { } } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!isEnabled()) return if (!config.burrowsSoopyGuess) return val packet = event.packet diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt index 3c2623fea85d..f52c34320413 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GriffinPetWarning { +@SkyHanniModule +object GriffinPetWarning { private var lastWarnTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt index 41d69d63e515..0d1cd7bd0613 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt @@ -1,16 +1,18 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.diana.InquisitorFoundEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightInquisitors { +@SkyHanniModule +object HighlightInquisitors { private val config get() = SkyHanniMod.feature.event.diana - @SubscribeEvent + @HandleEvent fun onInquisitorFound(event: InquisitorFoundEvent) { if (!config.highlightInquisitors) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 205fc41f2102..d9539fe155cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -1,13 +1,16 @@ package at.hannibal2.skyhanni.features.event.diana import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.diana.InquisitorFoundEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.EntityUtils @@ -27,11 +30,11 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.network.play.server.S02PacketChat -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object InquisitorWaypointShare { private val config get() = SkyHanniMod.feature.event.diana.inquisitorSharing @@ -107,7 +110,7 @@ object InquisitorWaypointShare { val inquisitorTime = mutableListOf() - @SubscribeEvent + @HandleEvent fun onInquisitorFound(event: InquisitorFoundEvent) { val inquisitor = event.inquisitorEntity inquisitorsNearby = inquisitorsNearby.editCopy { add(inquisitor) } @@ -218,8 +221,8 @@ object InquisitorWaypointShare { HypixelCommands.partyChat("x: $x, y: $y, z: $z ") } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onFirstChatEvent(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.HUB, priority = HandleEvent.LOW, receiveCancelled = true) + fun onFirstChatEvent(event: PacketReceivedEvent) { if (!isEnabled()) return val packet = event.packet if (packet !is S02PacketChat) return @@ -230,13 +233,13 @@ object InquisitorWaypointShare { partyInquisitorCheckerPattern.matchMatcher(message) { if (detectFromChat()) { - event.isCanceled = true + event.cancel() } } partyOnlyCoordsPattern.matchMatcher(message) { if (detectFromChat()) { - event.isCanceled = true + event.cancel() } } diedPattern.matchMatcher(message) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt index 9d0f44298ce1..abac5accddfd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues @@ -20,6 +21,7 @@ import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern +@SkyHanniModule object MythologicalCreatureTracker { private val config get() = SkyHanniMod.feature.event.diana.mythologicalMobtracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt index 37c9d50f1b83..d290c5df8dc2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/SoopyGuessBurrow.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.BurrowGuessEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.toLorenzVec @@ -21,7 +22,8 @@ import kotlin.math.sin /** * Taken and ported from Soopyboo32's javascript module SoopyV2 */ -class SoopyGuessBurrow { +@SkyHanniModule +object SoopyGuessBurrow { private var dingIndex = 0 private var hasDinged = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt index e6e5ead994de..cc904a081679 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionData.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuHoppityJson import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats.RabbitCollectionRarity +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object HoppityCollectionData { private val rabbitRarities = mutableMapOf() private val rarityBonuses = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt index b570ae37338d..e4a7578c54c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityCollectionStats.kt @@ -1,15 +1,20 @@ package at.hannibal2.skyhanni.features.event.hoppity +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.CollectionUtils.collectWhile +import at.hannibal2.skyhanni.utils.CollectionUtils.consumeWhile import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.KSerializable import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -19,6 +24,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.RegexUtils.find +import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -27,6 +33,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object HoppityCollectionStats { private val config get() = ChocolateFactoryAPI.config @@ -54,6 +61,7 @@ object HoppityCollectionStats { "rabbits.found", "§.§l§m[ §a-z]+§r §.(?[0-9]+)§./§.(?[0-9]+)" ) + /** * REGEX-TEST: §a✔ §7Requirement */ @@ -61,6 +69,7 @@ object HoppityCollectionStats { "rabbit.requirement.met", "§a✔ §7Requirement" ) + /** * REGEX-TEST: §c✖ §7Requirement §e0§7/§a15 * REGEX-TEST: §c✖ §7Requirement §e6§7/§a20 @@ -71,10 +80,50 @@ object HoppityCollectionStats { "§c✖ §7Requirement.*", ) + /** + * REGEX-TEST: §c✖ §7Requirement §e0§7/§a15 + * REGEX-TEST: §c✖ §7Requirement §e6§7/§a20 + * REGEX-TEST: §c✖ §7Requirement §e651§7/§a1,000 + */ + private val requirementAmountNotMet by patternGroup.pattern( + "rabbit.requirement.notmet.amount", + "§c✖ §7Requirement §e(?[\\d,]+)§7/§a(?[\\d,]+)", + ) + + /** + * REGEX-TEST: Find 15 unique egg locations in the Deep Caverns. + */ + private val locationRequirementDescription by patternGroup.pattern( + "rabbit.requirement.location", + "Find 15 unique egg locations in (the )?(?.*)\\..*" + ) + private var display = emptyList() private val loggedRabbits get() = ProfileStorageData.profileSpecific?.chocolateFactory?.rabbitCounts ?: mutableMapOf() + @KSerializable + data class LocationRabbit( + val locationName: String, + val loreFoundCount: Int, + val requiredCount: Int, + ) { + private fun getSkyhanniFoundCount(): Int { + val islandType = IslandType.getByNameOrNull(locationName) ?: return 0 + val foundLocations = HoppityEggLocations.getEggsIn(islandType) + return foundLocations.size + } + + val foundCount get() = maxOf(getSkyhanniFoundCount(), loreFoundCount) + + fun hasMetRequirements(): Boolean { + return foundCount >= requiredCount + } + } + + private val locationRabbitRequirements: MutableMap + get() = ProfileStorageData.profileSpecific?.chocolateFactory?.locationRabbitRequirements ?: mutableMapOf() + var inInventory = false @SubscribeEvent @@ -118,6 +167,28 @@ object HoppityCollectionStats { } } + private fun addLocationRequirementRabbitsToHud(newList: MutableList) { + if (!config.showLocationRequirementsRabbitsInHoppityStats) return + val missingLocationRabbits = locationRabbitRequirements.values.filter { !it.hasMetRequirements() } + + val tips = locationRabbitRequirements.map { + it.key + " §7(§e" + it.value.locationName + "§7): " + (if (it.value.hasMetRequirements()) "§a" else "§c") + + it.value.foundCount + "§7/§a" + it.value.requiredCount + } + + newList.add(Renderable.hoverTips( + if (missingLocationRabbits.isEmpty()) + Renderable.wrappedString("§aFound enough eggs in all locations", width = 200) + else + Renderable.wrappedString( + "§cMissing Locations§7:§c " + + missingLocationRabbits.joinToString("§7, §c") { + it.locationName + }, width = 200), + tips + )) + } + private fun buildDisplay(event: InventoryFullyOpenedEvent): MutableList { logRabbits(event) @@ -125,6 +196,8 @@ object HoppityCollectionStats { newList.add(Renderable.string("§eHoppity Rabbit Collection§f:")) newList.add(LorenzUtils.fillTable(getRabbitStats(), padding = 5)) + addLocationRequirementRabbitsToHud(newList) + val loggedRabbitCount = loggedRabbits.size val foundRabbitCount = getFoundRabbitsFromHypixel(event) @@ -226,14 +299,39 @@ object HoppityCollectionStats { } } + private fun saveLocationRabbit(rabbitName: String, lore: List) { + val iterator = lore.iterator() + + val requirement = iterator.consumeWhile { line -> + val requirementMet = requirementMet.matches(line) + if (requirementMet) Pair(15, 15) // This is kind of hardcoded? + else requirementAmountNotMet.findMatcher(line) { + group("acquired").formatInt() to group("required").formatInt() + } + } ?: return + + val requirementDescriptionCollate = iterator.collectWhile { line -> + line.isNotEmpty() + }.joinToString(" ") { it.removeColor() } + + val location = locationRequirementDescription.findMatcher(requirementDescriptionCollate) { + group("location") + } ?: return + + locationRabbitRequirements[rabbitName] = LocationRabbit(location, requirement.first, requirement.second) + } + private fun logRabbits(event: InventoryFullyOpenedEvent) { - for ((_, item) in event.inventoryItems) { + for (item in event.inventoryItems.values) { val itemName = item.displayName?.removeColor() ?: continue val isRabbit = HoppityCollectionData.isKnownRabbit(itemName) if (!isRabbit) continue val itemLore = item.getLore() + + saveLocationRabbit(itemName, itemLore) + val found = !rabbitNotFoundPattern.anyMatches(itemLore) if (!found) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt index 914b10b0ecb3..55d6bc01d425 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.events.render.EntityRenderLayersEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.renderer.GlStateManager @@ -11,6 +12,7 @@ import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 +@SkyHanniModule object HoppityEggDisplayManager { private val config get() = HoppityEggsManager.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt index 00f59cdb8972..cce0aef79755 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocations.kt @@ -38,6 +38,10 @@ object HoppityEggLocations { val islandCollectedLocations get() = collectedEggStorage[LorenzUtils.skyBlockIsland]?.toSet() ?: emptySet() + fun getEggsIn(islandType: IslandType): Set { + return collectedEggStorage[islandType] ?: emptySet() + } + fun hasCollectedEgg(location: LorenzVec): Boolean = islandCollectedLocations.contains(location) @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index f4682dd519e0..46a72c421843 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -31,6 +32,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object HoppityEggLocator { private val config get() = HoppityEggsManager.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index 7febbab916e9..800167460663 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -28,6 +29,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object HoppityEggsManager { val config get() = SkyHanniMod.feature.event.hoppityEggs @@ -58,7 +60,7 @@ object HoppityEggsManager { */ val newRabbitFound by ChocolateFactoryAPI.patternGroup.pattern( "rabbit.found.new", - "§d§lNEW RABBIT! §6\\+(?.*) Chocolate §7and §6\\+(?.*)x Chocolate §7per second!" + "§d§lNEW RABBIT! (§6\\+(?.*) Chocolate §7and )?§6\\+(?.*)x Chocolate §7per second!" ) private val noEggsLeftPattern by ChocolateFactoryAPI.patternGroup.pattern( "egg.noneleft", diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt index d617241b027e..c57150352948 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsShared.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.event.hoppity import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec @@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object HoppityEggsShared { private val config get() = HoppityEggsManager.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt index 98362bc28620..2ec98ccf673b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityNpc.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,6 +20,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object HoppityNpc { private val config get() = HoppityEggsManager.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/HighlightJerries.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/HighlightJerries.kt index bcf3ac58a16d..bf9ac1a95c8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/HighlightJerries.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/HighlightJerries.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.event.jerry import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.passive.EntityVillager import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightJerries { +@SkyHanniModule +object HighlightJerries { private val config get() = SkyHanniMod.feature.event.jerry diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt index 1514b089e71d..e01c0386d326 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ConfigUtils @@ -25,6 +26,7 @@ import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object FrozenTreasureTracker { private val config get() = SkyHanniMod.feature.event.winter.frozenTreasureTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt index af2c17be0551..411e08e5e3a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.event.lobby.waypoints -import at.hannibal2.skyhanni.data.jsonobjects.repo.EventWaypointsJson +import at.hannibal2.skyhanni.data.jsonobjects.repo.EventWaypointData import at.hannibal2.skyhanni.utils.LorenzVec data class EventWaypoint( @@ -9,7 +9,7 @@ data class EventWaypoint( var isFound: Boolean = false, ) -fun loadEventWaypoints(waypoints: Map>): Map> { +fun loadEventWaypoints(waypoints: Map>): Map> { return buildMap { waypoints.forEach { lobby -> val set = mutableSetOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt index e7178dee0287..b56adecad580 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.event.lobby.waypoints.EventWaypoint import at.hannibal2.skyhanni.features.event.lobby.waypoints.loadEventWaypoints +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer @@ -22,7 +23,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // todo: create abstract class for this and BasketWaypoints -class PresentWaypoints { +@SkyHanniModule +object PresentWaypoints { private val config get() = SkyHanniMod.feature.event.lobbyWaypoints.christmasPresent private var presentLocations = mapOf>() @@ -118,9 +120,8 @@ class PresentWaypoints { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("EventWaypoints") - presentLocations = loadEventWaypoints(data.presents ?: error("'presents' is null in EventWaypoints!")) - presentEntranceLocations = - loadEventWaypoints(data.presents_entrances ?: error("'presents_entrances' is null in EventWaypoints!")) + presentLocations = loadEventWaypoints(data.presents) + presentEntranceLocations = loadEventWaypoints(data.presentsEntrances) } private fun isEnabled(): Boolean = diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt index 1a8fde1001db..3b639c24aec4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/easter/EasterEggWaypoints.kt @@ -5,7 +5,8 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer import at.hannibal2.skyhanni.utils.LorenzColor @@ -13,7 +14,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class EasterEggWaypoints { +@SkyHanniModule +object EasterEggWaypoints { private val config get() = SkyHanniMod.feature.event.lobbyWaypoints.easterEgg private var closest: EasterEgg? = null @@ -37,13 +39,11 @@ class EasterEggWaypoints { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!config.allWaypoints && !config.allEntranceWaypoints) return if (!isEnabled()) return - if (event.repeatSeconds(1)) { - isEgg = checkScoreboardEasterSpecific() - } + isEgg = checkScoreboardEasterSpecific() if (isEgg) { if (config.onlyClosest) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt index da267da0752d..dd72238c3820 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/halloween/BasketWaypoints.kt @@ -6,7 +6,8 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer import at.hannibal2.skyhanni.utils.LorenzColor @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BasketWaypoints { +@SkyHanniModule +object BasketWaypoints { private val config get() = SkyHanniMod.feature.event.lobbyWaypoints.halloweenBasket private var closest: Basket? = null @@ -38,13 +40,11 @@ class BasketWaypoints { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!config.allWaypoints && !config.allEntranceWaypoints) return if (!isEnabled()) return - if (event.repeatSeconds(1)) { - isHalloween = checkScoreboardHalloweenSpecific() - } + isHalloween = checkScoreboardHalloweenSpecific() if (isHalloween) { if (config.onlyClosest) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt index d8ff05378984..200e01d78cde 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/spook/TheGreatSpook.kt @@ -2,14 +2,16 @@ package at.hannibal2.skyhanni.features.event.spook import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TabListData import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TheGreatSpook { +@SkyHanniModule +object TheGreatSpook { // §r§cPrimal Fears§r§7: §r§6§lREADY!! private val config get() = SkyHanniMod.feature.event.spook @@ -19,9 +21,8 @@ class TheGreatSpook { private var notificationSeconds = 0 @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (isAllDisabled()) return - if (!event.repeatSeconds(1)) return if (isTimerEnabled() || isNotificationEnabled()) displayTimer = checkTabList(" §r§cPrimal Fears§r§7: ") if (isFearStatEnabled()) displayFearStat = checkTabList(" §r§5Fear: ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt index fbefaa67d0db..1dd620a98dc1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/JyrreTimer.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack @@ -17,7 +18,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class JyrreTimer { +@SkyHanniModule +object JyrreTimer { private val config get() = SkyHanniMod.feature.event.winter.jyrreTimer private val drankBottlePattern by RepoPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt index 684fb3ba6450..47431f54bb40 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class NewYearCakeReminder { +@SkyHanniModule +object NewYearCakeReminder { private val config get() = SkyHanniMod.feature.event.winter private val sidebarDetectionPattern by RepoPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt index e743db8b3c8c..4a4ef95ec84d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt @@ -6,15 +6,17 @@ import at.hannibal2.skyhanni.data.WinterAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst +import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object UniqueGiftCounter { private val config get() = SkyHanniMod.feature.event.winter.uniqueGiftCounter diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt deleted file mode 100644 index b26a05094b4d..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt +++ /dev/null @@ -1,120 +0,0 @@ -package at.hannibal2.skyhanni.features.fame - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import kotlin.time.Duration -import kotlin.time.Duration.Companion.days -import kotlin.time.Duration.Companion.seconds - -class AccountUpgradeReminder { - - private var inInventory = false - private var duration: Duration? = null - private var lastReminderSend = SimpleTimeMark.farPast() - - // TODO: find a way to save SimpleTimeMark directly in the config - private var nextCompletionTime: SimpleTimeMark? - get() = ProfileStorageData.playerSpecific?.nextAccountUpgradeCompletionTime?.asTimeMark() - set(value) { - value?.let { - ProfileStorageData.playerSpecific?.nextAccountUpgradeCompletionTime = it.toMillis() - } - } - - // TODO: Merge this logic with CityProjectFeatures reminder to reduce duplication - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!LorenzUtils.inSkyBlock) return - - if (!isEnabled()) return - val playerSpecific = ProfileStorageData.playerSpecific ?: return - if (ReminderUtils.isBusy()) return - if (LorenzUtils.skyBlockArea == "Community Center") return - - val upgrade = playerSpecific.currentAccountUpgrade ?: return - val nextCompletionTime = nextCompletionTime ?: return - if (!nextCompletionTime.isInPast()) return - if (lastReminderSend.passedSince() < 30.seconds) return - lastReminderSend = SimpleTimeMark.now() - - ChatUtils.clickableChat( - "The §a$upgrade §eupgrade has completed! §c(Click to disable these reminders)", - onClick = { - disable() - }, - oneTimeClick = true - ) - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!LorenzUtils.inSkyBlock) return - inInventory = event.inventoryName == "Community Shop" - } - - @SubscribeEvent - @Suppress("UNUSED_PARAMETER") - fun onInventoryClose(event: InventoryCloseEvent) { - inInventory = false - } - - @SubscribeEvent - fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { - if (!inInventory) return - val clickedItemLore = event.slot?.stack?.getLore() ?: return - if (clickedItemLore.getOrNull(0) != "§8Account Upgrade") return - val result = clickedItemLore.firstNotNullOfOrNull { - durationRegex.matchEntire(it) - } ?: return - duration = result.groups[1]!!.value.toInt().days - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (claimedRegex.matches(event.message)) { - clearUpgrade() - } else { - val upgrade = startedRegex.matchEntire(event.message)?.groups?.get(1)?.value ?: return - startUpgrade(upgrade) - } - } - - private fun startUpgrade(upgrade: String) { - val duration = duration ?: return - val playerSpecific = ProfileStorageData.playerSpecific ?: return - playerSpecific.currentAccountUpgrade = upgrade - - nextCompletionTime = SimpleTimeMark.now() + duration - } - - private fun clearUpgrade() { - val playerSpecific = ProfileStorageData.playerSpecific ?: return - playerSpecific.currentAccountUpgrade = null - nextCompletionTime = SimpleTimeMark.farPast() - } - - companion object { - - private val durationRegex = "§8Duration: (\\d{1,3})d".toRegex() - private val startedRegex = "§eYou started the §r§a(.+) §r§eupgrade!".toRegex() - private val claimedRegex = "§eYou claimed the §r§a.+ §r§eupgrade!".toRegex() - - private fun isEnabled() = SkyHanniMod.feature.misc.accountUpgradeReminder - - fun disable() { - SkyHanniMod.feature.misc.accountUpgradeReminder = false - ChatUtils.chat("Disabled account upgrade reminder.") - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index 7b2ef9bce103..c707e2209bf6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems @@ -40,7 +41,10 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class CityProjectFeatures { +@SkyHanniModule +object CityProjectFeatures { + + private val config get() = SkyHanniMod.feature.event.cityProject private var display = emptyList>() private var inInventory = false @@ -56,13 +60,9 @@ class CityProjectFeatures { "§aProject is (?:being built|released)!" ) - companion object { - - private val config get() = SkyHanniMod.feature.event.cityProject - fun disable() { - config.dailyReminder = false - ChatUtils.chat("Disabled city project reminder messages!") - } + fun disable() { + config.dailyReminder = false + ChatUtils.chat("Disabled city project reminder messages!") } @SubscribeEvent @@ -73,8 +73,9 @@ class CityProjectFeatures { if (LorenzUtils.skyBlockArea == "Community Center") return - if (playerSpecific.nextCityProjectParticipationTime == 0L) return - if (System.currentTimeMillis() <= playerSpecific.nextCityProjectParticipationTime) return + playerSpecific.nextCityProjectParticipationTime.let { + if (it.isFarPast() || it.isInFuture()) return + } if (lastReminderSend.passedSince() < 30.seconds) return lastReminderSend = SimpleTimeMark.now() @@ -131,7 +132,7 @@ class CityProjectFeatures { if (item.name != "§eContribute this component!") continue nextTime = now } - ProfileStorageData.playerSpecific?.nextCityProjectParticipationTime = nextTime.toMillis() + ProfileStorageData.playerSpecific?.nextCityProjectParticipationTime = nextTime } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt new file mode 100644 index 000000000000..22171ed3bf53 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/UpgradeReminder.kt @@ -0,0 +1,199 @@ +package at.hannibal2.skyhanni.features.fame + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches +import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import com.google.gson.annotations.Expose +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + +@SkyHanniModule +object UpgradeReminder { + private val patternGroup = RepoPattern.group("fame.upgrades") + + private val accountUpgradePattern by patternGroup.pattern( + "account", + "§8Account Upgrade" + ) + private val profileUpgradePattern by patternGroup.pattern( + "profile", + "§8Profile Upgrade" + ) + private val upgradeDurationPattern by patternGroup.pattern( + "duration", + "§8Duration: (?.+)" + ) + private val upgradeStartedPattern by patternGroup.pattern( + "started", + "§eYou started the §r§a(?.+) §r§eupgrade!" + ) + private val upgradeClaimedPattern by patternGroup.pattern( + "claimed", + "§eYou claimed the §r§a(?.+) §r§eupgrade!" + ) + private val upgradePattern by patternGroup.pattern( + "upgrade", + "§eClick to start upgrade!" + ) + + private var currentProfileUpgrade: CommunityShopUpgrade? + get() = ProfileStorageData.profileSpecific?.communityShopProfileUpgrade + set(value) { + ProfileStorageData.profileSpecific?.communityShopProfileUpgrade = value + } + + private var currentAccountUpgrade: CommunityShopUpgrade? + get() = ProfileStorageData.playerSpecific?.communityShopAccountUpgrade + set(value) { + ProfileStorageData.playerSpecific?.communityShopAccountUpgrade = value + } + + private var inInventory = false + private var clickedUpgradeType: UpgradeType? = null + private var clickedUpgrade: CommunityShopUpgrade? = null + private var lastReminderSend = SimpleTimeMark.farPast() + + // TODO: (for 0.27) merge this logic with reminder manager + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!isEnabled()) return + if (ReminderUtils.isBusy()) return + if (inInventory || LorenzUtils.skyBlockArea == "Community Center") return + if (lastReminderSend.passedSince() < 30.seconds) return + + currentProfileUpgrade?.sendReminderIfClaimable() + currentAccountUpgrade?.sendReminderIfClaimable() + + lastReminderSend = SimpleTimeMark.now() + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (!LorenzUtils.inSkyBlock) return + inInventory = event.inventoryName == "Community Shop" + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!inInventory) return + val item = event.item ?: return + clickedUpgradeType = UpgradeType.fromItem(item) ?: return + clickedUpgrade = CommunityShopUpgrade.fromItem(item) ?: return + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock) return + if (upgradeStartedPattern.matches(event.message)) { + clickedUpgrade?.start() + when (clickedUpgradeType) { + UpgradeType.PROFILE -> currentProfileUpgrade = clickedUpgrade + UpgradeType.ACCOUNT -> currentAccountUpgrade = clickedUpgrade + null -> {} + } + return + } + + upgradeClaimedPattern.matchMatcher(event.message) { + val claimedUpgradeName = group("upgrade") + when (claimedUpgradeName) { + currentProfileUpgrade?.name -> currentProfileUpgrade = null + currentAccountUpgrade?.name -> currentAccountUpgrade = null + } + } + } + + private fun isEnabled() = SkyHanniMod.feature.misc.accountUpgradeReminder + + fun disable() { + SkyHanniMod.feature.misc.accountUpgradeReminder = false + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(49, + "#player.currentAccountUpgrade", + "#player.communityShopAccountUpgrade.name" + ) + + event.move(49, + "#player.nextAccountUpgradeCompletionTime", + "#player.communityShopAccountUpgrade.completionTime" + ) + } + + class CommunityShopUpgrade( + @Expose val name: String?, + @Expose var completionTime: SimpleTimeMark = SimpleTimeMark.farFuture() + ) { + private var duration: Duration = Duration.ZERO + + fun start() { + this.completionTime = SimpleTimeMark.now() + duration + } + + fun sendReminderIfClaimable() { + if (this.name == null || this.completionTime.isInFuture()) return + ChatUtils.clickableChat( + "The §a$name §eupgrade has completed! §c(Click to disable these reminders)", onClick = { + disable() + }, oneTimeClick = true + ) + } + + companion object { + fun fromItem(item: ItemStack): CommunityShopUpgrade? { + val name = item.displayName + val lore = item.getLore() + val upgrade = CommunityShopUpgrade(name) + upgrade.duration = lore.matchFirst(upgradeDurationPattern) { + val durationStr = group("duration") + if (durationStr == "Instant!") return null + TimeUtils.getDuration(durationStr) + } ?: Duration.ZERO + return upgrade + } + } + } + + enum class UpgradeType { + PROFILE, + ACCOUNT, + ; + + companion object { + fun fromItem(item: ItemStack): UpgradeType? { + val lore = item.getLore() + return when { + accountUpgradePattern.anyMatches(lore) -> ACCOUNT + profileUpgradePattern.anyMatches(lore) -> PROFILE + else -> null + } + } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt index 4ba88f1cd8fc..5f64aba8c2d1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,7 +15,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class ChumBucketHider { +@SkyHanniModule +object ChumBucketHider { private val config get() = SkyHanniMod.feature.fishing.chumBucketHider private val titleEntity = TimeLimitedSet(5.seconds) @@ -34,7 +36,7 @@ class ChumBucketHider { if (entity !is EntityArmorStand) return if (entity in hiddenEntities) { - event.isCanceled = true + event.cancel() return } @@ -45,7 +47,7 @@ class ChumBucketHider { if (name.contains(LorenzUtils.getPlayerName()) && !config.hideOwn.get()) return titleEntity.add(entity) hiddenEntities.add(entity) - event.isCanceled = true + event.cancel() return } @@ -55,7 +57,7 @@ class ChumBucketHider { for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { hiddenEntities.add(entity) - event.isCanceled = true + event.cancel() return } } @@ -67,7 +69,7 @@ class ChumBucketHider { for (title in titleEntity.toSet()) { if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { hiddenEntities.add(entity) - event.isCanceled = true + event.cancel() return } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt index 72a7cb13177d..f48309bb0fd5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingAPI.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.fishing +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson import at.hannibal2.skyhanni.events.FishingBobberCastEvent import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent @@ -7,9 +8,11 @@ import at.hannibal2.skyhanni.events.ItemInHandChangeEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -27,9 +30,9 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.projectile.EntityFishHook import net.minecraft.init.Blocks import net.minecraft.item.ItemStack -import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object FishingAPI { private val trophyArmorNames by RepoPattern.pattern( @@ -53,17 +56,15 @@ object FishingAPI { var wearingTrophyArmor = false - @SubscribeEvent - fun onJoinWorld(event: EntityJoinWorldEvent) { - if (!LorenzUtils.inSkyBlock || !holdingRod) return - val entity = event.entity ?: return - if (entity !is EntityFishHook) return - if (entity.angler != Minecraft.getMinecraft().thePlayer) return + @HandleEvent(onlyOnSkyblock = true) + fun onJoinWorld(event: EntityEnterWorldEvent) { + if (!holdingRod) return + if (event.entity.angler != Minecraft.getMinecraft().thePlayer) return lastCastTime = SimpleTimeMark.now() - bobber = entity + bobber = event.entity bobberHasTouchedWater = false - FishingBobberCastEvent(entity).postAndCatch() + FishingBobberCastEvent(event.entity).postAndCatch() } private fun resetBobber() { @@ -118,8 +119,8 @@ object FishingAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Items") - lavaRods = data.lava_fishing_rods - waterRods = data.water_fishing_rods + lavaRods = data.lavaFishingRods + waterRods = data.waterFishingRods } private fun getAllowedBlocks() = if (holdingLavaRod) lavaBlocks else waterBlocks diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt index 854165823f28..8f59a5eed304 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingBaitWarnings.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.FishingBobberCastEvent import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI.isBait +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.EntityUtils @@ -19,7 +20,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class FishingBaitWarnings { +@SkyHanniModule +object FishingBaitWarnings { private val config get() = SkyHanniMod.feature.fishing.fishingBaitWarnings diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt index 32e31edf09e8..b4a7e5804b4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingHookDisplay.kt @@ -1,22 +1,25 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.FishingBobberCastEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.entity.EntityEnterWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.event.entity.EntityJoinWorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class FishingHookDisplay { +@SkyHanniModule +object FishingHookDisplay { private val config get() = SkyHanniMod.feature.fishing.fishingHookDisplay private var armorStand: EntityArmorStand? = null - private val potentionArmorStands = mutableListOf() + private val potentialArmorStands = mutableListOf() private val pattern = "§e§l(\\d+(\\.\\d+)?)".toPattern() @SubscribeEvent @@ -34,7 +37,7 @@ class FishingHookDisplay { if (!isEnabled()) return if (armorStand == null) { - val filter = potentionArmorStands.filter { it.hasCustomName() && it.hasCorrectName() } + val filter = potentialArmorStands.filter { it.hasCustomName() && it.hasCorrectName() } if (filter.size == 1) { armorStand = filter[0] } @@ -42,17 +45,14 @@ class FishingHookDisplay { } private fun reset() { - potentionArmorStands.clear() + potentialArmorStands.clear() armorStand = null } - @SubscribeEvent - fun onJoinWorld(event: EntityJoinWorldEvent) { + @HandleEvent + fun onJoinWorld(event: EntityEnterWorldEvent) { if (!isEnabled()) return - val entity = event.entity ?: return - if (entity !is EntityArmorStand) return - - potentionArmorStands.add(entity) + potentialArmorStands.add(event.entity) } @SubscribeEvent @@ -61,7 +61,7 @@ class FishingHookDisplay { if (!config.hideArmorStand) return if (event.entity == armorStand) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt index f917db711a73..26470fd9e5a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/FishingTimer.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LocationUtils @@ -23,7 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class FishingTimer { +@SkyHanniModule +object FishingTimer { private val config get() = SkyHanniMod.feature.fishing.barnTimer private val barnLocation = LorenzVec(108, 89, -252) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt index 7fa6fcfcc2f9..74bc567c13db 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/IsFishingDetection.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.events.FishingBobberInWaterEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -13,6 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object IsFishingDetection { var isFishing = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt index e19593859d64..834f0c07f135 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt @@ -3,17 +3,22 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig +import at.hannibal2.skyhanni.data.mob.Mob import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.MobEvent import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth +import at.hannibal2.skyhanni.utils.MobUtils.mob import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeLimitedSet import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase @@ -21,35 +26,41 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class SeaCreatureFeatures { +@SkyHanniModule +object SeaCreatureFeatures { private val config get() = SkyHanniMod.feature.fishing.rareCatches private val damageIndicatorConfig get() = SkyHanniMod.feature.combat.damageIndicator - private var rareSeaCreatures = listOf() private var lastRareCatch = SimpleTimeMark.farPast() - private var armorStandIds = TimeLimitedSet(6.minutes) + private var rareSeaCreatures = TimeLimitedSet(6.minutes) + private var entityIds = TimeLimitedSet(6.minutes) // TODO remove spawn event, check per tick if can see, cache if already warned about @SubscribeEvent fun onMobSpawn(event: MobEvent.Spawn.SkyblockMob) { if (!isEnabled()) return - val creature = SeaCreatureManager.allFishingMobs[event.mob.name] ?: return + val mob = event.mob + val creature = SeaCreatureManager.allFishingMobs[mob.name] ?: return if (!creature.rare) return - if (config.highlight && !(damageIndicatorConfig.enabled && - DamageIndicatorConfig.BossCategory.SEA_CREATURES in damageIndicatorConfig.bossesToShow) - ) { - event.mob.highlight(LorenzColor.GREEN.toColor()) - rareSeaCreatures += event.mob.baseEntity + val entity = mob.baseEntity + val shouldNotify = entity.entityId !in entityIds + entityIds.addIfAbsent(entity.entityId) + rareSeaCreatures.add(mob) + + var shouldHighlight = config.highlight + if (damageIndicatorConfig.enabled && DamageIndicatorConfig.BossCategory.SEA_CREATURES in damageIndicatorConfig.bossesToShow) { + val seaCreaturesBosses = + BossType.entries.filter { it.bossTypeToggle == DamageIndicatorConfig.BossCategory.SEA_CREATURES } + if (seaCreaturesBosses.any { it.fullName.removeColor() == mob.name }) { + shouldHighlight = false + } } - val id = event.mob.armorStand?.entityId ?: return - if (armorStandIds.contains(id)) return - armorStandIds.add(id) + if (shouldHighlight) mob.highlight(LorenzColor.GREEN.toColor()) if (lastRareCatch.passedSince() < 1.seconds) return - if (event.mob.name == "Water Hydra" && event.mob.baseEntity.health == (event.mob.baseEntity.baseMaxHealth.toFloat() / 2)) return - - if (config.alertOtherCatches) { + if (mob.name == "Water Hydra" && entity.health == (entity.baseMaxHealth.toFloat() / 2)) return + if (config.alertOtherCatches && shouldNotify) { val text = if (config.creatureName) "${creature.displayName} NEARBY!" else "${creature.rarity.chatColorCode}RARE SEA CREATURE!" LorenzUtils.sendTitle(text, 1.5.seconds, 3.6, 7f) @@ -59,7 +70,7 @@ class SeaCreatureFeatures { @SubscribeEvent fun onMobDeSpawn(event: MobEvent.DeSpawn.SkyblockMob) { - rareSeaCreatures.filter { it != event.mob.baseEntity } + rareSeaCreatures.remove(event.mob) } @SubscribeEvent @@ -78,8 +89,8 @@ class SeaCreatureFeatures { @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - rareSeaCreatures = listOf() - armorStandIds.clear() + rareSeaCreatures.clear() + entityIds.clear() } @SubscribeEvent @@ -97,8 +108,10 @@ class SeaCreatureFeatures { private fun isEnabled() = LorenzUtils.inSkyBlock && !DungeonAPI.inDungeon() && !LorenzUtils.inKuudraFight private val getEntityOutlineColor: (entity: Entity) -> Int? = { entity -> - if (entity is EntityLivingBase && entity in rareSeaCreatures && entity.distanceToPlayer() < 30) { - LorenzColor.GREEN.toColor().rgb - } else null + (entity as? EntityLivingBase)?.mob?.let { mob -> + if (mob in rareSeaCreatures && entity.distanceToPlayer() < 30) { + LorenzColor.GREEN.toColor().rgb + } else null + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt index 59d9d818b240..b665cf7bc941 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureManager.kt @@ -5,13 +5,24 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.SeaCreatureJson import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SeaCreatureManager { +@SkyHanniModule +object SeaCreatureManager { private var doubleHook = false + private val seaCreatureMap = mutableMapOf() + var allFishingMobs = mapOf() + var allVariants = mapOf>() + + private val doubleHookMessages = setOf( + "§eIt's a §r§aDouble Hook§r§e! Woot woot!", + "§eIt's a §r§aDouble Hook§r§e!" + ) + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!LorenzUtils.inSkyBlock) return @@ -35,20 +46,20 @@ class SeaCreatureManager { allFishingMobs = emptyMap() var counter = 0 - val data = event.getConstant>("SeaCreatures", SeaCreatureJson.TYPE) + val data = event.getConstant>("SeaCreatures", SeaCreatureJson.TYPE) val allFishingMobs = mutableMapOf() val variants = mutableMapOf>() for ((variantName, variant) in data) { - val chatColor = variant.chat_color + val chatColor = variant.chatColor val variantFishes = mutableListOf() variants[variantName] = variantFishes - for ((name, seaCreature) in variant.sea_creatures) { - val chatMessage = seaCreature.chat_message - val fishingExperience = seaCreature.fishing_experience + for ((name, seaCreature) in variant.seaCreatures) { + val chatMessage = seaCreature.chatMessage + val fishingExperience = seaCreature.fishingExperience val rarity = seaCreature.rarity - val rare = seaCreature.rare ?: false + val rare = seaCreature.rare val creature = SeaCreature(name, fishingExperience, chatColor, rare, rarity) seaCreatureMap[chatMessage] = creature @@ -61,19 +72,7 @@ class SeaCreatureManager { allVariants = variants } - companion object { - - private val seaCreatureMap = mutableMapOf() - var allFishingMobs = mapOf() - var allVariants = mapOf>() - - private val doubleHookMessages = setOf( - "§eIt's a §r§aDouble Hook§r§e! Woot woot!", - "§eIt's a §r§aDouble Hook§r§e!" - ) - - fun getSeaCreatureFromMessage(message: String): SeaCreature? { - return seaCreatureMap.getOrDefault(message, null) - } + private fun getSeaCreatureFromMessage(message: String): SeaCreature? { + return seaCreatureMap.getOrDefault(message, null) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt index 72997fc6da51..ebb8879647af 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureMessageShortener.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SeaCreatureMessageShortener { +@SkyHanniModule +object SeaCreatureMessageShortener { private val config get() = SkyHanniMod.feature.fishing diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt index 6f63134db8ea..5904e1d7f61d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SharkFishCounter.kt @@ -5,13 +5,15 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SharkFishCounter { +@SkyHanniModule +object SharkFishCounter { private var counter = mutableListOf(0, 0, 0, 0) private var display = "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt index 7587e5536af7..f50cd9a6bb13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ShowFishingItemName.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI.isBait +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture @@ -17,7 +18,8 @@ import net.minecraft.entity.item.EntityItem import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds -class ShowFishingItemName { +@SkyHanniModule +object ShowFishingItemName { private val config get() = SkyHanniMod.feature.fishing.fishedItemName private var itemsOnGround = TimeLimitedCache(750.milliseconds) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt index a9fd806acd70..75d9430d4de4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.EntityUtils @@ -22,10 +23,11 @@ import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class ThunderSparksHighlight { +@SkyHanniModule +object ThunderSparksHighlight { private val config get() = SkyHanniMod.feature.fishing.thunderSpark - private val texture = + private const val TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTY0MzUwNDM3MjI1NiwKICAicHJvZmlsZUlkIiA6ICI2MzMyMDgwZTY3YTI0Y2MxYjE3ZGJhNzZmM2MwMGYxZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJUZWFtSHlkcmEiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2IzMzI4ZDNlOWQ3MTA0MjAzMjI1NTViMTcyMzkzMDdmMTIyNzBhZGY4MWJmNjNhZmM1MGZhYTA0YjVjMDZlMSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" private val sparks = mutableListOf() @@ -34,7 +36,7 @@ class ThunderSparksHighlight { if (!isEnabled()) return EntityUtils.getEntities().filter { - it !in sparks && it.hasSkullTexture(texture) + it !in sparks && it.hasSkullTexture(TEXTURE) }.forEach { sparks.add(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index c31e73f7d960..0410a04a91d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.EntityUtils @@ -15,12 +16,12 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sendTitle import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereWireframeInWorld import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.getLorenzVec @@ -31,7 +32,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -class TotemOfCorruption { +@SkyHanniModule +object TotemOfCorruption { private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption @@ -74,7 +76,7 @@ class TotemOfCorruption { for (totem in totems) { if (event.type == EnumParticleTypes.SPELL_WITCH && event.speed == 0.0f) { if (totem.location.distance(event.location) < 4.0) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt index c160033de2a0..a9dba3cc1d18 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -35,6 +36,7 @@ import kotlin.time.Duration.Companion.seconds typealias CategoryName = String +@SkyHanniModule object FishingProfitTracker { val config get() = SkyHanniMod.feature.fishing.fishingProfitTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt index ab9498b8c259..39b372c9baaf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI import at.hannibal2.skyhanni.features.fishing.SeaCreatureManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut @@ -15,15 +16,13 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.RegexUtils.matches -import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.allLettersFirstUppercase -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import at.hannibal2.skyhanni.utils.tracker.TrackerData import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object SeaCreatureTracker { private val config get() = SkyHanniMod.feature.fishing.seaCreatureTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt index 1138af3b8be7..24f52e0b24e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerIgnoreY import at.hannibal2.skyhanni.utils.LorenzUtils @@ -19,7 +20,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class GeyserFishing { +@SkyHanniModule +object GeyserFishing { private val config get() = SkyHanniMod.feature.fishing.trophyFishing.geyserOptions private val geyserOffset = LorenzVec(0.1f, 0.6f, 0.1f) @@ -70,7 +72,7 @@ class GeyserFishing { val geyser = geyser ?: return if (bobber.distanceTo(event.location) < 3 && bobber.distanceTo(geyser) < 3) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt index 8337e367d35f..7c0e9bb4a9e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/OdgerWaypoint.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class OdgerWaypoint { +@SkyHanniModule +object OdgerWaypoint { private val config get() = SkyHanniMod.feature.fishing.trophyFishing private val location = LorenzVec(-373, 207, -808) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt index 714efc7e3b59..d54f7cf48493 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishDisplay.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.fishing.trophyfishing.TrophyFishDisplayConfig.HideCaught import at.hannibal2.skyhanni.config.features.fishing.trophyfishing.TrophyFishDisplayConfig.TextPart import at.hannibal2.skyhanni.config.features.fishing.trophyfishing.TrophyFishDisplayConfig.TrophySorting @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.fishing.TrophyFishCaughtEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addSingleString import at.hannibal2.skyhanni.utils.CollectionUtils.addString @@ -39,6 +41,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object TrophyFishDisplay { private val config get() = SkyHanniMod.feature.fishing.trophyFishing.display @@ -56,7 +59,7 @@ object TrophyFishDisplay { } } - @SubscribeEvent + @HandleEvent fun onTrophyFishCaught(event: TrophyFishCaughtEvent) { recentlyDroppedTrophies[getInternalName(event.trophyFishName)] = event.rarity update() diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt index 5409062f5fac..e0aaa5719fe2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFilletValue +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard -class TrophyFishFillet { +@SkyHanniModule +object TrophyFishFillet { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt index 2d8a7cb0e37f..44893f949a22 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt @@ -2,10 +2,11 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.jsonobjects.repo.TrophyFishInfo import at.hannibal2.skyhanni.data.jsonobjects.repo.TrophyFishJson -import at.hannibal2.skyhanni.data.jsonobjects.repo.TrophyFishJson.TrophyFishInfo import at.hannibal2.skyhanni.events.NeuProfileDataLoadedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import net.minecraft.event.HoverEvent @@ -13,13 +14,14 @@ import net.minecraft.util.ChatComponentText import net.minecraft.util.ChatStyle import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TrophyFishManager { private val config get() = SkyHanniMod.feature.fishing.trophyFishing @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("TrophyFish") - trophyFishInfo = data.trophy_fish + trophyFishInfo = data.trophyFish } val fish: MutableMap>? @@ -85,15 +87,6 @@ object TrophyFishManager { fun getInfoByName(name: String) = trophyFishInfo.values.find { it.displayName == name } fun TrophyFishInfo.getFilletValue(rarity: TrophyRarity): Int { - if (fillet == null) { - ErrorManager.logErrorStateWithData( - "Error trying to read trophy fish info", - "fillet in TrophyFishInfo is null", - "displayName" to displayName, - "TrophyFishInfo" to this, - ) - return -1 - } return fillet.getOrDefault(rarity, -1) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt index d6cff8d69531..606f780417c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishMessages.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.features.fishing.trophyfishing.ChatMessagesC import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.fishing.TrophyFishCaughtEvent import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getTooltip +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sumAllValues import at.hannibal2.skyhanni.utils.ConfigUtils @@ -18,7 +19,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TrophyFishMessages { +@SkyHanniModule +object TrophyFishMessages { private val config get() = SkyHanniMod.feature.fishing.trophyFishing.chatMessages private val trophyFishPattern by RepoPattern.pattern( @@ -45,7 +47,7 @@ class TrophyFishMessages { val trophyFishes = TrophyFishManager.fish ?: return val trophyFishCounts = trophyFishes.getOrPut(internalName) { mutableMapOf() } val amount = trophyFishCounts.addOrPut(rarity, 1) - TrophyFishCaughtEvent(internalName, rarity).postAndCatch() + TrophyFishCaughtEvent(internalName, rarity).post() if (shouldBlockTrophyFish(rarity, amount)) { event.blockedReason = "low_trophy_fish" diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index d642140b9581..191dc125acc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.InventoryUtils @@ -25,15 +26,13 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AnitaMedalProfit { +@SkyHanniModule +object AnitaMedalProfit { private val config get() = GardenAPI.config.anitaShop private var display = emptyList() - companion object { - - var inInventory = false - } + var inInventory = false enum class MedalType(val displayName: String, val factorBronze: Int) { GOLD("§6Gold medal", 8), diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt index 80adc5658fbf..91911e140dab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SkyblockSeason import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AtmosphericFilterDisplay { +@SkyHanniModule +object AtmosphericFilterDisplay { private val config get() = SkyHanniMod.feature.garden.atmosphericFilterDisplay diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt index b7480f259af0..3a661161e134 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden +import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems import net.minecraft.block.state.IBlockState import net.minecraft.init.Blocks import net.minecraft.init.Items @@ -13,48 +14,49 @@ enum class CropType( val baseDrops: Double, iconSupplier: () -> ItemStack, val simpleName: String, + val farmingItem: FarmingItems, val replenish: Boolean = false, ) { WHEAT( "Wheat", "THEORETICAL_HOE_WHEAT", "CROPIE", 1.0, - { ItemStack(Items.wheat) }, "wheat" + { ItemStack(Items.wheat) }, "wheat", FarmingItems.WHEAT ), CARROT( "Carrot", "THEORETICAL_HOE_CARROT", "CROPIE", 3.0, - { ItemStack(Items.carrot) }, "carrot", replenish = true + { ItemStack(Items.carrot) }, "carrot", FarmingItems.CARROT, replenish = true ), POTATO( "Potato", "THEORETICAL_HOE_POTATO", "CROPIE", 3.0, - { ItemStack(Items.potato) }, "potato", replenish = true + { ItemStack(Items.potato) }, "potato", FarmingItems.POTATO, replenish = true ), NETHER_WART( "Nether Wart", "THEORETICAL_HOE_WARTS", "FERMENTO", 2.5, - { ItemStack(Items.nether_wart) }, "wart", replenish = true + { ItemStack(Items.nether_wart) }, "wart", FarmingItems.NETHER_WART, replenish = true ), PUMPKIN( "Pumpkin", "PUMPKIN_DICER", "SQUASH", 1.0, - { ItemStack(Blocks.pumpkin) }, "pumpkin" + { ItemStack(Blocks.pumpkin) }, "pumpkin", FarmingItems.PUMPKIN ), MELON( "Melon", "MELON_DICER", "SQUASH", 5.0, - { ItemStack(Items.melon) }, "melon" + { ItemStack(Items.melon) }, "melon", FarmingItems.MELON ), COCOA_BEANS( "Cocoa Beans", "COCO_CHOPPER", "SQUASH", 3.0, - { ItemStack(Items.dye, 1, EnumDyeColor.BROWN.dyeDamage) }, "cocoa", replenish = true + { ItemStack(Items.dye, 1, EnumDyeColor.BROWN.dyeDamage) }, "cocoa", FarmingItems.COCOA_BEANS, replenish = true ), SUGAR_CANE( "Sugar Cane", "THEORETICAL_HOE_CANE", "FERMENTO", 2.0, - { ItemStack(Items.reeds) }, "cane" + { ItemStack(Items.reeds) }, "cane", FarmingItems.SUGAR_CANE ), CACTUS( "Cactus", "CACTUS_KNIFE", "FERMENTO", 2.0, - { ItemStack(Blocks.cactus) }, "cactus" + { ItemStack(Blocks.cactus) }, "cactus", FarmingItems.CACTUS ), MUSHROOM( "Mushroom", "FUNGI_CUTTER", "FERMENTO", 1.0, - { ItemStack(Blocks.red_mushroom_block) }, "mushroom" + { ItemStack(Blocks.red_mushroom_block) }, "mushroom", FarmingItems.MUSHROOM ), ; @@ -64,6 +66,9 @@ enum class CropType( override fun toString(): String = cropName + val patternKeyName = name.lowercase().replace('_', '.') + val niceName = name.lowercase().replace('_', ' ') + companion object { fun getByNameOrNull(itemName: String): CropType? { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 0d75c932501c..9a24fec891be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop import at.hannibal2.skyhanni.features.garden.pests.PestAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.HypixelCommands @@ -36,6 +37,7 @@ import kotlin.math.log10 import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object FarmingFortuneDisplay { private val config get() = GardenAPI.config.farmingFortunes @@ -345,7 +347,8 @@ object FarmingFortuneDisplay { // TODO code cleanup (after ff rework) - for (line in tool?.getLore()!!) { + val lore = tool?.getLore() ?: return + for (line in lore) { tooltipFortunePattern.matchMatcher(line) { displayedFortune = group("display")?.toDouble() ?: 0.0 reforgeFortune = groupOrNull("reforge")?.toDouble() ?: 0.0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index b6ae8f105e8e..d648acc297e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData @@ -12,8 +13,8 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats import at.hannibal2.skyhanni.features.garden.CropType.Companion.getCropType import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay @@ -26,6 +27,7 @@ import at.hannibal2.skyhanni.features.garden.inventory.SkyMartCopperPrice import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateShopPrice +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack @@ -51,6 +53,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GardenAPI { var toolInHand: String? = null @@ -86,9 +89,8 @@ object GardenAPI { "BINGHOE" ) - @SubscribeEvent - fun onSendPacket(event: PacketEvent.SendEvent) { - if (!inGarden()) return + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onSendPacket(event: PacketSentEvent) { if (event.packet !is C09PacketHeldItemChange) return checkItemInHand() } @@ -273,7 +275,7 @@ object GardenAPI { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - gardenExperience = data.garden_exp + gardenExperience = data.gardenExp totalAmountVisitorsExisting = data.visitors.size } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index d42bf57314cb..b154a72e0219 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay import at.hannibal2.skyhanni.features.garden.pests.PestAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.NEUInternalName @@ -19,7 +20,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenCropMilestoneFix { +@SkyHanniModule +object GardenCropMilestoneFix { private val patternGroup = RepoPattern.group("garden.cropmilestone.fix") /** @@ -60,24 +62,24 @@ class GardenCropMilestoneFix { val amount = group("amount").toInt() val item = NEUInternalName.fromItemNameOrNull(group("item")) ?: return - val multiplier = NEUItems.getMultiplier(item) - val rawName = multiplier.first.itemNameWithoutColor + val primitiveStack = NEUItems.getPrimitiveMultiplier(item) + val rawName = primitiveStack.internalName.itemNameWithoutColor val cropType = CropType.getByNameOrNull(rawName) ?: return cropType.setCounter( - cropType.getCounter() + (amount * multiplier.second) + cropType.getCounter() + (amount * primitiveStack.amount) ) GardenCropMilestoneDisplay.update() } pestRareDropPattern.matchMatcher(event.message) { val item = NEUInternalName.fromItemNameOrNull(group("item")) ?: return - val multiplier = NEUItems.getMultiplier(item) - val rawName = multiplier.first.itemNameWithoutColor + val primitiveStack = NEUItems.getPrimitiveMultiplier(item) + val rawName = primitiveStack.internalName.itemNameWithoutColor val cropType = CropType.getByNameOrNull(rawName) ?: return cropType.setCounter( - cropType.getCounter() + multiplier.second + cropType.getCounter() + primitiveStack.amount ) GardenCropMilestoneDisplay.update() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt index 74269c52dd35..6423e00aeff8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropTimeCommand.kt @@ -41,7 +41,7 @@ object GardenCropTimeCommand { val internalName = entry.key val itemName = internalName.itemName if (itemName.removeColor().lowercase().contains(searchName)) { - val (baseId, baseAmount) = NEUItems.getMultiplier(internalName) + val (baseId, baseAmount) = NEUItems.getPrimitiveMultiplier(internalName) val baseName = baseId.itemName val crop = CropType.getByName(baseName.removeColor()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt index 8523a7a58288..11e307e88f1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropsInCommand.kt @@ -46,7 +46,7 @@ object GardenCropsInCommand { val internalName = entry.key val itemName = internalName.itemName if (itemName.removeColor().lowercase().contains(searchName)) { - val (baseId, baseAmount) = NEUItems.getMultiplier(internalName) + val (baseId, baseAmount) = NEUItems.getPrimitiveMultiplier(internalName) val baseName = baseId.itemName val crop = CropType.getByName(baseName.removeColor()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index 7bdf46dd0e6f..1067312de45b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -31,7 +32,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds -class GardenLevelDisplay { +@SkyHanniModule +object GardenLevelDisplay { private val config get() = GardenAPI.config.gardenLevels private var useRomanNumerals: Boolean diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 9778eebe33a4..35af817c6e7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ChatUtils @@ -22,7 +23,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -54,6 +54,7 @@ import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GardenNextJacobContest { private var dispatcher = Dispatchers.IO diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt index fcd7fcf9f970..1af272051633 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenOptimalSpeed.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -22,7 +23,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class GardenOptimalSpeed { +@SkyHanniModule +object GardenOptimalSpeed { private val config get() = GardenAPI.config.optimalSpeeds diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt index ab74b92d6ea4..44adceb6d584 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.garden.pests.SprayType import at.hannibal2.skyhanni.features.misc.LockMouseLook +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -23,6 +24,7 @@ import kotlin.math.floor import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object GardenPlotAPI { private val patternGroup = RepoPattern.group("garden.plot") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt index 5fbebd263af7..9be28436815d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenPlotBorders.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -10,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard import kotlin.time.Duration.Companion.milliseconds +@SkyHanniModule object GardenPlotBorders { private val config get() = GardenAPI.config.plotBorders diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt index 54804cf06849..889ed23e6057 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenWarpCommands.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.features.misc.LockMouseLook +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.NEUItems @@ -13,7 +14,8 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GardenWarpCommands { +@SkyHanniModule +object GardenWarpCommands { private val config get() = GardenAPI.config.gardenCommands @@ -32,19 +34,19 @@ class GardenWarpCommands { val message = event.message.lowercase() if (message == "/home") { - event.isCanceled = true + event.cancel() HypixelCommands.warp("garden") ChatUtils.chat("§aTeleported you to the spawn location!", prefix = false) } if (message == "/barn") { - event.isCanceled = true + event.cancel() HypixelCommands.teleportToPlot("barn") LockMouseLook.autoDisable() } tpPlotPattern.matchMatcher(event.message) { - event.isCanceled = true + event.cancel() val plotName = group("plot") HypixelCommands.teleportToPlot(plotName) LockMouseLook.autoDisable() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt index 32f4cafdf317..ebc266692430 100755 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenYawAndPitch.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings @@ -12,7 +13,8 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GardenYawAndPitch { +@SkyHanniModule +object GardenYawAndPitch { private val config get() = GardenAPI.config.yawPitchDisplay private var lastChange = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/SensitivityReducer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/SensitivityReducer.kt index b7027beb05e8..ceec04aa0f20 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/SensitivityReducer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/SensitivityReducer.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.HypixelJoinEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.misc.LockMouseLook +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld @@ -18,6 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.abs import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object SensitivityReducer { private val config get() = SkyHanniMod.feature.garden.sensitivityReducerConfig private val storage get() = SkyHanniMod.feature.storage diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt index 8bd3a1decf40..8700e49425be 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/ToolTooltipTweaks.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getAbilityFortune import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,15 +20,17 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.text.DecimalFormat import kotlin.math.roundToInt -class ToolTooltipTweaks { +@SkyHanniModule +object ToolTooltipTweaks { private val config get() = GardenAPI.config.tooltipTweak + private val tooltipFortunePattern = "^§5§o§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))?$".toRegex() private val counterStartLine = setOf("§5§o§6Logarithmic Counter", "§5§o§6Collection Analysis") private val reforgeEndLine = setOf("§5§o", "§5§o§7chance for multiple crops.") - private val abilityDescriptionStart = "§5§o§7These boots gain §a+2❈ Defense" - private val abilityDescriptionEnd = "§5§o§7Skill level." + private const val ABILITY_DESCRIPTION_START = "§5§o§7These boots gain §a+2❈ Defense" + private const val ABILITY_DESCRIPTION_END = "§5§o§7Skill level." private val statFormatter = DecimalFormat("0.##") @@ -132,12 +135,12 @@ class ToolTooltipTweaks { iterator.remove() } - if (line == abilityDescriptionStart) { + if (line == ABILITY_DESCRIPTION_START) { removingAbilityDescription = true } if (removingAbilityDescription) { iterator.remove() - if (line == abilityDescriptionEnd) { + if (line == ABILITY_DESCRIPTION_END) { removingAbilityDescription = false } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index 3beb8e9c8437..a9977f8091ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.HypixelCommands @@ -16,14 +17,17 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.Collections import kotlin.time.Duration +import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class ComposterDisplay { +@SkyHanniModule +object ComposterDisplay { private val config get() = GardenAPI.config.composters private val storage get() = GardenAPI.storage @@ -48,8 +52,6 @@ class ComposterDisplay { } } - private val BUCKET by lazy { "BUCKET".asInternalName().getItemStack() } - @SubscribeEvent fun onTabListUpdate(event: TabListUpdateEvent) { if (!(config.displayEnabled && GardenAPI.inGarden())) return @@ -84,7 +86,7 @@ class ComposterDisplay { private fun addComposterEmptyTime(emptyTime: Duration?): List { return if (emptyTime != null) { - GardenAPI.storage?.composterEmptyTime = System.currentTimeMillis() + emptyTime.inWholeMilliseconds + GardenAPI.storage?.composterEmptyTime = emptyTime.fromNow() val format = emptyTime.format() listOf(bucket, "§b$format") } else { @@ -127,22 +129,21 @@ class ComposterDisplay { val storage = storage ?: return - if (ComposterAPI.getOrganicMatter() <= config.notifyLow.organicMatter && System.currentTimeMillis() >= storage.informedAboutLowMatter) { + if (ComposterAPI.getOrganicMatter() <= config.notifyLow.organicMatter && storage.informedAboutLowMatter.isInPast()) { if (config.notifyLow.title) { LorenzUtils.sendTitle("§cYour Organic Matter is low", 4.seconds) } ChatUtils.chat("§cYour Organic Matter is low!") - storage.informedAboutLowMatter = System.currentTimeMillis() + 60_000 * 5 + storage.informedAboutLowMatter = 5.0.minutes.fromNow() } - if (ComposterAPI.getFuel() <= config.notifyLow.fuel && - System.currentTimeMillis() >= storage.informedAboutLowFuel + if (ComposterAPI.getFuel() <= config.notifyLow.fuel && storage.informedAboutLowFuel.isInPast() ) { if (config.notifyLow.title) { LorenzUtils.sendTitle("§cYour Fuel is low", 4.seconds) } ChatUtils.chat("§cYour Fuel is low!") - storage.informedAboutLowFuel = System.currentTimeMillis() + 60_000 * 5 + storage.informedAboutLowFuel = 5.0.minutes.fromNow() } } @@ -159,13 +160,13 @@ class ComposterDisplay { private fun checkWarningsAndOutsideGarden() { val format = GardenAPI.storage?.let { - if (it.composterEmptyTime != 0L) { - val duration = it.composterEmptyTime - System.currentTimeMillis() - if (duration > 0) { - if (duration < 1000 * 60 * 20) { + if (!it.composterEmptyTime.isFarPast()) { + val duration = it.composterEmptyTime.timeUntil() + if (duration > 0.0.seconds) { + if (duration < 20.0.minutes) { warn("Your composter in the garden is almost empty!") } - TimeUtils.formatDuration(duration, maxUnits = 3) + duration.format(maxUnits = 3) } else { warn("Your composter is empty!") "§cComposter is empty!" @@ -187,8 +188,8 @@ class ComposterDisplay { if (ReminderUtils.isBusy()) return - if (System.currentTimeMillis() < storage.lastComposterEmptyWarningTime + 1000 * 60 * 2) return - storage.lastComposterEmptyWarningTime = System.currentTimeMillis() + if (storage.lastComposterEmptyWarningTime.passedSince() >= 2.0.minutes) return + storage.lastComposterEmptyWarningTime = SimpleTimeMark.now() if (IslandType.GARDEN.isInIsland()) { ChatUtils.chat(warningMessage) } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt index 0eaa6c73be44..352c7137ee39 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.composter import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -12,7 +13,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ComposterInventoryNumbers { +@SkyHanniModule +object ComposterInventoryNumbers { private val patternGroup = RepoPattern.group("garden.composter.inventory.numbers") private val valuePattern by patternGroup.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index b1ca52b98549..b198b3e3aabf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.composter.ComposterAPI.getLevel import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -55,6 +56,7 @@ import kotlin.math.floor import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds +@SkyHanniModule object ComposterOverlay { private var organicMatterFactors: Map = emptyMap() @@ -548,7 +550,7 @@ object ComposterOverlay { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - organicMatter = data.organic_matter + organicMatter = data.organicMatter fuelFactors = data.fuel updateOrganicMatterFactors() } @@ -577,7 +579,7 @@ object ComposterOverlay { || internalName == "SIMPLE_CARROT_CANDY" ) continue - var (newId, amount) = NEUItems.getMultiplier(internalName.asInternalName()) + var (newId, amount) = NEUItems.getPrimitiveMultiplier(internalName.asInternalName()) if (amount <= 9) continue if (internalName == "ENCHANTED_HUGE_MUSHROOM_1" || internalName == "ENCHANTED_HUGE_MUSHROOM_2") { // 160 * 8 * 4 is 5120 and not 5184, but hypixel made an error, so we have to copy the error diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt index bffd6ac17d39..99fb3f147953 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems @@ -19,7 +20,8 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenComposterInventoryFeatures { +@SkyHanniModule +object GardenComposterInventoryFeatures { private val config get() = GardenAPI.config.composters diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt index 9ec067a30949..204c0202208e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingContestAPI.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -24,6 +25,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object FarmingContestAPI { private val patternGroup = RepoPattern.group("garden.farming.contest") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt index 1027234f7c4c..fa57dbe600d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestFFNeededDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getLatestTrueFarmingFortune import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getLatestBlocksPerSecond +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -20,7 +21,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.ceil import kotlin.time.Duration.Companion.milliseconds -class JacobContestFFNeededDisplay { +@SkyHanniModule +object JacobContestFFNeededDisplay { private val config get() = GardenAPI.config private var display = emptyList>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt index 99be1d561ddf..3d4fef9a3c66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.FarmingContestEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class JacobContestStatsSummary { +@SkyHanniModule +object JacobContestStatsSummary { private val config get() = GardenAPI.config private var blocksBroken = 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt index bc9f551366e1..b3fd91d32a8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestTimeNeeded.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay.getLatestTrueFarmingFortune import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getLatestBlocksPerSecond +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.LorenzUtils @@ -22,7 +23,8 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class JacobContestTimeNeeded { +@SkyHanniModule +object JacobContestTimeNeeded { private val config get() = GardenAPI.config private var display = emptyList>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt index a26082e25590..3cbf7d4f89e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobFarmingContestsInventory.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems @@ -31,7 +32,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.text.SimpleDateFormat import java.util.Locale -class JacobFarmingContestsInventory { +@SkyHanniModule +object JacobFarmingContestsInventory { private val realTime = mutableMapOf() @@ -93,12 +95,12 @@ class JacobFarmingContestsInventory { "Your Contests" -> { val (year, month, day) = FarmingContestAPI.getSbDateFromItemName(itemName) ?: return openContest(year, month, day) - event.isCanceled = true + event.cancel() } "Jacob's Farming Contests" -> { openFromJacobMenu(itemName) - event.isCanceled = true + event.cancel() } else -> { @@ -154,7 +156,7 @@ class JacobFarmingContestsInventory { OSUtils.openBrowser("https://elitebot.dev/contests/upcoming#$timestamp") ChatUtils.chat("Opening upcoming contests in elitebot.dev") } - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt index 4e990d412aa1..b55ed769dda8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt @@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropInfo import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropsJson -import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropsJson.DropInfo import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -27,6 +28,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ArmorDropTracker { private val config get() = GardenAPI.config.farmingArmorDrop @@ -124,10 +126,10 @@ object ArmorDropTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("ArmorDrops") - armorDropInfo = data.special_crops + armorDropInfo = data.specialCrops } - private var armorDropInfo = mapOf() + private var armorDropInfo = mapOf() private var currentArmorDropChance = 0.0 private var lastCalculationTime = SimpleTimeMark.farPast() @@ -138,7 +140,7 @@ object ArmorDropTracker { lastCalculationTime = SimpleTimeMark.now() val armorDropName = crop.specialDropType - val armorName = armorDropInfo[armorDropName]?.armor_type ?: return 0.0 + val armorName = armorDropInfo[armorDropName]?.armorType ?: return 0.0 val pieceCount = InventoryUtils.getArmor() .mapNotNull { it?.getInternalName()?.asString() } .count { it.contains(armorName) || it.contains("FERMENTO") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 3f796c47d081..b149dedad1fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -13,9 +13,10 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.isBazaarItem +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.isBazaarItem import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarData +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -40,6 +41,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object CropMoneyDisplay { var multipliers = mapOf() @@ -158,7 +160,7 @@ object CropMoneyDisplay { } val bazaarData = internalName.getBazaarData() val price = - if (LorenzUtils.noTradeMode || bazaarData == null) internalName.getNpcPrice() / 160 else (bazaarData.sellPrice + bazaarData.buyPrice) / 320 + if (LorenzUtils.noTradeMode || bazaarData == null) internalName.getNpcPrice() / 160 else (bazaarData.instantBuyPrice + bazaarData.sellOfferPrice) / 320 extraDicerCoins = 60 * 60 * GardenCropSpeed.getRecentBPS() * dicerDrops * price } @@ -341,8 +343,8 @@ object CropMoneyDisplay { val bazaarData = internalName.getBazaarData() ?: continue var npcPrice = internalName.getNpcPrice() * cropsPerHour - var sellOffer = bazaarData.buyPrice * cropsPerHour - var instantSell = bazaarData.sellPrice * cropsPerHour + var sellOffer = bazaarData.sellOfferPrice * cropsPerHour + var instantSell = bazaarData.instantBuyPrice * cropsPerHour if (debug) { debugList.addAsSingletonList(" npcPrice: ${npcPrice.addSeparators()}") debugList.addAsSingletonList(" sellOffer: ${sellOffer.addSeparators()}") @@ -359,10 +361,10 @@ object CropMoneyDisplay { if (debug) { debugList.addAsSingletonList(" added seedsPerHour: $seedsPerHour") } - val factor = NEUItems.getMultiplier(internalName).second + val factor = NEUItems.getPrimitiveMultiplier(internalName).amount npcPrice += "SEEDS".asInternalName().getNpcPrice() * seedsPerHour / factor - sellOffer += it.buyPrice * seedsPerHour - instantSell += it.sellPrice * seedsPerHour + sellOffer += it.sellOfferPrice * seedsPerHour + instantSell += it.instantBuyPrice * seedsPerHour } } } @@ -419,7 +421,7 @@ object CropMoneyDisplay { val internalName = rawInternalName.asInternalName() if (!internalName.isBazaarItem()) continue - val (newId, amount) = NEUItems.getMultiplier(internalName) + val (newId, amount) = NEUItems.getPrimitiveMultiplier(internalName) val itemName = newId.itemNameWithoutColor val crop = getByNameOrNull(itemName) crop?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt index 710862f90d14..aa977b65a575 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropSpeedMeter.kt @@ -7,19 +7,24 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CropSpeedMeter { +@SkyHanniModule +object CropSpeedMeter { private var display = emptyList() private var currentCrop: CropType? = null private var currentBlocks = 0 private var snapshot = emptyList() + var enabled = false + private var startCrops = mapOf() + @SubscribeEvent fun onCropClick(event: CropClickEvent) { if (!isEnabled()) return @@ -98,7 +103,6 @@ class CropSpeedMeter { val baseDrops = it.baseDrops val farmingFortune = (cropsPerBlocks * 100 / baseDrops).round(3) - list.add(" §7Calculated farming Fortune: §e" + farmingFortune.addSeparators()) list.add("§cOpen /cropmilestones again to recalculate!") @@ -112,16 +116,10 @@ class CropSpeedMeter { currentBlocks++ } - companion object { - - var enabled = false - private var startCrops = mapOf() - - fun toggle() { - enabled = !enabled - ChatUtils.chat("Crop Speed Meter " + if (enabled) "§aEnabled" else "§cDisabled") - startCrops = emptyMap() - } + fun toggle() { + enabled = !enabled + ChatUtils.chat("Crop Speed Meter " + if (enabled) "§aEnabled" else "§cDisabled") + startCrops = emptyMap() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt index 63b3e9615164..90e4da6bffbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -22,6 +23,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern +@SkyHanniModule object DicerRngDropTracker { private val itemDrops = mutableListOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index 6f8523c34d56..0aac3e747a47 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -192,8 +192,9 @@ class FarmingWeightDisplay { list.add( Renderable.clickAndHover( "§6Farming Weight§7: $weight$leaderboard", - listOf("§eClick to open your Farming Profile."), - onClick = { openWebsite(LorenzUtils.getPlayerName()) } + listOf("§eClick to open your Farming Profile."), onClick = { + openWebsite(LorenzUtils.getPlayerName()) + } ) ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt index b1c2a3b82afa..2412c75963c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBestCropTime.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.ConfigUtils @@ -18,41 +19,39 @@ import at.hannibal2.skyhanni.utils.TimeUnit import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenBestCropTime { +@SkyHanniModule +object GardenBestCropTime { var display = emptyList>() - companion object { + private val config get() = GardenAPI.config.cropMilestones + val timeTillNextCrop = mutableMapOf() - private val config get() = GardenAPI.config.cropMilestones - val timeTillNextCrop = mutableMapOf() - - fun reset() { - timeTillNextCrop.clear() - updateTimeTillNextCrop() - } + fun reset() { + timeTillNextCrop.clear() + updateTimeTillNextCrop() + } - fun updateTimeTillNextCrop() { - val useOverflow = config.overflow.bestCropTime - for (crop in CropType.entries) { - val speed = crop.getSpeed() ?: continue - if (crop.isMaxed(useOverflow)) continue + fun updateTimeTillNextCrop() { + val useOverflow = config.overflow.bestCropTime + for (crop in CropType.entries) { + val speed = crop.getSpeed() ?: continue + if (crop.isMaxed(useOverflow)) continue - val counter = crop.getCounter() - val currentTier = GardenCropMilestones.getTierForCropCount(counter, crop, allowOverflow = true) + val counter = crop.getCounter() + val currentTier = GardenCropMilestones.getTierForCropCount(counter, crop, allowOverflow = true) - val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier, crop) - val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 - val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier, crop) + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier, crop) + val nextTier = if (config.bestShowMaxedNeeded.get()) 46 else currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier, crop) - val have = counter - cropsForCurrentTier - val need = cropsForNextTier - cropsForCurrentTier + val have = counter - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier - val missing = need - have - val missingTimeSeconds = missing / speed - val millis = missingTimeSeconds * 1000 - timeTillNextCrop[crop] = millis - } + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[crop] = millis } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt index 33036b52a398..854e409633e3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenBurrowingSporesNotifier.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GardenBurrowingSporesNotifier { +@SkyHanniModule +object GardenBurrowingSporesNotifier { @SubscribeEvent fun onChat(event: LorenzChatEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index 5b50a29ff230..f782b1b37a0f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIconRenderable import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.setSpeed +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -39,6 +40,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GardenCropMilestoneDisplay { private var progressDisplay = emptyList() @@ -47,7 +49,6 @@ object GardenCropMilestoneDisplay { private val config get() = GardenAPI.config.cropMilestones private val overflowConfig get() = config.overflow private val storage get() = ProfileStorageData.profileSpecific?.garden?.customGoalMilestone - private val bestCropTime = GardenBestCropTime() private var lastPlaySoundTime = SimpleTimeMark.farPast() private var needsInventory = false @@ -85,7 +86,7 @@ object GardenCropMilestoneDisplay { } if (config.next.bestDisplay) { - config.next.displayPos.renderStringsAndItems(bestCropTime.display, posLabel = "Best Crop Time") + config.next.displayPos.renderStringsAndItems(GardenBestCropTime.display, posLabel = "Best Crop Time") } } @@ -136,14 +137,14 @@ object GardenCropMilestoneDisplay { fun update() { progressDisplay = emptyList() mushroomCowPerkDisplay = emptyList() - bestCropTime.display = emptyList() + GardenBestCropTime.display = emptyList() val currentCrop = GardenAPI.getCurrentlyFarmedCrop() currentCrop?.let { progressDisplay = drawProgressDisplay(it) } if (config.next.bestDisplay && config.next.bestAlwaysOn || currentCrop != null) { - bestCropTime.display = bestCropTime.drawBestDisplay(currentCrop) + GardenBestCropTime.display = GardenBestCropTime.drawBestDisplay(currentCrop) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 72e73ee2d7f2..f4d9542293e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -6,13 +6,14 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.setCounter import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.jsonobjects.repo.DicerDropsJson -import at.hannibal2.skyhanni.data.jsonobjects.repo.DicerDropsJson.DicerType +import at.hannibal2.skyhanni.data.jsonobjects.repo.DicerType import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -20,6 +21,7 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer +@SkyHanniModule object GardenCropSpeed { private val config get() = GardenAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt index aa59a604d5b2..529414a4eaba 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCustomKeybinds.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorKeyBinding +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -17,6 +18,7 @@ import java.util.IdentityHashMap import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GardenCustomKeybinds { private val config get() = GardenAPI.config.keyBind diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt index 9188b66eb58c..54e74c87a976 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LocationUtils @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenStartLocation { private val config get() = GardenAPI.config.cropStartLocation diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt index 75c9f5e2714b..34b4191d4e46 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WildStrawberryDyeNotification.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.farming import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.OwnInventoryItemUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemBlink import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class WildStrawberryDyeNotification { +@SkyHanniModule +object WildStrawberryDyeNotification { private var lastCloseTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt index 73c8d9a1a965..9bc0fc051f36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/WrongFungiCutterWarning.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFungiCutterMode import at.hannibal2.skyhanni.utils.SoundUtils @@ -13,7 +14,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class WrongFungiCutterWarning { +@SkyHanniModule +object WrongFungiCutterWarning { private var mode = FungiMode.UNKNOWN private var lastPlaySoundTime = 0L diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneAPI.kt index 92ba29550895..0a29c85ecd73 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneAPI.kt @@ -2,15 +2,17 @@ package at.hannibal2.skyhanni.features.garden.farming.lane import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent -import at.hannibal2.skyhanni.events.farming.FarmingLaneSwitchEvent +import at.hannibal2.skyhanni.events.garden.farming.FarmingLaneSwitchEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object FarmingLaneAPI { val config get() = GardenAPI.config.farmingLane @@ -36,7 +38,7 @@ object FarmingLaneAPI { if (currentLane == lane) return currentLane = lane - FarmingLaneSwitchEvent(lane).postAndCatch() + FarmingLaneSwitchEvent(lane).post() } private fun warnNoLane(crop: CropType?) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneCreator.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneCreator.kt index f555d4048aa9..77a7a37253df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneCreator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneCreator.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneAPI.getValue +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LocationUtils @@ -16,6 +17,7 @@ import kotlin.math.absoluteValue import kotlin.math.max import kotlin.math.min +@SkyHanniModule object FarmingLaneCreator { val config get() = FarmingLaneAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt index 15fcc42c6853..59a9f5e7be9c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/lane/FarmingLaneFeatures.kt @@ -1,14 +1,16 @@ package at.hannibal2.skyhanni.features.garden.farming.lane +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.farming.FarmingLaneSwitchEvent +import at.hannibal2.skyhanni.events.garden.farming.FarmingLaneSwitchEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneAPI.getValue import at.hannibal2.skyhanni.features.garden.farming.lane.FarmingLaneAPI.setValue import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzColor @@ -27,6 +29,7 @@ import kotlin.math.absoluteValue import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object FarmingLaneFeatures { val config get() = FarmingLaneAPI.config @@ -49,7 +52,7 @@ object FarmingLaneFeatures { ; } - @SubscribeEvent + @HandleEvent fun onFarmingLaneSwitch(event: FarmingLaneSwitchEvent) { display = emptyList() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 55e7567803c9..80f77f85084a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -1,17 +1,22 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -19,6 +24,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -28,8 +34,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.round import kotlin.time.Duration.Companion.days +@SkyHanniModule object CaptureFarmingGear { - private val farmingItems get() = GardenAPI.storage?.fortune?.farmingItems private val outdatedItems get() = GardenAPI.storage?.fortune?.outdatedItems private val patternGroup = RepoPattern.group("garden.fortuneguide.capture") @@ -80,9 +86,24 @@ object CaptureFarmingGear { "RANCHERS", "FARMER", "RABBIT" ) + init { + CarrolynTable.entries.forEach { + it.completeMessagePattern + it.thxMessagePattern + } + } + // TODO upadte armor on equpment/wardeobe update as well fun captureFarmingGear() { - val farmingItems = farmingItems ?: return + for (armor in InventoryUtils.getArmor()) { + if (armor == null) continue + val split = armor.getInternalName().asString().split("_") + if (split.first() in farmingSets) { + val category = armor.getItemCategoryOrNull() ?: continue + FarmingItems.getFromItemCategoryOne(category)?.setItem(armor) + } + } + val itemStack = InventoryUtils.getItemInHand() ?: return val currentCrop = itemStack.getCropType() @@ -91,22 +112,7 @@ object CaptureFarmingGear { //todo better fall back items //todo Daedalus axe } else { - for (item in FarmingItems.entries) { - if (item.name == currentCrop.name) { - farmingItems[item] = itemStack - } - } - } - for (armor in InventoryUtils.getArmor()) { - if (armor == null) continue - val split = armor.getInternalName().asString().split("_") - if (split.first() in farmingSets) { - for (item in FarmingItems.entries) { - if (item.name == split.last()) { - farmingItems[item] = armor - } - } - } + currentCrop.farmingItem.setItem(itemStack) } TabListData.getTabList().matchFirst(strengthPattern) { @@ -114,22 +120,13 @@ object CaptureFarmingGear { } } - fun reverseCarrotFortune() { - val storage = GardenAPI.storage?.fortune ?: return - storage.carrotFortune = !storage.carrotFortune - ChatUtils.chat("Toggled exportable carrot fortune to: ${storage.carrotFortune}") - } - - fun reversePumpkinFortune() { - val storage = GardenAPI.storage?.fortune ?: return - storage.pumpkinFortune = !storage.pumpkinFortune - ChatUtils.chat("Toggled expired pumpkin fortune to: ${storage.pumpkinFortune}") - } - - fun reverseCocoaBeansFortune() { - val storage = GardenAPI.storage?.fortune ?: return - storage.cocoaBeansFortune = !storage.cocoaBeansFortune - ChatUtils.chat("Toggled supreme chocolate bar fortune to: ${storage.cocoaBeansFortune}") + fun handelCarrolyn(input: Array) { + val string = input.joinToString("_").uppercase() + val crop = CropType.entries.firstOrNull { it.name == string } + ?: ChatUtils.userError("Invalid Argument, no crop with the name: $string").run { return } + val carrolyn = CarrolynTable.getByCrop(crop) + ?: ChatUtils.userError("Invalid Argument, crop is not valid").run { return } + carrolyn.setVisibleActive(!carrolyn.get()) } private fun getUniqueVisitorsForTier(tier: Int): Int { @@ -151,15 +148,14 @@ object CaptureFarmingGear { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!LorenzUtils.inSkyBlock) return val storage = GardenAPI.storage?.fortune ?: return - val farmingItems = farmingItems ?: return val outdatedItems = outdatedItems ?: return val items = event.inventoryItems if (PetAPI.isPetMenu(event.inventoryName)) { - pets(farmingItems, items, outdatedItems) + pets(items, outdatedItems) return } when (event.inventoryName) { - "Your Equipment and Stats" -> equipmentAndStats(items, farmingItems, outdatedItems) + "Your Equipment and Stats" -> equipmentAndStats(items, outdatedItems) "Your Skills" -> skills(items, storage) "Community Shop" -> communityShop(items) "Configure Plots" -> configurePlots(items, storage) @@ -248,69 +244,54 @@ object CaptureFarmingGear { } private fun pets( - farmingItems: MutableMap, items: Map, outdatedItems: MutableMap, ) { // If they've 2 of same pet, one will be overwritten - // optimize - - for (pet in listOf( - FarmingItems.ELEPHANT, - FarmingItems.MOOSHROOM_COW, - FarmingItems.RABBIT, - FarmingItems.BEE - )) { - if (farmingItems[pet] == null) { - farmingItems[pet] = FFGuideGUI.getFallbackItem(pet) - } - } // setting to current saved level -1 to stop later pages saving low rarity pets - var highestElephantRarity = (farmingItems[FarmingItems.ELEPHANT]?.getItemRarityOrNull()?.id ?: -1) - 1 - var highestMooshroomRarity = (farmingItems[FarmingItems.MOOSHROOM_COW]?.getItemRarityOrNull()?.id ?: -1) - 1 - var highestRabbitRarity = (farmingItems[FarmingItems.RABBIT]?.getItemRarityOrNull()?.id ?: -1) - 1 - var highestBeeRarity = (farmingItems[FarmingItems.BEE]?.getItemRarityOrNull()?.id ?: -1) - 1 + var highestElephantRarity = (FarmingItems.ELEPHANT.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 + var highestMooshroomRarity = (FarmingItems.MOOSHROOM_COW.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 + var highestRabbitRarity = (FarmingItems.RABBIT.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 + var highestBeeRarity = (FarmingItems.BEE.getItemOrNull()?.getItemRarityOrNull()?.id ?: -1) - 1 for ((_, item) in items) { - val split = item.getInternalName().asString().split(";") - if (split.first() == "ELEPHANT" && split.last().toInt() > highestElephantRarity) { - farmingItems[FarmingItems.ELEPHANT] = item + if (item.getItemCategoryOrNull() != ItemCategory.PET) continue + val (name, rarity) = item.getInternalName().asString().split(";") + if (name == "ELEPHANT" && rarity.toInt() > highestElephantRarity) { + FarmingItems.ELEPHANT.setItem(item) outdatedItems[FarmingItems.ELEPHANT] = false - highestElephantRarity = split.last().toInt() + highestElephantRarity = rarity.toInt() } - if (split.first() == "MOOSHROOM_COW" && split.last().toInt() > highestMooshroomRarity) { - farmingItems[FarmingItems.MOOSHROOM_COW] = item + if (name == "MOOSHROOM_COW" && rarity.toInt() > highestMooshroomRarity) { + FarmingItems.MOOSHROOM_COW.setItem(item) outdatedItems[FarmingItems.MOOSHROOM_COW] = false - highestMooshroomRarity = split.last().toInt() + highestMooshroomRarity = rarity.toInt() } - if (split.first() == "RABBIT" && split.last().toInt() > highestRabbitRarity) { - farmingItems[FarmingItems.RABBIT] = item + if (name == "RABBIT" && rarity.toInt() > highestRabbitRarity) { + FarmingItems.RABBIT.setItem(item) outdatedItems[FarmingItems.RABBIT] = false - highestRabbitRarity = split.last().toInt() + highestRabbitRarity = rarity.toInt() } - if (split.first() == "BEE" && split.last().toInt() > highestBeeRarity) { - farmingItems[FarmingItems.BEE] = item + if (name == "BEE" && rarity.toInt() > highestBeeRarity) { + FarmingItems.BEE.setItem(item) outdatedItems[FarmingItems.BEE] = false - highestBeeRarity = split.last().toInt() + highestBeeRarity = rarity.toInt() } } } private fun equipmentAndStats( items: Map, - farmingItems: MutableMap, outdatedItems: MutableMap, ) { for ((_, slot) in items) { val split = slot.getInternalName().asString().split("_") + val category = slot.getItemCategoryOrNull() ?: continue if (split.first() == "LOTUS") { - for (item in FarmingItems.entries) { - if (item.name == split.last()) { - farmingItems[item] = slot - outdatedItems[item] = false - } - } + val item = FarmingItems.getFromItemCategoryOne(category) ?: continue + item.setItem(slot) + outdatedItems[item] = false FarmingFortuneDisplay.loadFortuneLineData(slot, 0.0) val enchantments = slot.getEnchantments() ?: emptyMap() val greenThumbLvl = (enchantments["green_thumb"] ?: continue) @@ -328,12 +309,15 @@ object CaptureFarmingGear { val msg = event.message.removeColor().trim() fortuneUpgradePattern.matchMatcher(msg) { ProfileStorageData.playerSpecific?.gardenCommunityUpgrade = group("level").romanToDecimal() + return } farmingLevelUpPattern.matchMatcher(msg) { storage.farmingLevel = group("level").romanToDecimalIfNecessary() + return } anitaBuffPattern.matchMatcher(msg) { storage.anitaUpgrade = group("level").toInt() / 4 + return } lotusUpgradePattern.matchMatcher(msg) { val piece = group("piece").uppercase() @@ -342,6 +326,7 @@ object CaptureFarmingGear { outdatedItems[item] = true } } + return } petLevelUpPattern.matchMatcher(msg) { val pet = group("pet").uppercase().replace("✦", "").trim().replace(" ", "_") @@ -350,30 +335,29 @@ object CaptureFarmingGear { outdatedItems[item] = true } } + return } cakePattern.matchMatcher(msg) { - storage.cakeExpiring = System.currentTimeMillis() + 2.days.inWholeMilliseconds - } - if (msg == "CARROTS EXPORTATION COMPLETE!") { - storage.carrotFortune = true - } - if (msg == "PUMPKINS EXPORTATION COMPLETE!") { - storage.pumpkinFortune = true - } - if (msg == "CHOCOLATE BARS EXPORTATION COMPLETE!") { - storage.cocoaBeansFortune = true - } - if (msg == "[NPC] Carrolyn: Thank you for the carrots.") { - storage.carrotFortune = true - ChatUtils.chat("§aYou have already given Carrolyn enough Exportable Carrots.") - } - if (msg == "[NPC] Carrolyn: Thank you for the pumpkins.") { - storage.pumpkinFortune = true - ChatUtils.chat("§aYou have already given Carrolyn enough Expired Pumpkins.") + FFStats.cakeExpireTime = 2.days.fromNow() + return } - if (msg == "[NPC] Carrolyn: Thank you for the chocolate.") { - storage.cocoaBeansFortune = true - ChatUtils.chat("§aYou have already given Carrolyn enough Supreme Chocolate Bars.") + CarrolynTable.entries.forEach { + it.completeMessagePattern.matchMatcher(msg) { + it.set(true) + return + } + it.thxMessagePattern.matchMatcher(msg) { + it.set(true) + ChatUtils.chat(it.thxResponse) + return + } } } + + @SubscribeEvent + fun onConfigUpdaterMigratorConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(48, "#profile.garden.fortune.carrotFortune", "#profile.garden.fortune.carrolyn.CARROT") + event.move(48, "#profile.garden.fortune.pumpkinFortune", "#profile.garden.fortune.carrolyn.PUMPKIN") + event.move(48, "#profile.garden.fortune.cocoaBeansFortune", "#profile.garden.fortune.carrolyn.COCOA_BEANS") + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CarrolynTable.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CarrolynTable.kt new file mode 100644 index 000000000000..b7163768b318 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CarrolynTable.kt @@ -0,0 +1,58 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern + +enum class CarrolynTable(val crop: CropType, val label: String, completeMessage: String, thxMessage: String) { + EXPORTABLE_CARROTS( + CropType.CARROT, + "Exportable Carrots", + "CARROTS EXPORTATION COMPLETE!", + "[NPC] Carrolyn: Thank you for the carrots." + ), + EXPIRED_PUMPKIN( + CropType.PUMPKIN, + "Expired Pumpkin", + "PUMPKINS EXPORTATION COMPLETE!", + "[NPC] Carrolyn: Thank you for the pumpkins." + ), + SUPREME_CHOCOLATE_BAR( + CropType.COCOA_BEANS, + "Supreme Chocolate Bar", + "CHOCOLATE BARS EXPORTATION COMPLETE!", + "[NPC] Carrolyn: Thank you for the chocolate." + ), + ; + + val completeMessagePattern by RepoPattern.pattern( + "garden.ff.carrolyn.complete.${crop.patternKeyName}", completeMessage + ) + val thxMessagePattern by RepoPattern.pattern( + "garden.ff.carrolyn.thx.${crop.patternKeyName}", thxMessage + ) + + val thxResponse = "§aYou have already given Carrolyn enough $label." + + fun get() = GardenAPI.storage?.fortune?.carrolyn?.get(crop) ?: false + fun set(value: Boolean) = GardenAPI.storage?.fortune?.carrolyn?.set(crop, value) + + fun setVisibleActive(value: Boolean) { + set(value) + ChatUtils.chat("Toggled $label fortune to: ${get()}") + } + + companion object { + fun getByCrop(crop: CropType?) = if (crop == null) null else entries.firstOrNull { it.crop == crop } + + fun isCarrolynCrop(crop: CropType): Boolean = CarrolynTable.getByCrop(crop) != null + fun customTabComplete(command: String): List? { + if (command == "shcarrolyn") { + return entries.map { it.crop.name } + } + + return null + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index 0cafabd1c183..ff81cae6d57e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -2,528 +2,95 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.features.garden.CropType -import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.CropPage import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.OverviewPage import at.hannibal2.skyhanni.features.garden.fortuneguide.pages.UpgradePage -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.GuiRenderUtils -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.OSUtils -import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.guide.GuideGUI +import at.hannibal2.skyhanni.utils.guide.GuideTab +import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiScreen -import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Blocks import net.minecraft.init.Items import net.minecraft.item.ItemStack -import org.lwjgl.input.Mouse -import java.io.IOException -open class FFGuideGUI : GuiScreen() { - companion object { - - private var firefoxTrials = 0 - - fun open() { - if (LorenzUtils.isAprilFoolsDay) { - when (firefoxTrials) { - 0 -> { - ChatUtils.chat("Are you looking for the FF browser?", prefix = false) - } - - 1 -> { - ChatUtils.chat("Quickly, download Firefox! NOW!", prefix = false) - OSUtils.openBrowser("https://www.mozilla.org/en-US/firefox/new/") - } - - 2 -> { - ChatUtils.chat("Have you tried Firefix from Mozilla already?", prefix = false) - } - - 10 -> { - ChatUtils.chat("Firefox is simply the best!", prefix = false) - } - - 20 -> { - ChatUtils.chat( - "What do you mean with \"farming fortune\"? This is a web browser!", - prefix = false - ) - } - - 30 -> { - ChatUtils.chat("What are you still doing here? get Firefox!", prefix = false) - } - - else -> { - CaptureFarmingGear.captureFarmingGear() - SkyHanniMod.screenToOpen = FFGuideGUI() - } - } - firefoxTrials++ - } else { - CaptureFarmingGear.captureFarmingGear() - SkyHanniMod.screenToOpen = FFGuideGUI() - } - } - - val pages = mutableMapOf() - - var guiLeft = 0 - var guiTop = 0 - var screenHeight = 0 - - const val sizeX = 360 - const val sizeY = 180 +class FFGuideGUI : GuideGUI(FortuneGuidePage.OVERVIEW) { - var selectedPage = FortuneGuidePage.OVERVIEW - var currentCrop: CropType? = null + override val sizeX = 360 + override val sizeY = 180 - // todo set this to what they have equip - var currentPet = FarmingItems.ELEPHANT - var currentArmor = 0 - var currentEquipment = 0 - - var mouseX = 0 - var mouseY = 0 - var lastMouseScroll = 0 - var noMouseScrollFrames = 0 - var lastClickedHeight = 0 - - var tooltipToDisplay = mutableListOf() + companion object { fun isInGui() = Minecraft.getMinecraft().currentScreen is FFGuideGUI - fun FarmingItems.getItem(): ItemStack { - val fortune = GardenAPI.storage?.fortune ?: return getFallbackItem(this) - - val farmingItems = fortune.farmingItems - farmingItems[this]?.let { return it } - - val fallbackItem = getFallbackItem(this) - farmingItems[this] = fallbackItem - return fallbackItem + fun open() { + CaptureFarmingGear.captureFarmingGear() + SkyHanniMod.screenToOpen = FFGuideGUI() } - private val fallbackItems = mutableMapOf() - - fun getFallbackItem(item: FarmingItems) = fallbackItems.getOrPut(item) { - val name = "§cNo saved ${item.name.lowercase().replace("_", " ")}" - ItemStack(Blocks.barrier).setStackDisplayName(name) + fun updateDisplay() { + with(Minecraft.getMinecraft().currentScreen) { + if (this !is FFGuideGUI) return + this.refreshPage() + } } - - fun isFallbackItem(item: ItemStack) = item.name.startsWith("§cNo saved ") } + /** Value for which crop page is active */ + private var currentCrop: CropType? = null + init { FFStats.loadFFData() FortuneUpgrades.generateGenericUpgrades() - pages[FortuneGuidePage.OVERVIEW] = OverviewPage() - pages[FortuneGuidePage.CROP] = CropPage() - pages[FortuneGuidePage.UPGRADES] = UpgradePage() + FarmingItems.setDefaultPet() - if (currentCrop != null) { - for (item in FarmingItems.entries) { - if (item.name == currentCrop?.name) { - FFStats.getCropStats(currentCrop!!, item.getItem()) + pageList = mapOf( + FortuneGuidePage.OVERVIEW to OverviewPage(sizeX, sizeY), + FortuneGuidePage.CROP to CropPage({ currentCrop!! }, sizeX, sizeY), + FortuneGuidePage.UPGRADES to UpgradePage({ currentCrop }, sizeX, sizeY - 2), + ) + verticalTabs = listOf( + vTab(ItemStack(Items.gold_ingot), Renderable.string("§eBreakdown")) { + currentPage = if (currentCrop == null) FortuneGuidePage.OVERVIEW else FortuneGuidePage.CROP + }, + vTab(ItemStack(Items.map), Renderable.string("§eUpgrades")) { + currentPage = FortuneGuidePage.UPGRADES + }) + horizontalTabs = buildList { + add( + hTab(ItemStack(Blocks.grass), Renderable.string("§eOverview")) { + currentCrop = null + + it.pageSwitchHorizontal() } - } - } - } - - override fun drawScreen(unusedX: Int, unusedY: Int, partialTicks: Float) { - super.drawScreen(unusedX, unusedY, partialTicks) - drawDefaultBackground() - screenHeight = height - guiLeft = (width - sizeX) / 2 - guiTop = (height - sizeY) / 2 - - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1 - - GlStateManager.pushMatrix() - drawRect(guiLeft, guiTop, guiLeft + sizeX, guiTop + sizeY, 0x50000000) - renderTabs() - - if (selectedPage == FortuneGuidePage.UPGRADES) { - // - } else { - GuiRenderUtils.drawStringCentered("§7SkyHanni", guiLeft + 325, guiTop + 170) - if (currentCrop == null) { - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.HELMET.getItem(), guiLeft + 142, guiTop + 5, mouseX, mouseY, - if (currentArmor == 1) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.CHESTPLATE.getItem(), guiLeft + 162, guiTop + 5, mouseX, mouseY, - if (currentArmor == 2) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.LEGGINGS.getItem(), guiLeft + 182, guiTop + 5, mouseX, mouseY, - if (currentArmor == 3) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BOOTS.getItem(), guiLeft + 202, guiTop + 5, mouseX, mouseY, - if (currentArmor == 4) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) + ) + for (crop in CropType.entries) { + add( + hTab(crop.icon, Renderable.string("§e${crop.cropName}")) { + currentCrop = crop - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.NECKLACE.getItem(), guiLeft + 262, guiTop + 5, mouseX, mouseY, - if (currentEquipment == 1) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.CLOAK.getItem(), guiLeft + 282, guiTop + 5, mouseX, mouseY, - if (currentEquipment == 2) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BELT.getItem(), guiLeft + 302, guiTop + 5, mouseX, mouseY, - if (currentEquipment == 3) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BRACELET.getItem(), guiLeft + 322, guiTop + 5, mouseX, mouseY, - if (currentEquipment == 4) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.ELEPHANT.getItem(), guiLeft + 142, guiTop + 130, mouseX, mouseY, - if (currentPet == FarmingItems.ELEPHANT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.MOOSHROOM_COW.getItem(), guiLeft + 162, guiTop + 130, mouseX, mouseY, - if (currentPet == FarmingItems.MOOSHROOM_COW) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.RABBIT.getItem(), guiLeft + 182, guiTop + 130, mouseX, mouseY, - if (currentPet == FarmingItems.RABBIT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BEE.getItem(), guiLeft + 202, guiTop + 130, mouseX, mouseY, - if (currentPet == FarmingItems.BEE) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - } else { - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.ELEPHANT.getItem(), guiLeft + 142, guiTop + 160, mouseX, mouseY, - if (currentPet == FarmingItems.ELEPHANT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.MOOSHROOM_COW.getItem(), guiLeft + 162, guiTop + 160, mouseX, mouseY, - if (currentPet == FarmingItems.MOOSHROOM_COW) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.RABBIT.getItem(), guiLeft + 182, guiTop + 160, mouseX, mouseY, - if (currentPet == FarmingItems.RABBIT) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BEE.getItem(), guiLeft + 202, guiTop + 160, mouseX, mouseY, - if (currentPet == FarmingItems.BEE) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() - ) - - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.HELMET.getItem(), guiLeft + 162, guiTop + 80, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.CHESTPLATE.getItem(), guiLeft + 162, guiTop + 100, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.LEGGINGS.getItem(), guiLeft + 162, guiTop + 120, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BOOTS.getItem(), guiLeft + 162, guiTop + 140, mouseX, mouseY - ) - - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.NECKLACE.getItem(), guiLeft + 182, guiTop + 80, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.CLOAK.getItem(), guiLeft + 182, guiTop + 100, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BELT.getItem(), guiLeft + 182, guiTop + 120, mouseX, mouseY - ) - GuiRenderUtils.renderItemAndTip( - tooltipToDisplay, - FarmingItems.BRACELET.getItem(), guiLeft + 182, guiTop + 140, mouseX, mouseY + it.pageSwitchHorizontal() + } ) } } - pages[selectedPage]?.drawPage(mouseX, mouseY, partialTicks) + horizontalTabs.firstOrNull()?.fakeClick() + verticalTabs.firstOrNull()?.fakeClick() - GlStateManager.popMatrix() - - if (tooltipToDisplay.isNotEmpty()) { - GuiRenderUtils.drawTooltip(tooltipToDisplay, mouseX, mouseY, height) - tooltipToDisplay.clear() - } } - override fun handleMouseInput() { - super.handleMouseInput() - - if (Mouse.getEventButtonState()) { - mouseClickEvent() - } - if (!Mouse.getEventButtonState() && Mouse.getEventDWheel() != 0) { - lastMouseScroll = Mouse.getEventDWheel() - noMouseScrollFrames = 0 - } - } - - @Throws(IOException::class) - fun mouseClickEvent() { - var x = guiLeft + 15 - var y = guiTop - 28 - if (isMouseIn(x, y, 25, 28)) { - SoundUtils.playClickSound() - if (currentCrop != null) { - currentCrop = null - if (selectedPage != FortuneGuidePage.UPGRADES) { - selectedPage = FortuneGuidePage.OVERVIEW - } - } else { - if (selectedPage == FortuneGuidePage.UPGRADES) { - selectedPage = FortuneGuidePage.OVERVIEW - } else { - selectedPage = FortuneGuidePage.UPGRADES - } - } - } - for (crop in CropType.entries) { - x += 30 - if (isMouseIn(x, y, 25, 28)) { - SoundUtils.playClickSound() - if (currentCrop != crop) { - currentCrop = crop - if (selectedPage == FortuneGuidePage.OVERVIEW) { - selectedPage = FortuneGuidePage.CROP - } - for (item in FarmingItems.entries) { - if (item.name == crop.name) { - FFStats.getCropStats(crop, item.getItem()) - FortuneUpgrades.getCropSpecific(item.getItem()) - } - } - } else { - if (selectedPage == FortuneGuidePage.CROP) { - selectedPage = FortuneGuidePage.UPGRADES - for (item in FarmingItems.entries) { - if (item.name == crop.name) { - FortuneUpgrades.getCropSpecific(item.getItem()) - } - } - } else { - selectedPage = FortuneGuidePage.CROP - for (item in FarmingItems.entries) { - if (item.name == crop.name) { - FFStats.getCropStats(crop, item.getItem()) - } - } - } - } - } - } - - x = guiLeft - 28 - y = guiTop + 15 - if (isMouseIn(x, y, 28, 25) && - selectedPage != FortuneGuidePage.CROP && selectedPage != FortuneGuidePage.OVERVIEW - ) { - SoundUtils.playClickSound() - selectedPage = if (currentCrop == null) { - FortuneGuidePage.OVERVIEW - } else { - FortuneGuidePage.CROP - } - } - y += 30 - if (isMouseIn(x, y, 28, 25) && selectedPage != FortuneGuidePage.UPGRADES) { - selectedPage = FortuneGuidePage.UPGRADES - SoundUtils.playClickSound() - } - - if (selectedPage != FortuneGuidePage.UPGRADES) { - if (currentCrop == null) { - when { - isMouseInRect(guiLeft + 142, guiTop + 130) && currentPet != FarmingItems.ELEPHANT -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.ELEPHANT - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 162, guiTop + 130) && currentPet != FarmingItems.MOOSHROOM_COW -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.MOOSHROOM_COW - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 182, guiTop + 130) && currentPet != FarmingItems.RABBIT -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.RABBIT - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 202, guiTop + 130) && currentPet != FarmingItems.BEE -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.BEE - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 142, guiTop + 5) -> { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 1) 0 else 1 - } - - isMouseInRect(guiLeft + 162, guiTop + 5) -> { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 2) 0 else 2 - } - - isMouseInRect(guiLeft + 182, guiTop + 5) -> { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 3) 0 else 3 - } - - isMouseInRect(guiLeft + 202, guiTop + 5) -> { - SoundUtils.playClickSound() - currentArmor = if (currentArmor == 4) 0 else 4 - } - - isMouseInRect(guiLeft + 262, guiTop + 5) -> { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 1) 0 else 1 - } - - isMouseInRect(guiLeft + 282, guiTop + 5) -> { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 2) 0 else 2 - } - - isMouseInRect(guiLeft + 302, guiTop + 5) -> { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 3) 0 else 3 - } - - isMouseInRect(guiLeft + 322, guiTop + 5) -> { - SoundUtils.playClickSound() - currentEquipment = if (currentEquipment == 4) 0 else 4 - } - } - } else { - when { - isMouseInRect(guiLeft + 142, guiTop + 160) && currentPet != FarmingItems.ELEPHANT -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.ELEPHANT - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 162, guiTop + 160) && currentPet != FarmingItems.MOOSHROOM_COW -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.MOOSHROOM_COW - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 182, guiTop + 160) && currentPet != FarmingItems.RABBIT -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.RABBIT - FFStats.getTotalFF() - } - - isMouseInRect(guiLeft + 202, guiTop + 160) && currentPet != FarmingItems.BEE -> { - SoundUtils.playClickSound() - currentPet = FarmingItems.BEE - FFStats.getTotalFF() - } - } - } + private fun GuideTab.pageSwitchHorizontal() { + if (isSelected()) { + verticalTabs.first { it != lastVerticalTabWrapper.tab }.fakeClick() // Double Click Logic } else { - if (isMouseIn(guiLeft, guiTop, sizeX, sizeY)) { - lastClickedHeight = mouseY - } - } - } - - private fun isMouseInRect(left: Int, top: Int) = isMouseIn(left, top, 16, 16) - - private fun isMouseIn(x: Int, y: Int, width: Int, height: Int) = - GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, width, height) - - private fun renderTabs() { - var x = guiLeft + 15 - var y = guiTop - 28 - val selectedColor = 0x50000000 - val notSelectedColor = 0x50303030 - drawRect(x, y, x + 25, y + 28, if (currentCrop == null) selectedColor else notSelectedColor) - GuiRenderUtils.renderItemStack(ItemStack(Blocks.grass), x + 5, y + 5) - if (isMouseIn(x, y, 25, 28)) { - tooltipToDisplay.add("§eOverview") - } - - for (crop in CropType.entries) { - x += 30 - drawRect(x, y, x + 25, y + 28, if (currentCrop == crop) selectedColor else notSelectedColor) - GuiRenderUtils.renderItemStack(crop.icon, x + 5, y + 5) - if (isMouseIn(x, y, 25, 28)) { - tooltipToDisplay.add("§e${crop.cropName}") - } - } - - x = guiLeft - 28 - y = guiTop + 15 - - drawRect( - x, y, - x + 28, y + 25, - if (selectedPage != FortuneGuidePage.UPGRADES) selectedColor else notSelectedColor - ) - GuiRenderUtils.renderItemStack(ItemStack(Items.gold_ingot), x + 5, y + 5) - if (isMouseIn(x, y, 28, 25)) { - tooltipToDisplay.add("§eBreakdown") - } - y += 30 - drawRect( - x, y, - x + 28, y + 25, - if (selectedPage == FortuneGuidePage.UPGRADES) selectedColor else notSelectedColor - ) - GuiRenderUtils.renderItemStack(ItemStack(Items.map), x + 5, y + 5) - if (isMouseIn(x, y, 28, 25)) { - tooltipToDisplay.add("§eUpgrades") + lastVerticalTabWrapper.tab?.fakeClick() // First Click Logic } } enum class FortuneGuidePage { OVERVIEW, CROP, - UPGRADES - } - - abstract class FFGuidePage { + UPGRADES, - abstract fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt new file mode 100644 index 000000000000..19597e6dbe7f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFInfos.kt @@ -0,0 +1,153 @@ +package at.hannibal2.skyhanni.features.garden.fortuneguide + +import at.hannibal2.skyhanni.utils.GuiRenderUtils + +internal enum class FFInfos( + val sumTo: FFInfos?, + private val currentF: () -> Number, + private val maxF: (FFInfos) -> Number, +) { + UNIVERSAL(null, { FFStats.totalBaseFF }, FFTypes.TOTAL, { + val backupArmor = FarmingItems.currentArmor + val backupEquip = FarmingItems.currentEquip + FarmingItems.currentArmor = null + FarmingItems.currentEquip = null + val total = maxSumToThis(it) + 100 + FarmingItems.currentArmor = backupArmor + FarmingItems.currentEquip = backupEquip + total + }), + ANITA_BUFF(UNIVERSAL, { FFStats.baseFF }, FFTypes.ANITA, 60), + FARMING_LEVEL(UNIVERSAL, { FFStats.baseFF }, FFTypes.FARMING_LVL, 240), + COMMUNITY_SHOP(UNIVERSAL, { FFStats.baseFF }, FFTypes.COMMUNITY_SHOP, 40), + GARDEN_PLOTS(UNIVERSAL, { FFStats.baseFF }, FFTypes.PLOTS, 72), + CAKE_BUFF(UNIVERSAL, { FFStats.baseFF }, FFTypes.CAKE, 5), + TOTAL_ARMOR(UNIVERSAL, { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, FFTypes.TOTAL), + BASE_ARMOR(TOTAL_ARMOR, { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, FFTypes.BASE, { + when (FarmingItems.currentArmor) { + FarmingItems.HELMET -> 30 + FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS -> 35 + FarmingItems.BOOTS -> if (FFStats.usingSpeedBoots) 60 else 30 + else -> if (FFStats.usingSpeedBoots) 160 else 130 + } + }), + ABILITY_ARMOR(TOTAL_ARMOR, { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, FFTypes.ABILITY, { + when (FarmingItems.currentArmor) { + FarmingItems.HELMET, FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS -> if (FFStats.usingSpeedBoots) 16.667 else 18.75 + FarmingItems.BOOTS -> if (FFStats.usingSpeedBoots) 0 else 18.75 + else -> if (FFStats.usingSpeedBoots) 50 else 75 + } + }), + REFORGE_ARMOR(TOTAL_ARMOR, { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, FFTypes.REFORGE, { + when (FarmingItems.currentArmor) { + FarmingItems.HELMET, FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS -> 30 + FarmingItems.BOOTS -> if (FFStats.usingSpeedBoots) 25 else 30 + else -> if (FFStats.usingSpeedBoots) 115 else 120 + } + }), + ENCHANT_ARMOR( + sumTo = TOTAL_ARMOR, + from = { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, + what = FFTypes.PESTERMINATOR, + x4 = { FarmingItems.currentArmor == null }, + max = 5 + ), + GEMSTONE_ARMOR(TOTAL_ARMOR, { FarmingItems.currentArmor?.getFFData() ?: FFStats.armorTotalFF }, FFTypes.GEMSTONE, { + when (FarmingItems.currentArmor) { + FarmingItems.HELMET, FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS -> 20 + FarmingItems.BOOTS -> if (FFStats.usingSpeedBoots) 16 else 20 + else -> if (FFStats.usingSpeedBoots) 76 else 80 + } + }), + TOTAL_PET(UNIVERSAL, { FarmingItems.currentPet.getFFData() }, FFTypes.TOTAL), + PET_BASE(TOTAL_PET, { FarmingItems.currentPet.getFFData() }, FFTypes.BASE, { + when (FarmingItems.currentPet) { + FarmingItems.ELEPHANT -> 150 + FarmingItems.MOOSHROOM_COW -> 157 + FarmingItems.BEE -> 30 + else -> 0 + } + }), + PET_ITEM(TOTAL_PET, { FarmingItems.currentPet.getFFData() }, FFTypes.PET_ITEM, 60), + TOTAL_EQUIP( + sumTo = UNIVERSAL, + from = { FarmingItems.currentEquip?.getFFData() ?: FFStats.equipmentTotalFF }, + what = FFTypes.TOTAL + ), + BASE_EQUIP( + sumTo = TOTAL_EQUIP, + from = { FarmingItems.currentEquip?.getFFData() ?: FFStats.equipmentTotalFF }, + what = FFTypes.BASE, + x4 = { FarmingItems.currentEquip == null }, + max = 5.0 + ), + ABILITY_EQUIP( + sumTo = TOTAL_EQUIP, + from = { FarmingItems.currentEquip?.getFFData() ?: FFStats.equipmentTotalFF }, + what = FFTypes.ABILITY, + x4 = { FarmingItems.currentEquip == null }, + max = 15.0 + ), + REFORGE_EQUIP( + sumTo = TOTAL_EQUIP, + from = { FarmingItems.currentEquip?.getFFData() ?: FFStats.equipmentTotalFF }, + what = FFTypes.REFORGE, + x4 = { FarmingItems.currentEquip == null }, + max = 15.0 + ), + ENCHANT_EQUIP( + sumTo = TOTAL_EQUIP, + from = { FarmingItems.currentEquip?.getFFData() ?: FFStats.equipmentTotalFF }, + what = FFTypes.GREEN_THUMB, + x4 = { FarmingItems.currentEquip == null }, + max = { at.hannibal2.skyhanni.features.garden.GardenAPI.totalAmountVisitorsExisting.toDouble() / 4.0 } + ), + ; + + val current get() = currentF().toDouble() + val max get() = maxF(this).toDouble() + + fun bar(label: String, tooltip: String) = GuiRenderUtils.getFarmingBar(label, tooltip, current, max, 90) + + constructor(sumTo: FFInfos?, current: () -> Number, max: Number) : this(sumTo, current, { max }) + constructor(sumTo: FFInfos?, from: () -> Map, what: FFTypes, max: Number) : this(sumTo, { + from()[what] ?: 0.0 + }, { max } + ) + + constructor( + sumTo: FFInfos?, + from: () -> Map, + what: FFTypes, + x4: () -> Boolean, + max: Number, + ) : this(sumTo, { from()[what] ?: 0.0 }, { if (x4()) max.toDouble() * 4 else max } + ) + + constructor( + sumTo: FFInfos?, + from: () -> Map, + what: FFTypes, + x4: () -> Boolean, + max: () -> Number, + ) : this(sumTo, { from()[what] ?: 0.0 }, { if (x4()) max().toDouble() * 4 else max() } + ) + + constructor( + sumTo: FFInfos?, + from: () -> Map, + what: FFTypes, + max: (FFInfos) -> Number, + ) : this( + sumTo, { from()[what] ?: 0.0 }, max + ) + + constructor( + sumTo: FFInfos?, + from: () -> Map, + what: FFTypes, + ) : this(sumTo, { from()[what] ?: 0.0 }, ::maxSumToThis) + +} + +private fun maxSumToThis(self: FFInfos): Double = FFInfos.entries.filter { it.sumTo == self }.sumOf { it.max } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index 2f1ce1860a0e..a8b79ad70e23 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -6,8 +6,8 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetItem import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel @@ -16,225 +16,167 @@ import kotlin.math.floor object FFStats { - private val mathCrops = + private val mathCrops by lazy { listOf(CropType.WHEAT, CropType.CARROT, CropType.POTATO, CropType.SUGAR_CANE, CropType.NETHER_WART) - private val dicerCrops = listOf(CropType.PUMPKIN, CropType.MELON) + } + private val dicerCrops by lazy { listOf(CropType.PUMPKIN, CropType.MELON) } private val farmingBoots = arrayListOf("RANCHERS_BOOTS", "FARMER_BOOTS") - var cakeExpireTime = 0L + var cakeExpireTime + get() = GardenAPI.storage?.fortune?.cakeExpiring ?: SimpleTimeMark.farPast() + set(value) { + GardenAPI.storage?.fortune?.cakeExpiring = value + } - val necklaceFF = mutableMapOf() - val cloakFF = mutableMapOf() - val beltFF = mutableMapOf() - val braceletFF = mutableMapOf() - var equipmentTotalFF = mutableMapOf() + var equipmentTotalFF = mapOf() - val helmetFF = mutableMapOf() - val chestplateFF = mutableMapOf() - val leggingsFF = mutableMapOf() - val bootsFF = mutableMapOf() - var armorTotalFF = mutableMapOf() + var armorTotalFF = mapOf() var usingSpeedBoots = false - val elephantFF = mutableMapOf() - val mooshroomFF = mutableMapOf() - val rabbitFF = mutableMapOf() - val beeFF = mutableMapOf() var currentPetItem = "" - var baseFF = mutableMapOf() - - var totalBaseFF = mutableMapOf() + var baseFF = mapOf() - val cropPage = mutableMapOf>() + var totalBaseFF = mapOf() fun loadFFData() { - cakeExpireTime = GardenAPI.storage?.fortune?.cakeExpiring ?: -1L - - getEquipmentFFData(FarmingItems.NECKLACE.getItem(), necklaceFF) - getEquipmentFFData(FarmingItems.CLOAK.getItem(), cloakFF) - getEquipmentFFData(FarmingItems.BELT.getItem(), beltFF) - getEquipmentFFData(FarmingItems.BRACELET.getItem(), braceletFF) - - equipmentTotalFF = - (necklaceFF.toList() + cloakFF.toList() + beltFF.toList() + braceletFF.toList()).groupBy({ it.first }, - { it.second }).map { (key, values) -> key to values.sum() } - .toMap() as MutableMap - getArmorFFData(FarmingItems.HELMET.getItem(), helmetFF) - getArmorFFData(FarmingItems.CHESTPLATE.getItem(), chestplateFF) - getArmorFFData(FarmingItems.LEGGINGS.getItem(), leggingsFF) - getArmorFFData(FarmingItems.BOOTS.getItem(), bootsFF) + equipmentTotalFF = FarmingItems.equip.getFFData() - armorTotalFF = - (helmetFF.toList() + chestplateFF.toList() + leggingsFF.toList() + bootsFF.toList()).groupBy({ it.first }, - { it.second }).map { (key, values) -> key to values.sum() } - .toMap() as MutableMap + armorTotalFF = FarmingItems.armor.getFFData() - usingSpeedBoots = FarmingItems.BOOTS.getItem().getInternalName().asString() in farmingBoots + usingSpeedBoots = FarmingItems.BOOTS.getItem()?.getInternalName()?.asString() in farmingBoots - getPetFFData(FarmingItems.ELEPHANT.getItem(), elephantFF) - getPetFFData(FarmingItems.MOOSHROOM_COW.getItem(), mooshroomFF) - getPetFFData(FarmingItems.RABBIT.getItem(), rabbitFF) - getPetFFData(FarmingItems.BEE.getItem(), beeFF) - - getGenericFF(baseFF) + baseFF = getGenericFF() getTotalFF() } - fun getCropStats(crop: CropType, tool: ItemStack) { - cropPage.clear() - cropPage[FortuneStats.BASE] = Pair(totalBaseFF[FFTypes.TOTAL] ?: 100.0, if (usingSpeedBoots) 1373.0 else 1377.0) - cropPage[FortuneStats.CROP_UPGRADE] = Pair((crop.getUpgradeLevel()?.toDouble() ?: 0.0) * 5.0, 45.0) - cropPage[FortuneStats.ACCESSORY] = Pair(CropAccessoryData.cropAccessory.getFortune(crop), 30.0) - cropPage[FortuneStats.FFD] = Pair((tool.getFarmingForDummiesCount() ?: 0).toDouble(), 5.0) - cropPage[FortuneStats.TURBO] = Pair(FarmingFortuneDisplay.getTurboCropFortune(tool, crop), 25.0) - cropPage[FortuneStats.DEDICATION] = Pair(FarmingFortuneDisplay.getDedicationFortune(tool, crop), 92.0) - cropPage[FortuneStats.CULTIVATING] = Pair(FarmingFortuneDisplay.getCultivatingFortune(tool), 20.0) + fun getCropStats(crop: CropType, tool: ItemStack?) { + FortuneStats.reset() + + FortuneStats.BASE.set(FFInfos.UNIVERSAL.current, FFInfos.UNIVERSAL.max) + FortuneStats.CROP_UPGRADE.set((crop.getUpgradeLevel()?.toDouble() ?: 0.0) * 5.0, 45.0) + FortuneStats.ACCESSORY.set(CropAccessoryData.cropAccessory.getFortune(crop), 30.0) + FortuneStats.FFD.set((tool?.getFarmingForDummiesCount() ?: 0).toDouble(), 5.0) + FortuneStats.TURBO.set(FarmingFortuneDisplay.getTurboCropFortune(tool, crop), 25.0) + FortuneStats.DEDICATION.set(FarmingFortuneDisplay.getDedicationFortune(tool, crop), 92.0) + FortuneStats.CULTIVATING.set(FarmingFortuneDisplay.getCultivatingFortune(tool), 20.0) FarmingFortuneDisplay.loadFortuneLineData(tool, 0.0) when (crop) { in mathCrops -> { - cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 50.0) - cropPage[FortuneStats.COUNTER] = Pair(FarmingFortuneDisplay.getCounterFortune(tool), 96.0) - cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) - cropPage[FortuneStats.COLLECTION] = Pair(FarmingFortuneDisplay.getCollectionFortune(tool), 48.0) - cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 20.0) - cropPage[FortuneStats.GEMSTONE] = Pair(FarmingFortuneDisplay.gemstoneFortune, 30.0) + FortuneStats.BASE_TOOL.set(FarmingFortuneDisplay.getToolFortune(tool), 50.0) + FortuneStats.COUNTER.set(FarmingFortuneDisplay.getCounterFortune(tool), 96.0) + FortuneStats.HARVESTING.set(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + FortuneStats.COLLECTION.set(FarmingFortuneDisplay.getCollectionFortune(tool), 48.0) + FortuneStats.REFORGE.set(FarmingFortuneDisplay.reforgeFortune, 20.0) + FortuneStats.GEMSTONE.set(FarmingFortuneDisplay.gemstoneFortune, 30.0) } in dicerCrops -> { - cropPage[FortuneStats.SUNDER] = Pair(FarmingFortuneDisplay.getSunderFortune(tool), 75.0) - cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 20.0) - cropPage[FortuneStats.GEMSTONE] = Pair(FarmingFortuneDisplay.gemstoneFortune, 20.0) + FortuneStats.SUNDER.set(FarmingFortuneDisplay.getSunderFortune(tool), 75.0) + FortuneStats.REFORGE.set(FarmingFortuneDisplay.reforgeFortune, 20.0) + FortuneStats.GEMSTONE.set(FarmingFortuneDisplay.gemstoneFortune, 20.0) } CropType.MUSHROOM -> { - cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 30.0) - cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) - cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 16.0) - cropPage[FortuneStats.GEMSTONE] = Pair(FarmingFortuneDisplay.gemstoneFortune, 16.0) + FortuneStats.BASE_TOOL.set(FarmingFortuneDisplay.getToolFortune(tool), 30.0) + FortuneStats.HARVESTING.set(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + FortuneStats.REFORGE.set(FarmingFortuneDisplay.reforgeFortune, 16.0) + FortuneStats.GEMSTONE.set(FarmingFortuneDisplay.gemstoneFortune, 16.0) } CropType.COCOA_BEANS -> { - cropPage[FortuneStats.BASE_TOOL] = Pair(FarmingFortuneDisplay.getToolFortune(tool), 20.0) - cropPage[FortuneStats.SUNDER] = Pair(FarmingFortuneDisplay.getSunderFortune(tool), 75.0) - cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 16.0) - cropPage[FortuneStats.GEMSTONE] = Pair(FarmingFortuneDisplay.gemstoneFortune, 16.0) + FortuneStats.BASE_TOOL.set(FarmingFortuneDisplay.getToolFortune(tool), 20.0) + FortuneStats.SUNDER.set(FarmingFortuneDisplay.getSunderFortune(tool), 75.0) + FortuneStats.REFORGE.set(FarmingFortuneDisplay.reforgeFortune, 16.0) + FortuneStats.GEMSTONE.set(FarmingFortuneDisplay.gemstoneFortune, 16.0) } CropType.CACTUS -> { - cropPage[FortuneStats.HARVESTING] = Pair(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) - cropPage[FortuneStats.REFORGE] = Pair(FarmingFortuneDisplay.reforgeFortune, 16.0) - cropPage[FortuneStats.GEMSTONE] = Pair(FarmingFortuneDisplay.gemstoneFortune, 16.0) + FortuneStats.HARVESTING.set(FarmingFortuneDisplay.getHarvestingFortune(tool), 75.0) + FortuneStats.REFORGE.set(FarmingFortuneDisplay.reforgeFortune, 16.0) + FortuneStats.GEMSTONE.set(FarmingFortuneDisplay.gemstoneFortune, 16.0) } else -> {} } - if (crop == CropType.CARROT) { - val storage = GardenAPI.storage?.fortune ?: return - val carrotFortune = if (storage.carrotFortune) 12.0 else 0.0 - cropPage[FortuneStats.EXPORTED_CARROT] = Pair(carrotFortune, 12.0) - } - if (crop == CropType.PUMPKIN) { - val storage = GardenAPI.storage?.fortune ?: return - val pumpkinFortune = if (storage.pumpkinFortune) 12.0 else 0.0 - cropPage[FortuneStats.EXPIRED_PUMPKIN] = Pair(pumpkinFortune, 12.0) - } - if (crop == CropType.COCOA_BEANS) { - val storage = GardenAPI.storage?.fortune ?: return - val cocoaBeansFortune = if (storage.cocoaBeansFortune) 12.0 else 0.0 - cropPage[FortuneStats.SUPREME_CHOCOLATE_BAR] = Pair(cocoaBeansFortune, 12.0) + CarrolynTable.getByCrop(crop)?.let { + val ff = if (it.get()) 12.0 else 0.0 + FortuneStats.CARROLYN.set(ff, 12.0) } - cropPage[FortuneStats.CROP_TOTAL] = Pair( - cropPage.toList().sumOf { it.second.first }, - cropPage.toList().sumOf { it.second.second }) + FortuneStats.CROP_TOTAL.set(FortuneStats.getTotal()) } - private fun getEquipmentFFData(item: ItemStack, out: MutableMap) { + fun getEquipmentFFData(item: ItemStack?): Map = buildMap { FarmingFortuneDisplay.loadFortuneLineData(item, 0.0) - out[FFTypes.TOTAL] = 0.0 - out[FFTypes.BASE] = FarmingFortuneDisplay.itemBaseFortune - out[FFTypes.REFORGE] = FarmingFortuneDisplay.reforgeFortune - out[FFTypes.GREEN_THUMB] = FarmingFortuneDisplay.greenThumbFortune - out[FFTypes.ABILITY] = FarmingFortuneDisplay.getAbilityFortune(item) - out[FFTypes.TOTAL] = out.values.sum() + this[FFTypes.BASE] = FarmingFortuneDisplay.itemBaseFortune + this[FFTypes.REFORGE] = FarmingFortuneDisplay.reforgeFortune + this[FFTypes.GREEN_THUMB] = FarmingFortuneDisplay.greenThumbFortune + this[FFTypes.ABILITY] = FarmingFortuneDisplay.getAbilityFortune(item) + this[FFTypes.TOTAL] = this.values.sum() } - private fun getArmorFFData(item: ItemStack, out: MutableMap) { + fun getArmorFFData(item: ItemStack?): Map = buildMap { FarmingFortuneDisplay.loadFortuneLineData(item, 0.0) - out[FFTypes.TOTAL] = 0.0 - out[FFTypes.BASE] = FarmingFortuneDisplay.itemBaseFortune - out[FFTypes.REFORGE] = FarmingFortuneDisplay.reforgeFortune - out[FFTypes.GEMSTONE] = FarmingFortuneDisplay.gemstoneFortune - out[FFTypes.PESTERMINATOR] = FarmingFortuneDisplay.pesterminatorFortune - out[FFTypes.ABILITY] = FarmingFortuneDisplay.getAbilityFortune(item) - out[FFTypes.TOTAL] = out.values.sum() + this[FFTypes.BASE] = FarmingFortuneDisplay.itemBaseFortune + this[FFTypes.REFORGE] = FarmingFortuneDisplay.reforgeFortune + this[FFTypes.GEMSTONE] = FarmingFortuneDisplay.gemstoneFortune + this[FFTypes.PESTERMINATOR] = FarmingFortuneDisplay.pesterminatorFortune + this[FFTypes.ABILITY] = FarmingFortuneDisplay.getAbilityFortune(item) + this[FFTypes.TOTAL] = this.values.sum() } - private fun getPetFFData(item: ItemStack, out: MutableMap) { + fun getPetFFData(item: ItemStack?): Map = buildMap { val gardenLvl = GardenAPI.getGardenLevel(overflow = false) - out[FFTypes.TOTAL] = 0.0 - out[FFTypes.BASE] = getPetFF(item) - out[FFTypes.PET_ITEM] = when (item.getPetItem()) { + this[FFTypes.BASE] = getPetFF(item) + this[FFTypes.PET_ITEM] = when (item?.getPetItem()) { "GREEN_BANDANA" -> 4.0 * gardenLvl "YELLOW_BANDANA" -> 30.0 - "MINOS_RELIC" -> (out[FFTypes.BASE] ?: 0.0) * .33 + "MINOS_RELIC" -> (this[FFTypes.BASE] ?: 0.0) * .33 else -> 0.0 } - out[FFTypes.TOTAL] = out.values.sum() + this[FFTypes.TOTAL] = this.values.sum() } - private fun getGenericFF(out: MutableMap) { - val storage = GardenAPI.storage?.fortune ?: return - out[FFTypes.TOTAL] = 0.0 - out[FFTypes.BASE_FF] = 100.0 - out[FFTypes.FARMING_LVL] = storage.farmingLevel.toDouble() * 4 - out[FFTypes.COMMUNITY_SHOP] = (ProfileStorageData.playerSpecific?.gardenCommunityUpgrade ?: -1).toDouble() * 4 - out[FFTypes.PLOTS] = storage.plotsUnlocked.toDouble() * 3 - out[FFTypes.ANITA] = storage.anitaUpgrade.toDouble() * 4 - if (cakeExpireTime - System.currentTimeMillis() > 0 || cakeExpireTime == -1L) { - out[FFTypes.CAKE] = 5.0 + private fun getGenericFF(): Map = buildMap { + val storage = GardenAPI.storage?.fortune ?: return emptyMap() + this[FFTypes.BASE_FF] = 100.0 + this[FFTypes.FARMING_LVL] = storage.farmingLevel.toDouble() * 4 + this[FFTypes.COMMUNITY_SHOP] = (ProfileStorageData.playerSpecific?.gardenCommunityUpgrade ?: -1).toDouble() * 4 + this[FFTypes.PLOTS] = storage.plotsUnlocked.toDouble() * 3 + this[FFTypes.ANITA] = storage.anitaUpgrade.toDouble() * 4 + if (cakeExpireTime.isInFuture() || cakeExpireTime.isFarPast()) { + this[FFTypes.CAKE] = 5.0 } else { - out[FFTypes.CAKE] = 0.0 + this[FFTypes.CAKE] = 0.0 } - out[FFTypes.TOTAL] = out.values.sum() + this[FFTypes.TOTAL] = this.values.sum() } fun getTotalFF() { - var petList = mutableMapOf() - when (FFGuideGUI.currentPet) { - FarmingItems.ELEPHANT -> { - petList = elephantFF - } - FarmingItems.MOOSHROOM_COW -> { - petList = mooshroomFF - } + currentPetItem = FarmingItems.currentPet.getItem()?.getPetItem().toString() - FarmingItems.RABBIT -> { - petList = rabbitFF - } + totalBaseFF = combineFFData( + baseFF, armorTotalFF, equipmentTotalFF, FarmingItems.currentPet.getFFData() + ) + FFGuideGUI.updateDisplay() + } - FarmingItems.BEE -> { - petList = beeFF - } + fun List.getFFData(): Map = combineFFData(this.map { it.getFFData() }) - else -> {} - } - currentPetItem = FFGuideGUI.currentPet.getItem().getPetItem().toString() - - totalBaseFF = - (baseFF.toList() + armorTotalFF.toList() + equipmentTotalFF.toList() + petList.toList()).groupBy({ it.first }, - { it.second }).map { (key, values) -> key to values.sum() } - .toMap() as MutableMap - } + fun combineFFData(vararg value: Map) = combineFFData(value.toList()) + fun combineFFData(value: List>) = + value.map { it.toList() }.flatten().groupBy({ it.first }, { it.second }) + .mapValues { (_, values) -> values.sum() } - private fun getPetFF(pet: ItemStack): Double { + private fun getPetFF(pet: ItemStack?): Double { + if (pet == null) return 0.0 val petLevel = pet.getPetLevel() val strength = (GardenAPI.storage?.fortune?.farmingStrength) if (strength != null) { @@ -253,4 +195,5 @@ object FFStats { } return 0.0 } + } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt index f2bd6b3608de..46b5d1e0722e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingItems.kt @@ -1,26 +1,166 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide -enum class FarmingItems { - WHEAT, - CARROT, - POTATO, - NETHER_WART, - PUMPKIN, - MELON, - COCOA_BEANS, - SUGAR_CANE, - CACTUS, - MUSHROOM, - HELMET, - CHESTPLATE, - LEGGINGS, - BOOTS, - NECKLACE, - CLOAK, - BELT, - BRACELET, - ELEPHANT, - MOOSHROOM_COW, - RABBIT, - BEE, +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.utils.ItemCategory +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraft.client.gui.GuiScreen +import net.minecraft.init.Blocks +import net.minecraft.item.ItemStack + +enum class FarmingItems( + val itemCategory: ItemCategory, + private val ffCalculation: (ItemStack?) -> Map = { emptyMap() }, +) { + WHEAT(ItemCategory.HOE), + CARROT(ItemCategory.HOE), + POTATO(ItemCategory.HOE), + NETHER_WART(ItemCategory.HOE), + PUMPKIN(ItemCategory.AXE), + MELON(ItemCategory.AXE), + COCOA_BEANS(ItemCategory.AXE), + SUGAR_CANE(ItemCategory.HOE), + CACTUS(ItemCategory.HOE), + MUSHROOM(ItemCategory.HOE), + HELMET(ItemCategory.HELMET, FFStats::getArmorFFData), + CHESTPLATE(ItemCategory.CHESTPLATE, FFStats::getArmorFFData), + LEGGINGS(ItemCategory.LEGGINGS, FFStats::getArmorFFData), + BOOTS(ItemCategory.BOOTS, FFStats::getArmorFFData), + NECKLACE(ItemCategory.NECKLACE, FFStats::getEquipmentFFData), + CLOAK(ItemCategory.CLOAK, FFStats::getEquipmentFFData), + BELT(ItemCategory.BELT, FFStats::getEquipmentFFData), + BRACELET(ItemCategory.BRACELET, FFStats::getEquipmentFFData), + ELEPHANT(ItemCategory.PET, FFStats::getPetFFData), + MOOSHROOM_COW(ItemCategory.PET, FFStats::getPetFFData), + RABBIT(ItemCategory.PET, FFStats::getPetFFData), + BEE(ItemCategory.PET, FFStats::getPetFFData), + ; + + var selectedState = false + + fun getItem() = getItemOrNull() ?: fallbackItem + + private val fallbackItem: ItemStack by lazy { + val name = "§cNo saved ${name.lowercase().replace("_", " ")}" + ItemStack(Blocks.barrier).setStackDisplayName(name) + } + + fun getItemOrNull() = ProfileStorageData.profileSpecific?.garden?.fortune?.farmingItems?.get(this) + fun setItem(value: ItemStack) = ProfileStorageData.profileSpecific?.garden?.fortune?.farmingItems?.set(this, value) + + private fun onClick(): () -> Unit = when (this) { + in armor -> { + { + SoundUtils.playClickSound() + currentArmor = if (selectedState) null else this + armor.forEach { + it.selectedState = it == currentArmor + } + FFGuideGUI.updateDisplay() + } + } + + in equip -> { + { + SoundUtils.playClickSound() + currentEquip = if (selectedState) null else this + equip.forEach { + it.selectedState = it == currentEquip + } + FFGuideGUI.updateDisplay() + } + } + + in pets -> { + { + val prev = currentPet + currentPet = if (selectedState) lastEquippedPet else this + if (prev != currentPet) { + SoundUtils.playClickSound() + } + pets.forEach { + it.selectedState = it == currentPet + } + FFStats.getTotalFF() + } + } + + else -> { + {} + } + } + + fun getDisplay(clickEnabled: Boolean = false) = object : Renderable { + + val content = Renderable.clickable( + Renderable.itemStackWithTip( + getItem(), 1.0, 0, 0, false + ), + onClick = onClick(), + condition = { clickEnabled }) + + override val width = content.width + override val height = content.height + override val horizontalAlign = RenderUtils.HorizontalAlignment.CENTER + override val verticalAlign = RenderUtils.VerticalAlignment.CENTER + + override fun render(posX: Int, posY: Int) { + GuiScreen.drawRect( + 0, + 0, + width, + height, + if (this@FarmingItems.selectedState) 0xFFB3FFB3.toInt() else 0xFF43464B.toInt() + ) + content.render(posX, posY) + } + } + + private var ffData: Map? = null + + fun getFFData() = ffData ?: run { + val data = ffCalculation(getItemOrNull()) + ffData = data + data + } + + companion object { + + // TODO + var lastEquippedPet = ELEPHANT + + var currentPet: FarmingItems = lastEquippedPet + var currentArmor: FarmingItems? = null + var currentEquip: FarmingItems? = null + + val armor = listOf(HELMET, CHESTPLATE, LEGGINGS, BOOTS) + val equip = listOf(NECKLACE, CLOAK, BELT, BRACELET) + val pets = listOf(ELEPHANT, MOOSHROOM_COW, RABBIT, BEE) + + fun getArmorDisplay(clickEnabled: Boolean = false): List = armor.map { it.getDisplay(clickEnabled) } + + fun getEquipmentDisplay(clickEnabled: Boolean = false): List = + equip.map { it.getDisplay(clickEnabled) } + + fun getPetsDisplay(clickEnabled: Boolean = false): List = pets.map { it.getDisplay(clickEnabled) } + fun resetClickState() { + entries.filterNot { pets.contains(it) }.forEach { it.selectedState = false } + } + + fun resetFFData() { + entries.forEach { it.ffData = null } + } + + fun setDefaultPet(): FarmingItems { + currentPet = lastEquippedPet + pets.forEach { + it.selectedState = it == currentPet + } + return lastEquippedPet + } + + fun getFromItemCategory(category: ItemCategory) = entries.filter { it.itemCategory == category } + fun getFromItemCategoryOne(category: ItemCategory) = entries.firstOrNull { it.itemCategory == category } + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt index 1e911688aa3b..6ac7171fb5f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FarmingReforges.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide +// TODO replace with ReforgeAPI enum class FarmingReforges( val reforgeName: String, val reforgeItem: String, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt index 863bc95187e7..b5558b638042 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneStats.kt @@ -1,12 +1,21 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide -enum class FortuneStats(val label: String, val tooltip: String) { +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.utils.CollectionUtils.sumOfPair +import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase + +enum class FortuneStats( + private val label0: (CropType) -> String, + private val tooltip0: (CropType) -> String, + val onClick: (CropType) -> Unit = {}, +) { BASE( "§2Universal Farming Fortune", - "§7§2Farming fortune in that is\n§2applied to every crop\n§eNot the same as tab FF\n" + - "§eSee on the grass block page" + "§7§2Farming fortune in that is\n§2applied to every crop\n§eNot the same as tab FF\n" + "§eSee on the grass block page" ), - CROP_TOTAL("§6Crop Farming Fortune", "§7§2Farming fortune for this crop"), + CROP_TOTAL( + { crop -> "§6${crop.niceName.firstLetterUppercase()} Farming Fortune" }, + { "§7§2Farming fortune for this crop" }), ACCESSORY("§2Talisman Bonus", "§7§2Fortune from your talisman\n§2You get 10☘ per talisman tier"), CROP_UPGRADE("§2Crop Upgrade", "§7§2Fortune from Desk crop upgrades\n§2You get 5☘ per level"), BASE_TOOL("§2Base tool fortune", "§7§2Crop specific fortune from your tool"), @@ -20,19 +29,53 @@ enum class FortuneStats(val label: String, val tooltip: String) { CULTIVATING("§2Cultivating Enchantment", "§7§2Fortune for each enchantment level\n§2You get 2☘ per level"), TURBO("§2Turbo-Crop Enchantment", "§7§2Fortune for each enchantment level\n§2You get 5☘ per level"), DEDICATION("§2Dedication Enchantment", "§7§2Fortune for each enchantment level\n§2and crop milestone"), - EXPORTED_CARROT( - "§2Exportable Carrots", - "§7§2Gain 12☘ from giving 3,000 to Carrolyn in Scarleton!\n" + - "§eRun /shcarrot to toggle the stat" - ), - EXPIRED_PUMPKIN( - "§2Expired Pumpkin", - "§7§2Gain 12☘ from giving 3,000 to Carrolyn in Scarleton!\n" + - "§eRun /shpumpkin to toggle the stat" - ), - SUPREME_CHOCOLATE_BAR( - "§2Supreme Chocolate Bar", - "§7§2Gain 12☘ from giving 3,000 to Carrolyn in Scarleton!\n" + - "§eRun /shcocoabeans to toggle the stat" - ), + CARROLYN(::carrolynLabel, ::carrolynToolTip, ::carrolynOnClick), + ; + + constructor(label: String, tooltip: String) : this({ label }, { tooltip }) + + var current: Double = 0.0 + var max: Double = -1.0 + + fun label(crop: CropType) = label0(crop) + fun tooltip(crop: CropType) = tooltip0(crop) + + fun reset() { + current = 0.0 + max = -1.0 + } + + fun set(value: Pair) { + current = value.first + max = value.second + } + + fun set(current: Double, max: Double) { + this.current = current + this.max = max + } + + fun isActive() = max != -1.0 + + companion object { + + fun getTotal(): Pair = entries.filter { it.isActive() }.sumOfPair { it.current to it.max } + + fun reset() = entries.forEach { it.reset() } + } } + +private fun carrolynLabel(crop: CropType): String = + CarrolynTable.getByCrop(crop)?.label?.let { "§2$it" } ?: "§cError" + +private fun carrolynToolTip(crop: CropType): String = + "§7§2Gain 12☘ from giving 3,000\n§2 to Carrolyn in Scarleton!\n §e`Run /shcarrolyn ${ + crop.niceName + }` to toggle the stat\n §eor click the value" + +private fun carrolynOnClick(crop: CropType) = + CarrolynTable.getByCrop(crop)?.let { + it.setVisibleActive(!it.get()) + FFGuideGUI.updateDisplay() + } + diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt index 43b0c37d31a5..769253538aaa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt @@ -1,12 +1,16 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName + data class FortuneUpgrade( val description: String, val costCopper: Int?, - //todo make into NEUInternalName - val requiredItem: String, + private val requiredItemName: String, val itemQuantity: Int, val fortuneIncrease: Double, var cost: Int? = null, var costPerFF: Int? = null, // also the same as time to repay -) +) { + val requiredItem: NEUInternalName = requiredItemName.asInternalName() +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt index 191b9b7e5053..43289dc62b9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt @@ -9,12 +9,9 @@ import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop import at.hannibal2.skyhanni.features.garden.FarmingFortuneDisplay import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.currentPet -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrCommon import at.hannibal2.skyhanni.utils.ItemUtils.itemName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.addSuffix import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments @@ -25,8 +22,6 @@ import net.minecraft.item.ItemStack object FortuneUpgrades { - private val equipment = listOf(FarmingItems.NECKLACE, FarmingItems.CLOAK, FarmingItems.BELT, FarmingItems.BRACELET) - private val armor = listOf(FarmingItems.HELMET, FarmingItems.CHESTPLATE, FarmingItems.LEGGINGS, FarmingItems.BOOTS) private val axeCrops = listOf(CropType.MELON, CropType.PUMPKIN, CropType.COCOA_BEANS) val genericUpgrades = mutableListOf() @@ -64,7 +59,7 @@ object FortuneUpgrades { // todo fix NEU price data not being loaded if run too early private fun MutableList.populateAndSort(style: Int) { this.map { upgrade -> - val cost = (upgrade.requiredItem.asInternalName().getPrice() * upgrade.itemQuantity).toInt() + val cost = (upgrade.requiredItem.getPrice() * upgrade.itemQuantity).toInt() upgrade.cost = cost upgrade.costPerFF = (cost / upgrade.fortuneIncrease).toInt() } @@ -94,8 +89,8 @@ object FortuneUpgrades { private fun getEquipmentUpgrades() { val visitors = GardenAPI.storage?.uniqueVisitors?.toDouble() ?: 0.0 - for (piece in equipment) { - val item = piece.getItem() + for (piece in FarmingItems.equip) { + val item = piece.getItem() ?: return // todo tell them to buy the missing item if (!item.getInternalName().contains("LOTUS")) return val enchantments = item.getEnchantments() ?: emptyMap() @@ -124,11 +119,8 @@ object FortuneUpgrades { // todo adding armor tier upgrades later private fun getArmorUpgrades() { - for (piece in armor) { - val item = piece.getItem() - // todo skip if it doesnt exist -> tell them to buy it later - - if (FFGuideGUI.isFallbackItem(item)) return + for (piece in FarmingItems.armor) { + val item = piece.getItemOrNull() ?: return // todo tell them to buy it later recombobulateItem(item, genericUpgrades) when (item.getReforgeName()) { @@ -146,7 +138,7 @@ object FortuneUpgrades { // todo needs to be called when switching pets private fun getPetUpgrades() { - if (currentPet.getItem().getInternalName().contains(";")) { + if (FarmingItems.currentPet.getItemOrNull()?.getInternalName()?.contains(";") == true) { when (FFStats.currentPetItem) { "GREEN_BANDANA" -> {} "YELLOW_BANDANA" -> { @@ -160,11 +152,11 @@ object FortuneUpgrades { } } - fun getCropSpecific(tool: ItemStack) { + fun getCropSpecific(tool: ItemStack?) { cropSpecificUpgrades.clear() cropSpecificUpgrades.addAll(genericUpgrades) // todo tell them to get the tool if it is missing - val crop = tool.getCropType() ?: return + val crop = tool?.getCropType() ?: return val enchantments = tool.getEnchantments() ?: emptyMap() val turboCropLvl = enchantments[crop.getTurboCrop()] ?: 0 val dedicationLvl = enchantments["dedication"] ?: 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt index d9558cd2f5ed..ca813a4aef0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/CropPage.kt @@ -1,53 +1,87 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide.pages -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem +import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.fortuneguide.FFStats import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneStats +import at.hannibal2.skyhanni.utils.CollectionUtils.split import at.hannibal2.skyhanni.utils.GuiRenderUtils -import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase - -class CropPage : FFGuideGUI.FFGuidePage() { - - override fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) { - for (item in FarmingItems.entries) { - if (item.name == FFGuideGUI.currentCrop?.name) { - GuiRenderUtils.renderItemAndTip( - FFGuideGUI.tooltipToDisplay, - item.getItem(), - FFGuideGUI.guiLeft + 172, - FFGuideGUI.guiTop + 60, - mouseX, - mouseY - ) - } - } - - var x: Int - var y = FFGuideGUI.guiTop - 20 - var i = 0 - FFStats.cropPage.forEach { (key, value) -> - if (key == FortuneStats.CROP_TOTAL) { - val newLine = - key.label.replace("Crop", FFGuideGUI.currentCrop?.name?.replace("_", " ")?.firstLetterUppercase()!!) - GuiRenderUtils.drawFarmingBar( - newLine, key.tooltip, value.first, value.second, FFGuideGUI.guiLeft + 135, - FFGuideGUI.guiTop + 5, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) - } else { - if (i % 2 == 0) { - x = FFGuideGUI.guiLeft + 15 - y += 25 - } else { - x = FFGuideGUI.guiLeft + 255 - } - i++ - GuiRenderUtils.drawFarmingBar( - key.label, key.tooltip, value.first, value.second, x, y, - 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.guide.GuideTablePage +import at.hannibal2.skyhanni.utils.renderables.Renderable + +class CropPage(val crop0: () -> CropType, sizeX: Int, sizeY: Int, paddingX: Int = 15, paddingY: Int = 7) : + GuideTablePage( + sizeX, + sizeY, + paddingX, + paddingY + ) { + + val crop get() = crop0() + + override fun onEnter() { + val item = crop.farmingItem + FFStats.getCropStats(crop, item.getItemOrNull()) + + FarmingItems.resetClickState() + val toolLines = toolLines().split().map { Renderable.verticalContainer(it, 2) } + update( + listOf( + header(), + listOf( + toolLines[0], + equipDisplay(), + toolLines[1], ) - } - } + ), + emptyList() + ) + } + + private fun header(): List = buildList { + add(FortuneStats.BASE.getFarmingBar()) + + add( + FortuneStats.CROP_TOTAL.getFarmingBar(110) + ) + + add(FortuneStats.CROP_UPGRADE.getFarmingBar()) + } + + private fun FortuneStats.getFarmingBar( + width: Int = 90, + ) = Renderable.clickable( + GuiRenderUtils.getFarmingBar(label(crop), tooltip(crop), current, max, width), + { onClick(crop) }) + + private fun toolLines(): List = + FortuneStats.entries.filter { it.isActive() && it !in headers }.map { it.getFarmingBar() } + + private fun equipDisplay(): Renderable = + Renderable.fixedSizeCollum( + Renderable.verticalContainer( + listOf( + crop.farmingItem.getDisplay(), + Renderable.horizontalContainer( + listOf( + Renderable.verticalContainer(FarmingItems.getArmorDisplay(), 2), + Renderable.verticalContainer(FarmingItems.getEquipmentDisplay(), 2) + ), + 2, + horizontalAlign = RenderUtils.HorizontalAlignment.CENTER + ), + Renderable.horizontalContainer(FarmingItems.getPetsDisplay(true), 2) + ), + 2, + verticalAlign = RenderUtils.VerticalAlignment.BOTTOM + ), + 144, + horizontalAlign = RenderUtils.HorizontalAlignment.CENTER, + verticalAlign = RenderUtils.VerticalAlignment.BOTTOM + ) + + companion object { + private val headers = setOf(FortuneStats.BASE, FortuneStats.CROP_TOTAL, FortuneStats.CROP_UPGRADE) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt index 605081e4e90d..6eead6399f66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt @@ -1,272 +1,234 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide.pages -import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.currentArmor -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.currentEquipment -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.getItem +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFInfos import at.hannibal2.skyhanni.features.garden.fortuneguide.FFStats import at.hannibal2.skyhanni.features.garden.fortuneguide.FFTypes import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems -import at.hannibal2.skyhanni.utils.GuiRenderUtils -import at.hannibal2.skyhanni.utils.TimeUtils - -class OverviewPage : FFGuideGUI.FFGuidePage() { - - private var equipmentFF = mutableMapOf() - private var armorFF = mutableMapOf() +import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.guide.GuideTablePage +import at.hannibal2.skyhanni.utils.renderables.Renderable + +class OverviewPage(sizeX: Int, sizeY: Int, paddingX: Int = 15, paddingY: Int = 7, footerSpacing: Int = 6) : + GuideTablePage( + sizeX, sizeY, paddingX, paddingY, footerSpacing + ) { + + override fun onEnter() { + val (content, footer) = getPage() + update(content, footer) + } // TODO display armor stats for gemstones and pesterminator - override fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) { - val timeUntilCakes = TimeUtils.formatDuration(FFStats.cakeExpireTime - System.currentTimeMillis()) - - GuiRenderUtils.drawFarmingBar( - "§6Universal Farming Fortune", - "§7§2Farming fortune in that is\n§2applied to every crop\n§eNot the same as tab FF\n" + - "§eSee on the grass block page", FFStats.totalBaseFF[FFTypes.TOTAL] ?: 0, if (FFStats.usingSpeedBoots) 1373 else 1377, - FFGuideGUI.guiLeft + 15, FFGuideGUI.guiTop + 5, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + // TODO display pest bestiary + fun getPage(): Pair>, List> { + val content = mutableListOf>() + val footer = mutableListOf() + val timeUntilCakes = FFStats.cakeExpireTime.timeUntil().format(TimeUnit.HOUR, maxUnits = 1) - var line = if (FFTypes.ANITA.notSaved()) "§cAnita buff not saved\n§eVisit Anita to set it!" - else "§7§2Fortune for levelling your Anita extra crops\n§2You get 4☘ per buff level" - GuiRenderUtils.drawFarmingBar( - "§2Anita Buff", line, FFStats.baseFF[FFTypes.ANITA] ?: 0.0, 60, FFGuideGUI.guiLeft + 15, - FFGuideGUI.guiTop + 30, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 0, + FFInfos.UNIVERSAL.bar( + "§6Universal Farming Fortune", + "§7§2Farming fortune in that is\n§2applied to every crop\n§eNot the same as tab FF\n" + + "§eSee on the grass block page" + ) + ) + + content.addTable( + 1, + FFInfos.ANITA_BUFF.bar( + "§2Anita Buff", if (FFTypes.ANITA.notSaved()) "§cAnita buff not saved\n§eVisit Anita to set it!" + else "§7§2Fortune for levelling your Anita extra crops\n§2You get 4☘ per buff level" + ) ) - line = if (FFTypes.FARMING_LVL.notSaved()) "§cFarming level not saved\n§eOpen /skills to set it!" - else "§7§2Fortune for levelling your farming skill\n§2You get 4☘ per farming level" - GuiRenderUtils.drawFarmingBar( - "§2Farming Level", line, FFStats.baseFF[FFTypes.FARMING_LVL] ?: 0.0, 240, FFGuideGUI.guiLeft + 15, - FFGuideGUI.guiTop + 55, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 2, + FFInfos.FARMING_LEVEL.bar( + "§2Farming Level", + if (FFTypes.FARMING_LVL.notSaved()) "§cFarming level not saved\n§eOpen /skills to set it!" + else "§7§2Fortune for levelling your farming skill\n§2You get 4☘ per farming level" + ) ) - line = - if (FFTypes.COMMUNITY_SHOP.notSaved()) "§cCommunity upgrade level not saved\n§eVisit Elizabeth to set it!" - else "§7§2Fortune for community shop upgrades\n§2You get 4☘ per upgrade tier" - GuiRenderUtils.drawFarmingBar( - "§2Community upgrades", line, FFStats.baseFF[FFTypes.COMMUNITY_SHOP] ?: 0.0, - 40, FFGuideGUI.guiLeft + 15, FFGuideGUI.guiTop + 80, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 3, + FFInfos.COMMUNITY_SHOP.bar( + "§2Community upgrades", + if (FFTypes.COMMUNITY_SHOP.notSaved()) "§cCommunity upgrade level not saved\n§eVisit Elizabeth to set it!" + else "§7§2Fortune for community shop upgrades\n§2You get 4☘ per upgrade tier" + ) ) - line = - if (FFTypes.PLOTS.notSaved()) "§cUnlocked plot count not saved\n§eOpen /desk and view your plots to set it!" - else "§7§2Fortune for unlocking garden plots\n§2You get 3☘ per plot unlocked" - GuiRenderUtils.drawFarmingBar( - "§2Garden Plots", line, FFStats.baseFF[FFTypes.PLOTS] ?: 0.0, 72, FFGuideGUI.guiLeft + 15, - FFGuideGUI.guiTop + 105, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 4, + FFInfos.GARDEN_PLOTS.bar( + "§2Garden Plots", + if (FFTypes.PLOTS.notSaved()) "§cUnlocked plot count not saved\n§eOpen /desk and view your plots to set it!" + else "§7§2Fortune for unlocking garden plots\n§2You get 3☘ per plot unlocked" + ) ) - line = when (FFStats.cakeExpireTime) { - -1L -> "§eYou have not eaten a cake since\n§edownloading this update, assuming the\n§ebuff is active!" - else -> "§7§2Fortune for eating cake\n§2You get 5☘ for eating cake\n§2Time until cake buff runs out: $timeUntilCakes" - } - if (FFStats.cakeExpireTime - System.currentTimeMillis() < 0 && FFStats.cakeExpireTime != -1L) { - line = "§cYour cake buff has run out\nGo eat some cake!" - } - GuiRenderUtils.drawFarmingBar( - "§2Cake Buff", line, FFStats.baseFF[FFTypes.CAKE] ?: 0.0, 5, FFGuideGUI.guiLeft + 15, - FFGuideGUI.guiTop + 130, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + content.addTable( + 5, + FFInfos.CAKE_BUFF.bar( + "§2Cake Buff", when { + FFStats.cakeExpireTime.isFarPast() -> "§eYou have not eaten a cake since\n§edownloading this update, assuming the\n§ebuff is active!" + FFStats.cakeExpireTime.isInPast() -> "§cYour cake buff has run out\nGo eat some cake!" + else -> "§7§2Fortune for eating cake\n§2You get 5☘ for eating cake\n§2Time until cake buff runs out: $timeUntilCakes" + } + ) + ) + + val armorName = FarmingItems.currentArmor?.getItem()?.displayName ?: "" + + val wordArmor = if (FarmingItems.currentArmor == null) "Armor" else "Piece" + + + content.addTable( + 1, + FFInfos.TOTAL_ARMOR.bar( + "§2Total $wordArmor Fortune", + if (FarmingItems.currentArmor == null) "§7§2Total fortune from your armor\n§2Select a piece for more info" + else "§7§2Total fortune from your\n$armorName" + ) + ) + + content.addTable( + 2, + FFInfos.BASE_ARMOR.bar( + "§2Base $wordArmor Fortune", + if (FarmingItems.currentArmor == null) "§7§2The base fortune from your armor\n§2Select a piece for more info" + else "§7§2Base fortune from your\n$armorName" + ) + ) + + content.addTable( + 3, + FFInfos.ABILITY_ARMOR.bar( + "§2$wordArmor Ability", + if (FarmingItems.currentArmor == null) "§7§2The fortune from your armor's ability\n§2Select a piece for more info" + else "§7§2Ability fortune from your\n$armorName" + ) + ) + + content.addTable( + 4, + FFInfos.REFORGE_ARMOR.bar( + "§2$wordArmor Reforge", + if (FarmingItems.currentArmor == null) "§7§2The fortune from your armor's reforge\n§2Select a piece for more info" + else "§7§2Total fortune from your\n$armorName}" + ) + ) + + footer.add( + FFInfos.TOTAL_PET.bar("§2Total Pet Fortune", "§7§2The total fortune from your pet and its item") + ) - val armorItem = when (currentArmor) { - 1 -> FarmingItems.HELMET - 2 -> FarmingItems.CHESTPLATE - 3 -> FarmingItems.LEGGINGS - else -> FarmingItems.BOOTS - } - - armorFF = when (currentArmor) { - 1 -> FFStats.helmetFF - 2 -> FFStats.chestplateFF - 3 -> FFStats.leggingsFF - 4 -> FFStats.bootsFF - else -> FFStats.armorTotalFF - } - - var word = if (currentArmor == 0) "Armor" else "Piece" - - line = if (currentArmor == 0) "§7§2Total fortune from your armor\n§2Select a piece for more info" - else "§7§2Total fortune from your\n${armorItem.getItem().displayName}" - var value = if (FFStats.usingSpeedBoots) { - when (currentArmor) { - 0 -> 421 - 1 -> 101.67 - 2, 3 -> 106.67 - 4 -> 106 - else -> 0 - } - } else { - when (currentArmor) { - 0 -> 425 - 1, 4 -> 103.75 - 2, 3 -> 108.75 - else -> 0 - } - } - GuiRenderUtils.drawFarmingBar( - "§2Total $word Fortune", line, armorFF[FFTypes.TOTAL] ?: 0, value, - FFGuideGUI.guiLeft + 135, FFGuideGUI.guiTop + 30, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + footer.add( + FFInfos.PET_ITEM.bar( + "§2Pet Item", when (FFStats.currentPetItem) { + "GREEN_BANDANA" -> "§7§2The fortune from your pet's item\n§2Grants 4☘ per garden level" + "YELLOW_BANDANA" -> "§7§2The fortune from your pet's item" + "MINOS_RELIC" -> "§cGreen Bandana is better for fortune than minos relic!" + else -> "No fortune boosting pet item" + } + ) + ) + + val wordEquip = if (FarmingItems.currentEquip == null) "Equipment" else "Piece" - line = if (currentArmor == 0) "§7§2The base fortune from your armor\n§2Select a piece for more info" - else "§7§2Base fortune from your\n${armorItem.getItem().displayName}" - value = when (currentArmor) { - 0 -> if (FFStats.usingSpeedBoots) 160 else 130 - 1 -> 30 - 2 -> 35 - 3 -> 35 - else -> if (FFStats.usingSpeedBoots) 60 else 30 - } - GuiRenderUtils.drawFarmingBar( - "§2Base $word Fortune", line, armorFF[FFTypes.BASE] ?: 0, - value, FFGuideGUI.guiLeft + 135, - FFGuideGUI.guiTop + 55, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + val equipmentName = FarmingItems.currentEquip?.getItem()?.displayName ?: "" - line = if (currentArmor == 0) "§7§2The fortune from your armor's ability\n§2Select a piece for more info" - else "§7§2Ability fortune from your\n${armorItem.getItem().displayName}" - value = if (FFStats.usingSpeedBoots) { - when (currentArmor) { - 0 -> 50 - 4 -> 0 - else -> 16.667 - } - } else { - when (currentArmor) { - 0 -> 75 - else -> 18.75 - } - } - - GuiRenderUtils.drawFarmingBar( - "§2$word Ability", line, armorFF[FFTypes.ABILITY] ?: 0, - value, FFGuideGUI.guiLeft + 135, - FFGuideGUI.guiTop + 80, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 1, + FFInfos.TOTAL_EQUIP.bar( + "§2Total $wordEquip Fortune", + if (FarmingItems.currentEquip == null) "§7§2Total fortune from all your equipment\n§2Select a piece for more info" + else "§7§2Total fortune from your\n$equipmentName" + ) ) - line = if (currentArmor == 0) "§7§2The fortune from your armor's reforge\n§2Select a piece for more info" - else "§7§2Total fortune from your\n${armorItem.getItem().displayName}" - value = if (currentArmor == 0) { - if (FFStats.usingSpeedBoots) 115 else 120 - } else if (currentArmor == 4) { - if (FFStats.usingSpeedBoots) 25 else 30 - } else 30 - GuiRenderUtils.drawFarmingBar( - "§2$word Reforge", line, armorFF[FFTypes.REFORGE] ?: 0, - value, FFGuideGUI.guiLeft + 135, - FFGuideGUI.guiTop + 105, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) - var currentPet = FFStats.rabbitFF - var petMaxFF = 60 - when (FFGuideGUI.currentPet) { - FarmingItems.ELEPHANT -> { - currentPet = FFStats.elephantFF - petMaxFF = 210 - } - - FarmingItems.MOOSHROOM_COW -> { - currentPet = FFStats.mooshroomFF - petMaxFF = 217 - } - - FarmingItems.BEE -> { - currentPet = FFStats.beeFF - petMaxFF = 90 - } - - else -> {} - } - - GuiRenderUtils.drawFarmingBar( - "§2Total Pet Fortune", "§7§2The total fortune from your pet and its item", - currentPet[FFTypes.TOTAL] ?: 0, petMaxFF, FFGuideGUI.guiLeft + 105, - FFGuideGUI.guiTop + 155, 70, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 2, + FFInfos.BASE_EQUIP.bar( + "§2$wordEquip Base Fortune", + if (FarmingItems.currentEquip == null) "§7§2The base fortune from all your equipment\n§2Select a piece for more info" + else "§7§2Total base fortune from your\n$equipmentName" + ) ) - line = when (FFStats.currentPetItem) { - "GREEN_BANDANA" -> "§7§2The fortune from your pet's item\n§2Grants 4☘ per garden level" - "YELLOW_BANDANA" -> "§7§2The fortune from your pet's item" - "MINOS_RELIC" -> "§cGreen Bandana is better for fortune than minos relic!" - else -> "No fortune boosting pet item" - } - GuiRenderUtils.drawFarmingBar( - "§2Pet Item", line, currentPet[FFTypes.PET_ITEM] ?: 0, 60, FFGuideGUI.guiLeft + 185, - FFGuideGUI.guiTop + 155, 70, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 3, + FFInfos.ABILITY_EQUIP.bar( + "§2$wordEquip Ability", + if (FarmingItems.currentEquip == null) "§7§2The fortune from all of your equipment's abilities\n§2Select a piece for more info" + else "§7§2Total ability fortune from your\n$equipmentName" + ) ) - word = if (currentEquipment == 0) "Equipment" else "Piece" - - val equipmentItem = when (currentEquipment) { - 1 -> FarmingItems.NECKLACE - 2 -> FarmingItems.CLOAK - 3 -> FarmingItems.BELT - else -> FarmingItems.BRACELET - } - - equipmentFF = when (currentEquipment) { - 1 -> FFStats.necklaceFF - 2 -> FFStats.cloakFF - 3 -> FFStats.beltFF - 4 -> FFStats.braceletFF - else -> FFStats.equipmentTotalFF - } - - val maxEquipmentBaseFortune = 5.0 - val maxEquipmentAbilityFortune = 15.0 - val maxEquipmentReforgeFortune = 15.0 - val maxGreenThumbFortune = GardenAPI.totalAmountVisitorsExisting.toDouble() / 4 - - val maxFortunePerPiece = - maxEquipmentBaseFortune + maxEquipmentAbilityFortune + maxEquipmentReforgeFortune + maxGreenThumbFortune - - line = if (currentEquipment == 0) "§7§2Total fortune from all your equipment\n§2Select a piece for more info" - else "§7§2Total fortune from your\n${equipmentItem.getItem().displayName}" - GuiRenderUtils.drawFarmingBar( - "§2Total $word Fortune", line, equipmentFF[FFTypes.TOTAL] ?: 0, - if (currentEquipment == 0) maxFortunePerPiece * 4 else maxFortunePerPiece, - - FFGuideGUI.guiLeft + 255, FFGuideGUI.guiTop + 30, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 4, + FFInfos.REFORGE_EQUIP.bar( + "§2$wordEquip Reforge", + if (FarmingItems.currentEquip == null) "§7§2The fortune from all of your equipment's reforges\n§2Select a piece for more info" + else "§7§2Total reforge fortune from your\n$equipmentName" + ) ) - line = if (currentEquipment == 0) "§7§2The base fortune from all your equipment\n§2Select a piece for more info" - else "§7§2Total base fortune from your\n${equipmentItem.getItem().displayName}" - GuiRenderUtils.drawFarmingBar( - "§2$word Base Fortune", line, equipmentFF[FFTypes.BASE] ?: 0, - if (currentEquipment == 0) maxEquipmentBaseFortune * 4 else maxEquipmentBaseFortune, - FFGuideGUI.guiLeft + 255, FFGuideGUI.guiTop + 55, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + content.addTable( + 5, + Renderable.horizontalContainer( + FarmingItems.getPetsDisplay(true), + 4, + horizontalAlign = RenderUtils.HorizontalAlignment.CENTER, + verticalAlign = RenderUtils.VerticalAlignment.CENTER + ) + ) + + content.addTable( + 5, + FFInfos.ENCHANT_EQUIP.bar( + "§2$wordEquip Enchantment", + if (FarmingItems.currentEquip == null) "§7§2The fortune from all of your equipment's enchantments\n§2Select a piece for more info" + else "§7§2Total enchantment fortune from your\n${FarmingItems.currentEquip!!.getItem().displayName}" + ) + ) + + // Displays - line = - if (currentEquipment == 0) "§7§2The fortune from all of your equipment's abilities\n§2Select a piece for more info" - else "§7§2Total ability fortune from your\n${equipmentItem.getItem().displayName}" - GuiRenderUtils.drawFarmingBar( - "§2$word Ability", line, equipmentFF[FFTypes.ABILITY] ?: 0, - if (currentEquipment == 0) maxEquipmentAbilityFortune * 4 else maxEquipmentAbilityFortune, - FFGuideGUI.guiLeft + 255, FFGuideGUI.guiTop + 80, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 0, + Renderable.horizontalContainer( + FarmingItems.getArmorDisplay(true), + 4, + horizontalAlign = RenderUtils.HorizontalAlignment.CENTER, + verticalAlign = RenderUtils.VerticalAlignment.CENTER + ) ) - - line = - if (currentEquipment == 0) "§7§2The fortune from all of your equipment's reforges\n§2Select a piece for more info" - else "§7§2Total reforge fortune from your\n${equipmentItem.getItem().displayName}" - GuiRenderUtils.drawFarmingBar( - "§2$word Reforge", line, equipmentFF[FFTypes.REFORGE] ?: 0, - if (currentEquipment == 0) maxEquipmentReforgeFortune * 4 else maxEquipmentReforgeFortune, - FFGuideGUI.guiLeft + 255, FFGuideGUI.guiTop + 105, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay + content.addTable( + 0, + Renderable.horizontalContainer( + FarmingItems.getEquipmentDisplay(true), + 4, + horizontalAlign = RenderUtils.HorizontalAlignment.CENTER, + verticalAlign = RenderUtils.VerticalAlignment.CENTER + ) ) - line = - if (currentEquipment == 0) "§7§2The fortune from all of your equipment's enchantments\n§2Select a piece for more info" - else "§7§2Total enchantment fortune from your\n${equipmentItem.getItem().displayName}" - GuiRenderUtils.drawFarmingBar( - "§2$word Enchantment", line, equipmentFF[FFTypes.GREEN_THUMB] ?: 0, - if (currentEquipment == 0) maxGreenThumbFortune * 4 else maxGreenThumbFortune, - FFGuideGUI.guiLeft + 255, FFGuideGUI.guiTop + 130, 90, mouseX, mouseY, FFGuideGUI.tooltipToDisplay - ) + + return content to footer } private fun FFTypes.notSaved(): Boolean = FFStats.baseFF[this]?.let { it < 0.0 } ?: true } + +private fun MutableList>.addTable(row: Int, r: Renderable) { + this.getOrNull(row)?.add(r) ?: mutableListOf(r).let { this.add(row, it) } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt index e8134a3370a0..2323b5e3017e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt @@ -1,126 +1,103 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide.pages -import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems +import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrade import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrades -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi -import at.hannibal2.skyhanni.utils.GuiRenderUtils import at.hannibal2.skyhanni.utils.ItemUtils.itemName -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NumberUtil -import net.minecraft.client.renderer.GlStateManager -import net.minecraft.util.MathHelper +import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment +import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment +import at.hannibal2.skyhanni.utils.guide.GuideScrollPage +import at.hannibal2.skyhanni.utils.renderables.Renderable import java.text.DecimalFormat -class UpgradePage : FFGuideGUI.FFGuidePage() { +class UpgradePage(val crop0: () -> CropType?, sizeX: Int, sizeY: Int, paddingX: Int = 15, paddingY: Int = 7) : + GuideScrollPage( + sizeX, + sizeY, + paddingX, + paddingY, + marginY = 10, + hasHeader = true, + ) { - private var pageScroll = 0 - private var scrollVelocity = 0.0 - private val maxNoInputFrames = 100 - private var listLength = 0 + val crop get() = crop0() - override fun drawPage(mouseX: Int, mouseY: Int, partialTicks: Float) { - val adjustedY = FFGuideGUI.guiTop + 20 + pageScroll - val inverseScale = 1 / 0.75f + override fun onEnter() { + crop?.let { + FortuneUpgrades.getCropSpecific(it.farmingItem.getItemOrNull()) + } ?: { + FortuneUpgrades.getCropSpecific(null) // TODO + } - // TODO fix duplicate drawString lines, add guiLeft, guiTop and inverseScale - GlStateManager.scale(0.75f, 0.75f, 1f) - GuiRenderUtils.drawString( - "Upgrade", - (FFGuideGUI.guiLeft + 45) * inverseScale, - (FFGuideGUI.guiTop + 5) * inverseScale - ) - GuiRenderUtils.drawString( - "Item", - (FFGuideGUI.guiLeft + 190) * inverseScale, - (FFGuideGUI.guiTop + 5) * inverseScale - ) - GuiRenderUtils.drawString( - "FF increase", - (FFGuideGUI.guiLeft + 240) * inverseScale, - (FFGuideGUI.guiTop + 5) * inverseScale - ) - GuiRenderUtils.drawString( - "Cost/FF", - (FFGuideGUI.guiLeft + 290) * inverseScale, - (FFGuideGUI.guiTop + 5) * inverseScale + FarmingItems.resetClickState() + update( + content = buildList { + add(header()) + val upgradeList = if (crop == null) + FortuneUpgrades.genericUpgrades + else + FortuneUpgrades.cropSpecificUpgrades + addAll(upgradeList.map { upgrade -> upgrade.print() }) + } ) - GuiRenderUtils.drawString( - "Total", - (FFGuideGUI.guiLeft + 330) * inverseScale, - (FFGuideGUI.guiTop + 5) * inverseScale + } + + private fun header() = listOf("Upgrade", "", "Item", "FF", "Cost/FF", "Total").map { + Renderable.string( + it, + 0.9, + horizontalAlign = HorizontalAlignment.CENTER ) + } - val upgradeList = - if (FFGuideGUI.currentCrop == null) FortuneUpgrades.genericUpgrades else FortuneUpgrades.cropSpecificUpgrades - listLength = upgradeList.size - for ((index, upgrade) in upgradeList.withIndex()) { - if (adjustedY + 25 * index < FFGuideGUI.guiTop + 20) continue - if (adjustedY + 25 * index > FFGuideGUI.guiTop + 160) continue - val upgradeItem = upgrade.requiredItem.asInternalName().getItemStack() - var formattedUpgrade = upgradeItem.itemName - if (adjustedY + 25 * index - 5 < FFGuideGUI.lastClickedHeight && FFGuideGUI.lastClickedHeight < adjustedY + 25 * index + 10) { - FFGuideGUI.lastClickedHeight = 0 - BazaarApi.searchForBazaarItem(formattedUpgrade, upgrade.itemQuantity) - } - if (upgrade.itemQuantity != 1) { - formattedUpgrade = "$formattedUpgrade §fx${upgrade.itemQuantity}" - } - GuiRenderUtils.drawTwoLineString( - upgrade.description, - (FFGuideGUI.guiLeft + 15) * inverseScale, - (adjustedY + 25 * index) * inverseScale + private fun FortuneUpgrade.print() = buildList { + add( + Renderable.wrappedString( + description, + 136, + 0.75, + verticalAlign = VerticalAlignment.CENTER ) - GuiRenderUtils.renderItemAndTip( - FFGuideGUI.tooltipToDisplay, - upgradeItem, - (FFGuideGUI.guiLeft + 155) * inverseScale, - (adjustedY + 25 * index - 5) * inverseScale, - mouseX * inverseScale, - mouseY * inverseScale, - 0x00FFFFFF + ) + add( + Renderable.itemStackWithTip( + requiredItem.getItemStack(), + 8.0 / 9.0, + verticalAlign = VerticalAlignment.CENTER ) - GuiRenderUtils.drawString( - formattedUpgrade, - (FFGuideGUI.guiLeft + 180) * inverseScale, - (adjustedY + 25 * index) * inverseScale + ) + add( + Renderable.wrappedString( + requiredItem.itemName.let { if (itemQuantity == 1) it else "$it §fx$itemQuantity" }, // TODO wtf + 70, + 0.75, + verticalAlign = VerticalAlignment.CENTER ) - GuiRenderUtils.drawString( - "§a${DecimalFormat("0.##").format(upgrade.fortuneIncrease)}", - (FFGuideGUI.guiLeft + 270) * inverseScale, - (adjustedY + 25 * index) * inverseScale + ) + add( + Renderable.string( + "§a${DecimalFormat("0.##").format(fortuneIncrease)}", + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER ) - GuiRenderUtils.drawString( - "§6" + upgrade.costPerFF?.let { NumberUtil.format(it) }, - (FFGuideGUI.guiLeft + 300) * inverseScale, - (adjustedY + 25 * index) * inverseScale + ) // TODO cleaner formating + add( + Renderable.string( + "§6" + costPerFF?.let { NumberUtil.format(it) }, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER ) - GuiRenderUtils.drawString( - ("§6" + upgrade.cost?.let { NumberUtil.format(it) }), - (FFGuideGUI.guiLeft + 335) * inverseScale, - (adjustedY + 25 * index) * inverseScale + ) + add( + Renderable.string( + "§6" + cost?.let { NumberUtil.format(it) }, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER ) - } - GlStateManager.scale(inverseScale, inverseScale, 1f) - scrollScreen() - } - - private fun scrollScreen() { - scrollVelocity += FFGuideGUI.lastMouseScroll / 48.0 - scrollVelocity *= 0.95 - pageScroll += scrollVelocity.toInt() + FFGuideGUI.lastMouseScroll / 24 - - FFGuideGUI.noMouseScrollFrames++ - - if (FFGuideGUI.noMouseScrollFrames >= maxNoInputFrames) { - scrollVelocity *= 0.75 - } - - if (pageScroll > 0) { - pageScroll = 0 - } - - pageScroll = MathHelper.clamp_int(pageScroll, -(listLength * 15 - 15), 0) - FFGuideGUI.lastMouseScroll = 0 + ) } } + diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt index a0bf7fbc36df..42b8b5d35aa6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt @@ -2,10 +2,11 @@ package at.hannibal2.skyhanni.features.garden.inventory import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.jsonobjects.repo.AnitaUpgradeCostsJson -import at.hannibal2.skyhanni.data.jsonobjects.repo.AnitaUpgradeCostsJson.Price +import at.hannibal2.skyhanni.data.jsonobjects.repo.AnitaUpgradePrice import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.indexOfFirst import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AnitaExtraFarmingFortune { +@SkyHanniModule +object AnitaExtraFarmingFortune { private val config get() = GardenAPI.config.anitaShop @@ -26,7 +28,7 @@ class AnitaExtraFarmingFortune { "§5§o§aJacob's Ticket §8x(?.*)" ) - private var levelPrice = mapOf() + private var levelPrice = mapOf() @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { @@ -39,7 +41,7 @@ class AnitaExtraFarmingFortune { val anitaUpgrade = GardenAPI.storage?.fortune?.anitaUpgrade ?: return var contributionFactor = 1.0 - val baseAmount = levelPrice[anitaUpgrade + 1]?.jacob_tickets ?: return + val baseAmount = levelPrice[anitaUpgrade + 1]?.jacobTickets ?: return for (line in event.toolTip) { realAmountPattern.matchMatcher(line) { val realAmount = group("realAmount").formatDouble() @@ -51,8 +53,8 @@ class AnitaExtraFarmingFortune { var jacobTickets = 0 for ((level, price) in levelPrice) { if (level > anitaUpgrade) { - goldMedals += price.gold_medals - jacobTickets += price.jacob_tickets + goldMedals += price.goldMedals + jacobTickets += price.jacobTickets } } jacobTickets = (contributionFactor * jacobTickets).toInt() @@ -78,7 +80,7 @@ class AnitaExtraFarmingFortune { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("AnitaUpgradeCosts") - levelPrice = data.level_price + levelPrice = data.levelPrice } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt index eb73cf85c441..c9759cd58771 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.indexOfFirst import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenCropMilestoneInventory { +@SkyHanniModule +object GardenCropMilestoneInventory { private var average = -1.0 private val config get() = GardenAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt index f5e5e9b458d8..959f12bc2baf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryNumbers.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.model.ComposterUpgrade import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenInventoryNumbers { +@SkyHanniModule +object GardenInventoryNumbers { private val config get() = GardenAPI.config.number diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryTooltipOverflow.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryTooltipOverflow.kt index b4f76c9f2bc8..0f89f9cf267e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryTooltipOverflow.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenInventoryTooltipOverflow.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // TODO: Merge common code with skill overflow -class GardenInventoryTooltipOverflow { +@SkyHanniModule +object GardenInventoryTooltipOverflow { private val config get() = SkyHanniMod.feature.garden.cropMilestones.overflow diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/LogBookStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/LogBookStats.kt index 98437c7c17a4..0604f2528de9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/LogBookStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/LogBookStats.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -18,7 +19,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.init.Items import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class LogBookStats { +@SkyHanniModule +object LogBookStats { private val groupPattern = RepoPattern.group("garden.inventory.logbook") private val visitedPattern by groupPattern.pattern( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 0b6d3c936210..625216f858bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -1,10 +1,12 @@ package at.hannibal2.skyhanni.features.garden.inventory import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.garden.SkyMartConfig import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -17,14 +19,15 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.JsonPrimitive import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SkyMartCopperPrice { +@SkyHanniModule +object SkyMartCopperPrice { private val copperPattern by RepoPattern.pattern( "garden.inventory.skymart.copper", @@ -34,10 +37,7 @@ class SkyMartCopperPrice { private var display = emptyList() private val config get() = GardenAPI.config.skyMart - companion object { - - var inInventory = false - } + var inInventory = false @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { @@ -56,7 +56,8 @@ class SkyMartCopperPrice { } ?: continue val internalName = item.getInternalName() - val itemPrice = internalName.getPriceOrNull() ?: continue + val useSellPrice = config.overlayPriceType == SkyMartConfig.OverlayPriceTypeEntry.SELL_ORDER + val itemPrice = internalName.getPriceOrNull(useSellPrice) ?: continue val profit = itemPrice - (otherItemsPrice ?: 0.0) val factor = profit / copper diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt index 1391f5706174..157f05c30fb1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden.inventory.plots import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenNextPlotPrice { +@SkyHanniModule +object GardenNextPlotPrice { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotIcon.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotIcon.kt index 130de69264f8..1fc378b7e890 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotIcon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotIcon.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -17,6 +18,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenPlotIcon { private val config get() = GardenAPI.config.plotIcon @@ -88,7 +90,7 @@ object GardenPlotIcon { if (!isEnabled()) return lastClickedSlotId = event.slotId if (event.slotId == 53) { - event.isCanceled = true + event.cancel() if (event.clickedButton == 0) { if (editMode == 2) editMode = 0 @@ -104,7 +106,7 @@ object GardenPlotIcon { } if (editMode != 0) { if (event.slotId in 54..89) { - event.isCanceled = true + event.cancel() copyStack = event.slot?.stack?.copy()?.also { it.stackSize = 1 } ?: return @@ -115,7 +117,7 @@ object GardenPlotIcon { if (event.slotId != 53) { val plotList = plotList ?: return if (!whitelistedSlot.contains(event.slotId)) return - event.isCanceled = true + event.cancel() if (editMode == 2) { plotList.remove(event.slotId) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt index 6cc02cf1bad7..af84bd7717b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenPlotMenuHighlighting.kt @@ -9,11 +9,13 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.currentSpray import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBeingPasted import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.locked import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GardenPlotMenuHighlighting { +@SkyHanniModule +object GardenPlotMenuHighlighting { private val config get() = GardenAPI.config.plotMenuHighlighting diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt index 530c973221e2..0d3cadfacdec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt @@ -1,5 +1,7 @@ package at.hannibal2.skyhanni.features.garden.pests +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -19,6 +21,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.locked import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.uncleared +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun @@ -37,6 +40,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object PestAPI { val config get() = GardenAPI.config.pests @@ -150,12 +154,11 @@ object PestAPI { private fun updatePests() { if (!firstScoreboardCheck) return fixPests() - PestUpdateEvent().postAndCatch() + PestUpdateEvent().post() } - @SubscribeEvent + @HandleEvent(onlyOnIsland = IslandType.GARDEN) fun onPestSpawn(event: PestSpawnEvent) { - if (!GardenAPI.inGarden()) return PestSpawnTimer.lastSpawnTime = SimpleTimeMark.now() val plotNames = event.plotNames for (plotName in plotNames) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt index 4656ef06273c..468c389a6729 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden.pests +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.garden.pests.PestFinderConfig.VisibilityType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.pests import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.sendTeleportTo +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands @@ -31,13 +33,14 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object PestFinder { private val config get() = PestAPI.config.pestFinder private var display = emptyList() - @SubscribeEvent + @HandleEvent fun onPestUpdate(event: PestUpdateEvent) { update() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt index 581e6b2c6aa6..560f5c633776 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LocationUtils @@ -23,7 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds // TODO remove this workaround once PestParticleWaypoint does work again -class PestParticleLine { +@SkyHanniModule +object PestParticleLine { private val config get() = SkyHanniMod.feature.garden.pests.pestWaypoint class ParticleLocation(val location: LorenzVec, val spawnTime: SimpleTimeMark) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt index c2c395c1ad9d..5b9cbf220a2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleWaypoint.kt @@ -1,15 +1,18 @@ package at.hannibal2.skyhanni.features.garden.pests import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.garden.pests.PestUpdateEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerIgnoreY @@ -29,7 +32,8 @@ import kotlin.math.absoluteValue import kotlin.time.Duration.Companion.seconds // TODO delete workaround class PestParticleLine when this class works again -class PestParticleWaypoint { +@SkyHanniModule +object PestParticleWaypoint { private val config get() = SkyHanniMod.feature.garden.pests.pestWaypoint @@ -117,10 +121,10 @@ class PestParticleWaypoint { ++particles } - @SubscribeEvent - fun onFireWorkSpawn(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onFireWorkSpawn(event: PacketReceivedEvent) { if (event.packet !is S0EPacketSpawnObject) return - if (!GardenAPI.inGarden() || !config.hideParticles) return + if (!config.hideParticles) return val fireworkId = 76 if (event.packet.type == fireworkId) event.cancel() } @@ -167,7 +171,7 @@ class PestParticleWaypoint { reset() } - @SubscribeEvent + @HandleEvent fun onPestUpdate(event: PestUpdateEvent) { if (PestAPI.scoreboardPests == 0) reset() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt index 340068c947c5..62ddfb5f806b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName @@ -23,6 +24,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object PestProfitTracker { val config get() = SkyHanniMod.feature.garden.pests.pestProfitTacker diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt index 39df610e3906..0dcab57f5f04 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawn.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.features.garden.pests.PestSpawnConfig.ChatMe import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.HypixelCommands @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class PestSpawn { +@SkyHanniModule +object PestSpawn { private val config get() = PestAPI.config.pestSpawn @@ -117,7 +119,7 @@ class PestSpawn { } private fun pestSpawn(amount: Int, plotNames: List, unknownAmount: Boolean) { - PestSpawnEvent(amount, plotNames, unknownAmount).postAndCatch() + PestSpawnEvent(amount, plotNames, unknownAmount).post() if (unknownAmount) return // todo make this work with offline pest spawn messages val plotName = plotNames.firstOrNull() ?: error("first plot name is null") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawnTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawnTimer.kt index deb5af218934..1a958f77b63d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawnTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestSpawnTimer.kt @@ -1,20 +1,23 @@ package at.hannibal2.skyhanni.features.garden.pests +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.garden.pests.PestSpawnEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object PestSpawnTimer { private val config get() = PestAPI.config.pestTimer var lastSpawnTime = SimpleTimeMark.farPast() - @SubscribeEvent + @HandleEvent fun onPestSpawn(event: PestSpawnEvent) { lastSpawnTime = SimpleTimeMark.now() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt index 989ba801410d..62301f5d73b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayDisplay.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isSprayExpired import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.markExpiredSprayAsNotified import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.name import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.plots +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -20,7 +21,8 @@ import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.TimeUtils.timerColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SprayDisplay { +@SkyHanniModule +object SprayDisplay { private val config get() = PestAPI.config.spray private var display: String? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt index 07298818ea67..b01e6a08e5a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/SprayFeatures.kt @@ -7,18 +7,20 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.renderPlot import at.hannibal2.skyhanni.features.garden.pests.PestAPI.getPests +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class SprayFeatures { +@SkyHanniModule +object SprayFeatures { private val config get() = PestAPI.config.spray diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt index 81c64cec4275..2075c3a28972 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/StereoHarmonyDisplay.kt @@ -6,18 +6,20 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.NEUItems.getItemStack -import at.hannibal2.skyhanni.utils.RenderUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class StereoHarmonyDisplay { +@SkyHanniModule +object StereoHarmonyDisplay { private val config get() = PestAPI.config.stereoHarmony diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt index 3e0b9c7a93ad..5fa0debe5c1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorColorNames.kt @@ -2,9 +2,11 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object GardenVisitorColorNames { private var visitorColours = mutableMapOf() // name -> color code @@ -16,9 +18,9 @@ object GardenVisitorColorNames { visitorColours.clear() visitorItems.clear() for ((visitor, visitorData) in data.visitors) { - val rarity = visitorData.new_rarity ?: visitorData.rarity + val rarity = visitorData.newRarity ?: visitorData.rarity visitorColours[visitor] = rarity.color.getChatColor() - visitorItems[visitor] = visitorData.need_items + visitorItems[visitor] = visitorData.needItems } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt new file mode 100644 index 000000000000..c1b6a3d8fe6a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorCompactChat.kt @@ -0,0 +1,145 @@ +package at.hannibal2.skyhanni.features.garden.visitor + +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeResets +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.milliseconds + +@SkyHanniModule +object GardenVisitorCompactChat { + + private val config get() = VisitorAPI.config + + private val patternGroup = RepoPattern.group("garden.visitor.compact") + + /** + * REGEX-TEST: §8+§f2x §dGold Essence + * REGEX-TEST: §fDead Bush + * REGEX-TEST: §8+§52 Pelts + * REGEX-TEST: $8+§215 §7Garden Experience + * REGEX-TEST: §8+§35k §7Farming XP + * REGEX-TEST: §8+§311k §7Farming XP + * REGEX-TEST: §8+§c32 Copper + * REGEX-TEST: §7§aFine Flour §8x3 + * REGEX-TEST: §7§9Turbo-Carrot I Book + * REGEX-TEST: §7§8+§d1,241 Gemstone Powder + * REGEX-TEST: §7§8+§2Crystal Hollows Pass + */ + private val visitorRewardPattern by patternGroup.pattern( + "visitorreward", + "^ {4}(?:(?:§.)+\\+)?(?:(?§.)(?[\\d,]+(?:\\.?(?:\\d)?k)?)x? )?(?:(?(?:§.)+)?(?.*?))(?: (?:(?:§.)?)?x(?\\d+))?\$" + ) + + /** + * REGEX-TEST: §6§lOFFER ACCEPTED §8with §aLibrarian §8(§a§lUNCOMMON§8) + * REGEX-TEST: §6§lOFFER ACCEPTED §8with §6Sirius §8(§6§lLEGENDARY§8) + * REGEX-TEST: §6§lOFFER ACCEPTED §8with §cSpaceman §8(§c§lSPECIAL§8) + */ + private val fullyAcceptedPattern by patternGroup.pattern( + "fullyaccepted", + "§6§lOFFER ACCEPTED §8with (?§.)?(?.*) §8\\((?.*)\\)" + ) + private val discardRewardNamePattern by patternGroup.pattern( + "disregardrewardname", + "^(Copper|Farming XP|Farming Experience|Garden Experience|Bits)\$" + ) + private val rewardsTextPattern by patternGroup.pattern( + "rewardstext", + "^ {2}§a§lREWARDS" + ) + + private var visitorAcceptedChat = mutableListOf() + private var visitorNameFormatted = ""; + private var rewardsList = mutableListOf() + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (GardenAPI.inGarden() && config.compactRewardChat && ( + fullyAcceptedPattern.matcher(event.message.removeResets()).matches() || + visitorRewardPattern.matcher(event.message.removeResets()).matches() || + rewardsTextPattern.matcher(event.message.removeResets()).matches() + ) + ) { + handleChat(event) + } + } + + private fun handleChat(event: LorenzChatEvent) { + val transformedMessage = event.message.removeResets() + + fullyAcceptedPattern.matchMatcher(transformedMessage) { + visitorAcceptedChat = mutableListOf() + rewardsList = mutableListOf() + val visitorColor = groupOrNull("color") ?: "§7" + val visitorName = group("name") + visitorNameFormatted = "$visitorColor$visitorName" + } + + //If visitor name has not yet been matched, we aren't looking at a visitor accept message, and can ignore this. + if (visitorNameFormatted.isBlank()) return; + + //Match rewards and transform + visitorRewardPattern.matchMatcher(transformedMessage) { + val rewardColor = groupOrNull("rewardcolor") + val amountColor = groupOrNull("amountcolor") + val amount = groupOrNull("amount") + val altAmount = groupOrNull("altamount") + val reward = group("reward") + + val fullTextColor = if (rewardColor.isNullOrBlank() || rewardColor == "§7") { + if (amountColor.isNullOrBlank()) "§f" + else amountColor + } else rewardColor + + val amountString = if (amount != null) { + if (discardRewardNamePattern.matcher(reward).matches()) "$amount" + else "$amount " + } else { + if (altAmount == null) "" else "$altAmount " + } + + //Don't add name for copper, farming XP, garden XP, or bits + val rewardString = if (discardRewardNamePattern.matcher(reward).matches()) "" else reward + + rewardsList.add( + "$fullTextColor$amountString$rewardString" + ) + } + + compactChat(event) + } + + private fun compactChat(event: LorenzChatEvent) { + event.blockedReason = "compact_visitor" + visitorAcceptedChat.add(event.message) + if (visitorAcceptedChat.size == 3) { + DelayedRun.runDelayed(200.milliseconds) { + sendCompact() + } + } + } + + private fun sendCompact() { + //This prevents commission rewards, crop milestone data, etc. from triggering incorrectly + if (visitorNameFormatted.isBlank()) return; + + if (visitorAcceptedChat.isNotEmpty()) { + ChatUtils.hoverableChat(createCompactVisitorMessage(), hover = visitorAcceptedChat, prefix = false) + } + + this.visitorNameFormatted = "" + this.rewardsList.clear() + } + + private fun createCompactVisitorMessage(): String { + val rewardsFormatted = rewardsList.joinToString(separator = "§7, ") + return "§6§lOFFER ACCEPTED §7w/§r$visitorNameFormatted§6§l!§r $rewardsFormatted" + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt index c6f32ed6aff4..bd344bb51d3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorAcceptEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -29,6 +30,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object GardenVisitorDropStatistics { private val config get() = GardenAPI.config.visitors.dropsStatistics diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 7dcd156a1fb2..98230dfcf044 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -24,6 +24,7 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.blockReason import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -70,10 +71,10 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.round import kotlin.time.Duration.Companion.seconds -private val config get() = VisitorAPI.config - +@SkyHanniModule object GardenVisitorFeatures { + private val config get() = VisitorAPI.config private var display = emptyList>() private val patternGroup = RepoPattern.group("garden.visitor") @@ -180,68 +181,80 @@ object GardenVisitorFeatures { } private fun MutableList>.drawShoppingList(shoppingList: MutableMap) { - if (shoppingList.isNotEmpty()) { - var totalPrice = 0.0 - addAsSingletonList("§7Visitor Shopping List:") - for ((internalName, amount) in shoppingList) { - val name = internalName.itemName - val itemStack = internalName.getItemStack() + if (shoppingList.isEmpty()) return - val list = mutableListOf() - list.add(" §7- ") - list.add(itemStack) + var totalPrice = 0.0 + addAsSingletonList("§7Visitor Shopping List:") + for ((internalName, amount) in shoppingList) { + val name = internalName.itemName + val itemStack = internalName.getItemStack() + + val list = mutableListOf() + list.add(" §7- ") + list.add(itemStack) + + list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", { + if (Minecraft.getMinecraft().currentScreen is GuiEditSign) { + LorenzUtils.setTextIntoSign("$amount") + } else { + BazaarApi.searchForBazaarItem(name, amount) + } + }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() }) - list.add(Renderable.optionalLink("$name §ex${amount.addSeparators()}", { - if (Minecraft.getMinecraft().currentScreen is GuiEditSign) { - LorenzUtils.setTextIntoSign("$amount") - } else { - BazaarApi.searchForBazaarItem(name, amount) - } - }) { GardenAPI.inGarden() && !NEUItems.neuHasFocus() }) + if (config.shoppingList.showPrice) { + val price = internalName.getPrice() * amount + totalPrice += price + val format = NumberUtil.format(price) + list.add(" §7(§6$format§7)") + } - if (config.shoppingList.showPrice) { - val price = internalName.getPrice() * amount - totalPrice += price - val format = NumberUtil.format(price) - list.add(" §7(§6$format§7)") - } + addSackData(internalName, amount, list) - if (config.shoppingList.showSackCount) { - var amountInSacks = 0 - internalName.getAmountInSacksOrNull()?.let { - amountInSacks = it - val textColour = if (it >= amount) "a" else "e" - list.add(" §7(§${textColour}x${it.addSeparators()} §7in sacks)") - } - val ingredients = NEUItems.getRecipes(internalName) - // TODO describe what this line does - .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") } - ?.allIngredients() ?: return - val requiredIngredients = mutableMapOf() - for (ingredient in ingredients) { - val key = ingredient.internalItemId - requiredIngredients[key] = requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt() - } - var hasIngredients = true - for ((key, value) in requiredIngredients) { - val sackItem = key.asInternalName().getAmountInSacks() - if (sackItem < value * (amount - amountInSacks)) { - hasIngredients = false - break - } - } - if (hasIngredients) { - list.add(" §7(§aCraftable!§7)") - } - } + add(list) + } + if (totalPrice > 0) { + val format = NumberUtil.format(totalPrice) + this[0] = listOf("§7Visitor Shopping List: §7(§6$format§7)") + } + } - add(list) - } - if (totalPrice > 0) { - val format = NumberUtil.format(totalPrice) - this[0] = listOf("§7Visitor Shopping List: §7(§6$format§7)") + private fun addSackData( + internalName: NEUInternalName, + amount: Int, + list: MutableList, + ) { + if (!config.shoppingList.showSackCount) return + + var amountInSacks = 0 + internalName.getAmountInSacksOrNull()?.let { + amountInSacks = it + val textColour = if (it >= amount) "a" else "e" + list.add(" §7(§${textColour}x${it.addSeparators()} §7in sacks)") + } + + val ingredients = NEUItems.getRecipes(internalName) + // TODO describe what this line does + .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") } + ?.allIngredients() ?: emptySet() + if (ingredients.isEmpty()) return + + val requiredIngredients = mutableMapOf() + for (ingredient in ingredients) { + val key = ingredient.internalItemId + requiredIngredients[key] = + requiredIngredients.getOrDefault(key, 0) + ingredient.count.toInt() + } + var hasIngredients = true + for ((key, value) in requiredIngredients) { + val sackItem = key.asInternalName().getAmountInSacks() + if (sackItem < value * (amount - amountInSacks)) { + hasIngredients = false + break } } + if (hasIngredients) { + list.add(" §7(§aCraftable!§7)") + } } private fun MutableList>.drawVisitors( @@ -425,12 +438,12 @@ object GardenVisitorFeatures { finalList[index] = "$formattedLine §7(§6$format§7)" } if (!readingShoppingList) continue - val multiplier = NEUItems.getMultiplier(internalName) + val primitiveStack = NEUItems.getPrimitiveMultiplier(internalName) - val rawName = multiplier.first.itemNameWithoutColor + val rawName = primitiveStack.internalName.itemNameWithoutColor val cropType = getByNameOrNull(rawName) ?: continue - val cropAmount = multiplier.second.toLong() * amount + val cropAmount = primitiveStack.amount.toLong() * amount val formattedName = "§e${cropAmount.addSeparators()}§7x ${cropType.cropName} " val formattedSpeed = cropType.getSpeed()?.let { speed -> val duration = (cropAmount / speed).seconds diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt index 406f85298d54..e10d1be36da4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorSupercraft.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -21,7 +22,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GardenVisitorSupercraft { +@SkyHanniModule +object GardenVisitorSupercraft { private val isSupercraftEnabled get() = VisitorAPI.config.shoppingList.showSuperCraft @@ -72,7 +74,7 @@ class GardenVisitorSupercraft { private fun getSupercraftForSacks(internalName: NEUInternalName, amount: Int) { val ingredients = NEUItems.getRecipes(internalName) // TODO describe what this line does - .firstOrNull() { !it.allIngredients().first().internalItemId.contains("PEST") } + .firstOrNull { !it.allIngredients().first().internalItemId.contains("PEST") } ?.allIngredients() ?: return val ingredientReqs = mutableMapOf() for (ingredient in ingredients) { @@ -105,7 +107,7 @@ class GardenVisitorSupercraft { if (!hasIngredients) return if (event.slotId != 31) return - event.isCanceled = true + event.cancel() if (lastClick.passedSince() > 0.3.seconds) { HypixelCommands.recipe(lastSuperCraftMaterial) lastClick = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt index 36e0f8f7a0d7..3a69f2ece3b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorTimer.kt @@ -9,12 +9,12 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -29,7 +29,8 @@ import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import kotlin.time.toDuration -class GardenVisitorTimer { +@SkyHanniModule +object GardenVisitorTimer { private val config get() = GardenAPI.config.visitors.timer @@ -45,6 +46,7 @@ class GardenVisitorTimer { private var sixthVisitorReady = false private var lastTimerValue = "" private var lastTimerUpdate = SimpleTimeMark.farPast() + private var lastVisitors: Int = -1 // TODO nea? // private val visitorInterval by dynamic(GardenAPI::config, Storage.ProfileSpecific.GardenStorage::visitorInterval) @@ -56,11 +58,6 @@ class GardenVisitorTimer { } } - companion object { - - var lastVisitors: Int = -1 - } - @SubscribeEvent fun onVisitorArrival(event: VisitorArrivalEvent) { visitorJustArrived = true @@ -122,7 +119,7 @@ class GardenVisitorTimer { millis = sixthVisitorArrivalTime.timeUntil() val nextSixthVisitorArrival = SimpleTimeMark.now() + millis + (visitorInterval * (5 - visitorsAmount)) - GardenAPI.storage?.nextSixthVisitorArrival = nextSixthVisitorArrival.toMillis() + GardenAPI.storage?.nextSixthVisitorArrival = nextSixthVisitorArrival if (isSixthVisitorEnabled() && millis.isNegative()) { visitorsAmount++ if (!sixthVisitorReady) { @@ -185,9 +182,8 @@ class GardenVisitorTimer { fun onWorldChange(event: LorenzWorldChangeEvent) { lastVisitors = -1 GardenAPI.storage?.nextSixthVisitorArrival?.let { - val badTime = Duration.INFINITE.inWholeMilliseconds - if (it != badTime && it != -9223370336633802065) { - sixthVisitorArrivalTime = it.asTimeMark() + if (it.isFarFuture() && it.toMillis() != -9223370336633802065) { + sixthVisitorArrivalTime = it } } sixthVisitorReady = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt index 447396d43b28..54adcebadc99 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -1,12 +1,15 @@ package at.hannibal2.skyhanni.features.garden.visitor +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.VisitorBlockBehaviour import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenVisitor import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils @@ -25,9 +28,10 @@ import net.minecraft.entity.player.EntityPlayer import net.minecraft.network.play.client.C02PacketUseEntity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightVisitorsOutsideOfGarden { +@SkyHanniModule +object HighlightVisitorsOutsideOfGarden { - private var visitorJson = mapOf>() + private var visitorJson = mapOf>() private val config get() = GardenAPI.config.visitors @@ -57,7 +61,7 @@ class HighlightVisitorsOutsideOfGarden { val possibleJsons = visitorJson[mode] ?: return false val skinOrType = getSkinOrTypeFor(entity) return possibleJsons.any { - (it.position == null || it.position!!.distance(entity.position.toLorenzVec()) < 1) + (it.position == null || it.position.distance(entity.position.toLorenzVec()) < 1) && it.skinOrType == skinOrType } } @@ -86,8 +90,8 @@ class HighlightVisitorsOutsideOfGarden { private fun isVisitorNearby(location: LorenzVec) = EntityUtils.getEntitiesNearby(location, 2.0).any { isVisitor(it) } - @SubscribeEvent - fun onClickEntity(event: PacketEvent.SendEvent) { + @HandleEvent(onlyOnSkyblock = true) + fun onClickEntity(event: PacketSentEvent) { if (!shouldBlock) return val world = Minecraft.getMinecraft().theWorld ?: return val player = Minecraft.getMinecraft().thePlayer ?: return @@ -95,7 +99,7 @@ class HighlightVisitorsOutsideOfGarden { val packet = event.packet as? C02PacketUseEntity ?: return val entity = packet.getEntityFromWorld(world) ?: return if (isVisitor(entity) || (entity is EntityArmorStand && isVisitorNearby(entity.getLorenzVec()))) { - event.isCanceled = true + event.cancel() if (packet.action == C02PacketUseEntity.Action.INTERACT) { ChatUtils.chatAndOpenConfig("Blocked you from interacting with a visitor. Sneak to bypass or click here to change settings.", GardenAPI.config.visitors::blockInteracting diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt index c54ced2e28b8..06b7b3f7ffcd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/NPCVisitorFix.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.EntityUtils @@ -22,6 +23,7 @@ import kotlin.time.Duration.Companion.seconds /** * Fixing the visitor detection problem with Anita and Jacob, as those two are on the garden twice when visiting. */ +@SkyHanniModule object NPCVisitorFix { private val staticVisitors = listOf("Jacob", "Anita") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt index a948ed818d01..19aa098f6c5a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.garden.visitor.VisitorArrivalEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorLeftEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorRefusedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy @@ -18,6 +19,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack +@SkyHanniModule object VisitorAPI { private var visitors = mapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index f16750eda3f4..31f8db263491 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -1,42 +1,45 @@ package at.hannibal2.skyhanni.features.garden.visitor +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig +import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent +import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.ACCEPT_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.INFO_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.lastClickedNpc import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.entity.item.EntityArmorStand import net.minecraft.network.play.client.C02PacketUseEntity -import net.minecraftforge.event.entity.player.ItemTooltipEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class VisitorListener { +@SkyHanniModule +object VisitorListener { private val offersAcceptedPattern by RepoPattern.pattern( "garden.visitor.offersaccepted", "§7Offers Accepted: §a(?\\d+)" @@ -46,20 +49,14 @@ class VisitorListener { private val logger = LorenzLogger("garden/visitors/listener") - companion object { - private val VISITOR_INFO_ITEM_SLOT = 13 - private val VISITOR_ACCEPT_ITEM_SLOT = 29 - private val VISITOR_REFUSE_ITEM_SLOT = 33 - } - @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { VisitorAPI.reset() } // TODO make event - @SubscribeEvent - fun onSendEvent(event: PacketEvent.SendEvent) { + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onSendEvent(event: PacketSentEvent) { val packet = event.packet if (packet !is C02PacketUseEntity) return @@ -137,8 +134,8 @@ class VisitorListener { inventory.handleMouseClick_skyhanni(slot, slot.slotIndex, 0, 0) } - @SubscribeEvent(priority = EventPriority.HIGH) - fun onTooltip(event: ItemTooltipEvent) { + @HandleEvent(onlyOnIsland = IslandType.GARDEN) + fun onTooltip(event: ItemHoverEvent) { if (!GardenAPI.onBarnPlot) return if (!VisitorAPI.inInventory) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return @@ -153,7 +150,7 @@ class VisitorListener { val entity = event.entity if (entity is EntityArmorStand && entity.name == "§e§lCLICK") { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt index b62f65cad486..05041df18f87 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt @@ -1,11 +1,13 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.ACCEPT_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.REFUSE_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.VisitorBlockReason import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.lastClickedNpc +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -17,13 +19,13 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawBorder import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.inventory.Slot -import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.absoluteValue import kotlin.time.Duration.Companion.seconds -class VisitorRewardWarning { +@SkyHanniModule +object VisitorRewardWarning { private val config get() = VisitorAPI.config.rewardWarning @SubscribeEvent @@ -64,7 +66,7 @@ class VisitorRewardWarning { val shouldBlock = blockReason?.run { blockRefusing && isRefuseSlot || !blockRefusing && isAcceptSlot } ?: false if (!config.bypassKey.isKeyHeld() && shouldBlock) { - event.isCanceled = true + event.cancel() return } @@ -85,7 +87,7 @@ class VisitorRewardWarning { } @SubscribeEvent(priority = EventPriority.HIGH) - fun onTooltip(event: ItemTooltipEvent) { + fun onTooltip(event: LorenzToolTipEvent) { if (!GardenAPI.onBarnPlot) return if (!VisitorAPI.inInventory) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt index 60ed3ed66503..0eb596afceb0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/BeaconPower.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -45,9 +44,9 @@ object BeaconPower { ) private var expiryTime: SimpleTimeMark - get() = storage?.beaconPowerExpiryTime?.asTimeMark() ?: SimpleTimeMark.farPast() + get() = storage?.beaconPowerExpiryTime ?: SimpleTimeMark.farPast() set(value) { - storage?.beaconPowerExpiryTime = value.toMillis() + storage?.beaconPowerExpiryTime = value } private var stat: String? @@ -118,6 +117,5 @@ object BeaconPower { } } - private fun isEnabled() = LorenzUtils.inSkyBlock && config.beaconPower } diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt index 636bb64eff63..cf49749b27e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/MovableHotBar.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.gui import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GuiEditManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.transform import net.minecraft.client.Minecraft @@ -10,7 +11,8 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MovableHotBar { +@SkyHanniModule +object MovableHotBar { private val config get() = SkyHanniMod.feature.gui.hotbar diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt index 05e2b518a531..f0601c557440 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt @@ -27,6 +27,7 @@ import at.hannibal2.skyhanni.events.GuiPositionMovedEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.DelayedRun.runDelayed @@ -45,7 +46,8 @@ import kotlin.time.Duration.Companion.seconds typealias ScoreboardElementType = Pair -class CustomScoreboard { +@SkyHanniModule +object CustomScoreboard { private var display = emptyList() private var cache = emptyList() @@ -102,18 +104,16 @@ class CustomScoreboard { UnknownLinesHandler.handleUnknownLines() } - companion object { - internal val config get() = SkyHanniMod.feature.gui.customScoreboard - internal val displayConfig get() = config.display - internal val alignmentConfig get() = displayConfig.alignment - internal val arrowConfig get() = displayConfig.arrow - internal val eventsConfig get() = displayConfig.events - internal val mayorConfig get() = displayConfig.mayor - internal val partyConfig get() = displayConfig.party - internal val maxwellConfig get() = displayConfig.maxwell - internal val informationFilteringConfig get() = config.informationFiltering - internal val backgroundConfig get() = config.background - } + internal val config get() = SkyHanniMod.feature.gui.customScoreboard + internal val displayConfig get() = config.display + internal val alignmentConfig get() = displayConfig.alignment + internal val arrowConfig get() = displayConfig.arrow + internal val eventsConfig get() = displayConfig.events + internal val mayorConfig get() = displayConfig.mayor + internal val partyConfig get() = displayConfig.party + internal val maxwellConfig get() = displayConfig.maxwell + internal val informationFilteringConfig get() = config.informationFiltering + internal val backgroundConfig get() = config.background private fun createLines() = buildList { for (element in config.scoreboardEntries) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt index cf6840f4801f..8aae8fe55528 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.config.features.gui.customscoreboard.DisplayConfig import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.features.bingo.BingoAPI -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.displayConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt index a55cf8b6564d..3d4e6daadf76 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt @@ -2,9 +2,9 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsX +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsY +import at.hannibal2.skyhanni.data.GuiEditManager.getDummySize import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.RenderUtils import io.github.moulberry.notenoughupdates.util.Utils diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 4bc3fe36a723..467f752daac2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -17,13 +17,13 @@ import at.hannibal2.skyhanni.data.QuiverAPI.asArrowPercentage import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.features.dungeon.DungeonAPI -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.arrowConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.displayConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.informationFilteringConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.maxwellConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.mayorConfig -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.partyConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.arrowConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.config +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.maxwellConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.mayorConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.partyConfig import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern import at.hannibal2.skyhanni.test.command.ErrorManager @@ -745,20 +745,34 @@ private fun getEventsDisplayPair(): List { private fun getEventsShowWhen() = ScoreboardEvents.getEvent().isNotEmpty() private fun getMayorDisplayPair() = buildList { - add( - ((MayorAPI.currentMayor?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) } - ?: "") + - (if (mayorConfig.showTimeTillNextMayor) { - "§7 (§e${MayorAPI.timeTillNextMayor.format(maxUnits = 2)}§7)" - } else { - "" - })) to HorizontalAlignment.LEFT - ) + val currentMayorName = MayorAPI.currentMayor?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) } ?: "" + val timeTillNextMayor = if (mayorConfig.showTimeTillNextMayor) { + "§7 (§e${MayorAPI.nextMayorTimestamp.timeUntil().format(maxUnits = 2)}§7)" + } else { + "" + } + + add((currentMayorName + timeTillNextMayor) to HorizontalAlignment.LEFT) + if (mayorConfig.showMayorPerks) { - MayorAPI.currentMayor?.activePerks?.forEach { - add(" §7- §e${it.perkName}" to HorizontalAlignment.LEFT) + MayorAPI.currentMayor?.activePerks?.forEach { perk -> + add(" §7- §e${perk.perkName}" to HorizontalAlignment.LEFT) } } + + if (!mayorConfig.showExtraMayor) return@buildList + val jerryExtraMayor = MayorAPI.jerryExtraMayor + val extraMayor = jerryExtraMayor.first ?: return@buildList + + val extraMayorName = extraMayor.mayorName.let { MayorAPI.mayorNameWithColorCode(it) } + val extraTimeTillNextMayor = if (mayorConfig.showTimeTillNextMayor) { + "§7 (§6${jerryExtraMayor.second.timeUntil().format(maxUnits = 2)}§7)" + } else { + "" + } + + add((extraMayorName + extraTimeTillNextMayor) to HorizontalAlignment.LEFT) + } private fun getMayorShowWhen() = diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt index 3e7fe1577aa0..f8e7313d1042 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvents.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.features.dungeon.DungeonAPI -import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.eventsConfig +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.eventsConfig import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardEvents.VOTING import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern import at.hannibal2.skyhanni.features.misc.ServerRestartTitle diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt index 1f793709a013..c0446143362a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt @@ -1,7 +1,9 @@ package at.hannibal2.skyhanni.features.gui.customscoreboard +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +@SkyHanniModule object ScoreboardPattern { val group = RepoPattern.group("features.gui.customscoreboard") diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt index 049cbc35c388..9ec088723a0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverDisplay.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.QuiverUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.LorenzUtils @@ -22,7 +23,8 @@ import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class QuiverDisplay { +@SkyHanniModule +object QuiverDisplay { private val config get() = SkyHanniMod.feature.combat.quiverConfig.quiverDisplay diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt index 40ef08c6aff5..17ab6545d3d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/quiver/QuiverWarning.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.QuiverUpdateEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull @@ -23,7 +24,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.createCommaSeparatedList import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class QuiverWarning { +@SkyHanniModule +object QuiverWarning { private val config get() = SkyHanniMod.feature.combat.quiverConfig diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt index eae258eeec04..ccc95e36b60c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionOutbidWarning.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -10,6 +11,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object AuctionOutbidWarning { private val outbidPattern by RepoPattern.pattern( "auction.outbid", diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt index be7f959deb13..3efa9a8e593c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/AuctionsHighlighter.kt @@ -3,13 +3,13 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -18,6 +18,7 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object AuctionsHighlighter { private val config get() = SkyHanniMod.feature.inventory.auctions @@ -55,10 +56,9 @@ object AuctionsHighlighter { if (config.highlightAuctionsUnderbid) { lore.matchFirst(buyItNowPattern) { val coins = group("coins").formatLong() - stack.getInternalNameOrNull()?.getPriceOrNull()?.let { - if (coins > it) { - slot highlight LorenzColor.GOLD - } + val totalPrice = EstimatedItemValueCalculator.getTotalPrice(stack) + if (coins > totalPrice) { + slot highlight LorenzColor.GOLD } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index e0bd277692a4..5825436b8e39 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -34,7 +35,8 @@ import net.minecraft.init.Items import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ChestValue { +@SkyHanniModule +object ChestValue { private val config get() = SkyHanniMod.feature.inventory.chestValueConfig private var display = emptyList>() @@ -182,8 +184,7 @@ class ChestValue { val internalName = stack.getInternalNameOrNull() ?: continue if (internalName.getItemStackOrNull() == null) continue val list = mutableListOf() - val pair = EstimatedItemValueCalculator.calculate(stack, list) - var (total, _) = pair + var total = EstimatedItemValueCalculator.calculate(stack, list).first val key = "$internalName+$total" if (stack.item == Items.enchanted_book) total /= 2 diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt index 9a9555a86b18..b259ee1f43d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -18,7 +19,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DojoRankDisplay { +@SkyHanniModule +object DojoRankDisplay { private val config get() = SkyHanniMod.feature.crimsonIsle private var display = emptyList() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/FavoritePowerStone.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/FavoritePowerStone.kt new file mode 100644 index 000000000000..91727dc01841 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/FavoritePowerStone.kt @@ -0,0 +1,75 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.MaxwellAPI +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.KeyboardManager +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object FavoritePowerStone { + + private val config get() = SkyHanniMod.feature.inventory + private val storage get() = ProfileStorageData.profileSpecific + + private var highlightedSlots = setOf() + private var inInventory = false + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!isEnabled() || !inInventory) return + + highlightedSlots.forEach { event.gui.inventorySlots.inventorySlots[it] highlight LorenzColor.AQUA } + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (!isEnabled() || !KeyboardManager.isShiftKeyDown() || !inInventory) return + + val displayName = event.item?.name?.removeColor()?.trim() ?: return + val power = MaxwellAPI.getPowerByNameOrNull(displayName) ?: return + + if (power in MaxwellAPI.favoritePowers) { + MaxwellAPI.favoritePowers -= power + highlightedSlots -= event.slotId + } else { + MaxwellAPI.favoritePowers += power + highlightedSlots += event.slotId + } + + event.cancel() + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + if (!isEnabled() || !MaxwellAPI.isThaumaturgyInventory(event.inventoryName)) return + + inInventory = true + } + + @SubscribeEvent + fun onInventoryUpdated(event: InventoryUpdatedEvent) { + if (!isEnabled() || !inInventory) return + + highlightedSlots = event.inventoryItems + .filter { (_, item) -> item.displayName.removeColor() in MaxwellAPI.favoritePowers } + .keys + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inInventory = false + } + + private fun isEnabled() = LorenzUtils.inSkyBlock && storage != null && config.favoritePowerStone +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt index 4478114ec0e7..75b1d6ad3cd3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HarpFeatures.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiKeyPressEvent @@ -8,6 +9,8 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -24,11 +27,11 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.player.inventory.ContainerLocalMenu import net.minecraft.item.Item import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds // Delaying key presses by 300ms comes from NotEnoughUpdates +@SkyHanniModule object HarpFeatures { private val config get() = SkyHanniMod.feature.inventory.helper.harp @@ -128,8 +131,8 @@ object HarpFeatures { unSetGUIScale() } - @SubscribeEvent - fun onLeave(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + @HandleEvent + fun onDisconnect(event: ClientDisconnectEvent) { if (!config.guiScale) return unSetGUIScale() } @@ -172,7 +175,7 @@ object HarpFeatures { event.container.inventory.filterNotNull().indexOfFirst { songSelectedPattern.anyMatches(it.getLore()) }.takeIf { it != -1 }?.let { - event.isCanceled = true + event.cancel() Minecraft.getMinecraft().playerController.windowClick( event.container.windowId, it, diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt index 99801a3224c1..6b2f97fbd38b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HeldTimeInLore.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -12,6 +13,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object HeldTimeInLore { private val config get() = SkyHanniMod.feature.inventory diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index f87dee33af14..f7944fcdee6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -3,8 +3,9 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson -import at.hannibal2.skyhanni.data.jsonobjects.repo.HideNotClickableItemsJson.SalvageFilter +import at.hannibal2.skyhanni.data.jsonobjects.repo.SalvageFilter import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI @@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.InventoryUtils @@ -44,12 +46,12 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack -import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class HideNotClickableItems { +@SkyHanniModule +object HideNotClickableItems { private val config get() = SkyHanniMod.feature.inventory.hideNotClickable @@ -74,10 +76,10 @@ class HideNotClickableItems { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val hideNotClickable = event.getConstant("HideNotClickableItems") - hideNpcSellFilter.load(hideNotClickable.hide_npc_sell) - hideInStorageFilter.load(hideNotClickable.hide_in_storage) - hidePlayerTradeFilter.load(hideNotClickable.hide_player_trade) - notAuctionableFilter.load(hideNotClickable.not_auctionable) + hideNpcSellFilter.load(hideNotClickable.hideNpcSell) + hideInStorageFilter.load(hideNotClickable.hideInStorage) + hidePlayerTradeFilter.load(hideNotClickable.hidePlayerTrade) + notAuctionableFilter.load(hideNotClickable.notAuctionable) updateSalvageList(hideNotClickable.salvage) } @@ -113,9 +115,8 @@ class HideNotClickableItems { } @SubscribeEvent(priority = EventPriority.LOWEST) - fun onTooltip(event: ItemTooltipEvent) { + fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return - if (event.toolTip == null) return if (bypassActive()) return val guiChest = Minecraft.getMinecraft().currentScreen @@ -159,7 +160,7 @@ class HideNotClickableItems { val stack = slot.stack if (hide(chestName, stack)) { - event.isCanceled = true + event.cancel() if (lastClickTime.passedSince() > 5.seconds) { lastClickTime = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt index 09d1eb68595b..2b298a8031db 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HighlightBonzoMasks.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -23,6 +24,7 @@ import kotlin.time.Duration.Companion.seconds /** * @author Linnea Gräf */ +@SkyHanniModule object HighlightBonzoMasks { private val config get() = SkyHanniMod.feature.inventory.itemAbilities diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 9d1df7abdd6a..21defeadca87 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.pests.PestAPI import at.hannibal2.skyhanni.features.skillprogress.SkillProgress import at.hannibal2.skyhanni.features.skillprogress.SkillType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -57,6 +58,7 @@ import com.google.gson.JsonElement import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ItemDisplayOverlayFeatures { private val config get() = SkyHanniMod.feature.inventory diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt index 8b5fca955e19..8e2a5c5927e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt @@ -3,18 +3,20 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.CRIMSON_ARMOR import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson +import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures.isSelected +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ItemStars { +@SkyHanniModule +object ItemStars { private val config get() = SkyHanniMod.feature.inventory @@ -28,7 +30,7 @@ class ItemStars { private val armorParts = listOf("Helmet", "Chestplate", "Leggings", "Boots") @SubscribeEvent(priority = EventPriority.LOW) - fun onTooltip(event: ItemTooltipEvent) { + fun onTooltip(event: LorenzToolTipEvent) { if (!isEnabled()) return val stack = event.itemStack ?: return if (stack.stackSize != 1) return @@ -51,8 +53,8 @@ class ItemStars { val data = event.getConstant("Items") armorNames.clear() tiers.clear() - armorNames.addAll(data.crimson_armors) - for (tier in data.crimson_tiers) { + armorNames.addAll(data.crimsonArmors) + for (tier in data.crimsonTiers) { tiers[tier.key] = tier.value } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/MaxPurseItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/MaxPurseItems.kt index 3d01d1d70711..517cf4b59346 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/MaxPurseItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/MaxPurseItems.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.PurseAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MaxPurseItems { +@SkyHanniModule +object MaxPurseItems { private val config get() = SkyHanniMod.feature.inventory.bazaar private val patternGroup = RepoPattern.group("inventory.maxpurse") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt index 8f533dd9d504..5423aa3962d6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PowerStoneGuideFeatures { +@SkyHanniModule +object PowerStoneGuideFeatures { private var missing = mutableMapOf() private var inInventory = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt index a1fb4a359fd0..70069a84ea2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -18,7 +19,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class QuickCraftFeatures { +@SkyHanniModule +object QuickCraftFeatures { private val config get() = SkyHanniMod.feature.inventory private val quickCraftSlots = listOf(16, 25, 34) @@ -78,7 +80,7 @@ class QuickCraftFeatures { val clickedItem = event.slot?.stack ?: return if (!KeyboardManager.isModifierKeyDown() && needsQuickCraftConfirmation(clickedItem)) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt index 0173fdfc7d46..fe026284aa8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/RngMeterInventory.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RngMeterInventory { +@SkyHanniModule +object RngMeterInventory { private val config get() = SkyHanniMod.feature.inventory.rngMeter diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index 7868d0440fcf..b43a95b082d8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addButton import at.hannibal2.skyhanni.utils.CollectionUtils.addItemStack import at.hannibal2.skyhanni.utils.CollectionUtils.addSelector @@ -28,6 +29,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object SackDisplay { private var display = emptyList() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt index 0e7337bc0cbe..65c0d3940cb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickBrewing.kt @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ShiftClickBrewing { +@SkyHanniModule +object ShiftClickBrewing { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt index 4f9b08b20523..3f4eff4f35ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickEquipment.kt @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ShiftClickEquipment { +@SkyHanniModule +object ShiftClickEquipment { @SubscribeEvent fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt index aa47f46ddcfd..b7bd0694ac8e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ShiftClickNPCSell.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.makeShiftClick @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ShiftClickNPCSell { private val config get() = SkyHanniMod.feature.inventory.shiftClickNPCSell diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt index e06e7975cf58..0b3a2830efca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt @@ -5,15 +5,16 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.intellij.lang.annotations.Language @@ -68,6 +69,7 @@ class SkyblockGuideHighlightFeature private constructor( objectList.add(this) } + @SkyHanniModule companion object { private val skyblockGuideConfig get() = SkyHanniMod.feature.inventory.skyblockGuideConfig diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt index 23c5038e7dd8..87d461b45c9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/StatsTuning.kt @@ -5,20 +5,22 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.MaxwellAPI import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.createCommaSeparatedList -import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class StatsTuning { +@SkyHanniModule +object StatsTuning { private val config get() = SkyHanniMod.feature.inventory.statsTuning diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt index a9f44272cec6..56b1921f2ed3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperCraftFeatures.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.GetFromSackAPI import at.hannibal2.skyhanni.data.SackAPI import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NumberUtil.formatInt @@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object SuperCraftFeatures { val craftedPattern by RepoPattern.pattern( "inventory.supercrafting.craft.new", diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt index 667e7854d1e9..5c5011c85b1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SuperpairsClicksAlert { +@SkyHanniModule +object SuperpairsClicksAlert { private val config get() = SkyHanniMod.feature.inventory.helper.enchanting diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt index 1d6af4e8969a..32f6ebb7e888 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.InventoryUtils @@ -25,6 +26,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object UltraRareBookAlert { private val config get() = SkyHanniMod.feature.inventory.helper.enchanting diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt index dea4fbd2da28..9378e13b3881 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseCopyUnderbidPrice.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -20,7 +21,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AuctionHouseCopyUnderbidPrice { +@SkyHanniModule +object AuctionHouseCopyUnderbidPrice { private val config get() = SkyHanniMod.feature.inventory.auctions diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt index bc3d52a7f389..b253e01911f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/auctionhouse/AuctionHouseOpenPriceWebsite.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack @@ -19,7 +20,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class AuctionHouseOpenPriceWebsite { +@SkyHanniModule +object AuctionHouseOpenPriceWebsite { private val config get() = SkyHanniMod.feature.inventory.auctions private var lastClick = SimpleTimeMark.farPast() @@ -77,7 +79,7 @@ class AuctionHouseOpenPriceWebsite { if (!isEnabled()) return displayItem ?: return if (event.slotId != 8) return - event.isCanceled = true + event.cancel() if (lastClick.passedSince() > 0.3.seconds) { val url = "https://sky.coflnet.com/api/mod/open/$searchTerm" OSUtils.openBrowser(url) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt index c1f8dd1d1aa4..99e38fd776fb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarApi.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems @@ -32,43 +33,42 @@ import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarApi { +@SkyHanniModule +object BazaarApi { private var loadedNpcPriceData = false - companion object { + val holder = BazaarDataHolder() + var inBazaarInventory = false + private var currentSearchedItem = "" - val holder = BazaarDataHolder() - var inBazaarInventory = false - private var currentSearchedItem = "" + var currentlyOpenedProduct: NEUInternalName? = null - var currentlyOpenedProduct: NEUInternalName? = null + fun NEUInternalName.getBazaarData(): BazaarData? = HypixelBazaarFetcher.latestProductInformation[this] - fun NEUInternalName.getBazaarData(): BazaarData? = HypixelBazaarFetcher.latestProductInformation[this] + fun NEUInternalName.getBazaarDataOrError(): BazaarData = getBazaarData() ?: run { + ErrorManager.skyHanniError( + "Can not find bazaar data for $itemName", + "internal name" to this + ) + } - fun NEUInternalName.getBazaarDataOrError(): BazaarData = getBazaarData() ?: run { - ErrorManager.skyHanniError( - "Can not find bazaar data for $itemName", - "internal name" to this - ) - } + fun isBazaarItem(stack: ItemStack): Boolean = stack.getInternalName().isBazaarItem() - fun isBazaarItem(stack: ItemStack): Boolean = stack.getInternalName().isBazaarItem() + fun NEUInternalName.isBazaarItem() = getBazaarData() != null - fun NEUInternalName.isBazaarItem() = getBazaarData() != null + fun searchForBazaarItem(internalName: NEUInternalName, amount: Int = -1) { + searchForBazaarItem(internalName.itemNameWithoutColor, amount) + } - fun searchForBazaarItem(internalName: NEUInternalName, amount: Int = -1) { - searchForBazaarItem(internalName.itemNameWithoutColor, amount) - } - fun searchForBazaarItem(displayName: String, amount: Int = -1) { - if (!LorenzUtils.inSkyBlock) return - if (NEUItems.neuHasFocus()) return - if (LorenzUtils.noTradeMode) return - if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return - HypixelCommands.bazaar(displayName.removeColor()) - if (amount != -1) OSUtils.copyToClipboard(amount.toString()) - currentSearchedItem = displayName.removeColor() - } + fun searchForBazaarItem(displayName: String, amount: Int = -1) { + if (!LorenzUtils.inSkyBlock) return + if (NEUItems.neuHasFocus()) return + if (LorenzUtils.noTradeMode) return + if (DungeonAPI.inDungeon() || LorenzUtils.inKuudraFight) return + HypixelCommands.bazaar(displayName.removeColor()) + if (amount != -1) OSUtils.copyToClipboard(amount.toString()) + currentSearchedItem = displayName.removeColor() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt index 5a11084c8763..631ee8175232 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt @@ -5,7 +5,8 @@ import at.hannibal2.skyhanni.events.BazaarOpenedProductEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarDataOrError +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getAmountInInventory import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -17,7 +18,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarBestSellMethod { +@SkyHanniModule +object BazaarBestSellMethod { private val config get() = SkyHanniMod.feature.inventory.bazaar private var display = "" @@ -57,7 +59,7 @@ class BazaarBestSellMethod { if (having <= 0) return "" val data = internalName.getBazaarDataOrError() - val totalDiff = (data.buyPrice - data.sellPrice) * having + val totalDiff = (data.sellOfferPrice - data.instantBuyPrice) * having val result = NumberUtil.format(totalDiff.toInt()) val name = internalName.itemName diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt index cac9920c7428..bd420de23db0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarCancelledBuyOrderClipboard.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -21,7 +22,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarCancelledBuyOrderClipboard { +@SkyHanniModule +object BazaarCancelledBuyOrderClipboard { private val patternGroup = RepoPattern.group("bazaar.cancelledorder") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarData.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarData.kt index db97d5e6b7d0..21fdddfaf3cf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarData.kt @@ -7,8 +7,4 @@ data class BazaarData( val sellOfferPrice: Double, val instantBuyPrice: Double, val product: BazaarProduct, - @Deprecated("outdated", ReplaceWith("instantBuyPrice")) - val sellPrice: Double = instantBuyPrice, - @Deprecated("outdated", ReplaceWith("sellOfferPrice")) - val buyPrice: Double = sellOfferPrice, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt index 2e680450d549..61606346ad9e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOpenPriceWebsite.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack @@ -14,7 +15,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class BazaarOpenPriceWebsite { +@SkyHanniModule +object BazaarOpenPriceWebsite { private val config get() = SkyHanniMod.feature.inventory.bazaar private var lastClick = SimpleTimeMark.farPast() @@ -47,7 +49,7 @@ class BazaarOpenPriceWebsite { val lastItem = BazaarApi.currentlyOpenedProduct ?: return if (event.slotId == 22) { - event.isCanceled = true + event.cancel() if (lastClick.passedSince() > 0.3.seconds) { val name = getSkyBlockBzName(lastItem) OSUtils.openBrowser("https://www.skyblock.bz/product/$name") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt index 373b866f2aac..771de0001a31 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarOrderHelper.kt @@ -2,7 +2,8 @@ package at.hannibal2.skyhanni.features.inventory.bazaar import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarDataOrError +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarDataOrError +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils.getInventoryName import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,7 +20,8 @@ import net.minecraft.inventory.ContainerChest import net.minecraft.inventory.Slot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BazaarOrderHelper { +@SkyHanniModule +object BazaarOrderHelper { private val patternGroup = RepoPattern.group("bazaar.orderhelper") private val bazaarItemNamePattern by patternGroup.pattern( "itemname", @@ -34,13 +36,10 @@ class BazaarOrderHelper { "§7Price per unit: §6(?.*) coins" ) - companion object { - - fun isBazaarOrderInventory(inventoryName: String): Boolean = when (inventoryName) { - "Your Bazaar Orders" -> true - "Co-op Bazaar Orders" -> true - else -> false - } + fun isBazaarOrderInventory(inventoryName: String): Boolean = when (inventoryName) { + "Your Bazaar Orders" -> true + "Co-op Bazaar Orders" -> true + else -> false } @SubscribeEvent @@ -76,7 +75,7 @@ class BazaarOrderHelper { pricePattern.matchMatcher(line) { val price = group("number").formatDouble() - if (buyOrSell.first && price < data.sellPrice || buyOrSell.second && price > data.buyPrice) { + if (buyOrSell.first && price < data.instantBuyPrice || buyOrSell.second && price > data.sellOfferPrice) { slot highlight LorenzColor.GOLD return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt index b4a9a5c1ae99..009a972d09e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt @@ -4,7 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.isBazaarItem +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.isBazaarItem +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.addString import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -22,7 +23,8 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CraftMaterialsFromBazaar { +@SkyHanniModule +object CraftMaterialsFromBazaar { private val config get() = SkyHanniMod.feature.inventory.bazaar diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt index 45fbd65de143..7f0694e2a779 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt @@ -5,7 +5,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import kotlin.time.Duration -import kotlin.time.Duration.Companion.seconds enum class ChocolateAmount(val chocolate: () -> Long) { CURRENT({ profileStorage?.currentChocolate ?: 0 }), @@ -26,13 +25,13 @@ enum class ChocolateAmount(val chocolate: () -> Long) { fun timeUntilGoal(goal: Long): Duration { val profileStorage = profileStorage ?: return Duration.ZERO - val updatedAgo = SimpleTimeMark(profileStorage.lastDataSave).passedSince().inWholeSeconds - return ChocolateFactoryAPI.timeUntilNeed(goal - chocolate()) - updatedAgo.seconds + val updatedAgo = profileStorage.lastDataSave.passedSince() + return ChocolateFactoryAPI.timeUntilNeed(goal - chocolate()) - updatedAgo } companion object { fun chocolateSinceUpdate(): Long { - val lastUpdate = SimpleTimeMark(profileStorage?.lastDataSave ?: return 0) + val lastUpdate = profileStorage?.lastDataSave ?: return 0 val currentTime = SimpleTimeMark.now() val secondsSinceUpdate = (currentTime - lastUpdate).inWholeSeconds @@ -77,9 +76,9 @@ enum class ChocolateAmount(val chocolate: () -> Long) { private fun updateBestUpgrade() { profileStorage?.let { - if (it.bestUpgradeAvailableAt == 0L || it.bestUpgradeCost == 0L) return + if (it.bestUpgradeAvailableAt.isFarPast() || it.bestUpgradeCost == 0L) return val canAffordAt = SimpleTimeMark.now() + CURRENT.timeUntilGoal(it.bestUpgradeCost) - it.bestUpgradeAvailableAt = canAffordAt.toMillis() + it.bestUpgradeAvailableAt = canAffordAt } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index 5974b0485144..c331c8f543c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.HoppityEggLocationsJson import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzUtils @@ -25,6 +26,7 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ChocolateFactoryAPI { val config: ChocolateFactoryConfig get() = SkyHanniMod.feature.inventory.chocolateFactory @@ -33,11 +35,11 @@ object ChocolateFactoryAPI { val patternGroup = RepoPattern.group("misc.chocolatefactory") val chocolateAmountPattern by patternGroup.pattern( "chocolate.amount", - "(?[\\d,]+) Chocolate" + "(?[\\d,]+) Chocolate", ) private val chocolateFactoryInventoryNamePattern by patternGroup.pattern( "inventory.name", - "Hoppity|Chocolate Factory Milestones" + "Hoppity|Chocolate Factory Milestones", ) var rabbitSlots = mapOf() @@ -76,19 +78,23 @@ object ChocolateFactoryAPI { @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!isEnabled()) return + if (!LorenzUtils.inSkyBlock) return if (chocolateFactoryInventoryNamePattern.matches(event.inventoryName)) { - chocolateFactoryPaused = true - ChocolateFactoryStats.updateDisplay() + if (config.enabled) { + chocolateFactoryPaused = true + ChocolateFactoryStats.updateDisplay() + } return } if (event.inventoryName != "Chocolate Factory") return inChocolateFactory = true - factoryUpgrades = emptyList() - DelayedRun.runNextTick { - ChocolateFactoryDataLoader.updateInventoryItems(event.inventoryItems) + if (config.enabled) { + factoryUpgrades = emptyList() + DelayedRun.runNextTick { + ChocolateFactoryDataLoader.updateInventoryItems(event.inventoryItems) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index a8134cedf7ab..91c55723baa0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsCompactChat import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.HypixelCommands @@ -15,6 +16,7 @@ import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ChocolateFactoryBarnManager { private val config get() = ChocolateFactoryAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt index cc7731f802be..2439641c36b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryCustomReminder.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -20,6 +21,7 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryCustomReminder { private val configReminder get() = ChocolateFactoryAPI.config.customReminder private val configUpgradeWarnings get() = ChocolateFactoryAPI.config.chocolateUpgradeWarnings diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt index 5da9a19e8171..a0c177abbc7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.specialRabbitTextures +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -26,6 +27,7 @@ import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryDataLoader { private val config get() = ChocolateFactoryAPI.config @@ -178,7 +180,7 @@ object ChocolateFactoryDataLoader { profileStorage.rawChocPerSecond = (ChocolateFactoryAPI.chocolatePerSecond / profileStorage.chocolateMultiplier + .01).toInt() - profileStorage.lastDataSave = SimpleTimeMark.now().toMillis() + profileStorage.lastDataSave = SimpleTimeMark.now() ChocolateFactoryStats.updateDisplay() @@ -285,9 +287,9 @@ object ChocolateFactoryDataLoader { val activeDuration = TimeUtils.getDuration(formattedGroup) val activeUntil = SimpleTimeMark.now() + activeDuration - profileStorage.currentTimeTowerEnds = activeUntil.toMillis() + profileStorage.currentTimeTowerEnds = activeUntil } else { - profileStorage.currentTimeTowerEnds = 0 + profileStorage.currentTimeTowerEnds = SimpleTimeMark.farPast() } } timeTowerRechargePattern.matchMatcher(line) { @@ -296,7 +298,7 @@ object ChocolateFactoryDataLoader { val timeUntilTower = TimeUtils.getDuration(formattedGroup) val nextTimeTower = SimpleTimeMark.now() + timeUntilTower - profileStorage.nextTimeTower = nextTimeTower.toMillis() + profileStorage.nextTimeTower = nextTimeTower } } } @@ -433,7 +435,7 @@ object ChocolateFactoryDataLoader { list.filter { !it.isMaxed && it.slotIndex != ChocolateFactoryAPI.timeTowerIndex && it.effectiveCost != null } val bestUpgrade = notMaxed.minByOrNull { it.effectiveCost ?: Double.MAX_VALUE } - profileStorage.bestUpgradeAvailableAt = bestUpgrade?.canAffordAt?.toMillis() ?: 0 + profileStorage.bestUpgradeAvailableAt = bestUpgrade?.canAffordAt ?: SimpleTimeMark.farPast() profileStorage.bestUpgradeCost = bestUpgrade?.price ?: 0 ChocolateFactoryAPI.bestPossibleSlot = bestUpgrade?.getValidUpgradeIndex() ?: -1 diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt index 1616c0f61129..70a8f08791f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -10,6 +11,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryInventory { private val config get() = ChocolateFactoryAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt index 546e127c4c2b..6e2fc83e3142 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryKeybinds.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiKeyPressEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -10,6 +11,7 @@ import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds +@SkyHanniModule object ChocolateFactoryKeybinds { private val config get() = ChocolateFactoryAPI.config.keybinds private var lastClick = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryShortcut.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryShortcut.kt index 2e0f85edf487..644c6c280583 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryShortcut.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryShortcut.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,7 +15,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class ChocolateFactoryShortcut { +@SkyHanniModule +object ChocolateFactoryShortcut { private val config get() = ChocolateFactoryAPI.config private var showItem = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt index 51b2fa2b3d95..4491a1423866 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ClipboardUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators @@ -15,6 +16,7 @@ import com.google.gson.JsonElement import com.google.gson.JsonPrimitive import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryStats { private val config get() = ChocolateFactoryAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt index 94ebe2dacaae..15af541d0ca5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTimeTowerManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils @@ -11,10 +12,10 @@ import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.hours -import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ChocolateFactoryTimeTowerManager { private val config get() = ChocolateFactoryAPI.config @@ -28,8 +29,8 @@ object ChocolateFactoryTimeTowerManager { if (!LorenzUtils.inSkyBlock) return val profileStorage = profileStorage ?: return - if (SimpleTimeMark(profileStorage.currentTimeTowerEnds).isInPast()) { - profileStorage.currentTimeTowerEnds = SimpleTimeMark.farPast().toMillis() + if (profileStorage.currentTimeTowerEnds.isInPast()) { + profileStorage.currentTimeTowerEnds = SimpleTimeMark.farPast() } if (ChocolateFactoryAPI.inChocolateFactory) return @@ -38,13 +39,13 @@ object ChocolateFactoryTimeTowerManager { timeTowerReminder() } - val nextCharge = SimpleTimeMark(profileStorage.nextTimeTower) + val nextCharge = profileStorage.nextTimeTower if (nextCharge.isInPast() && !nextCharge.isFarPast() && currentCharges() < maxCharges()) { profileStorage.currentTimeTowerUses++ - val nextTimeTower = SimpleTimeMark(profileStorage.nextTimeTower) + (profileStorage.timeTowerCooldown).hours - profileStorage.nextTimeTower = nextTimeTower.toMillis() + val nextTimeTower = profileStorage.nextTimeTower + profileStorage.timeTowerCooldown.hours + profileStorage.nextTimeTower = nextTimeTower if (!config.timeTowerWarning) return ChatUtils.clickableChat( @@ -96,20 +97,18 @@ object ChocolateFactoryTimeTowerManager { fun timeTowerFull() = currentCharges() >= maxCharges() fun timeTowerActive(): Boolean { - val currentTime = profileStorage?.lastDataSave ?: 0 + val currentTime = profileStorage?.lastDataSave ?: SimpleTimeMark.farPast() val endTime = timeTowerEnds() return endTime > currentTime } - private fun timeTowerEnds(): Long { - return profileStorage?.currentTimeTowerEnds ?: 0 - } + private fun timeTowerEnds(): SimpleTimeMark = profileStorage?.currentTimeTowerEnds ?: SimpleTimeMark.farPast() private fun timeTowerReminder() { if (lastTimeTowerReminder.passedSince() < 20.seconds) return - val timeUntil = SimpleTimeMark(timeTowerEnds()).timeUntil() + val timeUntil = timeTowerEnds().timeUntil() if (timeUntil < 1.minutes && timeUntil.isPositive()) { ChatUtils.clickableChat( "§cYour Time Tower is about to end! " + @@ -126,7 +125,7 @@ object ChocolateFactoryTimeTowerManager { fun timeTowerFullTimeMark(): SimpleTimeMark { val profileStorage = profileStorage ?: return SimpleTimeMark.farPast() if (timeTowerFull()) return SimpleTimeMark.farPast() - val nextChargeDuration = SimpleTimeMark(profileStorage.nextTimeTower) + val nextChargeDuration = profileStorage.nextTimeTower val remainingChargesAfter = profileStorage.maxTimeTowerUses - (profileStorage.currentTimeTowerUses + 1) val endTime = nextChargeDuration + ChocolateFactoryAPI.timeTowerChargeDuration() * remainingChargesAfter @@ -135,11 +134,10 @@ object ChocolateFactoryTimeTowerManager { fun timeTowerActiveDuration(): Duration { if (!timeTowerActive()) return Duration.ZERO - val currentTime = profileStorage?.lastDataSave ?: 0 - val endTime = profileStorage?.currentTimeTowerEnds ?: 0 + val currentTime = profileStorage?.lastDataSave ?: SimpleTimeMark.farPast() + val endTime = profileStorage?.currentTimeTowerEnds ?: SimpleTimeMark.farPast() - val duration = endTime - currentTime - return duration.milliseconds + return endTime - currentTime } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt index b418c5ec2c15..f73655bc5aaf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.profileStorage +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryTooltip { private val config get() = ChocolateFactoryAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipCompact.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipCompact.kt index 150fcdf0287a..837a0e085bfb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipCompact.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipCompact.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -12,6 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ChocolateFactoryTooltipCompact { private val config get() = ChocolateFactoryAPI.config diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt new file mode 100644 index 000000000000..0c785c7612c8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltipStray.kt @@ -0,0 +1,38 @@ +package at.hannibal2.skyhanni.features.inventory.chocolatefactory + +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst +import at.hannibal2.skyhanni.utils.TimeUtils.format +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object ChocolateFactoryTooltipStray { + private val config get() = ChocolateFactoryAPI.config + + /** + * REGEX-TEST: §7You gained §6+2,465,018 Chocolate§7! + * REGEX-TEST: §7gained §6+30,292 Chocolate§7! + * REGEX-TEST: §7§6+36,330 Chocolate§7! + */ + private val chocolateGainedPattern by ChocolateFactoryAPI.patternGroup.pattern( + "rabbit.stray", + "(?:§.)+(?:You )?(?:gained )?§6\\+(?[\\d,]+) Chocolate§7!" + ) + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onTooltip(event: LorenzToolTipEvent) { + if (!ChocolateFactoryAPI.inChocolateFactory) return + if (!config.showStrayTime) return + if (event.slot.slotNumber > 26 || event.slot.slotNumber == ChocolateFactoryAPI.infoIndex) return + + val tooltip = event.toolTip + tooltip.matchFirst(chocolateGainedPattern) { + val amount = group("amount").formatLong() + val format = ChocolateFactoryAPI.timeUntilNeed(amount + 1).format(maxUnits = 2) + tooltip[tooltip.lastIndex] += " §7(§a+§b$format §aof production§7)" + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt index c99356106699..e04a882fe8c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils.minutes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateFactoryUpgradeWarning { private val config get() = ChocolateFactoryAPI.config.chocolateUpgradeWarnings @@ -25,7 +27,7 @@ object ChocolateFactoryUpgradeWarning { if (!LorenzUtils.inSkyBlock) return val profileStorage = profileStorage ?: return - val upgradeAvailableAt = SimpleTimeMark(profileStorage.bestUpgradeAvailableAt) + val upgradeAvailableAt = profileStorage.bestUpgradeAvailableAt if (upgradeAvailableAt.isInPast() && !upgradeAvailableAt.isFarPast()) { checkUpgradeWarning() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt index f71a4b341c9e..8aac00e5bbf1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt @@ -14,7 +14,7 @@ object ChocolatePositionChange { fun update(position: Int?, leaderboard: String) { position ?: return val storage = storage ?: return - val lastTime = storage.lastTime?.let { SimpleTimeMark(it) } + val lastTime = storage.lastTime val lastPosition = storage.lastPosition val lastLeaderboard = storage.lastLeaderboard @@ -34,7 +34,7 @@ object ChocolatePositionChange { } } - storage.lastTime = SimpleTimeMark.now().toMillis() + storage.lastTime = SimpleTimeMark.now() storage.lastLeaderboard = leaderboard storage.lastPosition = position } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index 13e260b81c3a..8d8ea540f9b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DisplayTableEntry import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -29,6 +30,7 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ChocolateShopPrice { private val config get() = ChocolateFactoryAPI.config.chocolateShopPrice diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt index ea33bc7ec743..f0722c8df103 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayHelper.kt @@ -3,9 +3,10 @@ package at.hannibal2.skyhanni.features.inventory.tiarelay import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.HypixelCommands @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes -class TiaRelayHelper { +@SkyHanniModule +object TiaRelayHelper { private val config get() = SkyHanniMod.feature.inventory.helper.tiaRelay private var inInventory = false @@ -33,7 +35,7 @@ class TiaRelayHelper { val soundName = event.soundName if (config.tiaRelayMute && soundName == "mob.wolf.whine") { - event.isCanceled = true + event.cancel() } if (!config.soundHelper) return @@ -54,18 +56,16 @@ class TiaRelayHelper { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.soundHelper) return - if (event.repeatSeconds(1)) { - if (InventoryUtils.openInventoryName().contains("Network Relay")) { - inInventory = true - } else { - inInventory = false - sounds.clear() - resultDisplay.clear() - } + if (InventoryUtils.openInventoryName().contains("Network Relay")) { + inInventory = true + } else { + inInventory = false + sounds.clear() + resultDisplay.clear() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayWaypoints.kt index 4e7730b03a69..c7faabb63f7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/tiarelay/TiaRelayWaypoints.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TiaRelayWaypoints { +@SkyHanniModule +object TiaRelayWaypoints { private val config get() = SkyHanniMod.feature.inventory.helper.tiaRelay private var waypoint: LorenzVec? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt new file mode 100644 index 000000000000..243b3132fdad --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt @@ -0,0 +1,595 @@ +package at.hannibal2.skyhanni.features.inventory.wardrobe + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.core.config.Position +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI.MAX_PAGES +import at.hannibal2.skyhanni.features.inventory.wardrobe.WardrobeAPI.MAX_SLOT_PER_PAGE +import at.hannibal2.skyhanni.mixins.transformers.gui.AccessorGuiContainer +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha +import at.hannibal2.skyhanni.utils.ColorUtils.darker +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColorInt +import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha +import at.hannibal2.skyhanni.utils.ConditionalUtils +import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf +import at.hannibal2.skyhanni.utils.ConfigUtils.jumpToEditor +import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.EntityUtils.getFakePlayer +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.removeEnchants +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment +import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment +import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable +import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color +import kotlin.math.min +import kotlin.time.Duration.Companion.milliseconds + +@SkyHanniModule +object CustomWardrobe { + + val config get() = SkyHanniMod.feature.inventory.customWardrobe + + private var displayRenderable: Renderable? = null + private var inventoryButton: Renderable? = null + private var editMode = false + private var waitingForInventoryUpdate = false + + private var activeScale: Int = 100 + private var currentMaxSize: Pair? = null + private var lastScreenSize: Pair? = null + private var guiName = "Custom Wardrobe" + + @SubscribeEvent + fun onGuiRender(event: GuiContainerEvent.BeforeDraw) { + if (!isEnabled() || editMode) return + val renderable = displayRenderable ?: run { + update() + displayRenderable ?: return + } + + val gui = event.gui + val screenSize = gui.width to gui.height + + if (screenSize != lastScreenSize) { + lastScreenSize = screenSize + val shouldUpdate = updateScreenSize(screenSize) + if (shouldUpdate) { + update() + return + } + } + + val (width, height) = renderable.width to renderable.height + val pos = Position((gui.width - width) / 2, (gui.height - height) / 2) + if (waitingForInventoryUpdate && config.loadingText) { + val loadingRenderable = Renderable.string( + "§cLoading...", + scale = activeScale / 100.0 + ) + val loadingPos = + Position(pos.rawX + (width - loadingRenderable.width) / 2, pos.rawY - loadingRenderable.height) + loadingPos.renderRenderable(loadingRenderable, posLabel = guiName, addToGuiManager = false) + } + + GlStateManager.translate(0f, 0f, 100f) + pos.renderRenderable(renderable, posLabel = guiName, addToGuiManager = false) + GlStateManager.translate(0f, 0f, -100f) + event.cancel() + } + + // Edit button in normal wardrobe while in edit mode + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) { + if (!isEnabled()) return + if (!editMode) return + val gui = Minecraft.getMinecraft().currentScreen as? GuiContainer ?: return + val renderable = inventoryButton ?: addReEnableButton().also { inventoryButton = it } + val accessorGui = gui as AccessorGuiContainer + val posX = accessorGui.guiLeft + (1.05 * accessorGui.width).toInt() + val posY = accessorGui.guiTop + (accessorGui.height - renderable.height) / 2 + Position(posX, posY).renderRenderable(renderable, posLabel = guiName, addToGuiManager = false) + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + waitingForInventoryUpdate = false + if (!isEnabled()) return + DelayedRun.runDelayed(250.milliseconds) { + if (!WardrobeAPI.inWardrobe()) { + reset() + } + } + } + + @SubscribeEvent + fun onConfigUpdate(event: ConfigLoadEvent) { + with(config.spacing) { + ConditionalUtils.onToggle( + globalScale, outlineThickness, outlineBlur, + slotWidth, slotHeight, playerScale, + maxPlayersPerRow, horizontalSpacing, verticalSpacing, + buttonSlotsVerticalSpacing, buttonHorizontalSpacing, buttonVerticalSpacing, + buttonWidth, buttonHeight, backgroundPadding, + ) { + currentMaxSize = null + lastScreenSize = null + } + } + } + + @SubscribeEvent + fun onInventoryUpdate(event: InventoryUpdatedEvent) { + if (!isEnabled() || editMode) return + update() + } + + private fun update() { + displayRenderable = createRenderables() + } + + private fun updateScreenSize(gui: Pair): Boolean { + val renderable = currentMaxSize ?: run { + activeScale = config.spacing.globalScale.get() + update() + return true + } + val previousActiveScale = activeScale + val unscaledRenderableWidth = renderable.first / activeScale + val unscaledRenderableHeight = renderable.second / activeScale + val autoScaleWidth = 0.95 * gui.first / unscaledRenderableWidth + val autoScaleHeight = 0.95 * gui.second / unscaledRenderableHeight + val maxScale = min(autoScaleWidth, autoScaleHeight).toInt() + + activeScale = config.spacing.globalScale.get().coerceAtMost(maxScale) + + return activeScale != previousActiveScale + } + + private fun createWarning(list: List): Pair> { + var wardrobeWarning: String? = null + var wardrobeSlots = list + + if (wardrobeSlots.isEmpty()) wardrobeWarning = "§cYour wardrobe is empty :(" + + if (config.hideLockedSlots) { + wardrobeSlots = wardrobeSlots.filter { !it.locked } + if (wardrobeSlots.isEmpty()) wardrobeWarning = "§cAll your slots are locked? Somehow" + } + + if (config.hideEmptySlots) { + wardrobeSlots = wardrobeSlots.filter { !it.isEmpty() } + if (wardrobeSlots.isEmpty()) wardrobeWarning = "§cAll slots are empty :(" + } + if (config.onlyFavorites) { + wardrobeSlots = wardrobeSlots.filter { it.favorite || it.isCurrentSlot() } + if (wardrobeSlots.isEmpty()) wardrobeWarning = "§cDidn't set any favorites" + } + + return wardrobeWarning to wardrobeSlots + } + + private fun createArmorTooltipRenderable( + slot: WardrobeSlot, + containerHeight: Int, + containerWidth: Int, + ): Renderable { + val loreList = mutableListOf() + val height = containerHeight - 3 + + // This is needed to keep the background size the same as the player renderable size + val hoverableSizes = MutableList(4) { height / 4 }.apply { + for (k in 0 until height % 4) this[k]++ + } + + for (armorIndex in 0 until 4) { + val stack = slot.armor[armorIndex]?.copy() + if (stack == null) { + loreList.add(Renderable.placeholder(containerWidth, hoverableSizes[armorIndex])) + } else { + loreList.add( + Renderable.hoverable( + Renderable.hoverTips( + Renderable.placeholder(containerWidth, hoverableSizes[armorIndex]), + stack.getTooltip(Minecraft.getMinecraft().thePlayer, false) + ), + Renderable.placeholder(containerWidth, hoverableSizes[armorIndex]), + bypassChecks = true + ) + ) + } + } + return Renderable.verticalContainer(loreList, spacing = 1) + } + + private fun createFakePlayerRenderable( + slot: WardrobeSlot, + playerWidth: Double, + containerHeight: Int, + containerWidth: Int, + ): Renderable { + val fakePlayer = getFakePlayer() + var scale = playerWidth + + fakePlayer.inventory.armorInventory = + slot.armor.map { it?.copy()?.removeEnchants() }.reversed().toTypedArray() + + val playerColor = if (!slot.isInCurrentPage()) { + scale *= 0.9 + Color.GRAY.withAlpha(100) + } else null + + return Renderable.fakePlayer( + fakePlayer, + followMouse = config.eyesFollowMouse, + width = containerWidth, + height = containerHeight, + entityScale = scale.toInt(), + padding = 0, + color = playerColor, + ) + } + + private fun createRenderables(): Renderable { + val (wardrobeWarning, list) = createWarning(WardrobeAPI.slots) + + val maxPlayersPerRow = config.spacing.maxPlayersPerRow.get().coerceAtLeast(1) + val maxPlayersRows = ((MAX_SLOT_PER_PAGE * MAX_PAGES - 1) / maxPlayersPerRow) + 1 + val containerWidth = (config.spacing.slotWidth.get() * (activeScale / 100.0)).toInt() + val containerHeight = (config.spacing.slotHeight.get() * (activeScale / 100.0)).toInt() + val playerWidth = (containerWidth * (config.spacing.playerScale.get() / 100.0)) + val horizontalSpacing = (config.spacing.horizontalSpacing.get() * (activeScale / 100.0)).toInt() + val verticalSpacing = (config.spacing.verticalSpacing.get() * (activeScale / 100.0)).toInt() + val backgroundPadding = (config.spacing.backgroundPadding.get() * (activeScale / 100.0)).toInt() + val buttonVerticalSpacing = (config.spacing.buttonVerticalSpacing.get() * (activeScale / 100.0)).toInt() + + var maxRenderableWidth = maxPlayersPerRow * containerWidth + (maxPlayersPerRow - 1) * horizontalSpacing + var maxRenderableHeight = maxPlayersRows * containerHeight + (maxPlayersRows - 1) * verticalSpacing + + val button = addButtons() + + if (button.width > maxRenderableWidth) maxRenderableWidth = button.width + maxRenderableHeight += button.height + buttonVerticalSpacing + + maxRenderableWidth += 2 * backgroundPadding + maxRenderableHeight += 2 * backgroundPadding + currentMaxSize = maxRenderableWidth to maxRenderableHeight + + wardrobeWarning?.let { text -> + val warningRenderable = Renderable.wrappedString( + text, + maxRenderableWidth, + 3.0 * (activeScale / 100.0), + horizontalAlign = HorizontalAlignment.CENTER + ) + val withButtons = Renderable.verticalContainer( + listOf(warningRenderable, button), + buttonVerticalSpacing, + horizontalAlign = HorizontalAlignment.CENTER + ) + return addGuiBackground(withButtons, backgroundPadding) + } + + val chunkedList = list.chunked(maxPlayersPerRow) + + val rowsRenderables = chunkedList.map { row -> + val slotsRenderables = row.map { slot -> + val armorTooltipRenderable = createArmorTooltipRenderable(slot, containerHeight, containerWidth) + + val playerBackground = createHoverableRenderable( + armorTooltipRenderable, + topLayerRenderable = addSlotHoverableButtons(slot), + hoveredColor = slot.getSlotColor(), + borderOutlineThickness = config.spacing.outlineThickness.get(), + borderOutlineBlur = config.spacing.outlineBlur.get(), + onClick = { slot.clickSlot() } + ) + + val playerRenderable = createFakePlayerRenderable(slot, playerWidth, containerHeight, containerWidth) + + Renderable.doubleLayered(playerBackground, playerRenderable, false) + } + Renderable.horizontalContainer(slotsRenderables, horizontalSpacing) + } + + val allSlotsRenderable = Renderable.verticalContainer( + rowsRenderables, + verticalSpacing, + horizontalAlign = HorizontalAlignment.CENTER + ) + + val withButtons = Renderable.verticalContainer( + listOf(allSlotsRenderable, button), + buttonVerticalSpacing, + horizontalAlign = HorizontalAlignment.CENTER + ) + + return addGuiBackground(withButtons, backgroundPadding) + } + + private fun addGuiBackground(renderable: Renderable, borderPadding: Int) = + Renderable.drawInsideRoundedRect( + Renderable.doubleLayered( + renderable, + Renderable.clickable( + Renderable.string( + "§7SkyHanni", + horizontalAlign = HorizontalAlignment.RIGHT, + verticalAlign = VerticalAlignment.BOTTOM, + scale = 1.0 * (activeScale / 100.0) + ).let { Renderable.hoverable(hovered = Renderable.underlined(it), unhovered = it) }, + onClick = { + config::enabled.jumpToEditor() + reset() + WardrobeAPI.currentPage = null + } + ), + blockBottomHover = false + ), + config.color.backgroundColor.toChromaColor(), + padding = borderPadding + ) + + private fun reset() { + WardrobeAPI.inCustomWardrobe = false + editMode = false + displayRenderable = null + inventoryButton = null + } + + private fun addButtons(): Renderable { + val (horizontalSpacing, verticalSpacing) = with(config.spacing) { + buttonHorizontalSpacing.get() * (activeScale / 100.0) to buttonVerticalSpacing.get() * (activeScale / 100.0) + } + + val backButton = createLabeledButton( + "§aBack", + onClick = { + InventoryUtils.clickSlot(48) + reset() + WardrobeAPI.currentPage = null + } + ) + val exitButton = createLabeledButton( + "§cClose", + onClick = { + InventoryUtils.clickSlot(49) + reset() + WardrobeAPI.currentPage = null + } + ) + + val greenColor = Color(85, 255, 85, 200) + val redColor = Color(255, 85, 85, 200) + + val onlyFavoriteButton = createLabeledButton( + "§eFavorite", + hoveredColor = if (config.onlyFavorites) greenColor else redColor, + onClick = { + config.onlyFavorites = !config.onlyFavorites + update() + } + ) + + val editButton = createLabeledButton( + "§bEdit", + onClick = { + DelayedRun.runNextTick { + reset() + editMode = true + } + } + ) + + val row = Renderable.horizontalContainer( + listOf(backButton, exitButton, onlyFavoriteButton), + horizontalSpacing.toInt(), + horizontalAlign = HorizontalAlignment.CENTER, + ) + + val total = Renderable.verticalContainer( + listOf(row, editButton), + verticalSpacing.toInt(), + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER + ) + + return total + } + + private fun addReEnableButton(): Renderable { + val color = Color(116, 150, 255, 200) + return createLabeledButton( + "§bEdit", + hoveredColor = color, + unhoveredColor = color.darker(0.8), + onClick = { + WardrobeAPI.inCustomWardrobe = false + editMode = false + update() + } + ) + } + + private fun addSlotHoverableButtons(wardrobeSlot: WardrobeSlot): Renderable { + val list = mutableListOf() + val textScale = 1.5 * (activeScale / 100.0) + list.add( + Renderable.clickable( + Renderable.hoverable( + Renderable.string( + (if (wardrobeSlot.favorite) "§c" else "§7") + "❤", + scale = textScale, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER + ), + Renderable.string( + (if (wardrobeSlot.favorite) "§4" else "§8") + "❤", + scale = textScale, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER + ) + ), + onClick = { + wardrobeSlot.favorite = !wardrobeSlot.favorite + update() + } + ) + ) + + if (config.estimatedValue && !wardrobeSlot.isEmpty()) { + val lore = WardrobeAPI.createPriceLore(wardrobeSlot) + list.add( + Renderable.hoverTips( + Renderable.string( + "§2$", + scale = textScale, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER, + ), + lore, + ), + ) + } + + return Renderable.verticalContainer(list, 1, HorizontalAlignment.RIGHT) + } + + private fun createLabeledButton( + text: String, + hoveredColor: Color = Color(130, 130, 130, 200), + unhoveredColor: Color = hoveredColor.darker(0.57), + onClick: () -> Unit, + ): Renderable { + val buttonWidth = (config.spacing.buttonWidth.get() * (activeScale / 100.0)).toInt() + val buttonHeight = (config.spacing.buttonHeight.get() * (activeScale / 100.0)).toInt() + val textScale = (activeScale / 100.0) + + val renderable = Renderable.hoverable( + Renderable.drawInsideRoundedRectWithOutline( + Renderable.doubleLayered( + Renderable.clickable( + Renderable.placeholder(buttonWidth, buttonHeight), + onClick + ), + Renderable.string( + text, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER, + scale = textScale + ), + false, + ), + hoveredColor, + padding = 0, + topOutlineColor = config.color.topBorderColor.toChromaColorInt(), + bottomOutlineColor = config.color.bottomBorderColor.toChromaColorInt(), + borderOutlineThickness = 2, + horizontalAlign = HorizontalAlignment.CENTER + ), + Renderable.drawInsideRoundedRect( + Renderable.doubleLayered( + Renderable.placeholder(buttonWidth, buttonHeight), + Renderable.string( + text, + horizontalAlign = HorizontalAlignment.CENTER, + verticalAlign = VerticalAlignment.CENTER, + scale = textScale + ), + ), + unhoveredColor.darker(0.57), + padding = 0, + horizontalAlign = HorizontalAlignment.CENTER + ) + ) + + return renderable + } + + private fun createHoverableRenderable( + hoveredRenderable: Renderable, + unhoveredRenderable: Renderable = Renderable.placeholder(hoveredRenderable.width, hoveredRenderable.height), + topLayerRenderable: Renderable = Renderable.placeholder(0, 0), + padding: Int = 0, + horizontalAlignment: HorizontalAlignment = HorizontalAlignment.CENTER, + verticalAlignment: VerticalAlignment = VerticalAlignment.CENTER, + hoveredColor: Color, + unHoveredColor: Color = hoveredColor, + borderOutlineThickness: Int, + borderOutlineBlur: Float = 0.5f, + onClick: () -> Unit, + onHover: () -> Unit = {}, + ): Renderable = + Renderable.hoverable( + Renderable.drawInsideRoundedRectWithOutline( + Renderable.doubleLayered( + Renderable.clickable( + hoveredRenderable, + onClick, + ), + topLayerRenderable, + ), + hoveredColor, + padding = padding, + topOutlineColor = config.color.topBorderColor.toChromaColorInt(), + bottomOutlineColor = config.color.bottomBorderColor.toChromaColorInt(), + borderOutlineThickness = borderOutlineThickness, + blur = borderOutlineBlur, + horizontalAlign = horizontalAlignment, + verticalAlign = verticalAlignment, + ), + Renderable.drawInsideRoundedRect( + unhoveredRenderable, + unHoveredColor, + padding = padding, + horizontalAlign = horizontalAlignment, + verticalAlign = verticalAlignment + ), + onHover = { onHover() }, + ) + + private fun WardrobeSlot.clickSlot() { + val previousPageSlot = 45 + val nextPageSlot = 53 + val wardrobePage = WardrobeAPI.currentPage ?: return + if (isInCurrentPage()) { + if (isEmpty() || locked || waitingForInventoryUpdate) return + WardrobeAPI.currentSlot = if (isCurrentSlot()) null else id + InventoryUtils.clickSlot(inventorySlot) + } else { + if (page < wardrobePage) { + WardrobeAPI.currentPage = wardrobePage - 1 + waitingForInventoryUpdate = true + InventoryUtils.clickSlot(previousPageSlot) + } else if (page > wardrobePage) { + WardrobeAPI.currentPage = wardrobePage + 1 + waitingForInventoryUpdate = true + InventoryUtils.clickSlot(nextPageSlot) + } + } + update() + } + + private fun WardrobeSlot.getSlotColor(): Color = with(config.color) { + when { + isCurrentSlot() -> equippedColor + favorite -> favoriteColor + else -> null + }?.toChromaColor()?.transformIf({ isInCurrentPage() }) { darker() } + ?: (if (isInCurrentPage()) samePageColor else otherPageColor).toChromaColor() + .transformIf({ locked || isEmpty() }) { darker(0.2) }.addAlpha(100) + } + + fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && WardrobeAPI.inWardrobe() +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/EstimatedWardrobePrice.kt new file mode 100644 index 000000000000..82acccf49874 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/EstimatedWardrobePrice.kt @@ -0,0 +1,40 @@ +package at.hannibal2.skyhanni.features.inventory.wardrobe + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object EstimatedWardrobePrice { + + private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues + + @SubscribeEvent + fun onTooltip(event: LorenzToolTipEvent) { + if (!isEnabled()) return + + val slot = WardrobeAPI.slots.firstOrNull { + event.slot.slotNumber == it.inventorySlot && it.isInCurrentPage() + } ?: return + + val lore = WardrobeAPI.createPriceLore(slot) + if (lore.isEmpty()) return + + val tooltip = event.toolTip + var index = 3 + + tooltip.add(index++, "") + tooltip.addAll(index, lore) + } + + private fun isEnabled() = + LorenzUtils.inSkyBlock && config.armor && WardrobeAPI.inWardrobe() && !WardrobeAPI.inCustomWardrobe + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(3, "misc.estimatedIemValueArmor", "misc.estimatedItemValues.armor") + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt new file mode 100644 index 000000000000..013aa1866f88 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt @@ -0,0 +1,207 @@ +package at.hannibal2.skyhanni.features.inventory.wardrobe + +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.DelayedRun +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import com.google.gson.annotations.Expose +import net.minecraft.init.Blocks +import net.minecraft.init.Items +import net.minecraft.item.EnumDyeColor +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.milliseconds + +@SkyHanniModule +object WardrobeAPI { + + val storage get() = ProfileStorageData.profileSpecific?.wardrobe + + private val repoGroup = RepoPattern.group("inventory.wardrobe") + private val inventoryPattern by repoGroup.pattern( + "inventory.name", + "Wardrobe \\((?\\d+)/\\d+\\)" + ) + + /** + * REGEX-TEST: §7Slot 4: §aEquipped + */ + private val equippedSlotPattern by repoGroup.pattern( + "equippedslot", + "§7Slot \\d+: §aEquipped" + ) + + private const val FIRST_SLOT = 36 + private const val FIRST_HELMET_SLOT = 0 + private const val FIRST_CHESTPLATE_SLOT = 9 + private const val FIRST_LEGGINGS_SLOT = 18 + private const val FIRST_BOOTS_SLOT = 27 + const val MAX_SLOT_PER_PAGE = 9 + const val MAX_PAGES = 2 + + var slots = listOf() + var inCustomWardrobe = false + + internal fun emptyArmor(): List = listOf(null, null, null, null) + + var currentSlot: Int? + get() = storage?.currentSlot + set(value) { + storage?.currentSlot = value + } + + var currentPage: Int? = null + private var inWardrobe = false + + init { + val list = mutableListOf() + var id = 0 + + for (page in 1..MAX_PAGES) { + for (slot in 0 until MAX_SLOT_PER_PAGE) { + val inventorySlot = FIRST_SLOT + slot + val helmetSlot = FIRST_HELMET_SLOT + slot + val chestplateSlot = FIRST_CHESTPLATE_SLOT + slot + val leggingsSlot = FIRST_LEGGINGS_SLOT + slot + val bootsSlot = FIRST_BOOTS_SLOT + slot + list.add(WardrobeSlot(++id, page, inventorySlot, helmetSlot, chestplateSlot, leggingsSlot, bootsSlot)) + } + } + slots = list + } + + private fun getWardrobeItem(itemStack: ItemStack?) = + if (itemStack?.item == ItemStack(Blocks.stained_glass_pane).item || itemStack == null) null else itemStack + + private fun getWardrobeSlotFromId(id: Int?) = slots.find { it.id == id } + + fun inWardrobe() = InventoryUtils.inInventory() && inWardrobe + + fun createPriceLore(slot: WardrobeSlot) = buildList { + if (slot.isEmpty()) return@buildList + add("§aEstimated Armor Value:") + var totalPrice = 0.0 + for (stack in slot.armor.filterNotNull()) { + val price = EstimatedItemValueCalculator.getTotalPrice(stack) + add(" §7- ${stack.name}: §6${NumberUtil.format(price)}") + totalPrice += price + } + if (totalPrice != 0.0) add(" §aTotal Value: §6§l${NumberUtil.format(totalPrice)} coins") + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryOpenEvent) { + inventoryPattern.matches(event.inventoryName).let { + inWardrobe = it + if (CustomWardrobe.config.enabled) inCustomWardrobe = it + } + } + + @SubscribeEvent + fun onInventoryUpdate(event: InventoryUpdatedEvent) { + if (!LorenzUtils.inSkyBlock) return + + inventoryPattern.matchMatcher(event.inventoryName) { + inWardrobe = true + currentPage = group("currentPage").formatInt() + } ?: return + + val itemsList = event.inventoryItems + + val allGrayDye = slots.all { + itemsList[it.inventorySlot]?.itemDamage == EnumDyeColor.GRAY.dyeDamage || !it.isInCurrentPage() + } + + if (allGrayDye) { + val allSlotsEmpty = slots.filter { it.isInCurrentPage() }.all { slot -> + (slot.inventorySlots.all { getWardrobeItem(itemsList[it]) == null }) + } + if (allSlotsEmpty) { + for (slot in slots.filter { it.isInCurrentPage() }) { + slot.getData()?.armor = emptyArmor() + } + } else return + } + + val foundCurrentSlot = processSlots(slots, itemsList) + if (!foundCurrentSlot && getWardrobeSlotFromId(currentSlot)?.page == currentPage) { + currentSlot = null + } + } + + private fun processSlots(slots: List, itemsList: Map): Boolean { + var foundCurrentSlot = false + + for (slot in slots.filter { it.isInCurrentPage() }) { + slot.getData()?.armor = listOf( + getWardrobeItem(itemsList[slot.helmetSlot]), + getWardrobeItem(itemsList[slot.chestplateSlot]), + getWardrobeItem(itemsList[slot.leggingsSlot]), + getWardrobeItem(itemsList[slot.bootsSlot]), + ) + if (equippedSlotPattern.matches(itemsList[slot.inventorySlot]?.name)) { + currentSlot = slot.id + foundCurrentSlot = true + } + slot.locked = (itemsList[slot.inventorySlot] == ItemStack(Items.dye, EnumDyeColor.RED.dyeDamage)) + if (slot.locked) slots.forEach { if (it.id > slot.id) it.locked = true } + } + + return foundCurrentSlot + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + if (!inWardrobe) return + DelayedRun.runDelayed(250.milliseconds) { + if (!inventoryPattern.matches(InventoryUtils.openInventoryName())) { + inWardrobe = false + currentPage = null + } + } + } + + @SubscribeEvent + fun onDebugCollect(event: DebugDataCollectEvent) { + event.title("Wardrobe") + event.addIrrelevant { + for (slot in slots) { + val slotInfo = buildString { + append("Slot ${slot.id}") + if (slot.favorite) append(" - Favorite: true") + } + if (slot.locked) { + add("$slotInfo is locked") + } else if (slot.isEmpty()) { + add("$slotInfo is empty") + } else { + add(slotInfo) + setOf("Helmet", "Chestplate", "Leggings", "Boots").forEachIndexed { id, armourName -> + slot.getData()?.armor?.get(id)?.name?.let { name -> + add(" $armourName: $name") + } + } + } + } + } + } + + class WardrobeData( + @Expose val id: Int, + @Expose var armor: List, + @Expose var locked: Boolean, + @Expose var favorite: Boolean, + ) +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeSlot.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeSlot.kt new file mode 100644 index 000000000000..e500887f984e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeSlot.kt @@ -0,0 +1,42 @@ +package at.hannibal2.skyhanni.features.inventory.wardrobe + +class WardrobeSlot( + val id: Int, + val page: Int, + val inventorySlot: Int, + val helmetSlot: Int, + val chestplateSlot: Int, + val leggingsSlot: Int, + val bootsSlot: Int, +) { + fun getData() = WardrobeAPI.storage?.data?.getOrPut(id) { + WardrobeAPI.WardrobeData( + id, + armor = WardrobeAPI.emptyArmor(), + locked = true, + favorite = false, + ) + } + + var locked: Boolean + get() = getData()?.locked ?: true + set(value) { + getData()?.locked = value + } + + var favorite: Boolean + get() = getData()?.favorite ?: false + set(value) { + getData()?.favorite = value + } + + val armor get() = getData()?.armor ?: WardrobeAPI.emptyArmor() + + val inventorySlots = listOf(helmetSlot, chestplateSlot, leggingsSlot, bootsSlot) + + fun isEmpty(): Boolean = armor.all { it == null } + + fun isCurrentSlot() = getData()?.id == WardrobeAPI.currentSlot + + fun isInCurrentPage() = (WardrobeAPI.currentPage == null && page == 1) || (page == WardrobeAPI.currentPage) +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/ChickenHeadTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/ChickenHeadTimer.kt index 8c6ff9029a0c..f315bb17dcc3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/ChickenHeadTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/ChickenHeadTimer.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class ChickenHeadTimer { +@SkyHanniModule +object ChickenHeadTimer { private val config get() = SkyHanniMod.feature.inventory.itemAbilities.chickenHead private var hasChickenHead = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt index f299d4e3c3e8..81477957e4cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/FireVeilWandParticles.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -20,7 +21,8 @@ import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class FireVeilWandParticles { +@SkyHanniModule +object FireVeilWandParticles { private val config get() = SkyHanniMod.feature.inventory.itemAbilities.fireVeilWands private val item by lazy { "FIRE_VEIL_WAND".asInternalName() } @@ -33,7 +35,7 @@ class FireVeilWandParticles { if (config.display == DisplayEntry.PARTICLES) return if (lastClick.passedSince() > 5.5.seconds) return if (event.type == EnumParticleTypes.FLAME && event.speed == 0.55f) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index 2ce1da3d4333..ac813c88ad6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.events.RenderObject import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbility.Companion.getMultiplier import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.CollectionUtils.mapKeysNotNull import at.hannibal2.skyhanni.utils.InventoryUtils @@ -35,7 +36,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.max -class ItemAbilityCooldown { +@SkyHanniModule +object ItemAbilityCooldown { private val config get() = SkyHanniMod.feature.inventory.itemAbilities diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt index f29337b12cbe..8af757f6e074 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/ColdOverlay.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.MiningAPI.inColdIsland import at.hannibal2.skyhanni.events.ColdUpdateEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils @@ -15,7 +16,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 import kotlin.time.Duration.Companion.seconds -class ColdOverlay { +@SkyHanniModule +object ColdOverlay { private val config get() = SkyHanniMod.feature.mining.coldOverlay diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt index 52549bee66db..6e6590c18371 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsGuide.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -25,7 +26,8 @@ import net.minecraft.client.player.inventory.ContainerLocalMenu import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DeepCavernsGuide { +@SkyHanniModule +object DeepCavernsGuide { private val config get() = SkyHanniMod.feature.mining.deepCavernsGuide @@ -131,7 +133,7 @@ class DeepCavernsGuide { @SubscribeEvent(priority = EventPriority.HIGH) fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { if (showStartIcon && event.slotId == 49) { - event.isCanceled = true + event.cancel() ChatUtils.chat("Manually enabled Deep Caverns Guide.") start() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt index 85453e6c7d45..1d8880cdefb3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/GoldenGoblinHighlight.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.mob.Mob import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -12,7 +13,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GoldenGoblinHighlight { +@SkyHanniModule +object GoldenGoblinHighlight { private val config get() = SkyHanniMod.feature.mining.highlightYourGoldenGoblin diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt index 09a2c5377471..fd8362d95594 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HighlightMiningCommissionMobs.kt @@ -4,9 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityMaxHealthUpdateEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth @@ -20,13 +21,15 @@ import net.minecraft.entity.monster.EntityMagmaCube import net.minecraft.entity.monster.EntitySlime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightMiningCommissionMobs { +@SkyHanniModule +object HighlightMiningCommissionMobs { private val config get() = SkyHanniMod.feature.mining - // TODO Commissin API + + // TODO Commission API private var active = listOf() - // TODO Commissin API + // TODO Commission API enum class MobType(val commissionName: String, val isMob: (EntityLivingBase) -> Boolean) { // Dwarven Mines @@ -52,7 +55,7 @@ class HighlightMiningCommissionMobs { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (!event.repeatSeconds(2)) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt index c594312a32d3..3933e097b87b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/HotmFeatures.kt @@ -4,14 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HotmData import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HotmFeatures { +@SkyHanniModule +object HotmFeatures { - val config get() = SkyHanniMod.feature.mining.hotm + private val config get() = SkyHanniMod.feature.mining.hotm fun isEnabled() = LorenzUtils.inSkyBlock && HotmData.inInventory @@ -35,7 +37,7 @@ class HotmFeatures { private fun handleLevelStackSize(event: RenderItemTipEvent) { if (!config.levelStackSize) return - HotmData.entries.firstOrNull() { + HotmData.entries.firstOrNull { event.stack == it.slot?.stack }?.let { event.stackTip = if (it.activeLevel == 0 || it.activeLevel == it.maxLevel) "" else diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index dcc39c8b94b5..14999c1072e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -23,7 +24,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.Collections -class KingTalismanHelper { +@SkyHanniModule +object KingTalismanHelper { private val config get() = SkyHanniMod.feature.mining.kingTalisman private val storage get() = ProfileStorageData.profileSpecific?.mining @@ -33,22 +35,19 @@ class KingTalismanHelper { "§6§lKing (?.*)" ) - companion object { + private var currentOffset: Int? = null + private var skyblockYear = 0 - private var currentOffset: Int? = null - private var skyblockYear = 0 - - private fun getCurrentOffset(): Int? { - if (SkyBlockTime.now().year != skyblockYear) { - return null - } - return currentOffset + private fun getCurrentOffset(): Int? { + if (SkyBlockTime.now().year != skyblockYear) { + return null } + return currentOffset + } - fun kingFix() { - currentOffset = null - ChatUtils.chat("Reset internal offset of King Talisman Helper.") - } + fun kingFix() { + currentOffset = null + ChatUtils.chat("Reset internal offset of King Talisman Helper.") } private val kingLocation = LorenzVec(129.6, 196.5, 194.1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt index 51c456b21997..92ba5fc13cd9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningCommissionsBlocksColor.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.LorenzUtils @@ -25,6 +26,7 @@ import net.minecraft.item.EnumDyeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object MiningCommissionsBlocksColor { private val config get() = SkyHanniMod.feature.mining.commissionsBlocksColor diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt index e3168e4b10cb..527c9d4c738e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/MiningNotifications.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.ColdUpdateEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LorenzUtils @@ -23,6 +24,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object MiningNotifications { private val ASCENSION_ROPE = "ASCENSION_ROPE".asInternalName().makePrimitiveStack(1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt index 7aed4e607270..18d4c250e9e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/TunnelsMaps.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.LorenzWarpEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.filterNotNullKeys import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode @@ -50,7 +51,8 @@ import java.awt.Color import kotlin.math.roundToInt import kotlin.time.Duration.Companion.seconds -class TunnelsMaps { +@SkyHanniModule +object TunnelsMaps { private val config get() = SkyHanniMod.feature.mining.tunnelMaps diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsNamesInCore.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsNamesInCore.kt index 80b9790878fd..6e17c300662b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsNamesInCore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsNamesInCore.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayerSqIgnoreY import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CrystalHollowsNamesInCore { +@SkyHanniModule +object CrystalHollowsNamesInCore { private val config get() = SkyHanniMod.feature.mining private val coreLocations = mapOf( diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsWalls.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsWalls.kt index df276f468adc..950e939768c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsWalls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/crystalhollows/CrystalHollowsWalls.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.mining.crystalhollows import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils.getCorners import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -15,12 +16,11 @@ import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class CrystalHollowsWalls { +@SkyHanniModule +object CrystalHollowsWalls { private val config get() = SkyHanniMod.feature.mining.crystalHollowsAreaWalls - fun isEnabled() = config.enabled && IslandType.CRYSTAL_HOLLOWS.isInIsland() - private enum class Areas(val color: Color) { MITHRIL(LorenzColor.GREEN.addOpacity(60)), PRECURSOR(LorenzColor.BLUE.addOpacity(60)), @@ -31,58 +31,60 @@ class CrystalHollowsWalls { ; } - private val expandTimes = 20 + private const val EXPAND_TIMES = 20 - private val heatHeight = 64.0 - private val maxHeight = 190.0 + // Heat is active at Y=64.0 and below as of SkyBlock 0.20.1. We draw the line + // one above to accurately show whether the player is inside the Magma Fields. + private const val HEAT_HEIGHT = 65.0 + private const val MAX_HEIGHT = 190.0 - private val minX = 0.0 - private val middleX = 513.0 - private val maxX = 1024.0 + private const val MIN_X = 0.0 + private const val MIDDLE_X = 513.0 + private const val MAX_X = 1024.0 - private val minZ = 0.0 - private val middleZ = 513.0 - private val maxZ = 1024.0 + private const val MIN_Z = 0.0 + private const val MIDDLE_Z = 513.0 + private const val MAX_Z = 1024.0 private val yViewOffset get() = -Minecraft.getMinecraft().thePlayer.getEyeHeight().toDouble() // Yes Hypixel has misaligned the nucleus private val nucleusBB = AxisAlignedBB( - 463.0, heatHeight, 460.0, - 560.0, maxHeight, 563.0 + 463.0, HEAT_HEIGHT, 460.0, + 560.0, MAX_HEIGHT, 563.0 ) - private val nucleusBBInflate = nucleusBB.inflateBlock(expandTimes) - private val nucleusBBExpand = nucleusBB.expandBlock(expandTimes) + private val nucleusBBInflate = nucleusBB.inflateBlock(EXPAND_TIMES) + private val nucleusBBExpand = nucleusBB.expandBlock(EXPAND_TIMES) private val nucleusBBOffsetY get() = nucleusBB.offset(0.0, yViewOffset, 0.0) - private fun Double.shiftPX() = this + LorenzVec.expandVector.x * expandTimes - private fun Double.shiftNX() = this - LorenzVec.expandVector.x * expandTimes + private fun Double.shiftPX() = this + LorenzVec.expandVector.x * EXPAND_TIMES + private fun Double.shiftNX() = this - LorenzVec.expandVector.x * EXPAND_TIMES - private fun Double.shiftPY() = this + LorenzVec.expandVector.y * expandTimes - private fun Double.shiftNY() = this - LorenzVec.expandVector.y * expandTimes + private fun Double.shiftPY() = this + LorenzVec.expandVector.y * EXPAND_TIMES + private fun Double.shiftNY() = this - LorenzVec.expandVector.y * EXPAND_TIMES - private fun Double.shiftPZ() = this + LorenzVec.expandVector.z * expandTimes - private fun Double.shiftNZ() = this - LorenzVec.expandVector.z * expandTimes + private fun Double.shiftPZ() = this + LorenzVec.expandVector.z * EXPAND_TIMES + private fun Double.shiftNZ() = this - LorenzVec.expandVector.z * EXPAND_TIMES @SubscribeEvent fun onRender(event: LorenzRenderWorldEvent) { if (!isEnabled()) return val position = RenderUtils.getViewerPos(event.partialTicks) - if (position.y < heatHeight + yViewOffset) { + if (position.y < HEAT_HEIGHT + yViewOffset) { drawHeat(event) } else if (nucleusBBOffsetY.isVecInside(position.toVec3())) { if (!config.nucleus) return drawNucleus(event) - } else if (position.x > middleX) { - if (position.z > middleZ) { + } else if (position.x > MIDDLE_X) { + if (position.z > MIDDLE_Z) { drawPrecursor(event) } else { drawMithril((event)) } } else { - if (position.z > middleZ) { + if (position.z > MIDDLE_Z) { drawGoblin(event) } else { drawJungle(event) @@ -107,7 +109,7 @@ class CrystalHollowsWalls { } private fun drawHeat(event: LorenzRenderWorldEvent) = RenderUtils.QuadDrawer.draw3D(event.partialTicks) { - val heatHeight = heatHeight.shiftNY() + val heatHeight = HEAT_HEIGHT.shiftNY() draw( LorenzVec(nucleusBB.minX, heatHeight, nucleusBB.minZ), LorenzVec(nucleusBB.maxX, heatHeight, nucleusBB.minZ), @@ -122,9 +124,9 @@ class CrystalHollowsWalls { } private fun drawNucleus(event: LorenzRenderWorldEvent) { - val (southEastCorner, southWestCorner, northEastCorner, northWestCorner) = nucleusBBInflate + val (southEastCorner, southWestCorner, northWestCorner, northEastCorner) = nucleusBBInflate .getCorners(nucleusBBInflate.minY) - val (southWestTopCorner, southEastTopCorner, northEastTopCorner, northWestTopCorner) = nucleusBBInflate + val (southEastTopCorner, southWestTopCorner, northWestTopCorner, northEastTopCorner) = nucleusBBInflate .getCorners(nucleusBBInflate.maxY) RenderUtils.QuadDrawer.draw3D(event.partialTicks) { @@ -137,49 +139,49 @@ class CrystalHollowsWalls { draw( southEastCorner, southEastTopCorner, - LorenzVec(nucleusBBInflate.minX, nucleusBBInflate.minY, middleZ), + LorenzVec(nucleusBBInflate.minX, nucleusBBInflate.minY, MIDDLE_Z), Areas.JUNGLE.color ) draw( southEastCorner, southEastTopCorner, - LorenzVec(middleX, nucleusBBInflate.minY, nucleusBBInflate.minZ), + LorenzVec(MIDDLE_X, nucleusBBInflate.minY, nucleusBBInflate.minZ), Areas.JUNGLE.color ) draw( northWestCorner, northWestTopCorner, - LorenzVec(nucleusBBInflate.maxX, nucleusBBInflate.minY, middleZ), + LorenzVec(nucleusBBInflate.maxX, nucleusBBInflate.minY, MIDDLE_Z), Areas.PRECURSOR.color ) draw( northWestCorner, northWestTopCorner, - LorenzVec(middleX, nucleusBBInflate.minY, nucleusBBInflate.maxZ), + LorenzVec(MIDDLE_X, nucleusBBInflate.minY, nucleusBBInflate.maxZ), Areas.PRECURSOR.color ) draw( southWestCorner, southWestTopCorner, - LorenzVec(nucleusBBInflate.minX, nucleusBBInflate.minY, middleZ), + LorenzVec(nucleusBBInflate.minX, nucleusBBInflate.minY, MIDDLE_Z), Areas.GOBLIN.color, ) draw( southWestCorner, southWestTopCorner, - LorenzVec(middleX, nucleusBBInflate.minY, nucleusBBInflate.maxZ), + LorenzVec(MIDDLE_X, nucleusBBInflate.minY, nucleusBBInflate.maxZ), Areas.GOBLIN.color ) draw( northEastCorner, northEastTopCorner, - LorenzVec(nucleusBBInflate.maxX, nucleusBBInflate.minY, middleZ), + LorenzVec(nucleusBBInflate.maxX, nucleusBBInflate.minY, MIDDLE_Z), Areas.MITHRIL.color ) draw( northEastCorner, northEastTopCorner, - LorenzVec(middleX, nucleusBBInflate.minY, nucleusBBInflate.minZ), + LorenzVec(MIDDLE_X, nucleusBBInflate.minY, nucleusBBInflate.minZ), Areas.MITHRIL.color ) } @@ -192,14 +194,14 @@ class CrystalHollowsWalls { color2: Color, ) { val nucleusX = if (isMinXEsleMaxX) nucleusBBExpand.minX else nucleusBBExpand.maxX - val middleX = if (isMinXEsleMaxX) middleX.shiftNX() else middleX.shiftPX() - val x = if (isMinXEsleMaxX) minX else maxX + val middleX = if (isMinXEsleMaxX) MIDDLE_X.shiftNX() else MIDDLE_X.shiftPX() + val x = if (isMinXEsleMaxX) MIN_X else MAX_X val nucleusZ = if (isMinZElseMaxZ) nucleusBBExpand.minZ else nucleusBBExpand.maxZ - val middleZ = if (isMinZElseMaxZ) middleZ.shiftNZ() else middleZ.shiftPZ() - val z = if (isMinZElseMaxZ) minZ else maxZ + val middleZ = if (isMinZElseMaxZ) MIDDLE_Z.shiftNZ() else MIDDLE_Z.shiftPZ() + val z = if (isMinZElseMaxZ) MIN_Z else MAX_Z - val heatHeight = heatHeight.shiftPY() + val heatHeight = HEAT_HEIGHT.shiftPY() val nucleusBase = LorenzVec(nucleusX, heatHeight, nucleusZ) @@ -218,26 +220,26 @@ class CrystalHollowsWalls { ) draw( nucleusXSideBase, - LorenzVec(nucleusX, maxHeight, middleZ), + LorenzVec(nucleusX, MAX_HEIGHT, middleZ), LorenzVec(x, heatHeight, middleZ), color1, ) draw( nucleusZSideBase, - LorenzVec(middleX, maxHeight, nucleusZ), + LorenzVec(middleX, MAX_HEIGHT, nucleusZ), LorenzVec(middleX, heatHeight, z), color2, ) draw( nucleusXSideBase, nucleusBase, - LorenzVec(nucleusX, maxHeight, middleZ), + LorenzVec(nucleusX, MAX_HEIGHT, middleZ), Areas.NUCLEUS.color, ) draw( nucleusZSideBase, nucleusBase, - LorenzVec(middleX, maxHeight, nucleusZ), + LorenzVec(middleX, MAX_HEIGHT, nucleusZ), Areas.NUCLEUS.color, ) } @@ -251,11 +253,11 @@ class CrystalHollowsWalls { color, heatHeight, nucleusX = if (isMinXEsleMaxX) nucleusBB.minX else nucleusBB.maxX, - middleX = if (isMinXEsleMaxX) middleX else middleX, - x = if (isMinXEsleMaxX) minX else maxX, + middleX = if (isMinXEsleMaxX) MIDDLE_X else MIDDLE_X, + x = if (isMinXEsleMaxX) MIN_X else MAX_X, nucleusZ = if (isMinZElseMaxZ) nucleusBB.minZ else nucleusBB.maxZ, - middleZ = if (isMinZElseMaxZ) middleX else middleX, - z = if (isMinZElseMaxZ) minZ else maxZ, + middleZ = if (isMinZElseMaxZ) MIDDLE_X else MIDDLE_X, + z = if (isMinZElseMaxZ) MIN_Z else MAX_Z, ) private fun RenderUtils.QuadDrawer.drawHeatArea( @@ -290,4 +292,5 @@ class CrystalHollowsWalls { ) } + private fun isEnabled() = config.enabled && IslandType.CRYSTAL_HOLLOWS.isInIsland() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt index 0a23e2aaa456..fc858de90997 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt @@ -5,8 +5,9 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.mining.MiningEventConfig import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventType.Companion.CompressFormat +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -19,6 +20,7 @@ import net.minecraft.init.Blocks import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object MiningEventDisplay { private val config get() = SkyHanniMod.feature.mining.miningEvent private var display = listOf() @@ -26,8 +28,7 @@ object MiningEventDisplay { private val islandEventData: MutableMap = mutableMapOf() @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!event.repeatSeconds(1)) return + fun onSecondPassed(event: SecondPassedEvent) { updateDisplay() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt index 698335f27fea..44fc087c74c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ChatUtils @@ -29,7 +30,8 @@ import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class MiningEventTracker { +@SkyHanniModule +object MiningEventTracker { private val config get() = SkyHanniMod.feature.mining.miningEvent private val patternGroup = RepoPattern.group("mining.eventtracker") @@ -59,11 +61,9 @@ class MiningEventTracker { private var canRequestAt = SimpleTimeMark.farPast() - companion object { - var apiErrorCount = 0 + var apiErrorCount = 0 - val apiError get() = apiErrorCount > 0 - } + val apiError get() = apiErrorCount > 0 @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index 2586f2257b4b..fb6e9054ae5a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -23,7 +24,8 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ExcavatorProfitTracker { +@SkyHanniModule +object ExcavatorProfitTracker { private val config get() = SkyHanniMod.feature.mining.fossilExcavator.profitTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt index 2e1bb94c2afe..9b7e39b6133e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/FossilExcavatorAPI.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland @@ -17,6 +18,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object FossilExcavatorAPI { private val patternGroup = RepoPattern.group("mining.fossil.excavator") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt index 568c1d985fe6..161330da5f9a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.formatLong @@ -9,7 +10,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GlacitePowderFeatures { +@SkyHanniModule +object GlacitePowderFeatures { private val config get() = SkyHanniMod.feature.mining.fossilExcavator private val patternGroup = RepoPattern.group("inventory.item.overlay") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt index 74fb3be55baa..ee2b5fab2aa9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.mining.fossilexcavator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.mining.FossilExcavationEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ProfitPerExcavation { +@SkyHanniModule +object ProfitPerExcavation { private val config get() = SkyHanniMod.feature.mining.fossilExcavator @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt index 64a2f591474c..ababbf3e1739 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolverDisplay.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.features.mining.fossilexcavator.FossilExcavatorAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -25,6 +26,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object FossilSolverDisplay { private val config get() = SkyHanniMod.feature.mining.fossilExcavator.solver diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt index e1c56ce69845..18750bff5194 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/CorpseLocator.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.hypixel.chat.event.PartyChatEvent import at.hannibal2.skyhanni.data.hypixel.chat.event.PlayerAllChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.HypixelCommands @@ -24,6 +25,7 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // TODO: Maybe implement automatic warp-in for chosen players if the user is not in a party. +@SkyHanniModule object CorpseLocator { private val config get() = SkyHanniMod.feature.mining.glaciteMineshaft.corpseLocator diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt index 162ef31ef459..edc44b30a8b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/glacitemineshaft/MineshaftWaypoints.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LocationUtils @@ -19,6 +20,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds // TODO rename to something else to reduce confusion +@SkyHanniModule object MineshaftWaypoints { private val config get() = SkyHanniMod.feature.mining.glaciteMineshaft diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/CorpseAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/CorpseAPI.kt index e8fc4509d02b..e49ca462f213 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/CorpseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/CorpseAPI.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.mining.mineshaft import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.mining.CorpseLootedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -10,7 +11,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CorpseAPI { +@SkyHanniModule +object CorpseAPI { private val patternGroup = RepoPattern.group("mining.mineshaft") private val chatPatternGroup = patternGroup.group("chat") diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt index d8dbe9e28fa4..73771d354e50 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.mining.mineshaft import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.mining.CorpseLootedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.itemName @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MineshaftCorpseProfitPer { +@SkyHanniModule +object MineshaftCorpseProfitPer { private val config get() = SkyHanniMod.feature.mining.mineshaft @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index 9e08572852a4..a936f963622a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -4,14 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.mining.PowderTrackerConfig.PowderDisplayEntry import at.hannibal2.skyhanni.data.BossbarData +import at.hannibal2.skyhanni.data.HotmData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.ConfigUtils @@ -29,6 +30,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object PowderTracker { private val config get() = SkyHanniMod.feature.mining.powderTracker @@ -85,6 +87,18 @@ object PowderTracker { calculateResourceHour(diamondEssenceInfo) calculateResourceHour(goldEssenceInfo) calculateResourceHour(chestInfo) + + doublePowder = powderBossBarPattern.matcher(BossbarData.getBossbar()).find() + powderBossBarPattern.matchMatcher(BossbarData.getBossbar()) { + powderTimer = group("time") + doublePowder = powderTimer != "00:00" + + tracker.update() + } + + if (lastChestPicked.passedSince() > 1.minutes) { + isGrinding = false + } } private val tracker = SkyHanniTracker("Powder Tracker", { Data() }, { it.powderTracker }) @@ -118,7 +132,7 @@ object PowderTracker { if (!isEnabled()) return val msg = event.message - if (config.greatExplorerMaxed) { + if (HotmData.GREAT_EXPLORER.let { it.enabled && it.isMaxLevel }) { uncoveredPattern.matchMatcher(msg) { tracker.modify { it.totalChestPicked += 1 @@ -153,23 +167,6 @@ object PowderTracker { tracker.update() } - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!isEnabled()) return - if (event.repeatSeconds(1)) { - doublePowder = powderBossBarPattern.matcher(BossbarData.getBossbar()).find() - powderBossBarPattern.matchMatcher(BossbarData.getBossbar()) { - powderTimer = group("time") - doublePowder = powderTimer != "00:00" - - tracker.update() - } - } - if (lastChestPicked.passedSince() > 1.minutes) { - isGrinding = false - } - } - @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { config.textFormat.afterChange { diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt index 1368984d7395..45ad93ca12d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/InfernoMinionFeatures.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class InfernoMinionFeatures { +@SkyHanniModule +object InfernoMinionFeatures { private val config get() = SkyHanniMod.feature.misc.minions private val infernoMinionTitlePattern by RepoPattern.pattern( "minion.infernominiontitle", diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt index 858e6d0ddb6e..05eecd3b7b7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.minion import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.events.entity.ItemAddInInventoryEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MinionCollectLogic { +@SkyHanniModule +object MinionCollectLogic { private var oldMap = mapOf() @@ -23,7 +25,7 @@ class MinionCollectLogic { val map = mutableMapOf() for (stack in InventoryUtils.getItemsInOwnInventory()) { val internalName = stack.getInternalName() - val (newId, amount) = NEUItems.getMultiplier(internalName) + val (newId, amount) = NEUItems.getPrimitiveMultiplier(internalName) val old = map[newId] ?: 0 map[newId] = old + amount * stack.stackSize } diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index bad1fe543c6d..2ece32b2d548 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.events.MinionCloseEvent import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.events.MinionStorageOpenEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.ChatUtils @@ -59,6 +60,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color +@SkyHanniModule object MinionFeatures { private val config get() = SkyHanniMod.feature.misc.minions @@ -381,7 +383,7 @@ object MinionFeatures { if (entity.customNameTag.contains("§c❤")) { val loc = entity.getLorenzVec() if (minions.any { it.key.distance(loc) < 5 }) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt index 7eba48a4de57..9cf785503530 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.events.MinionStorageOpenEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.skillprogress.SkillType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -26,7 +27,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.EnumMap -class MinionXp { +@SkyHanniModule +object MinionXp { private val config get() = SkyHanniMod.feature.misc.minions @@ -182,7 +184,7 @@ class MinionXp { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - xpInfoMap = event.getConstant("MinionXP").minion_xp.mapNotNull { xpType -> + xpInfoMap = event.getConstant("MinionXP").minionXp.mapNotNull { xpType -> xpType.value.mapNotNull { it.key.asInternalName() to XpInfo(SkillType.getByName(xpType.key), it.value) } }.flatten().toMap() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/AuctionHousePriceComparison.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/AuctionHousePriceComparison.kt index c7ba3c4e957c..bef3b469e66a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/AuctionHousePriceComparison.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/AuctionHousePriceComparison.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValueCalculator +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -19,7 +20,8 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class AuctionHousePriceComparison { +@SkyHanniModule +object AuctionHousePriceComparison { private val config get() = SkyHanniMod.feature.inventory.auctions.auctionsPriceComparison diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt index 22dfae308f48..096f7eeccd66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterSignEditing.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ClipboardUtils import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,7 +14,8 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BetterSignEditing { +@SkyHanniModule +object BetterSignEditing { private var pasteLastClicked = false private var copyLastClicked = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt index 653684d08757..3bfa54c7b841 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BetterWikiFromMenus.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.features.commands.WikiManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BetterWikiFromMenus { +@SkyHanniModule +object BetterWikiFromMenus { private val config get() = SkyHanniMod.feature.misc.commands.betterWiki @@ -53,7 +55,7 @@ class BetterWikiFromMenus { if (inSBGuideInventory && config.sbGuide) { val wikiSearch = itemClickedName.removeColor().replace("✔ ", "").replace("✖ ", "") WikiManager.sendWikiMessage(wikiSearch, autoOpen = config.menuOpenWiki) - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt index d4ed4f815baf..193f1e2ec39a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/BrewingStandOverlay.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BrewingStandOverlay { +@SkyHanniModule +object BrewingStandOverlay { @SubscribeEvent fun onRenderItemTip(event: RenderInventoryItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt index 536c6d5200cb..6060d2afb3f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.gui.GuiButton import net.minecraft.client.gui.GuiIngameMenu import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ButtonOnPause { +@SkyHanniModule +object ButtonOnPause { private val config get() = SkyHanniMod.feature.gui private val buttonId = System.nanoTime().toInt() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt index 10153cca38b6..bf495c61aadc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt @@ -6,10 +6,12 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorsJson import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.entity.EntityDisplayNameEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object ContributorManager { private val config get() = SkyHanniMod.feature.dev diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt index 89d1c574127f..347d47667383 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CopyPlaytime.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.misc.limbo.LimboPlaytime +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ClipboardUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object CopyPlaytime { @SubscribeEvent(priority = EventPriority.LOWEST) fun onTooltip(event: LorenzToolTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt index f06e498f2661..f0fef91def53 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CurrentPetDisplay.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -16,7 +17,8 @@ import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CurrentPetDisplay { +@SkyHanniModule +object CurrentPetDisplay { private val config get() = SkyHanniMod.feature.misc.pets diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt index 52058aca67df..8bbfbdb30256 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt @@ -5,12 +5,14 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class CustomTextBox { +@SkyHanniModule +object CustomTextBox { private val config get() = SkyHanniMod.feature.gui.customTextBox private var display = listOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt index 5d1b34564596..6fad15f8dff8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ExpOrbsOnGroundHider.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.item.EntityXPOrb import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ExpOrbsOnGroundHider { +@SkyHanniModule +object ExpOrbsOnGroundHider { @SubscribeEvent fun onCheckRender(event: CheckRenderEntityEvent<*>) { @@ -14,7 +16,7 @@ class ExpOrbsOnGroundHider { if (!SkyHanniMod.feature.misc.hideExpBottles) return if (event.entity is EntityXPOrb) { - event.isCanceled = true + event.cancel() } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt index d5246fc12f6f..0e891f44470f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixGhostEntities.kt @@ -1,9 +1,11 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.MobUtils.isDefaultValue import net.minecraft.entity.item.EntityArmorStand @@ -16,6 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent * This feature fixes ghost entities sent by hypixel that are not properly deleted in the correct order. * This included Diana, Dungeon and Crimson Isle mobs and nametags. */ +@SkyHanniModule object FixGhostEntities { private val config get() = SkyHanniMod.feature.misc @@ -29,8 +32,8 @@ object FixGhostEntities { recentlySpawnedEntities = ArrayDeque() } - @SubscribeEvent - fun onReceiveCurrentShield(event: PacketEvent.ReceiveEvent) { + @HandleEvent(onlyOnSkyblock = true) + fun onReceiveCurrentShield(event: PacketReceivedEvent) { if (!isEnabled()) return val packet = event.packet @@ -67,5 +70,5 @@ object FixGhostEntities { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.fixGhostEntities + fun isEnabled() = config.fixGhostEntities } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt index 7e266ca70aeb..7cde57e6eb13 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FixNEUHeavyPearls.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ItemAddEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -9,7 +10,8 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.hours -class FixNEUHeavyPearls { +@SkyHanniModule +object FixNEUHeavyPearls { private val config get() = SkyHanniMod.feature.misc private val heavyPearl = "HEAVY_PEARL".asInternalName() @@ -27,5 +29,5 @@ class FixNEUHeavyPearls { } } - fun isEnabled() = LorenzUtils.inSkyBlock && config.fixNeuHeavyPearls + private fun isEnabled() = LorenzUtils.inSkyBlock && config.fixNeuHeavyPearls } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt index cd842f6bba9b..112b59213651 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.HideArmorConfig.ModeEntry import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.EntityUtils.hasPotionEffect @@ -16,7 +17,8 @@ import net.minecraft.item.ItemStack import net.minecraft.potion.Potion import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HideArmor { +@SkyHanniModule +object HideArmor { private val config get() = SkyHanniMod.feature.misc.hideArmor2 private var armor = mapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt index 996273a642f0..e7a96f9e6967 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.boss.EntityWither import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HideFarEntities { +@SkyHanniModule +object HideFarEntities { private val config get() = SkyHanniMod.feature.misc.hideFarEntities private var ignored = emptySet() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt index 4dcdb0de9cde..e0045ba76e23 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt @@ -2,10 +2,9 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.data.jsonobjects.repo.TabListJson import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -15,23 +14,22 @@ import at.hannibal2.skyhanni.utils.TimeUtils.formatted import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class InGameDateDisplay { +@SkyHanniModule +object InGameDateDisplay { private val config get() = SkyHanniMod.feature.gui.inGameDate - private val monthAndDatePattern by RepoPattern.pattern( - "misc.ingametime.date", + private val patternGroup = RepoPattern.group("misc.ingametime") + private val monthAndDatePattern by patternGroup.pattern( + "date", ".*((Early|Late) )?(Winter|Spring|Summer|Autumn) [0-9]{1,2}(nd|rd|th|st)?.*" ) - private var display = "" - - // sun, moon, spooky - private var sunMoonIcons = emptyList() + private val timeSymbolsPattern by patternGroup.pattern( + "symbols", + "([☀☽࿇])" + ) - @SubscribeEvent - fun onRepoReload(event: RepositoryReloadEvent) { - sunMoonIcons = event.getConstant("TabList").sun_moon_symbols - } + private var display = "" @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { @@ -55,7 +53,7 @@ class InGameDateDisplay { val time = list.find { it.lowercase().contains("am ") || it.lowercase().contains("pm ") } ?: "??" theBaseString = "$monthAndDate, $year ${time.trim()}".removeColor() if (!config.includeSunMoon) { - sunMoonIcons.forEach { theBaseString = theBaseString.replace(it, "") } + theBaseString = timeSymbolsPattern.matcher(theBaseString).replaceAll("") } } else { theBaseString = date.formatted() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InWaterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InWaterDisplay.kt index f5e15b04a1b5..8129ff32ff4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InWaterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InWaterDisplay.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object InWaterDisplay { private val config get() = SkyHanniMod.feature.misc.stranded diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt index f0cf942648d1..bd8c0f41a53e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/JoinCrystalHollows.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class JoinCrystalHollows { +@SkyHanniModule +object JoinCrystalHollows { private var lastWrongPassTime = 0L diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt index fb0eb95db639..36bfb3fb78aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LesserOrbHider.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo @@ -12,12 +13,13 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class LesserOrbHider { +@SkyHanniModule +object LesserOrbHider { private val config get() = SkyHanniMod.feature.misc private val hiddenEntities = CollectionUtils.weakReferenceList() - private val lesserTexture = + private const val LESSER_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjgzMjM2NjM5NjA3MDM2YzFiYTM5MWMyYjQ2YTljN2IwZWZkNzYwYzhiZmEyOTk2YTYwNTU1ODJiNGRhNSJ9fX0=" @SubscribeEvent @@ -25,7 +27,7 @@ class LesserOrbHider { val entity = event.entity val itemStack = event.newItemStack ?: return - if (entity is EntityArmorStand && event.isHand && itemStack.getSkullTexture() == lesserTexture) { + if (entity is EntityArmorStand && event.isHand && itemStack.getSkullTexture() == LESSER_TEXTURE) { hiddenEntities.add(entity) } } @@ -35,7 +37,7 @@ class LesserOrbHider { if (!isEnabled()) return if (event.entity in hiddenEntities) { - event.isCanceled = true + event.cancel() } } @@ -47,7 +49,7 @@ class LesserOrbHider { for (armorStand in hiddenEntities) { val distance = armorStand.distanceTo(event.location) if (distance < 4) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt index 194b2e31045e..f7d8e20be216 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/LockMouseLook.kt @@ -6,11 +6,13 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.garden.SensitivityReducer +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object LockMouseLook { private val config get() = SkyHanniMod.feature.misc diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index 5edabcbb1944..e463549bc0c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -4,9 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.ConfigLoadEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle @@ -16,81 +17,79 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class MarkedPlayerManager { - companion object { +@SkyHanniModule +object MarkedPlayerManager { - val config get() = SkyHanniMod.feature.gui.markedPlayers + val config get() = SkyHanniMod.feature.gui.markedPlayers - val playerNamesToMark = mutableListOf() - private val markedPlayers = mutableMapOf() + private val playerNamesToMark = mutableListOf() + private val markedPlayers = mutableMapOf() - fun command(args: Array) { - if (args.size != 1) { - ChatUtils.userError("Usage: /shmarkplayer ") - return - } - - val displayName = args[0] - val name = displayName.lowercase() + fun command(args: Array) { + if (args.size != 1) { + ChatUtils.userError("Usage: /shmarkplayer ") + return + } + val displayName = args[0] + val name = displayName.lowercase() - if (name == LorenzUtils.getPlayerName().lowercase()) { - ChatUtils.userError("You can't add or remove yourself this way! Go to the settings and toggle 'Mark your own name'.") - return - } + if (name == LorenzUtils.getPlayerName().lowercase()) { + ChatUtils.userError("You can't add or remove yourself this way! Go to the settings and toggle 'Mark your own name'.") + return + } - if (name !in playerNamesToMark) { - playerNamesToMark.add(name) - findPlayers() - ChatUtils.chat("§aMarked §eplayer §b$displayName§e!") - } else { - playerNamesToMark.remove(name) - markedPlayers[name]?.let { RenderLivingEntityHelper.removeCustomRender(it) } - markedPlayers.remove(name) - ChatUtils.chat("§cUnmarked §eplayer §b$displayName§e!") - } + if (name !in playerNamesToMark) { + playerNamesToMark.add(name) + findPlayers() + ChatUtils.chat("§aMarked §eplayer §b$displayName§e!") + } else { + playerNamesToMark.remove(name) + markedPlayers[name]?.let { RenderLivingEntityHelper.removeCustomRender(it) } + markedPlayers.remove(name) + ChatUtils.chat("§cUnmarked §eplayer §b$displayName§e!") } + } - private fun findPlayers() { - for (entity in EntityUtils.getEntities()) { - if (entity in markedPlayers.values) continue + private fun findPlayers() { + for (entity in EntityUtils.getEntities()) { + if (entity in markedPlayers.values) continue - val name = entity.name.lowercase() - if (name in playerNamesToMark) { - markedPlayers[name] = entity - entity.setColor() - } + val name = entity.name.lowercase() + if (name in playerNamesToMark) { + markedPlayers[name] = entity + entity.setColor() } } + } - private fun refreshColours() = - markedPlayers.forEach { - it.value.setColor() - } - - private fun EntityOtherPlayerMP.setColor() { - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - this, - config.entityColor.get().toColor().withAlpha(127), - ::isEnabled - ) + private fun refreshColours() = + markedPlayers.forEach { + it.value.setColor() } - fun isMarkedPlayer(player: String): Boolean = player.lowercase() in playerNamesToMark + private fun EntityOtherPlayerMP.setColor() { + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + this, + config.entityColor.get().toColor().withAlpha(127), + ::isEnabled + ) + } - private fun isEnabled() = (LorenzUtils.inSkyBlock || OutsideSbFeature.MARKED_PLAYERS.isSelected()) - && config.highlightInWorld + fun isMarkedPlayer(player: String): Boolean = player.lowercase() in playerNamesToMark - fun replaceInChat(string: String): String { - if (!config.highlightInChat) return string + private fun isEnabled() = (LorenzUtils.inSkyBlock || OutsideSbFeature.MARKED_PLAYERS.isSelected()) + && config.highlightInWorld - val color = config.chatColor.getChatColor() - var text = string - for (markedPlayer in playerNamesToMark) { - text = text.replace(markedPlayer, "$color$markedPlayer§r") - } - return text + fun replaceInChat(string: String): String { + if (!config.highlightInChat) return string + + val color = config.chatColor.getChatColor() + var text = string + for (markedPlayer in playerNamesToMark) { + text = text.replace(markedPlayer, "$color$markedPlayer§r") } + return text } @SubscribeEvent @@ -109,12 +108,10 @@ class MarkedPlayerManager { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (event.repeatSeconds(1)) { - findPlayers() - } + findPlayers() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt index 09ee41e8d298..123394e9964a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MiscFeatures.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.util.EnumParticleTypes @@ -13,6 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent /** * I need these features in my dev env */ +@SkyHanniModule object MiscFeatures { @SubscribeEvent @@ -32,7 +34,7 @@ object MiscFeatures { EnumParticleTypes.EXPLOSION_LARGE, EnumParticleTypes.EXPLOSION_HUGE, EnumParticleTypes.EXPLOSION_NORMAL, - -> event.isCanceled = true + -> event.cancel() else -> {} } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt index d9df6321ba37..50148f031878 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MovementSpeedDisplay.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,21 +15,20 @@ import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer -class MovementSpeedDisplay { +@SkyHanniModule +object MovementSpeedDisplay { private val config get() = SkyHanniMod.feature.misc private var display = "" private val soulsandSpeeds = mutableListOf() - companion object { - /** - * This speed value represents the movement speed in blocks per second. - * This has nothing to do with the speed stat. - */ - var speed = 0.0 - var usingSoulsandSpeed = false - } + /** + * This speed value represents the movement speed in blocks per second. + * This has nothing to do with the speed stat. + */ + var speed = 0.0 + var usingSoulsandSpeed = false init { // TODO use LorenzTickEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt index 66ac9779232e..3de75461a398 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.BitsUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils @@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.utils.SoundUtils.createSound import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object NoBitsWarning { private val config get() = SkyHanniMod.feature.misc.bits diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index d4f94d6e2f51..7f077588980e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -1,17 +1,19 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted @@ -27,13 +29,13 @@ import at.hannibal2.skyhanni.utils.TimeUtils.timerColor import at.hannibal2.skyhanni.utils.Timer import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class NonGodPotEffectDisplay { +@SkyHanniModule +object NonGodPotEffectDisplay { private val config get() = SkyHanniMod.feature.misc.potionEffect private var checkFooter = false @@ -175,9 +177,8 @@ class NonGodPotEffectDisplay { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(1)) return if (!ProfileStorageData.loaded) return update() @@ -219,8 +220,9 @@ class NonGodPotEffectDisplay { } } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + // TODO use TablistFooterUpdateEvent instead + @HandleEvent(onlyOnSkyblock = true, priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { val packet = event.packet if (!checkFooter) return if (packet is S47PacketPlayerListHeaderFooter) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt index c5c30a09ee42..990f1a8b74e9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.projectile.EntitySmallFireball import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ParticleHider { +@SkyHanniModule +object ParticleHider { private fun inM7Boss() = DungeonAPI.inDungeon() && DungeonAPI.dungeonFloor == "M7" && DungeonAPI.inBossRoom @@ -18,13 +20,13 @@ class ParticleHider { fun onReceiveParticle(event: ReceiveParticleEvent) { val distanceToPlayer = event.distanceToPlayer if (SkyHanniMod.feature.misc.particleHiders.hideFarParticles && distanceToPlayer > 40 && !inM7Boss()) { - event.isCanceled = true + event.cancel() return } val type = event.type if (SkyHanniMod.feature.misc.particleHiders.hideCloseRedstoneParticles && type == EnumParticleTypes.REDSTONE && distanceToPlayer < 2) { - event.isCanceled = true + event.cancel() return } @@ -32,7 +34,7 @@ class ParticleHider { for (entity in EntityUtils.getEntities()) { val distance = entity.getLorenzVec().distance(event.location) if (distance < 5) { - event.isCanceled = true + event.cancel() return } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt index 1aac53222856..af2221a557b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PartyMemberOutlines.kt @@ -5,13 +5,15 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SpecialColour import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PartyMemberOutlines { +@SkyHanniModule +object PartyMemberOutlines { private val config get() = SkyHanniMod.feature.misc.highlightPartyMembers diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt index 34d8278c26a4..a4fea16ac177 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PatcherSendCoordinates.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.LocationUtils @@ -20,7 +21,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PatcherSendCoordinates { +@SkyHanniModule +object PatcherSendCoordinates { private val config get() = SkyHanniMod.feature.misc.patcherCoordsWaypoint private val patcherBeacon = mutableListOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt index 886827e23a1a..c80c30f09c74 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetCandyUsedDisplay.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getMaxPetLevel @@ -10,7 +11,8 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetCandyUsed import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetLevel import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PetCandyUsedDisplay { +@SkyHanniModule +object PetCandyUsedDisplay { private val config get() = SkyHanniMod.feature.misc.petCandy diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt index 2b3505f18142..55f34be5cc4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt @@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -16,24 +18,24 @@ import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp import at.hannibal2.skyhanni.utils.StringUtils import io.github.moulberry.notenoughupdates.NotEnoughUpdates -import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PetExpTooltip { +@SkyHanniModule +object PetExpTooltip { private val config get() = SkyHanniMod.feature.misc.pets.petExperienceToolTip - private val level100Common = 5_624_785 - private val level100Legendary = 25_353_230 - private val level200 = 210_255_385 + private const val LEVEL_100_COMMON = 5_624_785 + private const val LEVEL_100_LEGENDARY = 25_353_230 + private const val LEVEL_200_LEGENDARY = 210_255_385 @SubscribeEvent(priority = EventPriority.LOWEST) - fun onItemTooltipLow(event: ItemTooltipEvent) { + fun onItemTooltipLow(event: LorenzToolTipEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.petDisplay) return if (!KeyboardManager.isShiftKeyDown() && !config.showAlways) return - val itemStack = event.itemStack ?: return + val itemStack = event.itemStack val petExperience = itemStack.getPetExp()?.round(1) ?: return val name = itemStack.name try { @@ -98,15 +100,15 @@ class PetExpTooltip { private fun getMaxValues(petName: String, petExperience: Double): Pair { val useGoldenDragonLevels = - petName.contains("Golden Dragon") && (!config.showGoldenDragonEgg || petExperience >= level100Legendary) + petName.contains("Golden Dragon") && (!config.showGoldenDragonEgg || petExperience >= LEVEL_100_LEGENDARY) val maxLevel = if (useGoldenDragonLevels) 200 else 100 val maxXp = when { - useGoldenDragonLevels -> level200 // lvl 200 legendary - petName.contains("Bingo") -> level100Common + useGoldenDragonLevels -> LEVEL_200_LEGENDARY // lvl 200 legendary + petName.contains("Bingo") -> LEVEL_100_COMMON - else -> level100Legendary + else -> LEVEL_100_LEGENDARY } return Pair(maxLevel, maxXp) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt index 2f692708342a..12e82a893716 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetItemDisplay.kt @@ -2,13 +2,15 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetItem import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PetItemDisplay { +@SkyHanniModule +object PetItemDisplay { private val config get() = SkyHanniMod.feature.misc.pets diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt index f60eb930ee27..2da2ce052234 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PocketSackInASackDisplay.kt @@ -4,16 +4,18 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderItemEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.drawSlotText import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAppliedPocketSackInASack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PocketSackInASackDisplay { +@SkyHanniModule +object PocketSackInASackDisplay { private val config get() = SkyHanniMod.feature.inventory.pocketSackInASack - private val maxedStitched = 3 + private const val MAX_STITCHES = 3 @SubscribeEvent fun onRenderItemOverlayPost(event: GuiRenderItemEvent.RenderOverlayEvent.GuiRenderItemPost) { @@ -41,8 +43,8 @@ class PocketSackInASackDisplay { var next = false for (line in iterator) { if (line.contains("7This sack is")) { - val color = if (applied == maxedStitched) "§a" else "§b" - iterator.set("§7This sack is stitched $color$applied§7/$color$maxedStitched") + val color = if (applied == MAX_STITCHES) "§a" else "§b" + iterator.set("§7This sack is stitched $color$applied§7/$color$MAX_STITCHES") next = true continue } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt index 65559d8a6726..a29bcecc5ba7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt @@ -4,14 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.WorldClickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemCategory import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class PrivateIslandNoPickaxeAbility { +@SkyHanniModule +object PrivateIslandNoPickaxeAbility { - val config get() = SkyHanniMod.feature.mining + private val config get() = SkyHanniMod.feature.mining @SubscribeEvent fun onClick(event: WorldClickEvent) { @@ -21,7 +23,7 @@ class PrivateIslandNoPickaxeAbility { when (event.itemInHand?.getItemCategoryOrNull()) { ItemCategory.GAUNTLET, ItemCategory.PICKAXE, ItemCategory.DRILL -> { - event.isCanceled = true + event.cancel() } else -> {} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt index 8a4d3eebe2e2..20cd0bcdce27 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/QuickModMenuSwitch.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.data.jsonobjects.repo.ModGuiSwitcherJson import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -18,6 +19,7 @@ import net.minecraftforge.client.ClientCommandHandler import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object QuickModMenuSwitch { private val config get() = SkyHanniMod.feature.misc.quickModMenuSwitch diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt index 7aff5e148859..369c6984f5b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ReplaceRomanNumerals.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.ChatHoverEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.inventory.patternGroup import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -17,7 +18,8 @@ import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ReplaceRomanNumerals { +@SkyHanniModule +object ReplaceRomanNumerals { // Using toRegex here since toPattern doesn't seem to provide the necessary functionality private val splitRegex = "((§\\w)|(\\s+)|(\\W))+|(\\w*)".toRegex() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt index 23ed6e2960ea..3771771f73f3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/RestorePieceOfWizardPortalLore.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -10,7 +11,8 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getRecipientName import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RestorePieceOfWizardPortalLore { +@SkyHanniModule +object RestorePieceOfWizardPortalLore { private val config get() = SkyHanniMod.feature.misc diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt index 7277f3a8eca5..b2379958108e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.TimeUtils.format @@ -11,6 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object ServerRestartTitle { private val config get() = SkyHanniMod.feature.misc diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt index 9eca3a159a04..8a309ad0b33b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -13,7 +14,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class SkyBlockKickDuration { +@SkyHanniModule +object SkyBlockKickDuration { private val config get() = SkyHanniMod.feature.misc.kickDuration diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TabWidgetSettings.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TabWidgetSettings.kt index 08b10d5960ac..2e31bda49138 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TabWidgetSettings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TabWidgetSettings.kt @@ -4,16 +4,18 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RegexUtils.anyMatches import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TabWidgetSettings { +@SkyHanniModule +object TabWidgetSettings { private val patternGroup = RepoPattern.group("tab.widget.setting") private val mainPageSettingPattern by patternGroup.pattern( "gui", diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt index 5ca3e688c7f8..5512d69a8765 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TimeFeatures.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.WinterAPI import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RecalculatingValue @@ -18,7 +19,8 @@ import java.text.SimpleDateFormat import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.seconds -class TimeFeatures { +@SkyHanniModule +object TimeFeatures { private val config get() = SkyHanniMod.feature.gui private val winterConfig get() = SkyHanniMod.feature.event.winter diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt index c394e3a71676..0c6521e9c16d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TpsCounter.kt @@ -1,31 +1,30 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer -class TpsCounter { +@SkyHanniModule +object TpsCounter { private val config get() = SkyHanniMod.feature.gui - companion object { - - private const val minDataAmount = 5 - private const val waitAfterWorldSwitch = 6 - } + private const val MIN_DATA_AMOUNT = 5 + private const val WAIT_AFTER_WORLD_SWITCH = 6 private var packetsFromLastSecond = 0 private var tpsList = mutableListOf() - private var ignoreFirstTicks = waitAfterWorldSwitch + private var ignoreFirstTicks = WAIT_AFTER_WORLD_SWITCH private var hasPacketReceived = false private var display = "" @@ -38,7 +37,7 @@ class TpsCounter { if (ignoreFirstTicks > 0) { ignoreFirstTicks-- - val current = ignoreFirstTicks + minDataAmount + val current = ignoreFirstTicks + MIN_DATA_AMOUNT display = "§eTPS: §f(${current}s)" packetsFromLastSecond = 0 return@fixedRateTimer @@ -50,8 +49,8 @@ class TpsCounter { tpsList = tpsList.drop(1).toMutableList() } - display = if (tpsList.size < minDataAmount) { - val current = minDataAmount - tpsList.size + display = if (tpsList.size < MIN_DATA_AMOUNT) { + val current = MIN_DATA_AMOUNT - tpsList.size "§eTPS: §f(${current}s)" } else { val sum = tpsList.sum().toDouble() @@ -76,12 +75,12 @@ class TpsCounter { fun onWorldChange(event: LorenzWorldChangeEvent) { tpsList.clear() packetsFromLastSecond = 0 - ignoreFirstTicks = waitAfterWorldSwitch + ignoreFirstTicks = WAIT_AFTER_WORLD_SWITCH display = "" } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!config.tpsDisplay) return hasPacketReceived = true } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index ba53ee57d6f8..ac101a9096b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.misc.ContributorManager import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ConfigUtils @@ -26,6 +27,7 @@ import java.util.regex.Matcher import kotlin.random.Random import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object AdvancedPlayerList { val tabPlayerData = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt index 4db23889ff02..8c2a9632fa88 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListReader.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher @@ -15,6 +16,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent // heavily inspired by SBA code +@SkyHanniModule object TabListReader { private val config get() = SkyHanniMod.feature.gui.compactTabList diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt index 45bce0d20fa6..e95c02e8b22f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/TabListRenderer.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SkipTabListLineEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.filterToMutable import at.hannibal2.skyhanni.utils.KeyboardManager.isActive import at.hannibal2.skyhanni.utils.LorenzUtils @@ -18,6 +19,7 @@ import net.minecraft.entity.player.EnumPlayerModelParts import net.minecraftforge.client.event.RenderGameOverlayEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TabListRenderer { private val config get() = SkyHanniMod.feature.gui.compactTabList diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt index b132561ffc31..1565b7871c49 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt @@ -5,6 +5,7 @@ package at.hannibal2.skyhanni.features.misc.discordrpc import at.hannibal2.skyhanni.SkyHanniMod.Companion.coroutineScope import at.hannibal2.skyhanni.SkyHanniMod.Companion.feature import at.hannibal2.skyhanni.SkyHanniMod.Companion.logger +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.misc.DiscordRPCConfig.LineEntry import at.hannibal2.skyhanni.config.features.misc.DiscordRPCConfig.PriorityEntry @@ -17,6 +18,8 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.minecraft.ClientDisconnectEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -32,9 +35,9 @@ import com.jagrosh.discordipc.entities.RichPresenceButton import com.jagrosh.discordipc.entities.pipe.PipeStatus import kotlinx.coroutines.launch import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.network.FMLNetworkEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object DiscordRPCManager : IPCListener { private const val APPLICATION_ID = 1093298182735282176L @@ -184,8 +187,8 @@ object DiscordRPCManager : IPCListener { } } - @SubscribeEvent - fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) { + @HandleEvent + fun onDisconnect(event: ClientDisconnectEvent) { stop() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index b2fdf82942e8..a2ed65ee71e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.jsonobjects.repo.ItemsJson import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuReforgeStoneJson @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RenderItemTooltipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.item.ItemHoverEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -35,6 +37,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.roundToLong +@SkyHanniModule object EstimatedItemValue { private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues @@ -59,12 +62,11 @@ object EstimatedItemValue { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Items") - bookBundleAmount = data.book_bundle_amount ?: error("book_bundle_amount is missing") + bookBundleAmount = data.bookBundleAmount } - @SubscribeEvent + @HandleEvent(onlyOnSkyblock = true) fun onTooltip(event: ItemHoverEvent) { - if (!LorenzUtils.inSkyBlock) return if (!config.enabled) return if (Minecraft.getMinecraft().currentScreen !is GuiProfileViewer) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index 8602eece8227..c18408a0f5a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -54,6 +54,9 @@ import java.util.Locale object EstimatedItemValueCalculator { private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues + + private val kuudraSets = listOf("AURORA", "CRIMSON", "TERROR", "HOLLOW", "FERVOR") + private val additionalCostFunctions = listOf( ::addAttributeCost, ::addReforgeStone, @@ -92,6 +95,8 @@ object EstimatedItemValueCalculator { ::addEnchantments ) + fun getTotalPrice(stack: ItemStack): Double = EstimatedItemValueCalculator.calculate(stack, mutableListOf()).first + fun calculate(stack: ItemStack, list: MutableList): Pair { val basePrice = addBaseItem(stack, list) val totalPrice = additionalCostFunctions.fold(basePrice) { total, function -> total + function(stack, list) } @@ -101,13 +106,10 @@ object EstimatedItemValueCalculator { private fun addAttributeCost(stack: ItemStack, list: MutableList): Double { val attributes = stack.getAttributes() ?: return 0.0 var internalName = stack.getInternalName().asString().removePrefix("VANQUISHED_") - val kuudraSets = listOf("AURORA", "CRIMSON", "TERROR", "HOLLOW") var genericName = internalName if (kuudraSets.any { internalName.contains(it) } && listOf("CHESTPLATE", "LEGGINGS", "HELMET", "BOOTS").any { internalName.endsWith(it) }) { - for (prefix in listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_")) { - internalName = internalName.removePrefix(prefix) - } + internalName = removeCrimsonArmorPrefix(internalName) genericName = kuudraSets.fold(internalName) { acc, part -> acc.replace(part, "GENERIC_KUUDRA") } } if (internalName == "ATTRIBUTE_SHARD" && attributes.size == 1) { @@ -128,28 +130,67 @@ object EstimatedItemValueCalculator { if (attributes.size != 2) return 0.0 val basePrice = internalName.asInternalName().getPriceOrNull() ?: 0.0 var subTotal = 0.0 - val combo = ("$internalName+ATTRIBUTE_${attributes[0].first}+ATTRIBUTE_${attributes[1].first}").asInternalName() - val comboPrice = combo.getPriceOrNull() - if (comboPrice != null && comboPrice > basePrice) { - list.add("§7Attribute Combo: (§6${NumberUtil.format(comboPrice)}§7)") - subTotal += comboPrice - basePrice + val combo = ("$internalName+ATTRIBUTE_${attributes[0].first}+ATTRIBUTE_${attributes[1].first}") + var comboPrice = combo.asInternalName().getPriceOrNull() + + if (comboPrice != null) { + val useless = isUselessAttribute(combo) + val color = if (comboPrice > basePrice && !useless) "§6" else "§7" + list.add("§7Attribute Combo: ($color${NumberUtil.format(comboPrice)}§7)") + if (!useless) { + subTotal += addAttributePrice(comboPrice, basePrice) + } } else { list.add("§7Attributes:") } for (attr in attributes) { + val attributeName = "$genericName+ATTRIBUTE_${attr.first}" val price = - getPriceOrCompositePriceForAttribute("$genericName+ATTRIBUTE_${attr.first}", attr.second) + getPriceOrCompositePriceForAttribute(attributeName, attr.second) + var priceColor = "§7" + val useless = isUselessAttribute(attributeName) + var nameColor = if (!useless) "§9" else "§7" if (price != null) { - subTotal += price + if (price > basePrice && !useless) { + subTotal += addAttributePrice(price, basePrice) + priceColor = "§6" + } + } val displayName = attr.first.fixMending() list.add( - " §9${ + " $nameColor${ displayName.allLettersFirstUppercase() - } ${attr.second}§7: §6${if (price != null) NumberUtil.format(price) else "Unknown"}" + } ${attr.second}§7: $priceColor${if (price != null) NumberUtil.format(price) else "Unknown"}" ) } - return subTotal + // Adding 0.1 so that we always show the estimated item value overlay + return subTotal + 0.1 + } + + private fun removeCrimsonArmorPrefix(original: String): String { + var internalName = original + for (prefix in listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_")) { + internalName = internalName.removePrefix(prefix) + } + return internalName + } + + private fun addAttributePrice(attributePrice: Double, basePrice: Double): Double = + if (attributePrice > basePrice) { + attributePrice - basePrice + } else { + 0.0 + } + + private fun isUselessAttribute(internalName: String): Boolean { + if (internalName.contains("RESISTANCE")) return true + if (internalName.contains("SPEED")) return true + if (internalName.contains("EXPERIENCE")) return true + if (internalName.contains("FORTITUDE")) return true + if (internalName.contains("ENDER")) return true + + return false } private fun String.fixMending() = if (this == "MENDING") "VITALITY" else this @@ -489,7 +530,7 @@ object EstimatedItemValueCalculator { } private fun addBaseItem(stack: ItemStack, list: MutableList): Double { - val internalName = stack.getInternalName() + val internalName = removeCrimsonArmorPrefix(stack.getInternalName().asString()).asInternalName() var price = internalName.getPrice() if (price == -1.0) { price = 0.0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt deleted file mode 100644 index 2c3e008037cc..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt +++ /dev/null @@ -1,71 +0,0 @@ -package at.hannibal2.skyhanni.features.misc.items - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzToolTipEvent -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class EstimatedWardrobePrice { - - private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues - var data = mutableMapOf>() - - @SubscribeEvent - fun onTooltip(event: LorenzToolTipEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!config.armor) return - if (!InventoryUtils.openInventoryName().contains("Wardrobe")) return - - val slot = event.slot.slotNumber - val id = slot % 9 - // Only showing in the armor select line - if (slot - id != 36) return - val items = data[id] ?: return - - var index = 3 - val toolTip = event.toolTip - if (toolTip.size < 4) return - toolTip.add(index++, "") - toolTip.add(index++, "§aEstimated Armor Value:") - - var totalPrice = 0.0 - for (item in items) { - val price = EstimatedItemValueCalculator.calculate(item, mutableListOf()).first - totalPrice += price - - toolTip.add(index++, " §7- ${item.name}: §6${NumberUtil.format(price)}") - } - toolTip.add(index, " §aTotal Value: §6§l${NumberUtil.format(totalPrice)} coins") - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!config.armor) return - if (!event.inventoryName.startsWith("Wardrobe")) return - - val map = mutableMapOf>() - - for ((slot, item) in event.inventoryItems) { - item.getInternalNameOrNull() ?: continue - val price = EstimatedItemValueCalculator.calculate(item, mutableListOf()).first - if (price == 0.0) continue - val id = slot % 9 - val list = map.getOrPut(id) { mutableListOf() } - list.add(item) - } - data = map - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(3, "misc.estimatedIemValueArmor", "misc.estimatedItemValues.armor") - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt index b2b97c38195f..95c87e96d5d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/GlowingDroppedItems.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent import at.hannibal2.skyhanni.features.garden.pests.SprayType +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrNull import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -15,7 +16,8 @@ import net.minecraft.entity.item.EntityItem import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class GlowingDroppedItems { +@SkyHanniModule +object GlowingDroppedItems { private val config get() = SkyHanniMod.feature.misc.glowingDroppedItems diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt index 5c8f9b893d64..530cd48861c4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.chroma.ChromaManager import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -30,6 +31,7 @@ import java.util.TreeSet /** * Modified Enchant Parser from [SkyblockAddons](https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/features/enchants/EnchantManager.java) */ +@SkyHanniModule object EnchantParser { private val config get() = SkyHanniMod.feature.inventory.enchantParsing diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt index 2698c0e943cd..57e355ecdf16 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -19,6 +20,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object LimboPlaytime { private lateinit var modifiedList: MutableList private var setMinutes = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt index 1e110e5735b2..2888cc7071d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboTimeTracker.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.LorenzUtils @@ -25,6 +26,7 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit +@SkyHanniModule object LimboTimeTracker { private val storage get() = ProfileStorageData.playerSpecific?.limbo private val config get() = SkyHanniMod.feature.misc diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt index 8197c8ba94db..5fa36943a64c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt @@ -3,12 +3,14 @@ package at.hannibal2.skyhanni.features.misc.massconfiguration import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import io.github.notenoughupdates.moulconfig.processor.ConfigProcessorDriver import net.minecraft.client.Minecraft import net.minecraft.command.CommandBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DefaultConfigFeatures { private var didNotifyOnce = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt index 1e2cad06c3b5..05a10afe7a36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadCompactName.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc.teleportpad import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -11,7 +12,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TeleportPadCompactName { +@SkyHanniModule +object TeleportPadCompactName { private val patternGroup = RepoPattern.group("misc.teleportpad") private val namePattern by patternGroup.pattern( "name", @@ -32,7 +34,7 @@ class TeleportPadCompactName { val name = entity.name noNamePattern.matchMatcher(name) { - event.isCanceled = true + event.cancel() } namePattern.matchMatcher(name) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt index 2fdf09ac9117..1154bf472503 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/teleportpad/TeleportPadInventoryNumber.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TeleportPadInventoryNumber { +@SkyHanniModule +object TeleportPadInventoryNumber { private val numbers: Map by lazy { val baseNumber = mapOf( diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 86ce497fe4ef..56165f54f716 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.ConfigUtils @@ -26,14 +27,14 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils -import at.hannibal2.skyhanni.utils.RegexUtils.findMatcher -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.getLorenzVec @@ -46,6 +47,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object TrevorFeatures { private val patternGroup = RepoPattern.group("misc.trevor") private val trapperPattern by patternGroup.pattern( @@ -311,7 +313,7 @@ object TrevorFeatures { if (!config.trapperTalkCooldown) return val entity = event.entity if (entity is EntityArmorStand && entity.name == "§e§lCLICK") { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt index da000afcec7f..36c85981420f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt @@ -6,15 +6,17 @@ import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher +@SkyHanniModule object TrevorTracker { private val config get() = SkyHanniMod.feature.misc.trevorTheTrapper diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt index a75d88af7b92..fae931ff2598 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.About.UpdateStream import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.LorenzLogger @@ -24,6 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.concurrent.CompletableFuture import javax.net.ssl.HttpsURLConnection +@SkyHanniModule object UpdateManager { private val logger = LorenzLogger("update_manager") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt index 8afc503dd045..8999ba074941 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/visualwords/ModifyVisualWords.kt @@ -4,12 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.HypixelJoinEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.convertToFormatted import at.hannibal2.skyhanni.utils.TimeLimitedCache import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object ModifyVisualWords { private val config get() = SkyHanniMod.feature.gui.modifyWords diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt index 24d70e12c29a..da0ef76eba67 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.mob.Mob import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand.getMobInfo import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.TreeSet -class MatriarchHelper { +@SkyHanniModule +object MatriarchHelper { private val config get() = SkyHanniMod.feature.crimsonIsle.matriarchHelper diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt index 5a8259e89436..0ada23ab4bf0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/PabloHelper.kt @@ -1,13 +1,15 @@ package at.hannibal2.skyhanni.features.nether import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.GetFromSackAPI import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.HypixelCommands +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.RegexUtils.matchMatchers import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -15,7 +17,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes // https://wiki.hypixel.net/Pablo -class PabloHelper { +@SkyHanniModule +object PabloHelper { private val config get() = SkyHanniMod.feature.crimsonIsle @@ -35,9 +38,11 @@ class PabloHelper { if (InventoryUtils.countItemsInLowerInventory { it.name.contains(itemName) } > 0) return - ChatUtils.clickableChat("Click here to grab an $itemName from sacks!", onClick = { - HypixelCommands.getFromSacks(itemName, 1) - }) + GetFromSackAPI.getFromChatMessageSackItems( + itemName.asInternalName().makePrimitiveStack(), + "Click here to grab an $itemName from sacks!" + ) + lastSentMessage = SimpleTimeMark.now() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt index 9066df5027ef..daed44c077ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/SulphurSkitterBox.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.fishing.FishingAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.LocationUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -22,12 +23,13 @@ import net.minecraft.util.BlockPos import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class SulphurSkitterBox { +@SkyHanniModule +object SulphurSkitterBox { private val config get() = SkyHanniMod.feature.fishing.trophyFishing.sulphurSkitterBox private var spongeBlocks = listOf() private var closestBlock: BlockPos? = null - private val radius = 8 + private const val RADIUS = 8 @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -44,8 +46,8 @@ class SulphurSkitterBox { val loc = it.toLorenzVec() loc.getBlockAt() == Blocks.sponge && loc.distanceToPlayer() <= 15 }.filter { - val pos1 = it.add(-radius, -radius, -radius) - val pos2 = it.add(radius, radius, radius) + val pos1 = it.add(-RADIUS, -RADIUS, -RADIUS) + val pos2 = it.add(RADIUS, RADIUS, RADIUS) BlockPos.getAllInBox(pos1, pos2).any { pos -> pos.toLorenzVec().getBlockAt() in FishingAPI.lavaBlocks } @@ -63,8 +65,8 @@ class SulphurSkitterBox { if (!isEnabled()) return closestBlock?.let { if (it.toLorenzVec().distanceToPlayer() >= 50) return - val pos1 = it.add(-radius, -radius, -radius) - val pos2 = it.add(radius, radius, radius) + val pos1 = it.add(-RADIUS, -RADIUS, -RADIUS) + val pos2 = it.add(RADIUS, RADIUS, RADIUS) val axis = AxisAlignedBB(pos1, pos2).expandBlock() drawBox(axis, event.partialTicks) diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt index 1b4ed180b0d0..6cb7f3bf45ad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/VolcanoExplosivityDisplay.kt @@ -4,13 +4,15 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst +import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class VolcanoExplosivityDisplay { +@SkyHanniModule +object VolcanoExplosivityDisplay { private val config get() = SkyHanniMod.feature.crimsonIsle private val patternGroup = RepoPattern.group("crimson.volcano") diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt index fd32f9824130..9c152e1432dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazes.kt @@ -4,12 +4,13 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils @@ -22,7 +23,8 @@ import net.minecraft.entity.monster.EntityBlaze import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangBlazes { +@SkyHanniModule +object AshfangBlazes { private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang @@ -32,12 +34,10 @@ class AshfangBlazes { private var nearAshfang = false @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (event.repeatSeconds(1)) { - checkNearAshfang() - } + checkNearAshfang() if (nearAshfang) { for (entity in EntityUtils.getEntities() @@ -93,7 +93,7 @@ class AshfangBlazes { if (!entity.hasCustomName()) return if (entity.isDead) return if (entity in blazeArmorStand.values) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt index ff4cae5a7646..6f93cec121cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangBlazingSouls.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.EntityUtils @@ -18,11 +19,12 @@ import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangBlazingSouls { +@SkyHanniModule +object AshfangBlazingSouls { private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang.blazingSouls - private val texture = + private const val TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODI4N2IzOTdkYWY5NTE2YTBiZDc2ZjVmMWI3YmY5Nzk1MTVkZjNkNWQ4MzNlMDYzNWZhNjhiMzdlZTA4MjIxMiJ9fX0=" private val souls = mutableListOf() @@ -31,7 +33,7 @@ class AshfangBlazingSouls { if (!isEnabled()) return EntityUtils.getEntities() - .filter { it !in souls && it.hasSkullTexture(texture) } + .filter { it !in souls && it.hasSkullTexture(TEXTURE) } .forEach { souls.add(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt index 514f18876b80..68684ef49ece 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -15,6 +16,7 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object AshfangFreezeCooldown { private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt index adadbee9ce2a..10c58b485fa7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangGravityOrbs.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils @@ -19,11 +20,12 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class AshfangGravityOrbs { +@SkyHanniModule +object AshfangGravityOrbs { private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang.gravityOrbs - private val texture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV" + + private const val TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV" + "0L3RleHR1cmUvMWE2OWNjZjdhZDkwNGM5YTg1MmVhMmZmM2Y1YjRlMjNhZGViZjcyZWQxMmQ1ZjI0Yjc4Y2UyZDQ0YjRhMiJ9fX0=" private val orbs = mutableListOf() @@ -32,7 +34,7 @@ class AshfangGravityOrbs { if (!isEnabled()) return EntityUtils.getEntities() - .filter { it !in orbs && it.hasSkullTexture(texture) } + .filter { it !in orbs && it.hasSkullTexture(TEXTURE) } .forEach { orbs.add(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt index 203557278ed8..606f7d17f8bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideDamageIndicator.kt @@ -5,19 +5,21 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangHideDamageIndicator { +@SkyHanniModule +object AshfangHideDamageIndicator { @SubscribeEvent(priority = EventPriority.HIGH) fun onRenderLiving(event: SkyHanniRenderEntityEvent.Specials.Pre) { if (!isEnabled()) return if (DamageIndicatorManager.isDamageSplash(event.entity)) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt index ebd0f474d336..4c228a436f66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt @@ -3,33 +3,33 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangHideParticles { +@SkyHanniModule +object AshfangHideParticles { private var nearAshfang = false @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return - if (event.repeatSeconds(3)) { - nearAshfang = DamageIndicatorManager.getDistanceTo(BossType.NETHER_ASHFANG) < 40 - } + nearAshfang = DamageIndicatorManager.getDistanceTo(BossType.NETHER_ASHFANG) < 40 } @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { if (isEnabled()) { - event.isCanceled = true + event.cancel() } } @@ -44,7 +44,7 @@ class AshfangHideParticles { val name = stack.name if (name == "§aFairy Souls") continue if (name == "Glowstone") { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt index edd523ec29f4..f4061033ac98 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class AshfangNextResetCooldown { +@SkyHanniModule +object AshfangNextResetCooldown { private val config get() = SkyHanniMod.feature.crimsonIsle.ashfang private var spawnTime = 1L diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt index 318d7370d1fe..dbae485dcde8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/kuudra/KuudraAPI.kt @@ -6,11 +6,13 @@ import at.hannibal2.skyhanni.events.KuudraEnterEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object KuudraAPI { private val patternGroup = RepoPattern.group("data.kuudra") diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index e2d368c6f0ca..b1edb0142456 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -4,13 +4,14 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.SackAPI.getAmountInSacksOrNull +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper import at.hannibal2.skyhanni.features.nether.reputationhelper.FactionType @@ -85,32 +86,14 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } } - // TODO use WidgetUpdateEvent once its merged @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { - if (!isEnabled()) return - - questLoader.loadFromTabList() + fun onTabListWidgetUpdate(event: WidgetUpdateEvent) { + if (event.isWidget(TabWidget.FACTION_QUESTS)) { + if (!isEnabled()) return + questLoader.loadFromTabList() + } } -// @SubscribeEvent -// fun onTabListWidgetUpdate(event: WidgetUpdateEvent.NewValues) { -// if (!isEnabled()) return -// if (event.isWidget(TabWidget.FACTION_QUESTS)) { -// println("WidgetUpdateEvent.NewValues") -// questLoader.loadFromTabList(event.lines) -// } -// } -// -// @SubscribeEvent -// fun onTabListWidgetUpdate(event: WidgetUpdateEvent.Clear) { -// if (!isEnabled()) return -// if (event.isWidget(TabWidget.FACTION_QUESTS)) { -// println("WidgetUpdateEvent.Clear") -// questLoader.loadFromTabList(emptyList()) -// } -// } - @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt index fa1115f81c6d..694ebed350e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt @@ -1,7 +1,8 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage -import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson.ReputationQuest +import at.hannibal2.skyhanni.data.jsonobjects.repo.ReputationQuest +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.DojoQuest import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.quest.FetchQuest @@ -35,29 +36,15 @@ class QuestLoader(private val dailyQuestHelper: DailyQuestHelper) { } } - // TODO use WidgetUpdateEvent once its merged - // fun loadFromTabList(lines: List) { fun loadFromTabList() { - var i = -1 dailyQuestHelper.greatSpook = false var found = 0 - for (line in TabListData.getTabList()) { -// for (line in lines) { - if (line == "§5§lFaction Quests:") { - i = 0 - continue - } - if (i == -1) continue - - i++ + for (line in TabWidget.FACTION_QUESTS.lines) { readQuest(line) found++ if (dailyQuestHelper.greatSpook) return - if (i == 5) { - break - } } dailyQuestHelper.reputationHelper.tabListQuestsMissing = found == 0 diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt index c1edbfb4ff7d..1797e2227969 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/kuudra/DailyKuudraBossHelper.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.kuudra import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson.ReputationQuest +import at.hannibal2.skyhanni.data.jsonobjects.repo.ReputationQuest import at.hannibal2.skyhanni.events.KuudraCompleteEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt index 291b5901ba88..64b2bcf45c50 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.jsonobjects.repo.CrimsonIsleReputationJson.ReputationQuest +import at.hannibal2.skyhanni.data.jsonobjects.repo.ReputationQuest import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt index 57aa28b423fe..900d207a7dad 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -14,18 +15,19 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color -class BlobbercystsHighlight { +@SkyHanniModule +object BlobbercystsHighlight { private val config get() = SkyHanniMod.feature.rift.area.colosseum private val entityList = mutableListOf() - private val blobberName = "Blobbercyst " + private const val BLOBBER_NAME = "Blobbercyst " @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (!event.isMod(5)) return EntityUtils.getEntities().forEach { - if (it.name == blobberName) { + if (it.name == BLOBBER_NAME) { RenderLivingEntityHelper.setEntityColorWithNoHurtTime(it, Color.RED.withAlpha(80)) { isEnabled() } entityList.add(it) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt index c01d20157a39..161200fedad6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftAgaricusCap.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.InventoryUtils @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftAgaricusCap { +@SkyHanniModule +object RiftAgaricusCap { private val config get() = RiftAPI.config.area.dreadfarm private var startTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt index 9515330d1cd9..e1664e6c8087 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.InventoryUtils @@ -23,7 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color import kotlin.time.Duration.Companion.milliseconds -class RiftWiltedBerberisHelper { +@SkyHanniModule +object RiftWiltedBerberisHelper { private val config get() = RiftAPI.config.area.dreadfarm.wiltedBerberis private var isOnFarmland = false @@ -69,13 +71,13 @@ class RiftWiltedBerberisHelper { if (event.type != EnumParticleTypes.FIREWORKS_SPARK) { if (config.hideparticles && berberis != null) { - event.isCanceled = true + event.cancel() } return } if (config.hideparticles) { - event.isCanceled = true + event.cancel() } if (berberis == null) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt index d787ef22dcba..442dcadfa81d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/VoltHighlighter.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.EntityUtils.getEntities import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture @@ -23,12 +24,13 @@ import java.awt.Color import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -class VoltHighlighter { +@SkyHanniModule +object VoltHighlighter { private val config get() = RiftAPI.config.area.dreadfarm.voltCrux - private val LIGHTNING_DISTANCE = 7F - private val ARMOR_SLOT_HEAD = 3 + private const val LIGHTNING_DISTANCE = 7F + private const val ARMOR_SLOT_HEAD = 3 private val CHARGE_TIME = 12.seconds private var chargingSince = mapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt index 7b673f65e6ff..c09c7873f40a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -22,7 +23,8 @@ import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class LivingCaveDefenseBlocks { +@SkyHanniModule +object LivingCaveDefenseBlocks { private val config get() = RiftAPI.config.area.livingCave.defenseBlockConfig private var movingBlocks = mapOf() @@ -50,12 +52,12 @@ class LivingCaveDefenseBlocks { // Ignore particles around blocks if (staticBlocks.any { it.location.distance(location) < 3 }) { if (config.hideParticles) { - event.isCanceled = true + event.cancel() } return } if (config.hideParticles && movingBlocks.keys.any { it.location.distance(location) < 3 }) { - event.isCanceled = true + event.cancel() } if (event.type == EnumParticleTypes.CRIT_MAGIC) { @@ -84,7 +86,7 @@ class LivingCaveDefenseBlocks { movingBlocks = movingBlocks.editCopy { this[defenseBlock] = System.currentTimeMillis() + 250 } if (config.hideParticles) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt index 2ac0aee42bb9..a3ecd7fd5caa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveLivingMetalHelper.kt @@ -7,13 +7,15 @@ import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class LivingCaveLivingMetalHelper { +@SkyHanniModule +object LivingCaveLivingMetalHelper { private val config get() = RiftAPI.config.area.livingCave.livingCaveLivingMetalConfig private var lastClicked: LorenzVec? = null @@ -82,7 +84,7 @@ class LivingCaveLivingMetalHelper { pair?.let { if (it.second.distance(event.location) < 3) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt index f64d5b42c2a0..b0d4676f2e31 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -12,7 +13,8 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getLivingMetalProgr import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class LivingMetalSuitProgress { +@SkyHanniModule +object LivingMetalSuitProgress { private val config get() = RiftAPI.config.area.livingCave.livingMetalSuitProgress private var display = emptyList>() diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt index 30a98b54ada2..89e5d556b2b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/DanceRoomHelper.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase @@ -21,6 +22,7 @@ import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object DanceRoomHelper { private var display = emptyList() @@ -129,7 +131,7 @@ object DanceRoomHelper { @SubscribeEvent fun onTitleReceived(event: TitleReceivedEvent) { if (!isEnabled()) return - if (config.hideOriginalTitle && inRoom) event.isCanceled = true + if (config.hideOriginalTitle && inRoom) event.cancel() } private fun startCountdown(seconds: Int, milliseconds: Int) { @@ -158,7 +160,7 @@ object DanceRoomHelper { if (RiftAPI.inRift() && config.hidePlayers) { val entity = event.entity if (entity is EntityOtherPlayerMP && inRoom) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt index f15badfe63a0..d61331c23df1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftLavaMazeParkour.kt @@ -7,13 +7,15 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.ParkourHelper import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftLavaMazeParkour { +@SkyHanniModule +object RiftLavaMazeParkour { private val config get() = RiftAPI.config.area.mirrorverse.lavaMazeConfig private var parkourHelper: ParkourHelper? = null @@ -37,7 +39,7 @@ class RiftLavaMazeParkour { parkourHelper?.let { if (it.inParkour()) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt index 2c60dbce7ef2..ac12b43c00cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/RiftUpsideDownParkour.kt @@ -7,13 +7,15 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.ParkourHelper import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftUpsideDownParkour { +@SkyHanniModule +object RiftUpsideDownParkour { private val config get() = RiftAPI.config.area.mirrorverse.upsideDownParkour private var parkourHelper: ParkourHelper? = null @@ -37,7 +39,7 @@ class RiftUpsideDownParkour { parkourHelper?.let { if (it.inParkour()) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt index 697de2aa29a3..e835e3846cb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/mirrorverse/TubulatorParkour.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LocationUtils.isPlayerInside @@ -14,7 +15,8 @@ import at.hannibal2.skyhanni.utils.ParkourHelper import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TubulatorParkour { +@SkyHanniModule +object TubulatorParkour { private val config get() = RiftAPI.config.area.mirrorverse.tubulatorConfig private var parkourHelper: ParkourHelper? = null @@ -39,7 +41,7 @@ class TubulatorParkour { parkourHelper?.let { if (it.inParkour()) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt index 107e079551a4..a2e7576868d2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy @@ -28,6 +29,7 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes +@SkyHanniModule object RiftBloodEffigies { private val config get() = RiftAPI.config.area.stillgoreChateau.bloodEffigies diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt index 5cf2368f0ac3..3fa6af42fc0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminHighlighter.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -20,15 +21,16 @@ import net.minecraft.entity.monster.EntitySilverfish import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes -class VerminHighlighter { +@SkyHanniModule +object VerminHighlighter { private val config get() = RiftAPI.config.area.westVillage.verminHighlight private val checkedEntities = TimeLimitedSet(1.minutes) // TODO repo - private val fly = + private const val FLY_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTMwYWMxZjljNjQ5Yzk5Y2Q2MGU0YmZhNTMzNmNjMTg1MGYyNzNlYWI5ZjViMGI3OTQwZDRkNGQ3ZGM4MjVkYyJ9fX0=" - private val spider = + private const val SPIDER_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTY1MDU1NjEzMTkxNywKICAicHJvZmlsZUlkIiA6ICI0ODI5MmJkMjI1OTc0YzUwOTZiMTZhNjEyOGFmMzY3NSIsCiAgInByb2ZpbGVOYW1lIiA6ICJLVVJPVE9ZVEIyOCIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84ZmRmNjJkNGUwM2NhNTk0YzhjZDIxZGQxNzUzMjdmMWNmNzdjNGJjMDU3YTA5NTk2MDNkODNhNjhiYTI3MDA4IgogICAgfQogIH0KfQ==" @SubscribeEvent @@ -55,7 +57,7 @@ class VerminHighlighter { } private fun isVermin(entity: EntityLivingBase): Boolean = when (entity) { - is EntityArmorStand -> entity.hasSkullTexture(fly) || entity.hasSkullTexture(spider) + is EntityArmorStand -> entity.hasSkullTexture(FLY_TEXTURE) || entity.hasSkullTexture(SPIDER_TEXTURE) is EntitySilverfish -> entity.baseMaxHealth == 8 else -> false diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt index 6e27649e7e80..e5b5d95861a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt @@ -5,8 +5,9 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.InventoryUtils @@ -24,6 +25,7 @@ import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern +@SkyHanniModule object VerminTracker { private val patternGroup = RepoPattern.group("rift.area.westvillage.vermintracker") @@ -73,11 +75,9 @@ object VerminTracker { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!RiftAPI.inRift()) return - if (event.repeatSeconds(1)) { - checkVacuum() - } + checkVacuum() } private fun checkVacuum() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt index 8585814250fb..5bde50019a29 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -23,7 +24,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class KloonHacking { +@SkyHanniModule +object KloonHacking { private val config get() = RiftAPI.config.area.westVillage.hacking diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt index c595d7ab5340..a89698596a74 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftLarva.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.rift.area.wyldwoods import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.getEntities @@ -12,11 +13,12 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftLarva { +@SkyHanniModule +object RiftLarva { private val config get() = RiftAPI.config.area.wyldWoods.larvas private var hasHookInHand = false - private val larvaSkullTexture = + private const val LARVA_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTgzYjMwZTlkMTM1YjA1MTkwZWVhMmMzYWM2MWUyYWI1NWEyZDgxZTFhNThkYmIyNjk4M2ExNDA4MjY2NCJ9fX0=" @SubscribeEvent @@ -37,7 +39,7 @@ class RiftLarva { private fun findLarvas() { for (stand in getEntities()) { - if (stand.hasSkullTexture(larvaSkullTexture)) { + if (stand.hasSkullTexture(LARVA_SKULL_TEXTURE)) { RenderLivingEntityHelper.setEntityColor( stand, config.highlightColor.toChromaColor().withAlpha(1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt index 34e702ed0d60..555e5968c8e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/RiftOdonata.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.rift.area.wyldwoods import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.getEntities @@ -13,11 +14,12 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftOdonata { +@SkyHanniModule +object RiftOdonata { private val config get() = RiftAPI.config.area.wyldWoods.odonata private var hasBottleInHand = false - private val odonataSkullTexture = + private const val ODONATA_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWZkODA2ZGVmZGZkZjU5YjFmMjYwOWM4ZWUzNjQ2NjZkZTY2MTI3YTYyMzQxNWI1NDMwYzkzNThjNjAxZWY3YyJ9fX0=" private val emptyBottle by lazy { "EMPTY_ODONATA_BOTTLE".asInternalName() } @@ -39,7 +41,7 @@ class RiftOdonata { private fun findOdonatas() { for (stand in getEntities()) { - if (stand.hasSkullTexture(odonataSkullTexture)) { + if (stand.hasSkullTexture(ODONATA_SKULL_TEXTURE)) { RenderLivingEntityHelper.setEntityColor( stand, config.highlightColor.toChromaColor().withAlpha(1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt index c037d5cfc836..540fb3b816ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/wyldwoods/ShyCruxWarnings.kt @@ -3,13 +3,15 @@ package at.hannibal2.skyhanni.features.rift.area.wyldwoods import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds -class ShyCruxWarnings { +@SkyHanniModule +object ShyCruxWarnings { private val config get() = RiftAPI.config.area.wyldWoods private val shyNames = arrayOf("I'm ugly! :(", "Eek!", "Don't look at me!", "Look away!") diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt index cf1917a4d714..a5fa443866d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.InventoryUtils @@ -17,6 +18,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object CruxTalismanDisplay { private val config get() = RiftAPI.config.cruxTalisman diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 2f8ed7e1ae1e..56efab49b25f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.render.gui.ReplaceItemEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getAllItems @@ -28,6 +29,7 @@ import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object EnigmaSoulWaypoints { private val config get() = RiftAPI.config.enigmaSoulWaypoints @@ -145,9 +147,9 @@ object EnigmaSoulWaypoints { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("EnigmaSouls") - val areas = data.areas ?: error("'areas' is null in EnigmaSouls!") + val areas = data.areas soulLocations = buildMap { - for ((area, locations) in areas) { + for ((_, locations) in areas) { for (location in locations) { this[location.name] = location.position } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/HighlightRiftGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/HighlightRiftGuide.kt index c4b5851977d8..5068406ff5f9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/HighlightRiftGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/HighlightRiftGuide.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -11,7 +12,8 @@ import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightRiftGuide { +@SkyHanniModule +object HighlightRiftGuide { private var inInventory = false private var highlightedItems = emptyList() diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt index b908f49f852f..d708ca5775c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftHorsezookaHider.kt @@ -3,11 +3,13 @@ package at.hannibal2.skyhanni.features.rift.everywhere import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import net.minecraft.entity.passive.EntityHorse import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftHorsezookaHider { +@SkyHanniModule +object RiftHorsezookaHider { @SubscribeEvent fun onCheckRender(event: CheckRenderEntityEvent<*>) { @@ -15,7 +17,7 @@ class RiftHorsezookaHider { if (!SkyHanniMod.feature.rift.horsezookaHider) return if (event.entity is EntityHorse && InventoryUtils.itemInHandId.equals("HORSEZOOKA")) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt index d8ecd3299bef..a4d277cebf8d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -17,7 +18,8 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds -class RiftTimer { +@SkyHanniModule +object RiftTimer { private val config get() = RiftAPI.config.timer diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt index 2531c6d0fe8c..f5c0baf8cf52 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -17,7 +18,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RiftMotesOrb { +@SkyHanniModule +object RiftMotesOrb { private val config get() = RiftAPI.config.motesOrbs @@ -53,7 +55,7 @@ class RiftMotesOrb { orb.counter++ orb.pickedUp = false if (config.hideParticles && orb.isOrb) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index 07dad95c0e08..df91766ccef0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.features.rift.RiftAPI.motesNpcPrice +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConfigUtils @@ -26,7 +27,8 @@ import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ShowMotesNpcSellPrice { +@SkyHanniModule +object ShowMotesNpcSellPrice { private val config get() = RiftAPI.config.motes diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index fe6d3e4a1194..06bee04476bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -11,10 +11,11 @@ import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig import at.hannibal2.skyhanni.events.ActionBarUpdateEvent import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SkillOverflowLevelupEvent import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.XP_NEEDED_FOR_60 +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.chat import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.HypixelCommands @@ -41,6 +42,7 @@ import kotlin.math.ceil import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object SkillProgress { val config get() = SkyHanniMod.feature.skillProgress @@ -140,14 +142,12 @@ object SkillProgress { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (lastUpdate.passedSince() > 3.seconds) showDisplay = config.alwaysShow.get() - if (event.repeatSeconds(1)) { - allDisplay = formatAllDisplay(drawAllDisplay()) - etaDisplay = drawETADisplay() - } + allDisplay = formatAllDisplay(drawAllDisplay()) + etaDisplay = drawETADisplay() if (event.repeatSeconds(2)) { update() diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt index 691ed44988b2..0a94f9ee8b28 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.skillprogress import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.api.SkillAPI.excludedSkills import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.isRoman import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SkillTooltip { +@SkyHanniModule +object SkillTooltip { private val overflowConfig get() = SkillProgress.config.overflowConfig private val customGoalConfig get() = SkillProgress.config.customGoalConfig diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt index e6d0fe0f67eb..23ee38751c77 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeLimitedCache @@ -13,7 +14,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Pattern import kotlin.time.Duration.Companion.minutes -class HideMobNames { +@SkyHanniModule +object HideMobNames { private val lastMobName = TimeLimitedCache(2.minutes) private val mobNamesHidden = mutableListOf() @@ -61,7 +63,7 @@ class HideMobNames { val id = entity.entityId if (lastMobName.getOrNull(id) == name) { if (id in mobNamesHidden) { - event.isCanceled = true + event.cancel() } return } @@ -70,7 +72,7 @@ class HideMobNames { mobNamesHidden.remove(id) if (shouldNameBeHidden(name)) { - event.isCanceled = true + event.cancel() mobNamesHidden.add(id) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt index bf4fe497e235..2d949c6e4787 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt @@ -3,16 +3,18 @@ package at.hannibal2.skyhanni.features.slayer import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble -import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class SlayerBossSpawnSoon { +@SkyHanniModule +object SlayerBossSpawnSoon { private val config get() = SkyHanniMod.feature.slayer.slayerBossWarning diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt index bfb21cea5c40..2880d183b468 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils @@ -16,7 +17,8 @@ import net.minecraft.init.Items import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class SlayerItemsOnGround { +@SkyHanniModule +object SlayerItemsOnGround { private val config get() = SkyHanniMod.feature.slayer.itemsOnGround diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt index 107f7e0c92a0..1fce5eed234a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerMiniBossFeatures.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth @@ -24,7 +25,8 @@ import net.minecraft.entity.monster.EntityZombie import net.minecraft.entity.passive.EntityWolf import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SlayerMiniBossFeatures { +@SkyHanniModule +object SlayerMiniBossFeatures { private val config get() = SkyHanniMod.feature.slayer private var miniBosses = listOf() diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index 7acac81c1746..36f63647fc3f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils @@ -31,6 +32,7 @@ import com.google.gson.JsonPrimitive import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object SlayerProfitTracker { private val config get() = SkyHanniMod.feature.slayer.itemProfitTracker diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index b4f478c2a6a4..92d4872c74c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.ItemClickEvent import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.features.event.diana.DianaAPI import at.hannibal2.skyhanni.features.rift.RiftAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.DelayedRun @@ -23,7 +24,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class SlayerQuestWarning { +@SkyHanniModule +object SlayerQuestWarning { private val config get() = SkyHanniMod.feature.slayer diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 07bc097a808a..1d434e298b82 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter @@ -34,7 +35,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.ceil import kotlin.time.Duration.Companion.seconds -class SlayerRngMeterDisplay { +@SkyHanniModule +object SlayerRngMeterDisplay { private val config get() = SkyHanniMod.feature.slayer.rngMeterDisplay diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index 246e1d98d33f..3aaaeb86cefe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -42,6 +43,7 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds +@SkyHanniModule object VampireSlayerFeatures { private val config get() = SkyHanniMod.feature.slayer.vampire diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt index 7724c7e225a0..b7d97adf4877 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -7,11 +7,13 @@ import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.projectile.EntityFireball import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class BlazeSlayerClearView { +@SkyHanniModule +object BlazeSlayerClearView { private var nearBlaze = false @@ -38,7 +40,7 @@ class BlazeSlayerClearView { @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { if (isEnabled()) { - event.isCanceled = true + event.cancel() } } @@ -47,7 +49,7 @@ class BlazeSlayerClearView { if (isEnabled()) { val entity = event.entity if (entity is EntityFireball) { - event.isCanceled = true + event.cancel() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 4f94838e9e26..a07868d0e5e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.TitleReceivedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -26,7 +27,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -class BlazeSlayerDaggerHelper { +@SkyHanniModule +object BlazeSlayerDaggerHelper { private val config get() = SkyHanniMod.feature.slayer.blazes.hellion @@ -189,7 +191,7 @@ class BlazeSlayerDaggerHelper { it.updated = true } shield.active = true - event.isCanceled = true + event.cancel() clientSideClicked = false return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt index d3cecc658a89..1b54e4fd2e55 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.BossHealthChangeEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils @@ -13,7 +14,8 @@ import at.hannibal2.skyhanni.utils.SoundUtils.playSound import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class BlazeSlayerFirePitsWarning { +@SkyHanniModule +object BlazeSlayerFirePitsWarning { private val config get() = SkyHanniMod.feature.slayer.blazes diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt index bcc139de0588..8f0eb3d34519 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/FirePillarDisplay.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst @@ -12,7 +13,9 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class FirePillarDisplay { +@SkyHanniModule +object FirePillarDisplay { + private val config get() = SkyHanniMod.feature.slayer.blazes /** diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt index d501e3f0d892..421ffb7253d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/HellionShieldHelper.kt @@ -4,17 +4,16 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.entity.EntityLiving import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HellionShieldHelper { +@SkyHanniModule +object HellionShieldHelper { - companion object { - - val hellionShieldMobs = mutableMapOf() - } + val hellionShieldMobs = mutableMapOf() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { @@ -25,17 +24,17 @@ class HellionShieldHelper { fun onWorldChange(event: LorenzWorldChangeEvent) { hellionShieldMobs.clear() } -} -fun EntityLiving.setHellionShield(shield: HellionShield?) { - if (shield != null) { - HellionShieldHelper.hellionShieldMobs[this] = shield - RenderLivingEntityHelper.setEntityColorWithNoHurtTime( - this, - shield.color.toColor().withAlpha(80) - ) { LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs } - } else { - HellionShieldHelper.hellionShieldMobs.remove(this) - RenderLivingEntityHelper.removeCustomRender(this) + fun EntityLiving.setHellionShield(shield: HellionShield?) { + if (shield != null) { + hellionShieldMobs[this] = shield + RenderLivingEntityHelper.setEntityColorWithNoHurtTime( + this, + shield.color.toColor().withAlpha(80) + ) { LorenzUtils.inSkyBlock && SkyHanniMod.feature.slayer.blazes.hellion.coloredMobs } + } else { + hellionShieldMobs.remove(this) + RenderLivingEntityHelper.removeCustomRender(this) + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index a3359202c761..f0f63a0087b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor @@ -38,7 +39,8 @@ import net.minecraft.init.Blocks import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds -class EndermanSlayerFeatures { +@SkyHanniModule +object EndermanSlayerFeatures { private val config get() = SkyHanniMod.feature.slayer.endermen private val beaconConfig get() = config.beacon @@ -47,7 +49,7 @@ class EndermanSlayerFeatures { private val nukekubiSkulls = mutableSetOf() private var sittingBeacon = mapOf() private val logger = LorenzLogger("slayer/enderman") - private val nukekubiSkulTexture = + private const val NUKEKUBI_SKULL_TEXTURE = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=" @SubscribeEvent @@ -79,7 +81,7 @@ class EndermanSlayerFeatures { } } - if (config.highlightNukekebi && entity.inventory.any { it?.getSkullTexture() == nukekubiSkulTexture } && entity !in nukekubiSkulls) { + if (config.highlightNukekebi && entity.inventory.any { it?.getSkullTexture() == NUKEKUBI_SKULL_TEXTURE } && entity !in nukekubiSkulls) { nukekubiSkulls.add(entity) RenderLivingEntityHelper.setEntityColor( entity, diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt index 4eb8f91aadad..9a3c0aa1face 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec @@ -13,7 +14,8 @@ import net.minecraft.entity.monster.EntityEnderman import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class EndermanSlayerHideParticles { +@SkyHanniModule +object EndermanSlayerHideParticles { private var endermanLocations = listOf() @@ -40,7 +42,7 @@ class EndermanSlayerHideParticles { val distance = event.location.distanceToNearestEnderman() ?: return if (distance < 9) { - event.isCanceled = true + event.cancel() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt index ab6a44b77ade..c5bab7fc8bdf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/stranded/HighlightPlaceableNpcs.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor @@ -15,7 +16,8 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightPlaceableNpcs { +@SkyHanniModule +object HighlightPlaceableNpcs { private val config get() = SkyHanniMod.feature.misc.stranded diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index c656d0bef4a7..8bea95eb4c03 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils @@ -26,7 +27,8 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class SummoningMobManager { +@SkyHanniModule +object SummoningMobManager { private val config get() = SkyHanniMod.feature.combat.summonings diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt index e04890620234..ef9da0261b93 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningSoulsName.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith @@ -18,10 +19,11 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes -class SummoningSoulsName { +@SkyHanniModule +object SummoningSoulsName { // TODO repo - private val texture = + private const val TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTYwMTQ3OTI2NjczMywKICAicHJvZmlsZUlkIiA6ICJmMzA1ZjA5NDI0NTg0ZjU" + "4YmEyYjY0ZjAyZDcyNDYyYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJqcm9ja2EzMyIsCiAgInNpZ25hdH" + "VyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgI" + @@ -44,7 +46,7 @@ class SummoningSoulsName { for (entity in EntityUtils.getEntities()) { if (souls.contains(entity)) continue - if (entity.hasSkullTexture(texture)) { + if (entity.hasSkullTexture(TEXTURE)) { val soulLocation = entity.getLorenzVec() val map = mutableMapOf() diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt index 7622ac4962f3..3f8f803b0d22 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/BlockRendererDispatcherHook.kt @@ -9,7 +9,6 @@ import net.minecraft.util.BlockPos import net.minecraft.world.IBlockAccess import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable - // Taken and modified from Skytils fun modifyGetModelFromBlockState( blockRendererDispatcher: BlockRendererDispatcher, diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt index 72f4a2e90c00..041457d25735 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiContainerEvent.CloseWindowEvent import at.hannibal2.skyhanni.events.GuiContainerEvent.SlotClickEvent import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests +import at.hannibal2.skyhanni.utils.DelayedRun import io.github.moulberry.notenoughupdates.NEUApi import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.inventory.Slot @@ -37,10 +38,12 @@ class GuiContainerHook(guiAny: Any) { if (!SkyHanniDebugsAndTests.globalRender) return if (GuiContainerEvent.BeforeDraw(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch()) { NEUApi.setInventoryButtonsToDisabled() - GuiData.preDrawEventCanceled = true + GuiData.preDrawEventCancelled = true ci.cancel() } else { - GuiData.preDrawEventCanceled = false + DelayedRun.runNextTick { + GuiData.preDrawEventCancelled = false + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt index dfd47464d17a..9cd88d19488b 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiIngameHook.kt @@ -26,7 +26,8 @@ fun tryToReplaceScoreboardLine(text: String): String? { return tryToReplaceScoreboardLineHarder(text) } catch (t: Throwable) { ErrorManager.logErrorWithData( - t, "Error while changing the scoreboard text.", + t, + "Error while changing the scoreboard text.", "text" to text ) return text diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt index 6ed537234d3d..3c3c7fd70507 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt @@ -5,4 +5,4 @@ import net.minecraft.item.ItemStack fun renderToolTip(stack: ItemStack) { RenderItemTooltipEvent(stack).postAndCatch() -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt deleted file mode 100644 index b18d80613c6f..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt +++ /dev/null @@ -1,9 +0,0 @@ -package at.hannibal2.skyhanni.mixins.hooks - -import at.hannibal2.skyhanni.events.PacketEvent -import net.minecraft.network.Packet -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo - -fun onSendPacket(packet: Packet<*>, ci: CallbackInfo) { - if (PacketEvent.SendEvent(packet).postAndCatch()) ci.cancel() -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt deleted file mode 100644 index 71f6aaba9a93..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt +++ /dev/null @@ -1,9 +0,0 @@ -package at.hannibal2.skyhanni.mixins.hooks - -import at.hannibal2.skyhanni.events.PacketEvent -import net.minecraft.network.Packet -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo - -fun onReceivePacket(packet: Packet<*>, ci: CallbackInfo) { - if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() -} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt index eb7456b4c192..ba8efc2b5b07 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt @@ -1,75 +1,76 @@ package at.hannibal2.skyhanni.mixins.hooks import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests import net.minecraft.entity.EntityLivingBase import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class RenderLivingEntityHelper { +@SkyHanniModule +object RenderLivingEntityHelper { + + private val entityColorMap = mutableMapOf() + private val entityColorCondition = mutableMapOf Boolean>() + + private val entityNoHurtTimeCondition = mutableMapOf Boolean>() @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { entityColorMap.clear() entityColorCondition.clear() - entityNoHurTimeCondition.clear() + entityNoHurtTimeCondition.clear() } - companion object { - - private val entityColorMap = mutableMapOf() - private val entityColorCondition = mutableMapOf Boolean>() - - private val entityNoHurTimeCondition = mutableMapOf Boolean>() - - fun removeEntityColor(entity: T) { - entityColorMap.remove(entity) - entityColorCondition.remove(entity) - } + fun removeEntityColor(entity: T) { + entityColorMap.remove(entity) + entityColorCondition.remove(entity) + } - fun setEntityColor(entity: T, color: Int, condition: () -> Boolean) { - entityColorMap[entity] = color - entityColorCondition[entity] = condition - } + fun setEntityColor(entity: T, color: Int, condition: () -> Boolean) { + entityColorMap[entity] = color + entityColorCondition[entity] = condition + } - fun setNoHurtTime(entity: T, condition: () -> Boolean) { - entityNoHurTimeCondition[entity] = condition - } + fun setNoHurtTime(entity: T, condition: () -> Boolean) { + entityNoHurtTimeCondition[entity] = condition + } - fun setEntityColorWithNoHurtTime(entity: T, color: Int, condition: () -> Boolean) { - setEntityColor(entity, color, condition) - setNoHurtTime(entity, condition) - } + fun setEntityColorWithNoHurtTime(entity: T, color: Int, condition: () -> Boolean) { + setEntityColor(entity, color, condition) + setNoHurtTime(entity, condition) + } - fun removeNoHurtTime(entity: T) { - entityNoHurTimeCondition.remove(entity) - } + fun removeNoHurtTime(entity: T) { + entityNoHurtTimeCondition.remove(entity) + } - fun removeCustomRender(entity: T) { - removeEntityColor(entity) - removeNoHurtTime(entity) - } + fun removeCustomRender(entity: T) { + removeEntityColor(entity) + removeNoHurtTime(entity) + } - fun internalSetColorMultiplier(entity: T): Int { - if (!SkyHanniDebugsAndTests.globalRender) return 0 - if (entityColorMap.containsKey(entity)) { - val condition = entityColorCondition[entity]!! - if (condition.invoke()) { - return entityColorMap[entity]!! - } + @JvmStatic + fun internalSetColorMultiplier(entity: T): Int { + if (!SkyHanniDebugsAndTests.globalRender) return 0 + if (entityColorMap.containsKey(entity)) { + val condition = entityColorCondition[entity]!! + if (condition.invoke()) { + return entityColorMap[entity]!! } - return 0 } + return 0 + } - fun internalChangeHurtTime(entity: T): Int { - if (!SkyHanniDebugsAndTests.globalRender) return entity.hurtTime - run { - val condition = entityNoHurTimeCondition[entity] ?: return@run - if (condition.invoke()) { - return 0 - } + @JvmStatic + fun internalChangeHurtTime(entity: T): Int { + if (!SkyHanniDebugsAndTests.globalRender) return entity.hurtTime + run { + val condition = entityNoHurtTimeCondition[entity] ?: return@run + if (condition.invoke()) { + return 0 } - return entity.hurtTime } + return entity.hurtTime } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java index a3c2f85de095..a5a6fad3cd2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; @@ -17,15 +18,15 @@ public class MixinItemStack implements ItemStackCachedData { @Unique - public CachedItemData skyhanni_cachedData = new CachedItemData(); + public CachedItemData skyhanni_cachedData = new CachedItemData((Void) null); public CachedItemData getSkyhanni_cachedData() { return skyhanni_cachedData; } - @Inject(method = "getTooltip", at = @At("RETURN")) - public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable> ci) { + @Inject(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onItemTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;Ljava/util/List;Z)Lnet/minecraftforge/event/entity/player/ItemTooltipEvent;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable> cir, List list) { ItemStack stack = (ItemStack) (Object) this; - ToolTipData.onHover(stack, ci.getReturnValue()); + ToolTipData.onHover(stack, list); } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java index 879e41061f7e..b8bb676db082 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.mixins.transformers; import at.hannibal2.skyhanni.events.EntityEquipmentChangeEvent; -import at.hannibal2.skyhanni.mixins.hooks.NetHandlerPlayClientHookKt; +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.Entity; import net.minecraft.network.Packet; @@ -18,7 +18,10 @@ public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) private void onSendPacket(Packet packet, CallbackInfo ci) { - NetHandlerPlayClientHookKt.onSendPacket(packet, ci); + NetHandlerPlayClient handler = (NetHandlerPlayClient) (Object) this; + if (new PacketSentEvent(handler, packet).post()) { + ci.cancel(); + } } @Inject(method = "handleEntityEquipment", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setCurrentItemOrArmor(ILnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java index 11d7ed309516..a003480213bc 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.mixins.transformers; -import at.hannibal2.skyhanni.mixins.hooks.NetworkManagerHookKt; +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import net.minecraft.network.NetworkManager; @@ -15,8 +15,8 @@ public abstract class MixinNetworkManager extends SimpleChannelInboundHandler packet, CallbackInfo ci) { - if (packet != null) { - NetworkManagerHookKt.onReceivePacket(packet, ci); + if (packet != null && new PacketReceivedEvent(packet).post()) { + ci.cancel(); } } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/AccessorGuiContainer.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/AccessorGuiContainer.java index 5d9d6146dfd3..8a4485694af4 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/AccessorGuiContainer.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/AccessorGuiContainer.java @@ -20,4 +20,10 @@ public interface AccessorGuiContainer { @Invoker("drawGuiContainerBackgroundLayer") void invokeDrawGuiContainerBackgroundLayer_skyhanni(float f, int i, int mouseY); + + @Accessor("xSize") + int getWidth(); + + @Accessor("ySize") + int getHeight(); } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java index f23b290f1d5f..5ef136e3f5c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java @@ -23,12 +23,12 @@ protected MixinRendererLivingEntity(RenderManager renderManager) { @Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true) private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable cir) { - cir.setReturnValue(RenderLivingEntityHelper.Companion.internalSetColorMultiplier(entity)); + cir.setReturnValue(RenderLivingEntityHelper.internalSetColorMultiplier(entity)); } @Redirect(method = "setBrightness", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", opcode = Opcodes.GETFIELD)) private int changeHurtTime(EntityLivingBase entity) { - return RenderLivingEntityHelper.Companion.internalChangeHurtTime(entity); + return RenderLivingEntityHelper.internalChangeHurtTime(entity); } @Inject(method = "renderLayers", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt index 6eea21007982..04b9651c30c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/HighlightMissingRepoItems.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -15,7 +16,8 @@ import net.minecraft.inventory.Slot import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class HighlightMissingRepoItems { +@SkyHanniModule +object HighlightMissingRepoItems { @SubscribeEvent(priority = EventPriority.LOWEST) fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt index 3653e01fa554..033f7199913e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.test -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketReceivedEvent +import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -31,9 +34,8 @@ import net.minecraft.network.play.server.S1DPacketEntityEffect import net.minecraft.network.play.server.S20PacketEntityProperties import net.minecraft.network.play.server.S28PacketEffect import net.minecraft.network.play.server.S2APacketParticles -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object PacketTest { private var enabled = false @@ -68,8 +70,8 @@ object PacketTest { ChatUtils.chat("Packet test: $enabled") } - @SubscribeEvent - fun onSendPacket(event: PacketEvent.SendEvent) { + @HandleEvent + fun onSendPacket(event: PacketSentEvent) { if (!enabled) return val packet = event.packet @@ -89,8 +91,8 @@ object PacketTest { println("Send: $packetName") } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(priority = HandleEvent.LOW, receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (!enabled) return val packet = event.packet packet.print() diff --git a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt index 0c12c6d4ee84..15ef4ac5cfe5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/ParkourWaypointSaver.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec @@ -16,7 +17,8 @@ import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.milliseconds -class ParkourWaypointSaver { +@SkyHanniModule +object ParkourWaypointSaver { private val config get() = SkyHanniMod.feature.dev.waypoint private var timeLastSaved = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/test/ShowItemUuid.kt b/src/main/java/at/hannibal2/skyhanni/test/ShowItemUuid.kt index 6a352ca0f682..f8c2029cf90d 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/ShowItemUuid.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/ShowItemUuid.kt @@ -3,10 +3,12 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getItemUuid import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ShowItemUuid { +@SkyHanniModule +object ShowItemUuid { @SubscribeEvent fun onTooltip(event: LorenzToolTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 83b1f0828492..a31816140a65 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt index 47d2a40ce351..5898b5d98d46 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.InventoryUpdatedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.getSkullOwner @@ -20,6 +21,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TestCopyBestiaryValues { class BestiarityObject { // TODO fix typo diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt index 8f1f74b1411c..5121e342139c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object TestCopyRngMeterValues { private val patternGroup = RepoPattern.group("test.dev.copyrng") diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt index 303c41bbe8ca..43a615d53bf6 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestExportTools.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiKeyPressEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.CopyItemCommand.copyItemToClipboard import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.KSerializable @@ -20,6 +21,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.io.InputStreamReader import java.io.Reader +@SkyHanniModule object TestExportTools { private val config get() = SkyHanniMod.feature.dev.debug diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt b/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt index 9b11abd60f51..8c8acb12b10a 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestShowSlotNumber.kt @@ -2,10 +2,12 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TestShowSlotNumber { +@SkyHanniModule +object TestShowSlotNumber { @SubscribeEvent fun onRenderItemTip(event: RenderInventoryItemTipEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt index 26c0870de830..01b943959637 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/WorldEdit.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ClipboardUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha @@ -17,6 +18,7 @@ import net.minecraft.util.BlockPos import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color +@SkyHanniModule object WorldEdit { private var leftPos = null as BlockPos? diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index 54fe130546c8..34b08b82fad0 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -27,7 +27,7 @@ object ErrorManager { private val replace = mapOf( "at.hannibal2.skyhanni" to "SH", - "io.mouberry,notenoughupdates" to "NEU", + "io.moulberry.notenoughupdates" to "NEU", "net.minecraft." to "MC.", "net.minecraftforge.fml." to "FML.", ) @@ -49,6 +49,8 @@ object ErrorManager { "at at.hannibal2.skyhanni.config.commands.Commands\$createCommand\$1.processCommand", "at at.hannibal2.skyhanni.test.command.ErrorManager.logError", "at at.hannibal2.skyhanni.events.LorenzEvent.postAndCatch", + "at at.hannibal2.skyhanni.api.event.SkyHanniEvent.post", + "at at.hannibal2.skyhanni.api.event.EventHandler.post", "at net.minecraft.launchwrapper.", ) diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt index de5b25a92048..0892d11252a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackParticlesCommand.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzVec @@ -19,6 +20,7 @@ import java.util.concurrent.ConcurrentLinkedDeque import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object TrackParticlesCommand { private var cutOffTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt index a2acc1042b48..b5913c210be5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PlaySoundEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzVec @@ -20,6 +21,7 @@ import java.util.concurrent.ConcurrentLinkedDeque import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +@SkyHanniModule object TrackSoundsCommand { private var cutOffTime = SimpleTimeMark.farPast() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt index ca9f11cc6ece..663281ed1ba2 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CachedItemData.kt @@ -16,8 +16,7 @@ data class CachedItemData( // null = not loaded var riftExportable: Boolean? = null, - // null = not loaded - var itemRarityLastCheck: Long = 0L, // Can't use SimpleTimeMark here + var itemRarityLastCheck: SimpleTimeMark = SimpleTimeMark.farPast(), // null = not loaded var itemRarity: LorenzRarity? = null, @@ -26,5 +25,12 @@ data class CachedItemData( var lastInternalName: NEUInternalName? = null, - var lastInternalNameFetchTime: Long = 0L, // Still can't use SimpleTimeMark here -) + var lastInternalNameFetchTime: SimpleTimeMark = SimpleTimeMark.farPast(), +) { + /** + * Delegate constructor to avoid calling a function with default arguments from java. + * We can't call the generated no args constructors (or rather we cannot generate that constructor), because inline + * classes are not part of the java-kotlin ABI that is super well supported (especially with default arguments). + */ + constructor(void: Void?) : this() +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt index 94cdc4f0d207..aff0e745a070 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ConfigUtils.jumpToEditor import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.chat.Text @@ -23,6 +24,7 @@ import kotlin.reflect.KMutableProperty0 import kotlin.time.Duration.Companion.milliseconds import kotlin.time.times +@SkyHanniModule object ChatUtils { // TODO log based on chat category (error, warning, debug, user error, normal) @@ -258,7 +260,7 @@ object ChatUtils { fun MessageSendToServerEvent.isCommand(commandsWithSlash: Collection) = splitMessage.takeIf { it.isNotEmpty() }?.get(0) in commandsWithSlash - fun MessageSendToServerEvent.senderIsSkyhanni() = originatingModContainer?.modId == "skyhanni" + fun MessageSendToServerEvent.senderIsSkyhanni() = originatingModContainer?.id == "skyhanni" fun MessageSendToServerEvent.eventWithNewMessage(message: String) = MessageSendToServerEvent(message, message.split(" "), this.originatingModContainer) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index 2e1237fe875e..6b4d70046515 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -2,11 +2,13 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.RenderableUtils import net.minecraft.enchantment.Enchantment import net.minecraft.item.ItemStack import java.util.Collections import java.util.Queue import java.util.WeakHashMap +import kotlin.math.ceil object CollectionUtils { @@ -182,6 +184,30 @@ object CollectionUtils { } } + inline fun Iterator.consumeWhile(block: (T) -> R): R? { + while (hasNext()) { + return block(next()) ?: continue + } + return null + } + + inline fun Iterator.collectWhile(block: (T) -> Boolean): List { + return collectWhileTo(mutableListOf(), block) + } + + inline fun > Iterator.collectWhileTo(collection: C, block: (T) -> Boolean): C { + while (hasNext()) { + val element = next() + if (block(element)) { + collection.add(element) + } else { + break + } + } + return collection + } + + /** Updates a value if it is present in the set (equals), useful if the newValue is not reference equal with the value in the set */ inline fun MutableSet.refreshReference(newValue: T) = if (this.contains(newValue)) { this.remove(newValue) @@ -279,6 +305,38 @@ object CollectionUtils { })) } + fun Collection>.tableStretchXPadding(xSpace: Int): Int { + if (this.isEmpty()) return xSpace + val off = RenderableUtils.calculateTableXOffsets(this as List>, 0) + val xLength = off.size - 1 + val emptySpace = xSpace - off.last() + if (emptySpace < 0) { + // throw IllegalArgumentException("Not enough space for content") + } + return emptySpace / (xLength - 1) + } + + fun Collection>.tableStretchYPadding(ySpace: Int): Int { + if (this.isEmpty()) return ySpace + val off = RenderableUtils.calculateTableYOffsets(this as List>, 0) + val yLength = off.size - 1 + val emptySpace = ySpace - off.last() + if (emptySpace < 0) { + // throw IllegalArgumentException("Not enough space for content") + } + return emptySpace / (yLength - 1) + } + + /** Splits the input into equal sized lists. If the list can't get divided clean by [subs] then the last entry gets reduced. e.g. 13/4 = [4,4,4,1]*/ + fun Collection.split(subs: Int = 2): List> { + if (this.isEmpty()) return listOf(emptyList()) + val list = this.chunked(ceil(this.size.toDouble() / subs.toDouble()).toInt()).toMutableList() + while (list.size < subs) { + list.add(emptyList()) + } + return list + } + inline fun Map.mapKeysNotNull(transform: (Map.Entry) -> R?): Map { val destination = LinkedHashMap() for (element in this) { @@ -290,6 +348,15 @@ object CollectionUtils { return destination } + inline fun Iterable.sumOfPair(selector: (T) -> Pair): Pair { + var sum = Pair(0.0, 0.0) + for (element in this) { + val add = selector(element) + sum = sum.first + add.first.toDouble() to sum.second + add.second.toDouble() + } + return sum + } + inline fun Iterable.zipWithNext3(transform: (a: T, b: T, c: T) -> R): List { val iterator = iterator() if (!iterator.hasNext()) return emptyList() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt index 52656f6ad44c..ed0a9740eade 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt @@ -1,11 +1,10 @@ package at.hannibal2.skyhanni.utils import java.awt.Color -import kotlin.math.max object ColorUtils { - /** Transfer string colors from the config to java.awt.Color */ + /** Transfer string colors from the config to [Color] */ fun String.toChromaColor() = Color(toChromaColorInt(), true) fun String.toChromaColorInt() = SpecialColour.specialToChromaRGB(this) @@ -25,14 +24,13 @@ object ColorUtils { (start.blue * (1 - percent) + end.blue * percent).toInt() ) - fun Color.darker(factor: Double): Color { - return Color( - max((red * factor).toInt(), 0), - max((green * factor).toInt(), 0), - max((blue * factor).toInt(), 0), - alpha - ) - } + /** Darkens a color by a [factor]. The lower the [factor], the darker the color. */ + fun Color.darker(factor: Double = 0.7) = Color( + (red * factor).toInt().coerceIn(0, 255), + (green * factor).toInt().coerceIn(0, 255), + (blue * factor).toInt().coerceIn(0, 255), + alpha + ) fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt index 86486fd458b4..889530cd622e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityOutlineRenderer.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent import at.hannibal2.skyhanni.mixins.transformers.CustomRenderGlobal +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager @@ -32,6 +33,7 @@ import java.lang.reflect.Method * https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/features/EntityOutlines/EntityOutlineRenderer.java * */ +@SkyHanniModule object EntityOutlineRenderer { private val entityRenderCache: CachedInfo = CachedInfo(null, null, null) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index bd07f2115999..430310709c42 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer import at.hannibal2.skyhanni.events.SkyHanniRenderEntityEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo @@ -13,18 +14,22 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.block.state.IBlockState import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.client.resources.DefaultPlayerSkin import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityEnderman import net.minecraft.entity.player.EntityPlayer +import net.minecraft.entity.player.EnumPlayerModelParts import net.minecraft.item.ItemStack import net.minecraft.potion.Potion +import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraft.util.AxisAlignedBB import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.fml.common.eventhandler.Event import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +@SkyHanniModule object EntityUtils { fun EntityLivingBase.hasNameTagWith( @@ -188,6 +193,27 @@ object EntityUtils { fun EntityLivingBase.isRunicAndCorrupt() = baseMaxHealth == health.toInt().derpy() * 3 * 4 fun Entity.cleanName() = this.name.removeColor() + + /** + * @return a fake player with the same skin as the real player + */ + fun getFakePlayer(): EntityOtherPlayerMP { + val mc = Minecraft.getMinecraft() + return object : EntityOtherPlayerMP( + mc.theWorld, + mc.thePlayer.gameProfile + ) { + override fun getLocationSkin() = + mc.thePlayer.locationSkin ?: DefaultPlayerSkin.getDefaultSkin(mc.thePlayer.uniqueID) + + override fun getTeam() = object : ScorePlayerTeam(null, null) { + override fun getNameTagVisibility() = EnumVisible.NEVER + } + + override fun isWearing(part: EnumPlayerModelParts?) = + mc.thePlayer.isWearing(part) && part != EnumPlayerModelParts.CAPE + } + } } private fun Event.cancel() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GenericWrapper.kt b/src/main/java/at/hannibal2/skyhanni/utils/GenericWrapper.kt new file mode 100644 index 000000000000..c390c05597bf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/GenericWrapper.kt @@ -0,0 +1,9 @@ +package at.hannibal2.skyhanni.utils + +class GenericWrapper(val it: T) { + companion object { + @JvmStatic + @JvmName("getSimpleTimeMark") + fun getSimpleTimeMark(it: SimpleTimeMark) = GenericWrapper(it) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt index e68af00ca8f4..403484fcdebf 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt @@ -3,6 +3,10 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressBarConfig import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager import at.hannibal2.skyhanni.features.chroma.ChromaType +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.NumberUtil.fractionOf +import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment +import at.hannibal2.skyhanni.utils.renderables.Renderable import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.FontRenderer @@ -17,11 +21,11 @@ import java.awt.Color import java.text.DecimalFormat import kotlin.math.ceil import kotlin.math.min -import kotlin.math.roundToInt /** * Some functions taken from NotEnoughUpdates */ +// TODO cleanup of redundant functions object GuiRenderUtils { fun drawStringCentered(str: String?, fr: FontRenderer, x: Float, y: Float, shadow: Boolean, colour: Int) { @@ -71,12 +75,7 @@ object GuiRenderUtils { fun drawStringCentered(str: String?, x: Int, y: Int) { drawStringCentered( - str, - Minecraft.getMinecraft().fontRendererObj, - x.toFloat(), - y.toFloat(), - true, - 0xffffff + str, Minecraft.getMinecraft().fontRendererObj, x.toFloat(), y.toFloat(), true, 0xffffff ) } @@ -126,30 +125,33 @@ object GuiRenderUtils { if (tooltipY + tooltipHeight + 6 > screenHeight) tooltipY = screenHeight - tooltipHeight - 6 // main background GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3, - tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, -0xfeffff0 + tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, -0xfeffff0 ) // borders GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3 + 1, - tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColor + tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColor ) GuiScreen.drawRect( - tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, - tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColor + tooltipX + tooltipTextWidth + 2, + tooltipY - 3 + 1, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 3 - 1, + borderColor ) GuiScreen.drawRect( - tooltipX - 3, tooltipY - 3, - tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColor + tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColor ) GuiScreen.drawRect( - tooltipX - 3, tooltipY + tooltipHeight + 2, - tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColor + tooltipX - 3, + tooltipY + tooltipHeight + 2, + tooltipX + tooltipTextWidth + 3, + tooltipY + tooltipHeight + 3, + borderColor ) GlStateManager.translate(0f, 0f, -100f) GlStateManager.disableDepth() @@ -175,109 +177,38 @@ object GuiRenderUtils { fun isPointInRect(x: Int, y: Int, left: Int, top: Int, width: Int, height: Int) = left <= x && x < left + width && top <= y && y < top + height - fun drawProgressBar(x: Int, y: Int, barWidth: Int, progress: Float) { - GuiScreen.drawRect(x, y, x + barWidth, y + 6, 0xFF43464B.toInt()) - val width = barWidth * progress - GuiScreen.drawRect(x + 1, y + 1, (x + width).toInt() + 1, y + 5, 0xFF00FF00.toInt()) - if (progress != 1f) GuiScreen.drawRect( - (x + width).toInt() + 1, - y + 1, - x + barWidth - 1, - y + 5, - 0xFF013220.toInt() - ) - } - - fun renderItemAndTip( - list: MutableList, - item: ItemStack?, - x: Int, - y: Int, - mouseX: Int, - mouseY: Int, - color: Int = 0xFF43464B.toInt(), - ) { - GuiScreen.drawRect(x, y, x + 16, y + 16, color) - if (item != null) { - renderItemStack(item, x, y) - if (isPointInRect(mouseX, mouseY, x, y, 16, 16)) { - val tt: List = item.getTooltip(Minecraft.getMinecraft().thePlayer, false) - list.addAll(tt) - } - } - } - - fun renderItemAndTip( - list: MutableList, - item: ItemStack?, - x: Float, - y: Float, - mouseX: Float, - mouseY: Float, - color: Int = 0xFF43464B.toInt(), - ) { - renderItemAndTip(list, item, x.toInt(), y.toInt(), mouseX.toInt(), mouseY.toInt(), color) - } - - // assuming 70% font size - fun drawFarmingBar( + fun getFarmingBar( label: String, tooltip: String, currentValue: Number, maxValue: Number, - xPos: Int, - yPos: Int, width: Int, - mouseX: Int, - mouseY: Int, - output: MutableList, textScale: Float = .7f, - ) { - var currentVal = currentValue.toDouble() - currentVal = if (currentVal < 0) 0.0 else currentVal - - var barProgress = currentVal / maxValue.toFloat() - if (maxValue == 0) barProgress = 1.0 - barProgress = when { - barProgress > 1 -> 1.0 - barProgress < 0 -> 0.0 - else -> barProgress - } - - val filledWidth = (width * barProgress).toInt() - val current = DecimalFormat("0.##").format(currentVal) - val progressPercentage = (barProgress * 10000).roundToInt() / 100 - val inverseScale = 1 / textScale - val textWidth: Int = Minecraft.getMinecraft().fontRendererObj.getStringWidth("$progressPercentage%") - val barColor = barColorGradient(barProgress) - - GlStateManager.scale(textScale, textScale, 1f) - drawString(label, xPos * inverseScale, yPos * inverseScale) - drawString( - "§2$current / ${DecimalFormat("0.##").format(maxValue)}☘", - xPos * inverseScale, - (yPos + 8) * inverseScale - ) - drawString( - "§2$progressPercentage%", - (xPos + width - textWidth * textScale) * inverseScale, - (yPos + 8) * inverseScale - ) - GlStateManager.scale(inverseScale, inverseScale, 1f) - - GuiScreen.drawRect(xPos, yPos + 16, xPos + width, yPos + 20, 0xFF43464B.toInt()) - GuiScreen.drawRect(xPos + 1, yPos + 17, xPos + width - 1, yPos + 19, barColor.darkenColor()) - GuiScreen.drawRect( - xPos + 1, yPos + 17, - if (filledWidth < 2) xPos + 1 else xPos + filledWidth - 1, yPos + 19, barColor - ) - - if (tooltip != "" && isPointInRect(mouseX, mouseY, xPos - 2, yPos - 2, width + 4, 20 + 4)) { - val split = tooltip.split("\n") - for (line in split) { - output.add(line) - } - } + ): Renderable { + val current = currentValue.toDouble().coerceAtLeast(0.0) + val percent = current.fractionOf(maxValue) + val scale = textScale.toDouble() + return Renderable.hoverTips(Renderable.verticalContainer( + listOf( + Renderable.string(label, scale = scale), + Renderable.fixedSizeLine( + listOf( + Renderable.string( + "§2${DecimalFormat("0.##").format(current)} / ${ + DecimalFormat( + "0.##" + ).format(maxValue) + }☘", scale = scale, horizontalAlign = HorizontalAlignment.LEFT + ), + Renderable.string( + "§2${(percent * 100).round(1)}%", + scale = scale, + horizontalAlign = HorizontalAlignment.RIGHT + ), + ), width + ), Renderable.progressBar(percent, width = width) + ) + ), tooltip.split('\n').map { Renderable.string(it) }) } private fun barColorGradient(double: Double): Int { @@ -293,8 +224,11 @@ object GuiRenderUtils { fun drawScaledRec(left: Int, top: Int, right: Int, bottom: Int, colour: Int, inverseScale: Float) { GuiScreen.drawRect( - (left * inverseScale).toInt(), (top * inverseScale).toInt(), - (right * inverseScale).toInt(), (bottom * inverseScale).toInt(), colour + (left * inverseScale).toInt(), + (top * inverseScale).toInt(), + (right * inverseScale).toInt(), + (bottom * inverseScale).toInt(), + colour ) } @@ -339,15 +273,7 @@ object GuiRenderUtils { Utils.drawTexturedRect(x, y, w_2.toFloat(), height, 0f, w_2 / xSize, vMinEmpty, vMaxEmpty, GL11.GL_NEAREST) Utils.drawTexturedRect( - x + w_2, - y, - w_2.toFloat(), - height, - 1 - w_2 / xSize, - 1f, - vMinEmpty, - vMaxEmpty, - GL11.GL_NEAREST + x + w_2, y, w_2.toFloat(), height, 1 - w_2 / xSize, 1f, vMinEmpty, vMaxEmpty, GL11.GL_NEAREST ) if (useChroma) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt index 3ae6548e9897..156d4806bd7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/HypixelCommands.kt @@ -1,5 +1,8 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.api.GetFromSackAPI +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName + object HypixelCommands { fun skyblock() { send("skyblock") @@ -50,7 +53,7 @@ object HypixelCommands { } fun getFromSacks(itemName: String, amount: Int) { - send("gfs $itemName $amount") + GetFromSackAPI.getFromSack(itemName.asInternalName(), amount) } fun widget() { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index e3f06b83b241..53ee6cf7a4ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -34,8 +34,12 @@ object InventoryUtils { } else "" } + fun inInventory() = Minecraft.getMinecraft().currentScreen is GuiChest + fun ContainerChest.getInventoryName() = this.lowerChestInventory.displayName.unformattedText.trim() + fun getWindowId(): Int? = (Minecraft.getMinecraft().currentScreen as? GuiChest)?.inventorySlots?.windowId + fun getItemsInOwnInventory() = getItemsInOwnInventoryWithNull()?.filterNotNull() ?: emptyList() @@ -112,4 +116,10 @@ object InventoryUtils { } fun NEUInternalName.getAmountInInventory(): Int = countItemsInLowerInventory { it.getInternalNameOrNull() == this } + + fun clickSlot(slot: Int) { + val windowId = getWindowId() ?: return + val controller = Minecraft.getMinecraft().playerController + controller.windowClick(windowId, slot, 0, 0, Minecraft.getMinecraft().thePlayer) + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index cf5cc266e499..6af19e382e11 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -98,12 +98,12 @@ object ItemUtils { fun ItemStack.getInternalNameOrNull(): NEUInternalName? { val data = cachedData - if (data.lastInternalNameFetchTime.asTimeMark().passedSince() < 1.seconds) { + if (data.lastInternalNameFetchTime.passedSince() < 1.seconds) { return data.lastInternalName } val internalName = grabInternalNameOrNull() data.lastInternalName = internalName - data.lastInternalNameFetchTime = SimpleTimeMark.now().toMillis() + data.lastInternalNameFetchTime = SimpleTimeMark.now() return internalName } @@ -123,6 +123,13 @@ object ItemUtils { // Checks for hypixel enchantments in the attributes fun ItemStack.hasEnchantments() = getEnchantments()?.isNotEmpty() ?: false + fun ItemStack.removeEnchants(): ItemStack = apply { + val tag = tagCompound ?: NBTTagCompound() + tag.removeTag("ench") + tag.removeTag("StoredEnchantments") + tagCompound = tag + } + fun ItemStack.getSkullTexture(): String? { if (item != Items.skull) return null if (tagCompound == null) return null @@ -238,7 +245,7 @@ object ItemUtils { private fun ItemStack.updateCategoryAndRarity() { val data = cachedData - data.itemRarityLastCheck = SimpleTimeMark.now().toMillis() + data.itemRarityLastCheck = SimpleTimeMark.now() val internalName = getInternalName() if (internalName == NEUInternalName.NONE) { data.itemRarity = null @@ -267,7 +274,7 @@ object ItemUtils { } private fun itemRarityLastCheck(data: CachedItemData) = - data.itemRarityLastCheck.asTimeMark().passedSince() > 10.seconds + data.itemRarityLastCheck.passedSince() > 10.seconds /** * Use when comparing the name (e.g. regex), not for showing to the user diff --git a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt index 20e8cab67f0f..c04057e725f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper import io.github.notenoughupdates.moulconfig.internal.KeybindHelper @@ -16,6 +17,7 @@ import org.apache.commons.lang3.SystemUtils import org.lwjgl.input.Keyboard import org.lwjgl.input.Mouse +@SkyHanniModule object KeyboardManager { private var lastClickedMouseButton = -1 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 0dc0047a55b3..f52f7f72b76d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -26,7 +26,6 @@ import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.SharedMonsterAttributes -import net.minecraft.launchwrapper.Launch import net.minecraft.util.AxisAlignedBB import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.FMLCommonHandler @@ -294,7 +293,7 @@ object LorenzUtils { Minecraft.getMinecraft().playerController.windowClick( container.windowId, slotNumber, 0, 1, Minecraft.getMinecraft().thePlayer ) - isCanceled = true + this.cancel() } } @@ -327,9 +326,6 @@ object LorenzUtils { inline fun > T.isAnyOf(vararg array: T): Boolean = array.contains(this) - // TODO move to val by lazy - fun isInDevEnvironment() = ((Launch.blackboard ?: mapOf())["fml.deobfuscatedEnvironment"] as Boolean?) ?: true - fun shutdownMinecraft(reason: String? = null) { System.err.println("SkyHanni-${SkyHanniMod.version} forced the game to shutdown.") reason?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 297a40585e77..262b768a4ad9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -7,8 +7,9 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.MultiFilterJson import at.hannibal2.skyhanni.events.NeuProfileDataLoadedEvent import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarDataHolder +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ItemBlink.checkBlinkItem import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -17,6 +18,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.isInt import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.json.BaseGsonBuilder import at.hannibal2.skyhanni.utils.json.fromJson +import at.hannibal2.skyhanni.utils.system.PlatformUtils import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.google.gson.TypeAdapter @@ -45,6 +47,7 @@ import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.opengl.GL11 +@SkyHanniModule object NEUItems { val manager: NEUManager get() = NotEnoughUpdates.INSTANCE.manager @@ -133,7 +136,7 @@ object NEUItems { name = name.removePrefix("§7[lvl 1➡100] ") if (name.contains("[lvl 1➡100]")) { - if (LorenzUtils.isInDevEnvironment()) { + if (PlatformUtils.isDevEnvironment) { error("wrong name: '$name'") } println("wrong name: '$name'") @@ -152,7 +155,7 @@ object NEUItems { fun getInternalNameOrNull(nbt: NBTTagCompound): NEUInternalName? = ItemResolutionQuery(manager).withItemNBT(nbt).resolveInternalName()?.asInternalName() - fun NEUInternalName.getPrice(useSellingPrice: Boolean = false) = getPriceOrNull(useSellingPrice) ?: -1.0 + fun NEUInternalName.getPrice(useSellPrice: Boolean = false) = getPriceOrNull(useSellPrice) ?: -1.0 fun NEUInternalName.getNpcPrice() = getNpcPriceOrNull() ?: -1.0 @@ -166,20 +169,20 @@ object NEUItems { fun transHypixelNameToInternalName(hypixelId: String): NEUInternalName = manager.auctionManager.transformHypixelBazaarToNEUItemId(hypixelId).asInternalName() - fun NEUInternalName.getPriceOrNull(useSellingPrice: Boolean = false): Double? { + fun NEUInternalName.getPriceOrNull(useSellPrice: Boolean = false): Double? { if (this == NEUInternalName.WISP_POTION) { return 20_000.0 } getBazaarData()?.let { - return if (useSellingPrice) it.sellOfferPrice else it.instantBuyPrice + return if (useSellPrice) it.sellOfferPrice else it.instantBuyPrice } val result = manager.auctionManager.getLowestBin(asString()) if (result != -1L) return result.toDouble() if (equals("JACK_O_LANTERN")) { - return "PUMPKIN".asInternalName().getPrice(useSellingPrice) + 1 + return "PUMPKIN".asInternalName().getPrice(useSellPrice) + 1 } if (equals("GOLDEN_CARROT")) { // 6.8 for some players @@ -217,9 +220,14 @@ object NEUItems { const val itemFontSize = 2.0 / 3.0 - fun ItemStack.renderOnScreen(x: Float, y: Float, scaleMultiplier: Double = itemFontSize) { + fun ItemStack.renderOnScreen( + x: Float, + y: Float, + scaleMultiplier: Double = itemFontSize, + rescaleSkulls: Boolean = true + ) { val item = checkBlinkItem() - val isSkull = item.item === Items.skull + val isSkull = rescaleSkulls && item.item === Items.skull val baseScale = (if (isSkull) 4f / 3f else 1f) val finalScale = baseScale * scaleMultiplier @@ -272,12 +280,6 @@ object NEUItems { fun allNeuRepoItems(): Map = NotEnoughUpdates.INSTANCE.manager.itemInformation - @Deprecated("outdated", ReplaceWith("NEUItems.getPrimitiveMultiplier(internalName, tryCount)")) - fun getMultiplier(internalName: NEUInternalName, tryCount: Int = 0): Pair { - val (name, amount) = getPrimitiveMultiplier(internalName, tryCount) - return Pair(name, amount) - } - fun getPrimitiveMultiplier(internalName: NEUInternalName, tryCount: Int = 0): PrimitiveItemStack { multiplierCache[internalName]?.let { return it } if (tryCount == 10) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index 658118bcb1be..cf01b2bf9f9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson.ShortCut +import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourShortCut import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.toSingletonListOrEmpty @@ -18,7 +18,7 @@ import kotlin.time.Duration.Companion.seconds class ParkourHelper( val locations: List, - private val shortCuts: List, + private val shortCuts: List, val platformSize: Double = 1.0, val detectionRange: Double = 1.0, val depth: Boolean = true, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ReflectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ReflectionUtils.kt index 1fe8b882c797..f714ebc97f26 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ReflectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ReflectionUtils.kt @@ -1,7 +1,5 @@ package at.hannibal2.skyhanni.utils -import net.minecraftforge.fml.common.Loader -import net.minecraftforge.fml.common.ModContainer import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Modifier @@ -66,19 +64,5 @@ object ReflectionUtils { return Class.forName(this.className) } - private val packageLookup by lazy { - Loader.instance().modList - .flatMap { mod -> mod.ownedPackages.map { it to mod } } - .toMap() - } - - val Class<*>.shPackageName - get() = - canonicalName?.substringBeforeLast('.') - - fun Class<*>.getModContainer(): ModContainer? { - return packageLookup[shPackageName] - } - fun Class<*>.getDeclaredFieldOrNull(name: String): Field? = declaredFields.firstOrNull { it.name == name } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index dbbc553e73ea..1506882cd40d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -2,9 +2,9 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.GuiEditManager -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY -import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsX +import at.hannibal2.skyhanni.data.GuiEditManager.getAbsY +import at.hannibal2.skyhanni.data.GuiEditManager.getDummySize import at.hannibal2.skyhanni.data.model.Graph import at.hannibal2.skyhanni.data.model.toPositionsList import at.hannibal2.skyhanni.events.GuiContainerEvent @@ -559,6 +559,7 @@ object RenderUtils { renderables: List, extraSpace: Int = 0, posLabel: String, + addToGuiManager: Boolean = true, ) { if (renderables.isEmpty()) return var longestY = 0 @@ -575,7 +576,21 @@ object RenderUtils { GlStateManager.popMatrix() } - GuiEditManager.add(this, posLabel, longestX, longestY) + if (addToGuiManager) GuiEditManager.add(this, posLabel, longestX, longestY) + } + + fun Position.renderRenderable( + renderable: Renderable, + posLabel: String, + addToGuiManager: Boolean = true, + ) { + GlStateManager.pushMatrix() + val (x, y) = transform() + Renderable.withMousePosition(x, y) { + renderable.render(0, 0) + } + GlStateManager.popMatrix() + if (addToGuiManager) GuiEditManager.add(this, posLabel, renderable.width, 0) } /** diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt index 2184322e5d60..4e6df449e4e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt @@ -33,9 +33,10 @@ value class SimpleTimeMark(private val millis: Long) : Comparable "The Far Past" + farFuture() -> "The Far Future" + else -> Instant.ofEpochMilli(millis).toString() } fun formattedDate(pattern: String): String { @@ -60,6 +61,9 @@ value class SimpleTimeMark(private val millis: Long) : Comparable() private var debugCache: List? = null @@ -115,8 +118,8 @@ object TabListData { var dirty = false - @SubscribeEvent(receiveCanceled = true) - fun onPacketReceive(event: PacketEvent.ReceiveEvent) { + @HandleEvent(receiveCancelled = true) + fun onPacketReceive(event: PacketReceivedEvent) { if (event.packet is S38PacketPlayerListItem) { dirty = true } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedCache.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedCache.kt index caf5b773473a..e17389c52b14 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedCache.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedCache.kt @@ -25,6 +25,8 @@ class TimeLimitedCache( fun clear() = cache.invalidateAll() + fun remove(key: K) = cache.invalidate(key) + fun entries(): Set> = cache.asMap().entries fun values(): Collection = cache.asMap().values diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt index aab5595daae6..c0626fccba0a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeLimitedSet.kt @@ -13,9 +13,17 @@ class TimeLimitedSet( cache[element] = Unit } + fun addIfAbsent(element: T) { + if (!contains(element)) add(element) + } + + fun remove(element: T) = cache.remove(element) + operator fun contains(element: T): Boolean = cache.containsKey(element) fun clear() = cache.clear() - fun toSet(): Set = cache.keys().toSet() + fun toSet(): Set = cache.keys().let { keys -> + if (keys.isEmpty()) emptySet() else keys.toSet() + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 075bf95025e1..8bb09e6fc7ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -1,8 +1,10 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils.enumJoinToPattern import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +@SkyHanniModule object UtilsPatterns { private val patternGroup = RepoPattern.group("utils") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideGUI.kt new file mode 100644 index 000000000000..944a3201a797 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideGUI.kt @@ -0,0 +1,121 @@ +package at.hannibal2.skyhanni.utils.guide + +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned +import net.minecraft.client.gui.GuiScreen +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.item.ItemStack + +const val selectedColor = 0x50000000 +const val notSelectedColor = 0x50303030 +const val tabSpacing = 5 +const val tabShortSide = 25 +const val tabLongSide = 28 + +abstract class GuideGUI>(defaultScreen: pageEnum) : GuiScreen() { + + abstract val sizeX: Int + abstract val sizeY: Int + lateinit var pageList: Map + lateinit var horizontalTabs: List + lateinit var verticalTabs: List + protected var currentPage: pageEnum = defaultScreen + set(value) { + pageList[field]?.onLeave() + pageList[value]?.onEnter() + field = value + } + + val lastVerticalTabWrapper = object : tabWrapper { + override var tab: GuideTab? = null + } + val lastHorizontalTabWrapper = object : tabWrapper { + override var tab: GuideTab? = null + } + + fun hTab(item: ItemStack, tip: Renderable, onClick: (GuideTab) -> Unit) = + GuideTab(item, tip, false, lastHorizontalTabWrapper, onClick) + + fun vTab(item: ItemStack, tip: Renderable, onClick: (GuideTab) -> Unit) = + GuideTab(item, tip, true, lastVerticalTabWrapper, onClick) + + interface tabWrapper { + var tab: GuideTab? + } + + fun refreshPage() { + pageList[currentPage]?.refresh() + } + + private fun renderHorizontalTabs() { + var offset = Pair(tabSpacing.toFloat() * 3f, -tabLongSide.toFloat()) + GlStateManager.translate(offset.first, offset.second, 0f) + for (tab in horizontalTabs) { + tab.render(offset.first.toInt(), offset.second.toInt()) + val xShift = (tabShortSide + tabSpacing).toFloat() + offset = offset.first + xShift to offset.second + GlStateManager.translate(xShift, 0f, 0f) + } + GlStateManager.translate(-offset.first, -offset.second, 0f) + } + + private fun renderVerticalTabs() { + var offset = Pair(-tabLongSide.toFloat(), tabSpacing.toFloat() * 3f) + GlStateManager.translate(offset.first, offset.second, 0f) + for (tab in verticalTabs) { + tab.render(offset.first.toInt(), offset.second.toInt()) + val yShift = (tabShortSide + tabSpacing).toFloat() + offset = offset.first to offset.second + yShift + GlStateManager.translate(0f, yShift, 0f) + } + GlStateManager.translate(-offset.first, -offset.second, 0f) + } + + override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) = try { + super.drawScreen(mouseX, mouseY, partialTicks) + drawDefaultBackground() + val guiLeft = (width - sizeX) / 2 + val guiTop = (height - sizeY) / 2 + + /* + val mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth + val mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1 + */ + + val relativeMouseX = mouseX - guiLeft + val relativeMouseY = mouseY - guiTop + + GlStateManager.pushMatrix() + GlStateManager.translate(guiLeft.toFloat(), guiTop.toFloat(), 0f) + drawRect(0, 0, sizeX, sizeY, 0x50000000) + + Renderable.withMousePosition(relativeMouseX, relativeMouseY) { + renderHorizontalTabs() + renderVerticalTabs() + + Renderable.string( + "§7SkyHanni ", + horizontalAlign = RenderUtils.HorizontalAlignment.RIGHT, + verticalAlign = RenderUtils.VerticalAlignment.BOTTOM + ).renderXYAligned(0, 0, sizeX, sizeY) + + val page = pageList[currentPage] + page?.drawPage(relativeMouseX, relativeMouseY) + + GlStateManager.translate(-guiLeft.toFloat(), -guiTop.toFloat(), 0f) + } + + GlStateManager.popMatrix() + + } catch (e: Exception) { + GlStateManager.popMatrix() + ErrorManager.logErrorWithData( + e, "Something broke in GuideGUI", + "Guide" to this.javaClass.typeName, + "Page" to currentPage.name + ) + } +} + diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuidePage.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuidePage.kt new file mode 100644 index 000000000000..a563a531c669 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuidePage.kt @@ -0,0 +1,15 @@ +package at.hannibal2.skyhanni.utils.guide + +abstract class GuidePage { + abstract fun drawPage(mouseX: Int, mouseY: Int) + + abstract fun onEnter() + + abstract fun onLeave() + + fun refresh() { + onLeave() + onEnter() + } + +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideRenderablePage.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideRenderablePage.kt new file mode 100644 index 000000000000..ce68a4afee2d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideRenderablePage.kt @@ -0,0 +1,23 @@ +package at.hannibal2.skyhanni.utils.guide + +import at.hannibal2.skyhanni.utils.renderables.Renderable +import net.minecraft.client.renderer.GlStateManager + +abstract class GuideRenderablePage( + val paddingX: Int = 0, + val paddingY: Int = 0 +) : GuidePage() { + + protected var renderable: Renderable? = null + + final override fun drawPage(mouseX: Int, mouseY: Int) { + GlStateManager.translate(paddingX.toFloat(), paddingY.toFloat(), 0f) + renderable?.render(paddingX, paddingY) + GlStateManager.translate(-paddingX.toFloat(), -paddingY.toFloat(), 0f) + } + + override fun onLeave() { + renderable = null + } + +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideScrollPage.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideScrollPage.kt new file mode 100644 index 000000000000..97cf68442ccf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideScrollPage.kt @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.utils.guide + +import at.hannibal2.skyhanni.utils.CollectionUtils.tableStretchXPadding +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.ScrollValue + +abstract class GuideScrollPage( + val sizeX: Int, + val sizeY: Int, + paddingX: Int = 0, + paddingY: Int = 0, + val marginY: Int = 5, + val velocity: Double = 3.0, + val hasHeader: Boolean = true, +) : GuideRenderablePage(paddingX, paddingY) { + + private val scroll = ScrollValue() + + fun update(content: List>) { + renderable = Renderable.scrollTable( + content = content, + height = sizeY - paddingY * 2, + scrollValue = scroll, + velocity = velocity, + xPadding = content.tableStretchXPadding(sizeX - paddingX * 2), + yPadding = marginY, + hasHeader = hasHeader, + button = 0 + ) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTab.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTab.kt new file mode 100644 index 000000000000..acc69c8cccab --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTab.kt @@ -0,0 +1,67 @@ +package at.hannibal2.skyhanni.utils.guide + +import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment +import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.renderables.Renderable +import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned +import net.minecraft.client.gui.Gui +import net.minecraft.item.ItemStack + +class GuideTab( + val item: ItemStack, + val tip: Renderable, + val isVertical: Boolean = false, + var lastTab: GuideGUI.tabWrapper, + val onClick: (GuideTab) -> Unit +) { + + fun fakeClick() = click() + + private fun click() { + onClick.invoke(this) + this.select() + if (lastTab.tab != this) { + lastTab.tab?.unSelect() + lastTab.tab = this + } + } + + fun select() { + selectColor = selectedColor + } + + fun unSelect() { + selectColor = notSelectedColor + } + + fun isSelected() = selectColor == selectedColor + + val width = if (isVertical) tabLongSide else tabShortSide + val height = if (isVertical) tabShortSide else tabLongSide + + private var selectColor = notSelectedColor + + private val renderable = Renderable.clickAndHover(object : Renderable { + override val width = this@GuideTab.width + override val height = this@GuideTab.height + override val horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT + override val verticalAlign: VerticalAlignment = VerticalAlignment.TOP + + val itemRender = Renderable.itemStack( + item, 1.0, horizontalAlign = HorizontalAlignment.CENTER, verticalAlign = VerticalAlignment.CENTER + ) + + override fun render(posX: Int, posY: Int) { + Gui.drawRect(0, 0, width, height, selectColor) + itemRender.renderXYAligned(posX, posY, width, height) + } + }, listOf(tip), onClick = { + click() + SoundUtils.playClickSound() + }) + + fun render(posX: Int, posY: Int) { + renderable.render(posX, posY) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTablePage.kt b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTablePage.kt new file mode 100644 index 000000000000..85dd5bddaad3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/guide/GuideTablePage.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.utils.guide + +import at.hannibal2.skyhanni.utils.CollectionUtils.tableStretchXPadding +import at.hannibal2.skyhanni.utils.CollectionUtils.tableStretchYPadding +import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment +import at.hannibal2.skyhanni.utils.renderables.Renderable + +abstract class GuideTablePage( + val sizeX: Int, + val sizeY: Int, + paddingX: Int = 0, + paddingY: Int = 0, + val footerSpacing: Int = 2 +) : GuideRenderablePage(paddingX, paddingY) { + + fun update( + content: List>, + footer: List = emptyList() + ) { + val ySpace = (content + listOf(footer)).tableStretchYPadding(sizeY - paddingY * 2) + renderable = + Renderable.verticalContainer( + listOf( + Renderable.table( + content, + xPadding = content.tableStretchXPadding(sizeX - paddingX * 2), + yPadding = ySpace + ), + Renderable.horizontalContainer(footer, footerSpacing, horizontalAlign = HorizontalAlignment.CENTER) + ), spacing = ySpace + ) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt index d73edc0b0a06..bc9f706f8c2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt @@ -33,5 +33,7 @@ object BaseGsonBuilder { .registerTypeAdapter(SimpleTimeMark::class.java, SkyHanniTypeAdapters.TIME_MARK.nullSafe()) .enableComplexMapKeySerialization() - fun lenientGson(): GsonBuilder = gson().registerTypeAdapterFactory(SkippingTypeAdapterFactory) + fun lenientGson(): GsonBuilder = gson() + .registerTypeAdapterFactory(SkippingTypeAdapterFactory) + .registerTypeAdapterFactory(ListEnumSkippingTypeAdapterFactory) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt new file mode 100644 index 000000000000..c17462472eb7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/EnumSkippingTypeAdapterFactory.kt @@ -0,0 +1,53 @@ +package at.hannibal2.skyhanni.utils.json + +import com.google.gson.Gson +import com.google.gson.TypeAdapter +import com.google.gson.TypeAdapterFactory +import com.google.gson.reflect.TypeToken +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonToken +import com.google.gson.stream.JsonWriter +import java.lang.reflect.ParameterizedType + +object ListEnumSkippingTypeAdapterFactory : TypeAdapterFactory { + override fun create(gson: Gson, type: TypeToken): TypeAdapter? { + val rawType = type.rawType + if (rawType == List::class.java) { + val actualType = (type.type as ParameterizedType).actualTypeArguments[0] + if (actualType is Class<*> && actualType.isEnum) { + @Suppress("UNCHECKED_CAST") + return ListEnumSkippingTypeAdapter(actualType as Class>) as TypeAdapter + } + } + return null + } +} + +/* + Instead of saving null to the config when the enum value is unknown we instead skip the value. + We also skip the value if it is null inside a list of enums. This ensures we don't crash later, + either in moulconfig or outside of it, as we assume lists of enums don't contain null values. + */ +class ListEnumSkippingTypeAdapter>(private val enumClass: Class) : TypeAdapter>() { + override fun write(out: JsonWriter, value: List?) { + value ?: return + out.beginArray() + value.forEach { out.value(it.name) } + out.endArray() + } + + override fun read(reader: JsonReader): List { + val list = mutableListOf() + reader.beginArray() + while (reader.hasNext()) { + if (reader.peek() == JsonToken.NULL) { + reader.skipValue() + continue + } + val name = reader.nextString() + enumClass.enumConstants.firstOrNull { it.name == name }?.let { list.add(it) } + } + reader.endArray() + return list + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkippingTypeAdapterFactory.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkippingTypeAdapterFactory.kt index 3a25054955f3..d99650f0cb1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkippingTypeAdapterFactory.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkippingTypeAdapterFactory.kt @@ -8,6 +8,12 @@ import com.google.gson.reflect.TypeToken import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonWriter +/* + Instead of crashing on a wrong value in the config we set the value to null and log a warning. + This prevents user's config from resetting to default values. + Which is especially important for when people downgrade their mod version, either on purpose or by accident. + This does not always work, and can cause a crash later on, but the full config reset is avoided. + */ object SkippingTypeAdapterFactory : TypeAdapterFactory { override fun create(gson: Gson, type: TypeToken): TypeAdapter { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 88b291844fab..870a3a2f297e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -8,8 +8,10 @@ import at.hannibal2.skyhanni.data.ToolTipData import at.hannibal2.skyhanni.features.chroma.ChromaShaderManager import at.hannibal2.skyhanni.features.chroma.ChromaType import at.hannibal2.skyhanni.features.misc.DarkenShader +import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.CollectionUtils.contains import at.hannibal2.skyhanni.utils.ColorUtils +import at.hannibal2.skyhanni.utils.ColorUtils.addAlpha import at.hannibal2.skyhanni.utils.ColorUtils.darker import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked import at.hannibal2.skyhanni.utils.LorenzColor @@ -19,6 +21,7 @@ import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment +import at.hannibal2.skyhanni.utils.guide.GuideGUI import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.calculateTableXOffsets import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.calculateTableYOffsets import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned @@ -26,12 +29,13 @@ import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned import at.hannibal2.skyhanni.utils.shader.ShaderManager import io.github.notenoughupdates.moulconfig.gui.GuiScreenElementWrapper -import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.Gui import net.minecraft.client.gui.GuiIngameMenu import net.minecraft.client.gui.inventory.GuiEditSign +import net.minecraft.client.gui.inventory.GuiInventory.drawEntityOnScreen import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.ResourceLocation import java.awt.Color @@ -230,18 +234,20 @@ interface Renderable { } private fun shouldAllowLink(debug: Boolean = false, bypassChecks: Boolean): Boolean { - val isGuiScreen = Minecraft.getMinecraft().currentScreen != null + val guiScreen = Minecraft.getMinecraft().currentScreen + + val isGuiScreen = guiScreen != null if (bypassChecks) { return isGuiScreen } val inMenu = Minecraft.getMinecraft().currentScreen !is GuiIngameMenu - val isGuiPositionEditor = Minecraft.getMinecraft().currentScreen !is GuiPositionEditor - val isNotInSignAndOnSlot = if (Minecraft.getMinecraft().currentScreen !is GuiEditSign) { - ToolTipData.lastSlot == null || GuiData.preDrawEventCanceled + val isGuiPositionEditor = guiScreen !is GuiPositionEditor + val isNotInSignAndOnSlot = if (guiScreen !is GuiEditSign && guiScreen !is GuideGUI<*>) { + ToolTipData.lastSlot == null || GuiData.preDrawEventCancelled } else true - val isConfigScreen = Minecraft.getMinecraft().currentScreen !is GuiScreenElementWrapper + val isConfigScreen = guiScreen !is GuiScreenElementWrapper - val openGui = Minecraft.getMinecraft().currentScreen?.javaClass?.name ?: "none" + val openGui = guiScreen?.javaClass?.name ?: "none" val isInNeuPv = openGui == "io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer" val neuFocus = NEUItems.neuHasFocus() val isInSkyTilsPv = openGui == "gg.skytils.skytilsmod.gui.profile.ProfileGui" @@ -290,10 +296,10 @@ interface Renderable { bypassChecks: Boolean = false, condition: () -> Boolean = { true }, highlightsOnHoverSlots: List = emptyList(), + onHover: () -> Unit = {}, ) = object : Renderable { - override val width: Int - get() = max(hovered.width, unhovered.width) - override val height = 10 + override val width = max(hovered.width, unhovered.width) + override val height = max(hovered.height, unhovered.height) override val horizontalAlign get() = if (isHovered) hovered.horizontalAlign else unhovered.horizontalAlign override val verticalAlign get() = if (isHovered) hovered.verticalAlign else unhovered.verticalAlign @@ -302,6 +308,7 @@ interface Renderable { override fun render(posX: Int, posY: Int) { val pair = Pair(posX, posY) isHovered = if (isHovered(posX, posY) && condition() && shouldAllowLink(true, bypassChecks)) { + onHover() hovered.render(posX, posY) HighlightOnHoverSlot.currentSlots[pair] = highlightsOnHoverSlots true @@ -313,20 +320,67 @@ interface Renderable { } } + /** Bottom Layer must be bigger then the top layer */ + fun doubleLayered( + bottomLayer: Renderable, + topLayer: Renderable, + blockBottomHover: Boolean = true, + ) = object : Renderable { + override val width = bottomLayer.width + override val height = bottomLayer.height + override val horizontalAlign = bottomLayer.horizontalAlign + override val verticalAlign = bottomLayer.verticalAlign + + override fun render(posX: Int, posY: Int) { + val (x, y) = topLayer.renderXYAligned(posX, posY, width, height) + val (posX, posY) = if (topLayer.isHovered(posX + x, posY + y) && blockBottomHover) { + bottomLayer.width + 1 to bottomLayer.height + 1 + } else { + posX to posY + } + bottomLayer.render(posX, posY) + } + } + + fun itemStackWithTip( + item: ItemStack, + scale: Double = NEUItems.itemFontSize, + xSpacing: Int = 2, + ySpacing: Int = 0, + rescaleSkulls: Boolean = true, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = + hoverTips( + itemStack( + item, + scale, + xSpacing, + ySpacing, + rescaleSkulls, + horizontalAlign = horizontalAlign, + verticalAlign = verticalAlign + ), + item.getTooltip(Minecraft.getMinecraft().thePlayer, false), + stack = item + ) + fun itemStack( item: ItemStack, scale: Double = NEUItems.itemFontSize, xSpacing: Int = 2, + ySpacing: Int = 1, + rescaleSkulls: Boolean = true, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, verticalAlign: VerticalAlignment = VerticalAlignment.CENTER, ) = object : Renderable { - override val width = (15.5 * scale + 1.5).toInt() + xSpacing - override val height = (15.5 * scale + 1.5).toInt() + override val width = (15.5 * scale + 0.5).toInt() + xSpacing + override val height = (15.5 * scale + 0.5).toInt() + ySpacing override val horizontalAlign = horizontalAlign override val verticalAlign = verticalAlign override fun render(posX: Int, posY: Int) { - item.renderOnScreen(xSpacing / 2.0f, 0F, scaleMultiplier = scale) + item.renderOnScreen(xSpacing / 2.0f, 0F, scaleMultiplier = scale, rescaleSkulls) } } @@ -379,7 +433,7 @@ interface Renderable { scale: Double = 1.0, color: Color = Color.WHITE, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, - verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + verticalAlign: VerticalAlignment = VerticalAlignment.CENTER, ) = object : Renderable { val list by lazy { @@ -390,9 +444,9 @@ interface Renderable { override val width by lazy { if (list.size == 1) { - (Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) / scale).toInt() + 1 + (Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) * scale).toInt() + 1 } else { - (width / scale).toInt() + 1 + width } } @@ -431,6 +485,7 @@ interface Renderable { content: List>, xPadding: Int = 1, yPadding: Int = 0, + useEmptySpace: Boolean = false, horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, verticalAlign: VerticalAlignment = VerticalAlignment.TOP, ) = object : Renderable { @@ -442,6 +497,9 @@ interface Renderable { override val width = xOffsets.last() - xPadding override val height = yOffsets.last() - yPadding + val emptySpaceX = if (useEmptySpace) 0 else xPadding + val emptySpaceY = if (useEmptySpace) 0 else yPadding + override fun render(posX: Int, posY: Int) { content.forEachIndexed { rowIndex, row -> row.forEachIndexed { index, renderable -> @@ -450,8 +508,8 @@ interface Renderable { renderable?.renderXYAligned( posX + xOffsets[index], posY + yOffsets[rowIndex], - xOffsets[index + 1] - xOffsets[index], - yOffsets[rowIndex + 1] - yOffsets[rowIndex] + xOffsets[index + 1] - xOffsets[index] - emptySpaceX, + yOffsets[rowIndex + 1] - yOffsets[rowIndex] - emptySpaceY ) GlStateManager.popMatrix() } @@ -531,7 +589,7 @@ interface Renderable { } // TODO use this to render current boosted crop in next jacob contest crops - fun Renderable.renderBounds(color: Color = LorenzColor.GREEN.toColor()) = object : Renderable { + fun Renderable.renderBounds(color: Color = LorenzColor.GREEN.toColor().addAlpha(100)) = object : Renderable { override val width = this@renderBounds.width override val height = this@renderBounds.height override val horizontalAlign = this@renderBounds.horizontalAlign @@ -557,7 +615,52 @@ interface Renderable { override val horizontalAlign = horizontalAlign override val verticalAlign = verticalAlign override fun render(posX: Int, posY: Int) { - render.renderXAligned(0, 0, width) + render.renderXAligned(posX, posY, width) + } + } + + fun fixedSizeLine( + content: List, + width: Int, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + val render = content + + override val width = width + override val height = render.maxOfOrNull { it.height } ?: 0 + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + val emptySpace = width - render.sumOf { it.width } + val spacing = emptySpace / render.size + + override fun render(posX: Int, posY: Int) { + var xOffset = posX + render.forEach { + val x = it.width + spacing + it.renderXYAligned(xOffset, posY, x, height) + xOffset += x + GlStateManager.translate(x.toFloat(), 0f, 0f) + } + GlStateManager.translate(-(xOffset - posX).toFloat(), 0f, 0f) + } + } + + fun fixedSizeCollum( + content: Renderable, + height: Int, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + val render = content + + override val width = render.width + override val height = height + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + override fun render(posX: Int, posY: Int) { + render.renderYAligned(posX, posY, height) } } @@ -601,7 +704,7 @@ interface Renderable { override fun render(posX: Int, posY: Int) { var yOffset = posY renderables.forEach { - it.renderXAligned(yOffset, posX, width) + it.renderXAligned(posX, yOffset, width) yOffset += it.height + spacing GlStateManager.translate(0f, (it.height + spacing).toFloat(), 0f) } @@ -722,7 +825,15 @@ interface Renderable { yOffsets.indexOfFirst { it >= scroll.asInt() }..<(yOffsets.indexOfFirst { it >= end } .takeIf { it > 0 } ?: yOffsets.size) - 1 - for (rowIndex in range) { + + val range2 = + if (range.last + 3 <= yOffsets.size && yOffsets[range.last + 2] - yOffsets[range.first] <= height - renderY) { + range.first..range.last() + 1 + } else { + range + } + + for (rowIndex in range2) { content[rowIndex].forEachIndexed { index, renderable -> GlStateManager.translate(xOffsets[index].toFloat(), 0f, 0f) renderable?.renderXYAligned( @@ -762,5 +873,85 @@ interface Renderable { GlStateManager.translate(-padding.toFloat(), -padding.toFloat(), 0f) } } + + fun drawInsideRoundedRectWithOutline( + input: Renderable, + color: Color, + padding: Int = 2, + radius: Int = 10, + smoothness: Int = 2, + topOutlineColor: Int, + bottomOutlineColor: Int, + borderOutlineThickness: Int, + blur: Float = 0.7f, + horizontalAlign: HorizontalAlignment = HorizontalAlignment.LEFT, + verticalAlign: VerticalAlignment = VerticalAlignment.TOP, + ) = object : Renderable { + override val width = input.width + padding * 2 + override val height = input.height + padding * 2 + override val horizontalAlign = horizontalAlign + override val verticalAlign = verticalAlign + + override fun render(posX: Int, posY: Int) { + RenderUtils.drawRoundRect(0, 0, width, height, color.rgb, radius, smoothness) + RenderUtils.drawRoundRectOutline( + 0, + 0, + width, + height, + topOutlineColor, + bottomOutlineColor, + borderOutlineThickness, + radius, + blur + ) + + GlStateManager.translate(padding.toFloat(), padding.toFloat(), 0f) + input.render(posX + padding, posY + padding) + GlStateManager.translate(-padding.toFloat(), -padding.toFloat(), 0f) + } + } + + fun fakePlayer( + player: EntityPlayer, + followMouse: Boolean = false, + eyesX: Float = 0f, + eyesY: Float = 0f, + width: Int = 50, + height: Int = 100, + entityScale: Int = 30, + padding: Int = 5, + color: Int? = null, + colorCondition: () -> Boolean = { true }, + ) = object : Renderable { + override val width = width + 2 * padding + override val height = height + 2 * padding + override val horizontalAlign = HorizontalAlignment.LEFT + override val verticalAlign = VerticalAlignment.TOP + val playerWidth = entityScale + val playerHeight = entityScale * 2 + val playerX = width / 2 + padding + val playerY = height / 2 + playerHeight / 2 + padding + + override fun render(posX: Int, posY: Int) { + GlStateManager.color(1f, 1f, 1f, 1f) + if (color != null) RenderLivingEntityHelper.setEntityColor(player, color, colorCondition) + val mouse = currentRenderPassMousePosition ?: return + val mouseXRelativeToPlayer = + if (followMouse) (posX + playerX - mouse.first).toFloat() else eyesX + val mouseYRelativeToPlayer = + if (followMouse) (posY + playerY - mouse.second - 1.62 * entityScale).toFloat() else eyesY + GlStateManager.translate(0f, 0f, 100f) + drawEntityOnScreen( + playerX, + playerY, + entityScale, + mouseXRelativeToPlayer, + mouseYRelativeToPlayer, + player + ) + GlStateManager.translate(0f, 0f, -100f) + } + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt index 14e4fde134a1..0d2c887854ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableTooltips.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils.renderables +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.RenderUtils @@ -15,6 +16,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent import java.awt.Color +@SkyHanniModule object RenderableTooltips { private var tooltip: DeferredTooltip? = null @@ -73,7 +75,7 @@ object RenderableTooltips { RenderHelper.disableStandardItemLighting() GlStateManager.enableDepth() - val zLevel = 300f + val zLevel = 400f GlStateManager.translate(tooltipX.toFloat(), tooltipY.toFloat(), zLevel) RenderUtils.drawGradientRect( diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt index e1f93574e0f3..d1a8aae02b1d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt @@ -13,22 +13,25 @@ internal object RenderableUtils { buildList { add(0) while (true) { - buffer += content.map { it.getOrNull(index) }.takeIf { it.any { it != null } }?.maxOf { + buffer += content.map { it.getOrNull(index) }.takeIf { it.any { it != null } }?.maxOfOrNull { it?.width ?: 0 }?.let { it + xPadding } ?: break add(buffer) index++ } + if (this.size == 1) { + add(xPadding) + } } } /** Calculates the absolute y position of the rows in a table*/ fun calculateTableYOffsets(content: List>, yPadding: Int) = run { var buffer = 0 - listOf(0) + content.map { row -> - buffer += row.maxOf { it?.height ?: 0 } + yPadding + listOf(0) + (content.takeIf { it.isNotEmpty() }?.map { row -> + buffer += (row.maxOfOrNull { it?.height ?: 0 } ?: 0) + yPadding buffer - } + } ?: listOf(yPadding)) } private fun calculateAlignmentXOffset(renderable: Renderable, xSpace: Int) = when (renderable.horizontalAlign) { @@ -45,25 +48,28 @@ internal object RenderableUtils { else -> 0 } - fun Renderable.renderXYAligned(posX: Int, posY: Int, xSpace: Int, ySpace: Int) { + fun Renderable.renderXYAligned(posX: Int, posY: Int, xSpace: Int, ySpace: Int): Pair { val xOffset = calculateAlignmentXOffset(this, xSpace) val yOffset = calculateAlignmentYOffset(this, ySpace) GlStateManager.translate(xOffset.toFloat(), yOffset.toFloat(), 0f) this.render(posX + xOffset, posY + yOffset) GlStateManager.translate(-xOffset.toFloat(), -yOffset.toFloat(), 0f) + return xOffset to yOffset } - fun Renderable.renderXAligned(posX: Int, posY: Int, xSpace: Int) { + fun Renderable.renderXAligned(posX: Int, posY: Int, xSpace: Int): Int { val xOffset = calculateAlignmentXOffset(this, xSpace) GlStateManager.translate(xOffset.toFloat(), 0f, 0f) this.render(posX + xOffset, posY) GlStateManager.translate(-xOffset.toFloat(), 0f, 0f) + return xOffset } - fun Renderable.renderYAligned(posX: Int, posY: Int, ySpace: Int) { + fun Renderable.renderYAligned(posX: Int, posY: Int, ySpace: Int): Int { val yOffset = calculateAlignmentYOffset(this, ySpace) GlStateManager.translate(0f, yOffset.toFloat(), 0f) this.render(posX, posY + yOffset) GlStateManager.translate(0f, -yOffset.toFloat(), 0f) + return yOffset } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt index 931a5aac9999..80881bbce88b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -1,18 +1,20 @@ package at.hannibal2.skyhanni.utils.repopatterns import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.features.dev.RepoPatternConfig import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzEvent -import at.hannibal2.skyhanni.events.PreInitFinishedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.utils.PreInitFinishedEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.substringBeforeLastOrNull -import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.system.PlatformUtils import net.minecraft.launchwrapper.Launch import net.minecraftforge.fml.common.FMLCommonHandler import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -25,6 +27,7 @@ import java.util.regex.PatternSyntaxException /** * Manages [RepoPattern]s. */ +@SkyHanniModule object RepoPatternManager { val allPatterns: Collection> get() = usedKeys.values @@ -74,7 +77,7 @@ object RepoPatternManager { } } - val localLoading: Boolean get() = config.forceLocal.get() || (!insideTest && LorenzUtils.isInDevEnvironment()) + val localLoading: Boolean get() = config.forceLocal.get() || (!insideTest && PlatformUtils.isDevEnvironment) /** * Crash if in a development environment, or if inside a guarded event handler. @@ -247,7 +250,7 @@ object RepoPatternManager { file.writeText(data) } - @SubscribeEvent + @HandleEvent fun onPreInitFinished(event: PreInitFinishedEvent) { wasPreinitialized = true val dumpDirective = System.getenv("SKYHANNI_DUMP_REGEXES") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/system/PlatformUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/system/PlatformUtils.kt new file mode 100644 index 000000000000..4828bc2af825 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/system/PlatformUtils.kt @@ -0,0 +1,31 @@ +package at.hannibal2.skyhanni.utils.system + +import net.minecraft.launchwrapper.Launch +import net.minecraftforge.fml.common.Loader +import net.minecraftforge.fml.common.ModContainer + +/** + * This object contains utilities for all platform specific operations. + * i.e. operations that are specific to the mod loader or the environment the mod is running in. + */ +object PlatformUtils { + + private val modPackages: Map by lazy { + Loader.instance().modList + .flatMap { mod -> mod.ownedPackages.map { it to mod } } + .toMap() + } + + val isDevEnvironment: Boolean by lazy { + Launch.blackboard?.get("fml.deobfuscatedEnvironment") as? Boolean ?: true + } + + fun getModFromPackage(packageName: String?): ModInstance? = modPackages[packageName]?.let { + ModInstance(it.modId, it.name, it.version) + } + + fun Class<*>.getModInstance(): ModInstance? = getModFromPackage(canonicalName?.substringBeforeLast('.')) + +} + +data class ModInstance(val id: String, val name: String, val version: String) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt index 51a0e4f65719..2a3fd21d9983 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.config.features.misc.TrackerConfig.PriceFromEntry import at.hannibal2.skyhanni.config.storage.ProfileSpecificStorage import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.TrackerManager -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.Companion.getBazaarData +import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -41,8 +41,8 @@ open class SkyHanniTracker( private val storedTrackers get() = SkyHanniMod.feature.storage.trackerDisplayModes fun getPricePer(name: NEUInternalName) = when (config.priceFrom) { - PriceFromEntry.INSTANT_SELL -> name.getBazaarData()?.sellPrice ?: name.getPriceOrNull() ?: 0.0 - PriceFromEntry.SELL_OFFER -> name.getBazaarData()?.buyPrice ?: name.getPriceOrNull() ?: 0.0 + PriceFromEntry.INSTANT_SELL -> name.getBazaarData()?.instantBuyPrice ?: name.getPriceOrNull() ?: 0.0 + PriceFromEntry.SELL_OFFER -> name.getBazaarData()?.sellOfferPrice ?: name.getPriceOrNull() ?: 0.0 else -> name.getNpcPriceOrNull() ?: 0.0 } diff --git a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt index f8f952bbe50d..78304f0ae892 100644 --- a/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt +++ b/src/test/java/at/hannibal2/skyhanni/test/garden/VisitorListenerTest.kt @@ -27,7 +27,7 @@ class VisitorListenerTest { mockkObject(VisitorAPI) every { VisitorAPI.addVisitor(any()) } returns true - listener = VisitorListener() + listener = VisitorListener } @Test