Skip to content

Commit

Permalink
Merge branch 'refs/heads/beta' into feature/custom-scoreboard-custom-…
Browse files Browse the repository at this point in the history
…lines

# Conflicts:
#	src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
#	src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardEvent.kt
  • Loading branch information
j10a1n15 committed Sep 29, 2024
2 parents 2a79220 + 8988f7d commit 05f6810
Show file tree
Hide file tree
Showing 122 changed files with 437 additions and 296 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ jobs:
# - name: Checkout code
# uses: actions/checkout@v4
# - uses: ./.github/actions/setup-normal-workspace
# - name: Run detekt
# # detektMain is a LOT slower than detekt, but it does type analysis
# - name: Run detekt main (w/typing analysis)
# run: |
# ./gradlew detekt --stacktrace
# ./gradlew detektMain --stacktrace
# - name: Annotate detekt failures
# if: ${{ !cancelled() }}
# run: |
# chmod +x .github/scripts/process_detekt_sarif.sh
# ./.github/scripts/process_detekt_sarif.sh versions/1.8.9/build/reports/detekt/detekt.sarif
# ./.github/scripts/process_detekt_sarif.sh versions/1.8.9/build/reports/detekt/main.sarif


preprocess:
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ We use [IntelliJ](https://www.jetbrains.com/idea/) as an example.

- Download IntelliJ from the [JetBrains Website](https://www.jetbrains.com/idea/download/).
- Use the Community Edition. (Scroll down a bit.)
- When you encounter any bug with IntelliJ, please make sure to use the version `2024.1.6`, not `2024.2.x` or above.

### Cloning the project

Expand All @@ -30,6 +31,7 @@ We use [IntelliJ](https://www.jetbrains.com/idea/) as an example.

### Setting up IntelliJ


Once your project is imported into IntelliJ from the previous step, all dependencies like Minecraft, NEU, and so on should be automatically
downloaded. If not, you might need to link the Gradle project in the Gradle tab (little elephant) on the right.

Expand Down
75 changes: 41 additions & 34 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import at.skyhanni.sharedvariables.MultiVersionStage
import at.skyhanni.sharedvariables.ProjectTarget
import at.skyhanni.sharedvariables.SHVersionInfo
import at.skyhanni.sharedvariables.versionString
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import net.fabricmc.loom.task.RunGameTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down Expand Up @@ -39,11 +37,15 @@ val runDirectory = rootProject.file("run")
runDirectory.mkdirs()
// Minecraft configuration:
loom {
if (this.isForgeLike)
if (this.isForgeLike) {
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
pack200Provider.set(
dev.architectury.pack200.java
.Pack200Adapter(),
)
mixinConfig("mixins.skyhanni.json")
}
}
mixin {
useLegacyMixinAp.set(true)
defaultRefmapName.set("mixins.skyhanni.refmap.json")
Expand All @@ -67,11 +69,12 @@ loom {
}
}

if (target == ProjectTarget.MAIN)
if (target == ProjectTarget.MAIN) {
sourceSets.main {
resources.destinationDirectory.set(kotlin.destinationDirectory)
output.setResourcesDir(kotlin.destinationDirectory)
}
}

val shadowImpl: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
Expand All @@ -91,9 +94,11 @@ val headlessLwjgl by configurations.creating {
isVisible = false
}
tasks.runClient {
this.javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(target.minecraftVersion.javaLanguageVersion)
})
this.javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(target.minecraftVersion.javaLanguageVersion)
},
)
}
val shot = shots.shot("minecraft", rootProject.file("shots.txt"))

Expand All @@ -104,8 +109,9 @@ dependencies {
} else {
mappings(target.mappingDependency)
}
if (target.forgeDep != null)
if (target.forgeDep != null) {
"forge"(target.forgeDep!!)
}

// Discord RPC client
shadowImpl("com.jagrosh:DiscordIPC:0.5.3") {
Expand Down Expand Up @@ -218,10 +224,11 @@ if (target == ProjectTarget.MAIN) {
}
}

if (target == ProjectTarget.MAIN)
if (target == ProjectTarget.MAIN) {
tasks.compileJava {
dependsOn(tasks.processResources)
}
}

if (target.parent == ProjectTarget.MAIN) {
val mainRes = project(ProjectTarget.MAIN.projectPath).tasks.getAt("processResources")
Expand Down Expand Up @@ -338,27 +345,27 @@ publishing.publications {
}

// Detekt: TODO: Uncomment this when we're ready to enforce
/*detekt {
buildUponDefaultConfig = true // preconfigure defaults
config.setFrom(rootProject.layout.projectDirectory.file("detekt/detekt.yml")) // point to your custom config defining rules to run, overwriting default behavior
baseline = file(layout.projectDirectory.file("detekt/baseline.xml")) // a way of suppressing issues before introducing detekt
source.setFrom(project.sourceSets.named("main").map { it.allSource })
}
tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true) // observe findings in your browser with structure and code snippets
xml.required.set(true) // checkstyle like format mainly for integrations like Jenkins
sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
md.required.set(true) // simple Markdown format
}
}
tasks.withType<Detekt>().configureEach {
jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
outputs.cacheIf { false } // Custom rules won't work if cached
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
outputs.cacheIf { false } // Custom rules won't work if cached
}*/
// detekt {
// buildUponDefaultConfig = true // preconfigure defaults
// config.setFrom(rootProject.layout.projectDirectory.file("detekt/detekt.yml")) // point to your custom config defining rules to run, overwriting default behavior
// baseline = file(layout.projectDirectory.file("detekt/baseline.xml")) // a way of suppressing issues before introducing detekt
// source.setFrom(project.sourceSets.named("main").map { it.allSource })
// }
//
// tasks.withType<Detekt>().configureEach {
// reports {
// html.required.set(true) // observe findings in your browser with structure and code snippets
// xml.required.set(true) // checkstyle like format mainly for integrations like Jenkins
// sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
// md.required.set(true) // simple Markdown format
// }
// }
//
// tasks.withType<Detekt>().configureEach {
// jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
// outputs.cacheIf { false } // Custom rules won't work if cached
// }
// tasks.withType<DetektCreateBaselineTask>().configureEach {
// jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
// outputs.cacheIf { false } // Custom rules won't work if cached
// }
2 changes: 1 addition & 1 deletion detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config:

GrammarRules:
active: true
AvoidColour: # custom rule to prefer color to colour
AvoidBritishSpelling: # custom rule to prefer american spellings over british ones
active: true

FormattingRules:
Expand Down
46 changes: 46 additions & 0 deletions detekt/src/main/kotlin/grammar/AvoidBritishSpelling.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package at.hannibal2.skyhanni.detektrules.grammar

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.KtStringTemplateExpression

/**
* This rule reports all usages of the british spelling over the american spelling in the codebase,
* this will ignore any type annotations, i.e., `@ConfigEditorColour` will not be reported.
*/
class AvoidBritishSpelling(config: Config) : Rule(config) {
override val issue = Issue(
"AvoidBritishSpelling",
Severity.Style,
"Avoid using the word british spelling over american spelling.",
Debt.FIVE_MINS,
)

private val scannedWords = mapOf(
"colour" to "color",
"armour" to "armor",
)

override fun visitStringTemplateExpression(expression: KtStringTemplateExpression) {
val text =
expression.text // Be aware .getText() returns the entire span of this template, including variable names contained within. This should be rare enough of a problem for us to not care about it.

for (word in scannedWords) {
if (text.contains(word.key, ignoreCase = true)) {
report(
CodeSmell(
issue,
Entity.from(expression),
"Avoid using the word '${word.key}' in code, '${word.value}' is preferred instead.",
),
)
}
}
super.visitStringTemplateExpression(expression)
}
}
38 changes: 0 additions & 38 deletions detekt/src/main/kotlin/grammar/AvoidColour.kt

This file was deleted.

9 changes: 6 additions & 3 deletions detekt/src/main/kotlin/grammar/GrammarRuleSetProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class GrammarRuleSetProvider : RuleSetProvider {
override val ruleSetId: String = "GrammarRules"

override fun instance(config: Config): RuleSet {
return RuleSet(ruleSetId, listOf(
AvoidColour(config)
))
return RuleSet(
ruleSetId,
listOf(
AvoidBritishSpelling(config),
),
)
}
}
6 changes: 4 additions & 2 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ allprojects {
}
maven("https://repo.spongepowered.org/maven/") // mixin
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") // DevAuth
maven("https://jitpack.io") { // NotEnoughUpdates (compiled against)
maven("https://jitpack.io") {
// NotEnoughUpdates (compiled against)
content {
includeGroupByRegex("(com|io)\\.github\\..*")
}
Expand All @@ -42,8 +43,9 @@ preprocess {
ProjectTarget.activeVersions().forEach { target ->
nodes[target] = createNode(target.projectName, target.minecraftVersion.versionNumber, target.mappingStyle.identifier)
val p = project(target.projectPath)
if (target.isForge)
if (target.isForge) {
p.extra.set("loom.platform", "forge")
}
}
ProjectTarget.activeVersions().forEach { child ->
val parent = child.linkTo ?: return@forEach
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object DataWatcherAPI {

private val DATA_VALUE_CUSTOM_NAME = 2
private const val DATA_VALUE_CUSTOM_NAME = 2

@SubscribeEvent
fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ object GetFromSackAPI {
}

private fun bazaarMessage(item: String, amount: Int, isRemaining: Boolean = false) = ChatUtils.clickableChat(
"§lCLICK §r§eto get the ${if (isRemaining) "remaining " else ""}§ax${amount} §9$item §efrom bazaar",
"§lCLICK §r§eto get the ${if (isRemaining) "remaining " else ""}§ax$amount §9$item §efrom bazaar",
onClick = { HypixelCommands.bazaar(item.removeColor()) }, "§eClick to find on the bazaar!",
)

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/api/HotmAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object HotmAPI {

/** Use when new powder gets collected*/
fun gain(difference: Long) {
ChatUtils.debug("Gained §a${difference.addSeparators()} §e${displayName} Powder")
ChatUtils.debug("Gained §a${difference.addSeparators()} §e$displayName Powder")
addTotal(difference)
addCurrent(difference)
PowderGainEvent(this, difference).post()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,19 @@ public String toString() {
@ConfigOption(name = "Silver Duplicates", desc = "Hide duplicate messages for silver Trophy Fishes from chat.")
@ConfigEditorBoolean
public boolean silverHider = false;

@Expose
@ConfigOption(name = "Gold Alert", desc = "Send an alert upon catching a gold Trophy Fish.")
@ConfigEditorBoolean
public boolean goldAlert = false;

@Expose
@ConfigOption(name = "Diamond Alert", desc = "Send an alert upon catching a diamond Trophy Fish.")
@ConfigEditorBoolean
public boolean diamondAlert = false;

@Expose
@ConfigOption(name = "Play Sound Alert", desc = "Play a sound effect when rare trophy fishes are caught.")
@ConfigEditorBoolean
public boolean playSound = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ public String toString() {
@FeatureToggle
public boolean itemStars = false;

@Expose
@ConfigOption(name = "Ultimate Enchant Star", desc = "Show a star on Enchanted Books with an Ultimate Enchant.")
@ConfigEditorBoolean
@FeatureToggle
public boolean ultimateEnchantStar = false;

@Expose
@ConfigOption(name = "Missing Tasks", desc = "Highlight missing tasks in the SkyBlock Level Guide inventory.")
// TODO move( , "inventory.highlightMissingSkyBlockLevelGuide", "inventory.skyblockGuideConfig.highlightMissingSkyBlockLevelGuide")
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/IslandGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ object IslandGraphs {
color: Color = LorenzColor.WHITE.toColor(),
onFound: () -> Unit = {},
allowRerouting: Boolean = false,
condition: () -> Boolean = { true },
condition: () -> Boolean,
) {
reset()
currentTargetNode = this
Expand All @@ -415,7 +415,7 @@ object IslandGraphs {
color: Color = LorenzColor.WHITE.toColor(),
onFound: () -> Unit = {},
showGoalExact: Boolean = false,
condition: () -> Boolean = { true },
condition: () -> Boolean,
) {
reset()
shouldAllowRerouting = false
Expand All @@ -428,7 +428,7 @@ object IslandGraphs {
color: Color = LorenzColor.WHITE.toColor(),
onFound: () -> Unit = {},
showGoalExact: Boolean = false,
condition: () -> Boolean = { true },
condition: () -> Boolean,
) {
currentTarget = location
this.label = label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ object PlayerNameFormatter {
val color = rawColor ?: return null
val level = rawLevel?.getText() ?: error("level is null, color is not null")
val levelData = "$color$level"
val result = if (config.hideLevelBrackets) levelData else "§8[${levelData}§8]"
val result = if (config.hideLevelBrackets) levelData else "§8[$levelData§8]"
return result.applyFormattingFrom(rawLevel)
}

Expand Down
Loading

0 comments on commit 05f6810

Please sign in to comment.