Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into feature/custom-scoreboard-custom…
Browse files Browse the repository at this point in the history
…-lines
  • Loading branch information
j10a1n15 authored Oct 19, 2024
2 parents 9da567d + 13ed9b5 commit 91f9e87
Show file tree
Hide file tree
Showing 181 changed files with 614 additions and 588 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/process_detekt_sarif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ read -r -d '' jq_command <<'EOF'
",title=" + (.ruleId) +
",col=" + (.l.region.startColumn|tostring) +
",endColumn=" + (.l.region.endColumn|tostring) +
"::" + (.message.text)
"::" + (.message)
)
EOF

Expand Down
34 changes: 18 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,30 @@ jobs:
with:
name: "Test Results"
path: versions/1.8.9/build/reports/tests/test/
#detekt:
# name: Run detekt
# runs-on: ubuntu-latest
detekt:
name: Run detekt
runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - uses: ./.github/actions/setup-normal-workspace
# # detektMain is a LOT slower than detekt, but it does type analysis
# - name: Run detekt main (w/typing analysis)
# run: |
# ./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/main.sarif
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: ./.github/actions/setup-normal-workspace
# detektMain is a LOT slower than detekt, but it does type analysis
- name: Run detekt main (w/typing analysis)
run: |
./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/main.sarif

preprocess:
runs-on: ubuntu-latest
name: "Build multi version"
env:
SKIP_DETEKT: "true"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ detekt {

tasks.withType<Detekt>().configureEach {
onlyIf {
false // TODO: Remove onlyIf when we're ready to enforce
System.getenv("SKIP_DETEKT") != "true"
}

reports {
Expand Down
27 changes: 2 additions & 25 deletions detekt/baseline.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/api/ReforgeAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ object ReforgeAPI {
return Reforge(
name = it.reforgeName,
type = LorenzUtils.enumValueOf<ReforgeType>(type.first),
stats = it.reforgeStats ?: emptyMap(),
stats = it.reforgeStats.orEmpty(),
reforgeStone = it.internalName,
specialItems = type.second.takeIf { it.isNotEmpty() },
extraProperty = it.reforgeAbility,
Expand Down
1 change: 0 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ object SkillAPI {
val neededXp = levelingMap.filter { it.key < level }.values.sum().toLong()
ChatUtils.chat("You need §b${neededXp.addSeparators()} §eXP to be level §b${level.toDouble()}")
} else {
val base = levelingMap.values.sum().toLong()
val neededXP = xpRequiredForLevel(level.toDouble())
ChatUtils.chat("You need §b${neededXP.addSeparators()} §eXP to be level §b${level.toDouble()}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ConfigManager {
println("")
println(
"This crash is here to remind you to fix the missing " +
"@ConfigLink annotation over your new config position config element."
"@ConfigLink annotation over your new config position config element."
)
println("")
println("Steps to fix:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object ConfigUpdaterMigrator {
if (newParentElement !is JsonObject) {
logger.log(
"Catastrophic: element at path $old could not be relocated to $new, " +
"since another element already inhabits that path"
"since another element already inhabits that path"
)
return
}
Expand Down Expand Up @@ -128,13 +128,11 @@ object ConfigUpdaterMigrator {
?.flatMap { player ->
player.value.asJsonObject["profiles"]?.asJsonObject?.entrySet()?.map {
"storage.players.${player.key}.profiles.${it.key}"
} ?: listOf()
}
?: listOf()
}.orEmpty()
}.orEmpty()
),
"#player" to (
storage?.get("players")?.asJsonObject?.entrySet()?.map { "storage.players.${it.key}" }
?: listOf()
storage?.get("players")?.asJsonObject?.entrySet()?.map { "storage.players.${it.key}" }.orEmpty()
),
)
val migration = ConfigFixEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package at.hannibal2.skyhanni.config.commands

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.config.commands.Commands.commands
import at.hannibal2.skyhanni.config.commands.Commands.commandList
import net.minecraftforge.client.ClientCommandHandler

object CommandRegistrationEvent : SkyHanniEvent() {
fun register(name: String, block: CommandBuilder.() -> Unit) {
val info = CommandBuilder(name).apply(block)
if (commands.any { it.name == name }) {
if (commandList.any { it.name == name }) {
error("The command '$name is already registered!'")
}
ClientCommandHandler.instance.registerCommand(info.toSimpleCommand())
commands.add(info)
commandList.add(info)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ import at.hannibal2.skyhanni.utils.chat.ChatClickActionManager
import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui

@SkyHanniModule
@Suppress("LargeClass", "LongMethod")
object Commands {

val commands = mutableListOf<CommandBuilder>()
val commandList = mutableListOf<CommandBuilder>()

@HandleEvent
fun onCommandRegistration(event: CommandRegistrationEvent) {
Expand Down Expand Up @@ -299,6 +300,7 @@ object Commands {
event.register("shcolors") {
description = "Prints a list of all Minecraft color & formatting codes in chat."
category = CommandCategory.USERS_ACTIVE
@Suppress("AvoidBritishSpelling")
aliases = listOf("shcolor", "shcolours", "shcolour")
callback { ColorFormattingHelper.printColorCodeList() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config.core.elements

import net.minecraft.client.gui.Gui

@Suppress("EmptyFunctionBlock", "UnusedParameter")
abstract class GuiElement : Gui() {
abstract fun render(x: Int, y: Int)

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object BossbarData {
private var bossbar: String? = null
private var previousServerBossbar = ""

fun getBossbar() = bossbar ?: ""
fun getBossbar() = bossbar.orEmpty()

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import at.hannibal2.skyhanni.events.EntityMoveEvent
import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.SkyHanniWarpEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.SkyHanniWarpEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.DelayedRun
import at.hannibal2.skyhanni.utils.LorenzUtils
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object EventCounter {

private val config get() = SkyHanniMod.feature.dev.debug

private var map = mutableMapOf<String, Int>()
private val map = mutableMapOf<String, Int>()
private var lastUpdate = SimpleTimeMark.farPast()

private var enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,39 +87,17 @@ object GardenCropMilestonesCommunityFix {

val lore = stack.getLore()
val next = lore.nextAfter({ GardenCropMilestones.totalPattern.matches(it) }, 3) ?: return
val total = lore.nextAfter({ GardenCropMilestones.totalPattern.matches(it) }, 6) ?: return

// debug(" ")
// debug("crop: $crop")
// debug("realTier: $realTier")

val guessNextMax = nextMax(realTier, crop)
// debug("guessNextMax: ${guessNextMax.addSeparators()}")
val nextMax = amountPattern.matchMatcher(next) {
group("max").formatLong()
} ?: return
// debug("nextMax real: ${nextMax.addSeparators()}")

if (nextMax != guessNextMax) {
// debug("wrong, add to list")
wrongData.add("$crop:$realTier:${nextMax.addSeparators()}")
}

val guessTotalMax = GardenCropMilestones.getCropsForTier(46, crop) // no need to overflow here
// println("guessTotalMax: ${guessTotalMax.addSeparators()}")
val totalMax = amountPattern.matchMatcher(total) {
group("max").formatLong()
} ?: return
// println("totalMax real: ${totalMax.addSeparators()}")
val totalOffBy = guessTotalMax - totalMax
// debug("$crop total offf by: ${totalOffBy.addSeparators()}")
}

// fun debug(message: String) {
// if (SkyHanniMod.feature.dev.debug.enabled) {
// println(message)
// }
// }

/**
* This helps to fix wrong crop milestone data
* This command reads the clipboard content,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object GuiEditManager {

private var lastHotkeyPressed = SimpleTimeMark.farPast()

private var currentPositions = TimeLimitedCache<String, Position>(15.seconds)
private var currentBorderSize = mutableMapOf<String, Pair<Int, Int>>()
private val currentPositions = TimeLimitedCache<String, Position>(15.seconds)
private val currentBorderSize = mutableMapOf<String, Pair<Int, Int>>()
private var lastMovedGui: String? = null

@SubscribeEvent
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ object GuildAPI {

fun isInGuild(name: String) = name in getAllMembers()

fun getAllMembers() = ProfileStorageData.playerSpecific?.guildMembers ?: emptyList()
fun getAllMembers() = ProfileStorageData.playerSpecific?.guildMembers.orEmpty()
}
3 changes: 2 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ enum class HotmData(
"perk.enable",
"§a§lENABLED|(§.)*SELECTED",
)
@Suppress("UnusedPrivateProperty")
private val disabledPattern by patternGroup.pattern(
"perk.disabled",
"§c§lDISABLED|§7§eClick to select!",
Expand Down Expand Up @@ -530,7 +531,7 @@ enum class HotmData(
HotmAPI.MayhemPerk.entries.forEach {
it.chatPattern
}
(0..CORE_OF_THE_MOUNTAIN.maxLevel).forEach { level ->
for (level in 0..CORE_OF_THE_MOUNTAIN.maxLevel) {
val map = mutableMapOf<HotmReward, Double>()
if (level >= 1) map.addOrPut(HotmReward.EXTRA_TOKENS, 1.0)
if (level >= 2) map.addOrPut(HotmReward.ABILITY_LEVEL, 1.0)
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object HypixelData {
"servername.scoreboard",
"§e(?<prefix>.+\\.)?hypixel\\.net",
)
@Suppress("UnusedPrivateProperty")
private val islandNamePattern by patternGroup.pattern(
"islandname",
"(?:§.)*(Area|Dungeon): (?:§.)*(?<island>.*)",
Expand Down Expand Up @@ -139,7 +140,7 @@ object HypixelData {

// Data from locraw
var locrawData: JsonObject? = null
private var locraw: MutableMap<String, String> = listOf(
private val locraw: MutableMap<String, String> = listOf(
"server",
"gametype",
"lobbyname",
Expand All @@ -148,12 +149,12 @@ object HypixelData {
"map",
).associateWith { "" }.toMutableMap()

val server get() = locraw["server"] ?: ""
val gameType get() = locraw["gametype"] ?: ""
val lobbyName get() = locraw["lobbyname"] ?: ""
val lobbyType get() = locraw["lobbytype"] ?: ""
val mode get() = locraw["mode"] ?: ""
val map get() = locraw["map"] ?: ""
val server get() = locraw["server"].orEmpty()
val gameType get() = locraw["gametype"].orEmpty()
val lobbyName get() = locraw["lobbyname"].orEmpty()
val lobbyType get() = locraw["lobbytype"].orEmpty()
val mode get() = locraw["mode"].orEmpty()
val map get() = locraw["map"].orEmpty()

fun checkCurrentServerId() {
if (!LorenzUtils.inSkyBlock) return
Expand Down Expand Up @@ -267,7 +268,7 @@ object HypixelData {
if (obj.has("server")) {
locrawData = obj
for (key in locraw.keys) {
locraw[key] = obj[key]?.asString ?: ""
locraw[key] = obj[key]?.asString.orEmpty()
}
inLimbo = locraw["server"] == "limbo"
inLobby = locraw["lobbyname"] != ""
Expand All @@ -286,7 +287,7 @@ object HypixelData {
}
}

private var loggerIslandChange = LorenzLogger("debug/island_change")
private val loggerIslandChange = LorenzLogger("debug/island_change")

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
Expand Down Expand Up @@ -442,7 +443,7 @@ object HypixelData {
}
}

serverNameConnectionPattern.matchMatcher(mc.currentServerData?.serverIP ?: "") {
serverNameConnectionPattern.matchMatcher(mc.currentServerData?.serverIP.orEmpty()) {
hypixel = true
if (group("prefix") == "alpha.") {
hypixelAlpha = true
Expand Down Expand Up @@ -497,7 +498,7 @@ object HypixelData {
TabListData.fullyLoaded = true
// Can not use color coding, because of the color effect (§f§lSKYB§6§lL§e§lOCK§A§L GUEST)
val guesting = guestPattern.matches(ScoreboardData.objectiveTitle.removeColor())
foundIsland = TabWidget.AREA.matchMatcherFirstLine { group("island").removeColor() } ?: ""
foundIsland = TabWidget.AREA.matchMatcherFirstLine { group("island").removeColor() }.orEmpty()
newIsland = getIslandType(foundIsland, guesting)
}

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

private var lastDiceRoll = SimpleTimeMark.farPast()
private var superCraftedItems = TimeLimitedSet<NEUInternalName>(30.seconds)
private val superCraftedItems = TimeLimitedSet<NEUInternalName>(30.seconds)

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object LocationFixData {

private var locationFixes = mutableMapOf<IslandType, List<LocationFix>>()
private val locationFixes = mutableMapOf<IslandType, List<LocationFix>>()

private data class LocationFix(val area: AxisAlignedBB, val realLocation: String)

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

var favoritePowers: List<String>
get() = storage?.maxwell?.favoritePowers ?: listOf()
get() = storage?.maxwell?.favoritePowers.orEmpty()
set(value) {
storage?.maxwell?.favoritePowers = value
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object MayorAPI {
private var lastJerryExtraMayorReminder = SimpleTimeMark.farPast()

private var lastUpdate = SimpleTimeMark.farPast()
private var dispatcher = Dispatchers.IO
private val dispatcher = Dispatchers.IO

private var rawMayorData: MayorJson? = null
private var candidates = mapOf<Int, MayorCandidate>()
Expand Down
Loading

0 comments on commit 91f9e87

Please sign in to comment.