Skip to content

Commit

Permalink
Backend: Detekt VarCouldBeVal (#2949)
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Nov 19, 2024
1 parent 3c46cdc commit d6b0b38
Show file tree
Hide file tree
Showing 44 changed files with 71 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object MobDetection {

private val forceReset get() = !SkyHanniMod.feature.dev.mobDebug.enable

private var shouldClear: AtomicBoolean = AtomicBoolean(false)
private val shouldClear: AtomicBoolean = AtomicBoolean(false)

private fun mobDetectionReset() {
MobData.currentMobs.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object CompactBestiaryChatMessage {

private var inBestiary = false
private var bestiaryDescription = mutableListOf<String>()
private val bestiaryDescription = mutableListOf<String>()
private var acceptMoreDescription = true
var command = ""
private var blockedLines = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ object BestiaryData {
private var inInventory = false
private var isCategory = false
private var overallProgressEnabled = false
private var indexes = listOf(
10, 11, 12, 13, 14, 15, 16,
19, 20, 21, 22, 23, 24, 25,
28, 29, 30, 31, 32, 33, 34,
37, 38, 39, 40, 41, 42, 43
)
private val indexes = listOf(
10..16,
19..25,
28..34,
37..43,
).flatten()

@SubscribeEvent
fun onBackgroundDraw(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object FlareDisplay {

private val config get() = SkyHanniMod.feature.combat.flare
private var display = emptyList<Renderable>()
private var flares = mutableListOf<Flare>()
private val flares = mutableListOf<Flare>()

private var activeWarning = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class MobFinder {
// F2
private var floor2summons1 = false
private var floor2summons1SpawnTime = 0L
private var floor2summonsDiedOnce = mutableListOf<EntityOtherPlayerMP>()
private val floor2summonsDiedOnce = mutableListOf<EntityOtherPlayerMP>()
private var floor2secondPhase = false
private var floor2secondPhaseSpawnTime = 0L

// F3
private var floor3GuardianShield = false
private var floor3GuardianShieldSpawnTime = 0L
private var guardians = mutableListOf<EntityGuardian>()
private val guardians = mutableListOf<EntityGuardian>()
private var floor3Professor = false
private var floor3ProfessorSpawnTime = 0L
private var floor3ProfessorGuardianPrepare = false
Expand All @@ -76,7 +76,7 @@ class MobFinder {
// F6
private var floor6Giants = false
private var floor6GiantsSpawnTime = 0L
private var floor6GiantsSeparateDelay = mutableMapOf<UUID, Pair<Long, BossType>>()
private val floor6GiantsSeparateDelay = mutableMapOf<UUID, Pair<Long, BossType>>()
private var floor6Sadan = false
private var floor6SadanSpawnTime = 0L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlin.math.roundToInt

object GhostData {

private var session = mutableMapOf(
private val session = mutableMapOf(
Option.KILLS to 0.0,
Option.SORROWCOUNT to 0.0,
Option.VOLTACOUNT to 0.0,
Expand All @@ -15,7 +15,7 @@ object GhostData {
Option.TOTALDROPS to 0.0,
Option.SCAVENGERCOINS to 0.0,
Option.MAXKILLCOMBO to 0.0,
Option.SKILLXPGAINED to 0.0
Option.SKILLXPGAINED to 0.0,
)

// TODO repo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object CarnivalZombieShootout {
private data class Lamp(var pos: LorenzVec, var time: SimpleTimeMark)
private data class Updates(var zombie: SimpleTimeMark, var content: SimpleTimeMark)

private var lastUpdate = Updates(SimpleTimeMark.farPast(), SimpleTimeMark.farPast())
private val lastUpdate = Updates(SimpleTimeMark.farPast(), SimpleTimeMark.farPast())

private var content = Renderable.horizontalContainer(listOf())
private var drawZombies = mapOf<EntityZombie, ZombieType>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ object SoopyGuessBurrow {
private var guessPoint: LorenzVec? = null

private var lastSoundPoint: LorenzVec? = null
private var locations = mutableListOf<LorenzVec>()
private val locations = mutableListOf<LorenzVec>()

private var dingSlope = mutableListOf<Float>()
private val dingSlope = mutableListOf<Float>()

var distance: Double? = null
private var distance2: Double? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ object HoppityCollectionStats {
}
}

private var highlightMap = mutableMapOf<String, LorenzColor>()
private val highlightMap = mutableMapOf<String, LorenzColor>()

@SubscribeEvent
fun onInventoryClose(event: InventoryCloseEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object HoppityNpc {
ChocolateFactoryAPI.profileStorage?.hoppityShopYearOpened = value
}

private var slotsToHighlight = mutableSetOf<Int>()
private val slotsToHighlight = mutableSetOf<Int>()
private var inShop = false

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object SeaCreatureFeatures {
private val config get() = SkyHanniMod.feature.fishing.rareCatches
private val damageIndicatorConfig get() = SkyHanniMod.feature.combat.damageIndicator
private var lastRareCatch = SimpleTimeMark.farPast()
private var rareSeaCreatures = TimeLimitedSet<Mob>(6.minutes)
private var entityIds = TimeLimitedSet<Int>(6.minutes)
private val rareSeaCreatures = TimeLimitedSet<Mob>(6.minutes)
private val entityIds = TimeLimitedSet<Int>(6.minutes)

// TODO remove spawn event, check per tick if can see, cache if already warned about
@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlin.time.Duration.Companion.milliseconds
object ShowFishingItemName {

private val config get() = SkyHanniMod.feature.fishing.fishedItemName
private var itemsOnGround = TimeLimitedCache<EntityItem, String>(750.milliseconds)
private val itemsOnGround = TimeLimitedCache<EntityItem, String>(750.milliseconds)

// Textures taken from Skytils - moved to REPO
private val cheapCoins by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import kotlin.time.Duration.Companion.seconds
object TrophyFishDisplay {
private val config get() = SkyHanniMod.feature.fishing.trophyFishing.display

private var recentlyDroppedTrophies = TimeLimitedCache<NEUInternalName, TrophyRarity>(5.seconds)
private val recentlyDroppedTrophies = TimeLimitedCache<NEUInternalName, TrophyRarity>(5.seconds)
private val itemNameCache = mutableMapOf<String, NEUInternalName>()

private var display = emptyList<Renderable>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object FarmingWeightDisplay {
private var isLoadingLeaderboard = false
private var rankGoal = -1

private var nextPlayers = mutableListOf<UpcomingLeaderboardPlayer>()
private val nextPlayers = mutableListOf<UpcomingLeaderboardPlayer>()
private val nextPlayer get() = nextPlayers.firstOrNull()

private val eliteWeightApiGson by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ object GardenPlotIcon {
// TODO replace with enum
private var editMode = 0 // 0 = off, 1 = on, 2 = reset
private var lastClickedSlotId = -1
private var originalStack = mutableMapOf<Int, ItemStack>()
private var cachedStack = mutableMapOf<Int, ItemStack>()
private val originalStack = mutableMapOf<Int, ItemStack>()
private val cachedStack = mutableMapOf<Int, ItemStack>()
private val editStack = ItemStack(Items.wooden_axe)
private val whitelistedSlot =
listOf(2, 3, 4, 5, 6, 11, 12, 13, 14, 15, 20, 21, 23, 24, 29, 30, 31, 32, 33, 38, 39, 40, 41, 42)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object GardenPlotMenuHighlighting {

private val config get() = GardenAPI.config.plotMenuHighlighting

private var highlightedPlots = mutableMapOf<GardenPlotAPI.Plot, PlotStatusType>()
private val highlightedPlots = mutableMapOf<GardenPlotAPI.Plot, PlotStatusType>()

@SubscribeEvent
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object GardenVisitorColorNames {

private var visitorColors = mutableMapOf<String, String>() // name -> color code
private val visitorColors = mutableMapOf<String, String>() // name -> color code
var visitorItems = mutableMapOf<String, List<String>>()

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object QuiverWarning {
private val config get() = SkyHanniMod.feature.combat.quiverConfig

private var lastLowQuiverReminder = SimpleTimeMark.farPast()
private var arrowsInInstance = mutableSetOf<ArrowType>()
private val arrowsInInstance = mutableSetOf<ArrowType>()

@SubscribeEvent
fun onDungeonComplete(event: DungeonCompleteEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ object ItemPickupLog {
private val config get() = SkyHanniMod.feature.inventory.itemPickupLogConfig
private val coinIcon = "COIN_TALISMAN".toInternalName()

private var itemList = mutableMapOf<Int, Pair<ItemStack, Int>>()
private var itemsAddedToInventory = mutableMapOf<Int, PickupEntry>()
private var itemsRemovedFromInventory = mutableMapOf<Int, PickupEntry>()
private val itemList = mutableMapOf<Int, Pair<ItemStack, Int>>()
private val itemsAddedToInventory = mutableMapOf<Int, PickupEntry>()
private val itemsRemovedFromInventory = mutableMapOf<Int, PickupEntry>()
private var display: Renderable? = null
private var dirty = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object PowerStoneGuideFeatures {

private var missing = mutableMapOf<Int, NEUInternalName>()
private val missing = mutableMapOf<Int, NEUInternalName>()
private var inInventory = false

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ object ReforgeHelper {

private const val EXIT_BUTTON = 40

private var waitForChat = AtomicBoolean(false)
private val waitForChat = AtomicBoolean(false)

/** Gatekeeps instant double switches of the state */
private var waitDelay = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SkyblockGuideHighlightFeature private constructor(
private val objectList = mutableListOf<SkyblockGuideHighlightFeature>()

private var activeObject: SkyblockGuideHighlightFeature? = null
private var missing = mutableSetOf<Int>()
private val missing = mutableSetOf<Int>()

fun isEnabled() = LorenzUtils.inSkyBlock
fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import kotlin.time.Duration.Companion.seconds
object ChocolateFactoryStrayTracker {

private val config get() = ChocolateFactoryAPI.config
private var claimedStraysSlots = mutableListOf<Int>()
private val claimedStraysSlots = mutableListOf<Int>()

/**
* REGEX-TEST: §9Zero §d§lCAUGHT!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ object ExperimentsProfitTracker {

private val lastSplashes = mutableListOf<ItemStack>()
private var lastSplashTime = SimpleTimeMark.farPast()
private var lastBottlesInInventory = mutableMapOf<NEUInternalName, Int>()
private var currentBottlesInInventory = mutableMapOf<NEUInternalName, Int>()
private val lastBottlesInInventory = mutableMapOf<NEUInternalName, Int>()
private val currentBottlesInInventory = mutableMapOf<NEUInternalName, Int>()

class Data : ItemTrackerData() {
override fun resetItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ object TiaRelayHelper {

private var lastClickSlot = 0
private var lastClickTime = SimpleTimeMark.farPast()
private var sounds = mutableMapOf<Int, Sound>()
private val sounds = mutableMapOf<Int, Sound>()

private var resultDisplay = mutableMapOf<Int, Int>()
private val resultDisplay = mutableMapOf<Int, Int>()

@SubscribeEvent
fun onPlaySound(event: PlaySoundEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object CustomWardrobe {
private var activeScale: Int = 100
private var currentMaxSize: Pair<Int, Int>? = null
private var lastScreenSize: Pair<Int, Int>? = null
private var guiName = "Custom Wardrobe"
private const val GUI_NAME = "Custom Wardrobe"

@SubscribeEvent
fun onGuiRender(event: GuiContainerEvent.PreDraw) {
Expand Down Expand Up @@ -86,13 +86,13 @@ object CustomWardrobe {
)
val loadingPos =
Position(pos.rawX + (width - loadingRenderable.width) / 2, pos.rawY - loadingRenderable.height).setIgnoreCustomScale(true)
loadingPos.renderRenderable(loadingRenderable, posLabel = guiName, addToGuiManager = false)
loadingPos.renderRenderable(loadingRenderable, posLabel = GUI_NAME, addToGuiManager = false)
}

GlStateManager.pushMatrix()
GlStateManager.translate(0f, 0f, 100f)

pos.renderRenderable(renderable, posLabel = guiName, addToGuiManager = false)
pos.renderRenderable(renderable, posLabel = GUI_NAME, addToGuiManager = false)

if (EstimatedItemValue.config.enabled) {
GlStateManager.translate(0f, 0f, 400f)
Expand All @@ -112,7 +112,7 @@ object CustomWardrobe {
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).setIgnoreCustomScale(true).renderRenderable(renderable, posLabel = guiName, addToGuiManager = false)
Position(posX, posY).setIgnoreCustomScale(true).renderRenderable(renderable, posLabel = GUI_NAME, addToGuiManager = false)
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ object UserLuckBreakdown {
private const val MAIN_LUCK_NAME = "§a✴ SkyHanni User Luck"

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

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

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

private var showAllStats = true
Expand All @@ -69,7 +69,7 @@ object UserLuckBreakdown {
private val validItemSlots = (10..53).filter { it !in listOf(17, 18, 26, 27, 35, 36) && it !in 44..53 }
private val invalidItemSlots = (0..53).filter { it !in validItemSlots }

private var skillOverflowLuck = mutableMapOf<SkillType, Int>()
private val skillOverflowLuck = mutableMapOf<SkillType, Int>()

@SubscribeEvent
fun replaceItem(event: ReplaceItemEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ object AdvancedPlayerList {
return "$level $playerName ${suffix.trim()}"
}

private var randomOrderCache = TimeLimitedCache<String, Int>(20.minutes)
private val randomOrderCache = TimeLimitedCache<String, Int>(20.minutes)

private fun getRandomOrder(name: String) = randomOrderCache.getOrPut(name) {
(Random.nextDouble() * 500).toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ object EstimatedItemValueCalculator {
val price = getPriceOrCompositePriceForAttribute(attributeName, attr.second)
var priceColor = "§7"
val useless = isUselessAttribute(attributeName)
var nameColor = if (!useless) "§9" else "§7"
val nameColor = if (!useless) "§9" else "§7"
if (price != null) {
if (price > basePrice && !useless) {
subTotal += addAttributePrice(price, basePrice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ open class Enchant : Comparable<Enchant> {
var loreName = ""

@Expose
private var goodLevel = 0
private val goodLevel = 0

@Expose
private var maxLevel = 0
private val maxLevel = 0

private fun isNormal() = this is Normal
private fun isUltimate() = this is Ultimate
Expand Down Expand Up @@ -102,14 +102,14 @@ open class Enchant : Comparable<Enchant> {

class Stacking : Enchant() {
@Expose
private var nbtNum: String? = null
private val nbtNum: String? = null

@Expose
@Suppress("UnusedPrivateProperty")
private val statLabel: String? = null

@Expose
private var stackLevel: TreeSet<Int>? = null
private val stackLevel: TreeSet<Int>? = null

override fun toString() = "$nbtNum $stackLevel ${super.toString()}"
}
Expand Down
Loading

0 comments on commit d6b0b38

Please sign in to comment.