Skip to content

Commit

Permalink
Merge branch 'refs/heads/beta' into generic-event
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt
  • Loading branch information
CalMWolfs committed Oct 20, 2024
2 parents 34aad85 + 8ce3e9d commit 099d1ff
Show file tree
Hide file tree
Showing 54 changed files with 670 additions and 94 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ jobs:
preprocess:
runs-on: ubuntu-latest
name: "Build multi version"
env:
SKIP_DETEKT: "true"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/default_user.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,18 @@ dependencies {
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT")
annotationProcessor("com.google.code.gson:gson:2.10.1")
annotationProcessor("com.google.guava:guava:17.0")
} else if (target == ProjectTarget.MODERN) {
modCompileOnly("net.fabricmc:fabric-loader:0.16.7")
modCompileOnly("net.fabricmc.fabric-api:fabric-api:0.102.0+1.21")
}

implementation(kotlin("stdlib-jdk8"))
shadowImpl("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") {
exclude(group = "org.jetbrains.kotlin")
}

modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.1.0")
if (target.isForge) modRuntimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
else modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.2.1")

modCompileOnly("com.github.hannibal002:notenoughupdates:4957f0b:all") {
exclude(module = "unspecified")
Expand Down Expand Up @@ -251,6 +255,10 @@ if (target == ProjectTarget.MAIN) {
}
}

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(target.minecraftVersion.formattedJavaLanguageVersion))
}

if (target.parent == ProjectTarget.MAIN) {
val mainRes = project(ProjectTarget.MAIN.projectPath).tasks.getAt("processResources")
tasks.named("processResources") {
Expand Down Expand Up @@ -331,7 +339,8 @@ if (!MultiVersionStage.activeState.shouldCompile(target)) {

preprocess {
vars.put("MC", target.minecraftVersion.versionNumber)
vars.put("FORGE", if (target.forgeDep != null) 1 else 0)
vars.put("FORGE", if (target.isForge) 1 else 0)
vars.put("FABRIC", if (target.isFabric) 1 else 0)
vars.put("JAVA", target.minecraftVersion.javaVersion)
patternAnnotation.set("at.hannibal2.skyhanni.utils.compat.Pattern")
}
Expand Down Expand Up @@ -375,7 +384,7 @@ detekt {

tasks.withType<Detekt>().configureEach {
onlyIf {
System.getenv("SKIP_DETEKT") != "true"
target == ProjectTarget.MAIN
}

reports {
Expand Down
2 changes: 0 additions & 2 deletions detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<ID>CyclomaticComplexMethod:VampireSlayerFeatures.kt$VampireSlayerFeatures$private fun EntityOtherPlayerMP.process()</ID>
<ID>CyclomaticComplexMethod:VisualWordGui.kt$VisualWordGui$override fun drawScreen(unusedX: Int, unusedY: Int, partialTicks: Float)</ID>
<ID>Filename:AreaChangeEvents.kt$at.hannibal2.skyhanni.events.skyblock.AreaChangeEvents.kt</ID>
<ID>ImportOrdering:DungeonLividFinder.kt$import at.hannibal2.skyhanni.events.CheckRenderEntityEvent 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.SkyHanniMod import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceSqToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.drawLineToEye import at.hannibal2.skyhanni.utils.RenderUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation import net.minecraft.block.BlockStainedGlass import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.Minecraft import net.minecraft.entity.item.EntityArmorStand import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent</ID>
<ID>ImportOrdering:EntityUtils.kt$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 import at.hannibal2.skyhanni.utils.LocationUtils.distanceToIgnoreY import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.LorenzUtils.derpy import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.compat.getArmorOrFullInventory import at.hannibal2.skyhanni.utils.compat.getLoadedPlayers import at.hannibal2.skyhanni.utils.compat.getNameAsString import at.hannibal2.skyhanni.utils.compat.isOnMainThread import at.hannibal2.skyhanni.utils.compat.normalizeAsArray import net.minecraft.block.state.IBlockState import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.multiplayer.WorldClient 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.item.ItemStack import net.minecraft.potion.Potion import net.minecraft.tileentity.TileEntity import net.minecraft.util.AxisAlignedBB import net.minecraftforge.client.event.RenderLivingEvent //#if FORGE import net.minecraftforge.fml.common.eventhandler.Event import net.minecraftforge.fml.common.eventhandler.SubscribeEvent</ID>
<ID>InjectDispatcher:ClipboardUtils.kt$ClipboardUtils$IO</ID>
<ID>InjectDispatcher:GardenNextJacobContest.kt$GardenNextJacobContest$IO</ID>
<ID>InjectDispatcher:HypixelBazaarFetcher.kt$HypixelBazaarFetcher$IO</ID>
Expand Down
7 changes: 7 additions & 0 deletions detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ FormattingRules:
CustomCommentSpacing:
active: true

ImportRules:
active: true
CustomImportOrdering:
active: true


style:
MagicNumber: # I, Linnea Gräf, of sound mind and body, disagree with disabling this rule
Expand Down Expand Up @@ -73,6 +78,8 @@ formatting:
active: false
SpacingBetweenDeclarationsWithComments: # also nah
active: false
ImportOrdering: # handled by custom rule
active: false

complexity:
CyclomaticComplexMethod: # default threshold of 15, caught almost every complex method
Expand Down
19 changes: 19 additions & 0 deletions detekt/src/main/kotlin/PreprocessingPatterns.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package at.hannibal2.skyhanni.detektrules

enum class PreprocessingPattern(val text: String) {
IF("#if"),
ELSE("#else"),
ELSEIF("#elseif"),
ENDIF("#endif"),
DOLLAR_DOLLAR("$$"),
;

val asComment: String
get() = "//$text"

companion object {
fun String.containsPreprocessingPattern(): Boolean {
return entries.any { this.contains(it.text) }
}
}
}
12 changes: 2 additions & 10 deletions detekt/src/main/kotlin/formatting/CustomCommentSpacing.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.detektrules.formatting

import at.hannibal2.skyhanni.detektrules.PreprocessingPattern.Companion.containsPreprocessingPattern
import io.gitlab.arturbosch.detekt.api.CodeSmell
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Debt
Expand All @@ -17,18 +18,9 @@ class CustomCommentSpacing(config: Config) : Rule(config) {
Debt.FIVE_MINS
)

private val allowedPatterns = listOf(
"#if",
"#else",
"#elseif",
"#endif",
"$$"
)

override fun visitComment(comment: PsiComment) {
if (allowedPatterns.any { comment.text.contains(it) }) {
return
}
if (comment.text.containsPreprocessingPattern()) return

/**
* REGEX-TEST: // Test comment
Expand Down
114 changes: 114 additions & 0 deletions detekt/src/main/kotlin/imports/CustomImportOrdering.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package at.hannibal2.skyhanni.detektrules.imports

import at.hannibal2.skyhanni.detektrules.PreprocessingPattern
import at.hannibal2.skyhanni.detektrules.PreprocessingPattern.Companion.containsPreprocessingPattern
import io.gitlab.arturbosch.detekt.api.CodeSmell
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.Debt
import io.gitlab.arturbosch.detekt.api.Entity
import io.gitlab.arturbosch.detekt.api.Issue
import io.gitlab.arturbosch.detekt.api.Rule
import io.gitlab.arturbosch.detekt.api.Severity
import org.jetbrains.kotlin.psi.KtImportDirective
import org.jetbrains.kotlin.psi.KtImportList

class CustomImportOrdering(config: Config) : Rule(config) {
override val issue = Issue(
"CustomImportOrdering",
Severity.Style,
"Enforces correct import ordering, taking into account preprocessed imports.",
Debt.FIVE_MINS,
)

companion object {
private val importOrder = ImportSorter()

private val packageImportOrdering = listOf("java.", "javax.", "kotlin.")

private class ImportSorter : Comparator<KtImportDirective> {
override fun compare(
import1: KtImportDirective,
import2: KtImportDirective,
): Int {
val importPath1 = import1.importPath!!.pathStr
val importPath2 = import2.importPath!!.pathStr

val isTypeAlias1 = import1.aliasName != null
val isTypeAlias2 = import2.aliasName != null

val index1 = packageImportOrdering.indexOfFirst { importPath1.startsWith(it) }
val index2 = packageImportOrdering.indexOfFirst { importPath2.startsWith(it) }

return when {
isTypeAlias1 && isTypeAlias2 -> importPath1.compareTo(importPath2)
isTypeAlias1 && !isTypeAlias2 -> 1
!isTypeAlias1 && isTypeAlias2 -> -1
index1 == -1 && index2 == -1 -> importPath1.compareTo(importPath2)
index1 == -1 -> -1
index2 == -1 -> 1
else -> index1.compareTo(index2)
}
}
}
}

private fun isImportsCorrectlyOrdered(imports: List<KtImportDirective>, rawText: List<String>): Boolean {
if (rawText.any { it.isBlank() }) {
return false
}

var inPreprocess = false
val linesToIgnore = mutableListOf<String>()

for (line in rawText) {
if (line.contains(PreprocessingPattern.IF.asComment)) {
inPreprocess = true
continue
}
if (line.contains(PreprocessingPattern.ENDIF.asComment)) {
inPreprocess = false
continue
}
if (line.contains(PreprocessingPattern.DOLLAR_DOLLAR.asComment)) {
continue
}
if (inPreprocess) {
linesToIgnore.add(line)
}
}

val originalImports = rawText.filter { !it.containsPreprocessingPattern() && !linesToIgnore.contains(it) }
val formattedOriginal = originalImports.joinToString("\n") { it }

val expectedImports = imports.sortedWith(importOrder).map { "import ${it.importPath}" }
val formattedExpected = expectedImports.filter { !linesToIgnore.contains(it) }.joinToString("\n")

return formattedOriginal == formattedExpected
}

override fun visitImportList(importList: KtImportList) {

val testEntity = Entity.from(importList)

val rawText = importList.text.trim()
if (rawText.isBlank()) {
return
}

val importsCorrect = isImportsCorrectlyOrdered(importList.imports, rawText.lines())

if (!importsCorrect) {
report(
CodeSmell(
issue,
testEntity,
"Imports must be ordered in lexicographic order without any empty lines in-between " +
"with \"java\", \"javax\", \"kotlin\" and aliases in the end. This should then be followed by " +
"pre-processed imports.",
),
)
}

super.visitImportList(importList)
}
}
17 changes: 17 additions & 0 deletions detekt/src/main/kotlin/imports/ImportRuleSetProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package at.hannibal2.skyhanni.detektrules.imports

import com.google.auto.service.AutoService
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.RuleSet
import io.gitlab.arturbosch.detekt.api.RuleSetProvider

@AutoService(RuleSetProvider::class)
class ImportRuleSetProvider : RuleSetProvider {
override val ruleSetId: String = "ImportRules"

override fun instance(config: Config): RuleSet {
return RuleSet(ruleSetId, listOf(
CustomImportOrdering(config)
))
}
}
18 changes: 18 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@
#### Misc Improvements

+ Added distance display to waypoints created by Patcher's Send Coords feature. - jani (https://github.com/hannibal002/SkyHanni/pull/2704)
+ Made multiple improvements to the Custom Scoreboard. - Empa, j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2162)
+ Added an option to align the text.
+ Improved overall performance.
+ Added the Party Leader to the Party Element.
+ Separated title and footer alignment.
+ Added a custom alpha footer.

### Fixes

#### Dungeon Fixes

+ Fixed Magical Power resetting to 0 when opening "Your Bags" in the Catacombs. - j10a1n15 (https://github.com/hannibal002/SkyHanni/pull/2710)
+ Fixed a rare case where invisible Fels were highlighted even though they shouldn't. - Thunderblade73 (https://github.com/hannibal002/SkyHanni/pull/2746)

#### Fishing Fixes

Expand All @@ -107,6 +114,7 @@
+ Fixed Ashfang Blazes sometimes being highlighted with the wrong color. - Empa (https://github.com/hannibal002/SkyHanni/pull/2112)
+ Fixed Ashfang Reset Cooldown counting in the wrong direction. - Empa (https://github.com/hannibal002/SkyHanni/pull/2112)
+ Fixed Millennia-Aged Blaze not being highlighted by the Area Boss Highlight feature. - jani (https://github.com/hannibal002/SkyHanni/pull/2707)
+ Fixed a small typo in Bestiary Display. - hannibal2 (https://github.com/hannibal002/SkyHanni/pull/2748)

#### Custom Scoreboard Fixes

Expand All @@ -120,6 +128,7 @@
#### Garden Fixes

+ Fixed farming weight not disappearing when the config option is off. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2731)
+ Fixed New Visitor Ping triggering too late if the player is actively farming. - Luna (https://github.com/hannibal002/SkyHanni/pull/2767)

#### Crimson Isle Fixes

Expand All @@ -137,9 +146,18 @@

+ Fixed a crash when attempting to edit the Flowstate Helper config. - Daveed (https://github.com/hannibal002/SkyHanni/pull/2740)

#### Chocolate Factory Fixes

+ Fixed an issue where the Time Tower Usage Warning would notify you after expiration or when you have 0 charges. - MTOnline (https://github.com/hannibal002/SkyHanni/pull/2751)

#### Event Fixes

+ Fixed Fear Stat Display. - Fazfoxy (https://github.com/hannibal002/SkyHanni/pull/2766)

#### Misc Fixes

+ Fixed SkyHanni messages being sent twice. - CalMWolfs (https://github.com/hannibal002/SkyHanni/pull/2736)
+ Fixed the formatting of negative durations. - Empa (https://github.com/hannibal002/SkyHanni/pull/2726)

### Technical Details

Expand Down
4 changes: 2 additions & 2 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import at.skyhanni.sharedvariables.ProjectTarget
import com.replaymod.gradle.preprocess.Node

plugins {
id("dev.deftu.gradle.preprocess") version "0.6.1"
id("dev.deftu.gradle.preprocess") version "0.7.1"
id("net.kyori.blossom") version "1.3.2" apply false
id("gg.essential.loom") version "1.6.+" apply false
kotlin("jvm") version "2.0.0" apply false
Expand All @@ -14,7 +14,7 @@ plugins {

allprojects {
group = "at.hannibal2.skyhanni"
version = "0.28.Beta.4"
version = "0.28.Beta.5"
repositories {
mavenCentral()
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ object Commands {
callback { GriffinBurrowHelper.setTestBurrow(it) }
}
event.register("shtestisland") {
description = "Sets the current skyblock island for testing purposes."
description = "Changes the SkyBlock island SkyHanni thinks you are on"
category = CommandCategory.DEVELOPER_TEST
callback { SkyBlockIslandTest.onCommand(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;

Expand All @@ -14,6 +15,14 @@ public class StashConfig {
@FeatureToggle
public boolean enabled = true;

@ConfigOption(
name = "§cNotice",
desc = "Hypixel sends un-detectable empty messages wrapping the stash message. " +
"Enable §e§l/sh empty messages §r§7to hide them."
)
@ConfigEditorInfoText
public String notice = "";

@Expose
@ConfigOption(name = "Hide Duplicate Warnings", desc = "Hide duplicate warnings for previously reported stash counts.")
@ConfigEditorBoolean
Expand Down
Loading

0 comments on commit 099d1ff

Please sign in to comment.