Skip to content

Commit

Permalink
Backend: Detekt Fixes Part 4 (#2610)
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs authored Sep 29, 2024
1 parent 3569dec commit 8988f7d
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 79 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ object BingoNextStepHelper {
private val itemIslandRequired = mutableMapOf<String, IslandVisitStep>()
private val itemPreconditions = mutableMapOf<String, NextStep>()
private val islands = mutableMapOf<IslandType, IslandVisitStep>()
private val rhysTaskName = "30x Enchanted Minerals (Redstone, Lapis Lazuli, Coal) (for Rhys)"
private const val RHYS_TASK_NAME = "30x Enchanted Minerals (Redstone, Lapis Lazuli, Coal) (for Rhys)"

private val finalSteps = mutableListOf<NextStep>()
private var currentSteps = emptyList<NextStep>()
Expand Down Expand Up @@ -167,7 +167,7 @@ object BingoNextStepHelper {
}
}
}
if (currentStep is PartialProgressItemsStep && currentStep.displayName == rhysTaskName && event.message == "§e[NPC] §dRhys§f: §rThank you for the items!§r") {
if (currentStep is PartialProgressItemsStep && currentStep.displayName == RHYS_TASK_NAME && event.message == "§e[NPC] §dRhys§f: §rThank you for the items!§r") {
currentStep.amountHavingHidden -= 10
}
}
Expand Down Expand Up @@ -365,23 +365,23 @@ object BingoNextStepHelper {

private fun rhys() {
val redstoneForRhys = PartialProgressItemsStep(
rhysTaskName,
RHYS_TASK_NAME,
"Redstone",
160 * 10,
mapOf("Redstone" to 1, "Enchanted Redstone" to 160)
)
redstoneForRhys requires IslandType.DEEP_CAVERNS.getStep()

val lapisForRhys = PartialProgressItemsStep(
rhysTaskName,
RHYS_TASK_NAME,
"Lapis Lazuli",
160 * 10,
mapOf("Lapis Lazuli" to 1, "Enchanted Lapis Lazuli" to 160)
)
lapisForRhys requires IslandType.DEEP_CAVERNS.getStep()

val coalForRhys = PartialProgressItemsStep(
rhysTaskName,
RHYS_TASK_NAME,
"Coal",
160 * 10,
mapOf("Coal" to 1, "Enchanted Coal" to 160)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ object UniqueGiftingOpportunitiesFeatures {

private fun isEnabled() = holdingGift

private val hasNotGiftedNametag = "§a§lꤥ"
private val hasGiftedNametag = "§c§lꤥ"
private const val HAS_NOT_GIFTED_NAMETAG = "§a§lꤥ"
private const val HAS_GIFTED_NAMETAG = "§c§lꤥ"

private fun analyzeArmorStand(entity: EntityArmorStand) {
if (!config.useArmorStandDetection) return
if (entity.name != hasGiftedNametag) return
if (entity.name != HAS_GIFTED_NAMETAG) return

val matchedPlayer = EntityUtils.getEntitiesNearby<EntityPlayer>(entity.getLorenzVec(), 2.0)
.singleOrNull { !it.isNPC() } ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark
import kotlin.time.Duration.Companion.seconds

object MythicRabbitPetWarning {
val mythicRabbit = "§dRabbit"
var lastCheck = SimpleTimeMark.farPast()
private const val MYTHIC_RABBIT_DISPLAY_NAME = "§dRabbit"
private var lastCheck = SimpleTimeMark.farPast()

fun check() {
if (!HoppityEggsManager.config.petWarning) return
Expand All @@ -21,7 +21,7 @@ object MythicRabbitPetWarning {
}
}

fun correctPet() = PetAPI.isCurrentPet(mythicRabbit)
fun correctPet() = PetAPI.isCurrentPet(MYTHIC_RABBIT_DISPLAY_NAME)

private fun warn() {
ChatUtils.chat("Use a §dMythic Rabbit Pet §efor more chocolate!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ object FishingProfitTracker {

private val MAGMA_FISH by lazy { "MAGMA_FISH".asInternalName() }

private val nameAll: CategoryName = "All"
private var currentCategory: CategoryName = nameAll
private const val NAME_ALL: CategoryName = "All"
private var currentCategory: CategoryName = NAME_ALL

private var itemCategories = mapOf<String, List<NEUInternalName>>()

Expand All @@ -110,7 +110,7 @@ object FishingProfitTracker {

private fun getCurrentCategories(data: Data): Map<CategoryName, Int> {
val map = mutableMapOf<CategoryName, Int>()
map[nameAll] = data.items.size
map[NAME_ALL] = data.items.size
for ((name, items) in itemCategories) {
val amount = items.count { it in data.items }
if (amount > 0) {
Expand Down Expand Up @@ -145,7 +145,7 @@ object FishingProfitTracker {
checkMissingItems(data)
val list = amounts.keys.toList()
if (currentCategory !in list) {
currentCategory = nameAll
currentCategory = NAME_ALL
}

if (tracker.isInventoryOpen()) {
Expand All @@ -160,7 +160,7 @@ object FishingProfitTracker {
)
}

val filter: (NEUInternalName) -> Boolean = if (currentCategory == nameAll) {
val filter: (NEUInternalName) -> Boolean = if (currentCategory == NAME_ALL) {
{ true }
} else {
val items = itemCategories[currentCategory]!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ object SeaCreatureTracker {
}
}

private val nameAll: CategoryName = "All"
private var currentCategory: CategoryName = nameAll
private const val NAME_ALL: CategoryName = "All"
private var currentCategory: CategoryName = NAME_ALL

private fun getCurrentCategories(data: Data): Map<CategoryName, Int> {
val map = mutableMapOf<CategoryName, Int>()
map[nameAll] = data.amount.size
map[NAME_ALL] = data.amount.size
for ((category, names) in SeaCreatureManager.allVariants) {
val amount = names.count { it in data.amount }
if (amount > 0) {
Expand Down Expand Up @@ -103,7 +103,7 @@ object SeaCreatureTracker {
val amounts = getCurrentCategories(data)
val list = amounts.keys.toList()
if (currentCategory !in list) {
currentCategory = nameAll
currentCategory = NAME_ALL
}

if (tracker.isInventoryOpen()) {
Expand All @@ -118,7 +118,7 @@ object SeaCreatureTracker {
)
}

return if (currentCategory == nameAll) {
return if (currentCategory == NAME_ALL) {
{ true }
} else filterCurrentCategory()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ object BeaconPower {

private var display = ""

private val BEACON_POWER_SLOT = 22
private val STATS_SLOT = 23
private const val BEACON_POWER_SLOT = 22
private const val STATS_SLOT = 23

@SubscribeEvent
fun onInventoryUpdate(event: InventoryUpdatedEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object CustomScoreboard {

private var display = emptyList<ScoreboardElementType>()
private var cache = emptyList<ScoreboardElementType>()
private val guiName = "Custom Scoreboard"
private const val GUI_NAME = "Custom Scoreboard"

// Cached scoreboard data, only update after no change for 300ms
var activeLines = emptyList<String>()
Expand Down Expand Up @@ -80,12 +80,12 @@ object CustomScoreboard {

RenderBackground.updatePosition(finalRenderable)

config.position.renderRenderable(finalRenderable, posLabel = guiName)
config.position.renderRenderable(finalRenderable, posLabel = GUI_NAME)
}

@SubscribeEvent
fun onGuiPositionMoved(event: GuiPositionMovedEvent) {
if (event.guiName == guiName) {
if (event.guiName == GUI_NAME) {
with(alignmentConfig) {
if (horizontalAlignment != HorizontalAlignment.DONT_ALIGN ||
verticalAlignment != VerticalAlignment.DONT_ALIGN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import org.intellij.lang.annotations.Language

val patternGroup = RepoPattern.group("skyblockguide.highlight")

private const val keyPrefixInventory = "inventory"
private const val keyPrefixCondition = "condition"
private const val KEY_PREFIX_INVENTORY = "inventory"
private const val KEY_PREFIX_CONDITION = "condition"

class SkyblockGuideHighlightFeature private constructor(
private val config: () -> Boolean,
Expand All @@ -44,8 +44,8 @@ class SkyblockGuideHighlightFeature private constructor(
onTooltip: (LorenzToolTipEvent) -> Unit = {},
) : this(
config,
patternGroup.pattern("$key.$keyPrefixInventory", inventory),
patternGroup.pattern("$key.$keyPrefixCondition", loreCondition),
patternGroup.pattern("$key.$KEY_PREFIX_INVENTORY", inventory),
patternGroup.pattern("$key.$KEY_PREFIX_CONDITION", loreCondition),
onSlotClicked,
onTooltip
)
Expand All @@ -59,7 +59,7 @@ class SkyblockGuideHighlightFeature private constructor(
onTooltip: (LorenzToolTipEvent) -> Unit = {},
) : this(
config,
patternGroup.pattern("$key.$keyPrefixInventory", inventory),
patternGroup.pattern("$key.$KEY_PREFIX_INVENTORY", inventory),
loreCondition,
onSlotClicked,
onTooltip
Expand Down Expand Up @@ -132,13 +132,13 @@ class SkyblockGuideHighlightFeature private constructor(
}

private val taskOnlyCompleteOncePattern =
patternGroup.pattern("$keyPrefixCondition.once", "§7§eThis task can only be completed once!")
private val xPattern = patternGroup.pattern("$keyPrefixCondition.x", "§c ?✖.*")
patternGroup.pattern("$KEY_PREFIX_CONDITION.once", "§7§eThis task can only be completed once!")
private val xPattern = patternGroup.pattern("$KEY_PREFIX_CONDITION.x", "§c ?✖.*")
private val totalProgressPattern =
patternGroup.pattern("$keyPrefixCondition.total", "§7Total Progress: §3\\d{1,2}(?:\\.\\d)?%")
patternGroup.pattern("$KEY_PREFIX_CONDITION.total", "§7Total Progress: §3\\d{1,2}(?:\\.\\d)?%")
private val categoryProgressPattern =
patternGroup.pattern(
"$keyPrefixCondition.category",
"$KEY_PREFIX_CONDITION.category",
"§7Progress to Complete Category: §6\\d{1,2}(?:\\.\\d)?%"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ object ExperimentationTableAPI {
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND || !inTable) return

val entity = EntityUtils.getEntities<EntityArmorStand>().find { it.hasSkullTexture(experimentationTableSkull) } ?: return
val entity = EntityUtils.getEntities<EntityArmorStand>().find { it.hasSkullTexture(EXPERIMENTATION_TABLE_SKULL) } ?: return
val vec = entity.getLorenzVec()
if (storage?.tablePos != vec) storage?.tablePos = vec
}

private val experimentationTableSkull =
// TODO: Add to repo
private const val EXPERIMENTATION_TABLE_SKULL =
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTUyOWF" +
"iYzg4MzA5NTNmNGQ5MWVkZmZmMjQ2OTVhOWY2Mjc1OGZhNGM1MWIyOWFjMjQ2YzM3NDllYWFlODliMyJ9fX0="

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ object UserLuckBreakdown {

private lateinit var mainLuckItem: ItemStack
private val mainLuckID = "ENDER_PEARL".asInternalName()
private val mainLuckName = "§a✴ SkyHanni User Luck"
private const val MAIN_LUCK_NAME = "§a✴ SkyHanni User Luck"

private lateinit var fillerItem: ItemStack
private var fillerID = "STAINED_GLASS_PANE".asInternalName()
private val fillerName = " "
private const val FILLER_NAME = " "

private lateinit var limboItem: ItemStack
private var limboID = "ENDER_PEARL".asInternalName()
private val limboName = "§a✴ Limbo Personal Best"
private const val LIMBO_NAME = "§a✴ Limbo Personal Best"

private lateinit var skillsItem: ItemStack
private var skillsID = "DIAMOND_SWORD".asInternalName()
private val skillsName = "§a✴ Category: Skills"
private const val SKILLS_NAME = "§a✴ Category: Skills"

private var showAllStats = true

Expand All @@ -63,7 +63,7 @@ object UserLuckBreakdown {
"§7Show all stats: §.(?<toggle>.*)",
)

private val luckTooltipString = "§5§o §a✴ SkyHanni User Luck §f"
private const val LUCK_TOOLTIP = "§5§o §a✴ SkyHanni User Luck §f"
private var inCustomBreakdown = false

private val validItemSlots = (10..53).filter { it !in listOf(17, 18, 26, 27, 35, 36) && it !in 44..53 }
Expand Down Expand Up @@ -178,7 +178,7 @@ object UserLuckBreakdown {
if (lastIndex == -1) return

val luckString = tryTruncateFloat(totalLuck)
event.toolTip.add(lastIndex, "$luckTooltipString$luckString")
event.toolTip.add(lastIndex, "$LUCK_TOOLTIP$luckString")
}

private fun statsBreakdownLoreTooltip(event: LorenzToolTipEvent, limboLuck: Float) {
Expand All @@ -205,7 +205,7 @@ object UserLuckBreakdown {
if (totalLuck == 0f) return

val luckString = tryTruncateFloat(totalLuck)
event.toolTip.add(lastIndex, "$luckTooltipString$luckString")
event.toolTip.add(lastIndex, "$LUCK_TOOLTIP$luckString")
}

private fun tryTruncateFloat(input: Float): String {
Expand Down Expand Up @@ -239,7 +239,7 @@ object UserLuckBreakdown {
private fun createItems() {
fillerItem = ItemUtils.createItemStack(
fillerID.getItemStack().item,
fillerName,
FILLER_NAME,
listOf(),
1,
15,
Expand All @@ -251,17 +251,17 @@ object UserLuckBreakdown {

mainLuckItem = ItemUtils.createItemStack(
mainLuckID.getItemStack().item,
"$mainLuckName §f${tryTruncateFloat(totalLuck)}",
"$MAIN_LUCK_NAME §f${tryTruncateFloat(totalLuck)}",
*createItemLore("mainMenu", totalLuck),
)
limboItem = ItemUtils.createItemStack(
limboID.getItemStack().item,
limboName,
LIMBO_NAME,
*createItemLore("limbo", limboLuck),
)
skillsItem = ItemUtils.createItemStack(
skillsID.getItemStack().item,
skillsName,
SKILLS_NAME,
*createItemLore("skills"),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object LimboPlaytime {
private val enabled get() = SkyHanniMod.feature.misc.showLimboTimeInPlaytimeDetailed

private val itemID = "ENDER_PEARL".asInternalName()
private val itemName = "§aLimbo"
private const val ITEM_NAME = "§aLimbo"
private lateinit var limboItem: ItemStack
private var lastCreateCooldown = SimpleTimeMark.farPast()

Expand All @@ -60,7 +60,7 @@ object LimboPlaytime {
lastCreateCooldown = SimpleTimeMark.now()
limboItem = ItemUtils.createItemStack(
itemID.getItemStack().item,
itemName,
ITEM_NAME,
*createItemLore()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object CruxTalismanDisplay {
".*(?<tier>§[0-9a-z][IV1-4-]+)\\s+(?<name>§[0-9a-z]\\w+)§[0-9a-z]:\\s*(?<progress>§[0-9a-z](?:§[0-9a-z])?MAXED|§[0-9a-z]\\d+§[0-9a-z]/§[0-9a-z]\\d+).*"
)

private val partialName = "CRUX_TALISMAN"
private const val PARTIAL_NAME = "CRUX_TALISMAN"
private var display = emptyList<List<Any>>()
private val displayLine = mutableListOf<Crux>()
private val bonusesLine = mutableListOf<String>()
Expand Down Expand Up @@ -91,7 +91,7 @@ object CruxTalismanDisplay {
fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
if (!event.repeatSeconds(2)) return
if (!InventoryUtils.getItemsInOwnInventory().any { it.getInternalName().startsWith(partialName) }) return
if (!InventoryUtils.getItemsInOwnInventory().any { it.getInternalName().startsWith(PARTIAL_NAME) }) return

displayLine.clear()
bonusesLine.clear()
Expand Down
Loading

0 comments on commit 8988f7d

Please sign in to comment.