Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend: Removing more Deprecated methods #3168

Merged
merged 9 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Storage {
@Expose
var savedMouseloweredSensitivity: Float = .5f

@Deprecated("")
@Deprecated("Moved into separate file")
@Expose
var knownFeatureToggles: Map<String, List<String>> = HashMap()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ object BingoCardTips {
*/
private val rewardPattern by patternGroup.pattern(
"reward",
"(§.)+Reward",
"(?:§.)+Reward",
)
private val contributionRewardsPattern by patternGroup.pattern(
"reward.contribution",
"(§.)+Contribution Rewards.*",
"(?:§.)+Contribution Rewards.*",
)

/**
* REGEX-TEST: §eRow #4
*/
private val rowNamePattern by patternGroup.pattern(
"row.name",
"(§.)+Row #.*",
"(?:§.)+Row #.*",
)

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.SoundUtils
Expand All @@ -29,7 +29,7 @@ object Year300RaffleEvent {
private var lastTimerReceived = SimpleTimeMark.farPast()
private var lastTimeAlerted = SimpleTimeMark.farPast()

private var overlay: List<Any>? = null
private var overlay: Renderable? = null

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
Expand All @@ -43,9 +43,9 @@ object Year300RaffleEvent {

@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
config.activeTimerPosition.renderSingleLineWithItems(
config.activeTimerPosition.renderRenderable(
overlay ?: return,
posLabel = "300þ Anniversary Active Timer"
posLabel = "300þ Anniversary Active Timer",
)
}

Expand All @@ -65,9 +65,11 @@ object Year300RaffleEvent {
SoundUtils.centuryActiveTimerAlert.playSound()
lastTimeAlerted = SimpleTimeMark.now()
}
overlay = listOf(
Renderable.itemStack(displayItem),
Renderable.string("§eTime Left: ${timeLeft.format()}")
overlay = Renderable.horizontalContainer(
listOf(
Renderable.itemStack(displayItem),
Renderable.string("§eTime Left: ${timeLeft.format()}"),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

Expand All @@ -22,14 +23,24 @@ object RngMeterInventory {

private val config get() = SkyHanniMod.feature.inventory.rngMeter

/**
* REGEX-TEST: §8Catacombs (F1)
*/
private val floorPattern by RepoPattern.pattern(
"rngmeterinventory.floor.name",
"(?:§.)*Catacombs \\((?<floor>.*)\\)",
)

@HandleEvent
fun onRenderItemTip(event: RenderItemTipEvent) {
val chestName = InventoryUtils.openInventoryName()

val stack = event.stack
if (config.floorName && chestName == "Catacombs RNG Meter") {
if (stack.name.removeColor() == "RNG Meter") {
event.stackTip = stack.getLore()[0].between("(", ")")
floorPattern.firstMatcher(stack.getLore()) {
event.stackTip = group("floor")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.between
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
Expand Down Expand Up @@ -52,6 +51,14 @@ object ItemAbilityCooldown {
"§aYou buffed yourself for §r§c\\+\\d+❁ Strength",
)

/**
* REGEX-TEST: §63,848/3,473❤ §b-24 Mana (§6Instant Transmission§b) §b2,507/2,507✎ Mana
*/
private val abilityUsePattern by patternGroup.pattern(
"abilityuse",
".*§b-\\d+ Mana \\(§6(?<type>.*)§b\\).*",
)

private var lastAbility = ""
private var items = mapOf<String, List<ItemText>>()
private var abilityItems = mapOf<ItemStack, MutableList<ItemAbility>>()
Expand Down Expand Up @@ -265,9 +272,8 @@ object ItemAbilityCooldown {
}

private fun handleOldAbilities(message: String) {
// TODO use regex
if (message.contains(" (§6") && message.contains("§b) ")) {
val name: String = message.between(" (§6", "§b) ")
abilityUsePattern.matchMatcher(message) {
val name = group("type")
if (name == lastAbility) return
lastAbility = name
for (ability in ItemAbility.entries) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ object LorenzUtils {
// TODO move into lorenz logger. then rewrite lorenz logger and use something different entirely
fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis())

// TODO replace all calls with regex
@Deprecated("Do not use complicated string operations", ReplaceWith("Regex"))
fun String.between(start: String, end: String): String = this.split(start, end)[1]

// TODO use derpy() on every use case
val EntityLivingBase.baseMaxHealth: Int
get() = this.getEntityAttribute(SharedMonsterAttributes.maxHealth).baseValue.toInt()
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/utils/NEUInternalName.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class NEUInternalName private constructor(private val internalName: String) {
val SKYBLOCK_COIN = "SKYBLOCK_COIN".toInternalName()
val WISP_POTION = "WISP_POTION".toInternalName()

@Deprecated("Name changed", ReplaceWith("this.toInternalName()"))
fun String.asInternalName() = toInternalName()

fun String.toInternalName(): NEUInternalName = uppercase().replace(" ", "_").let {
internalNameMap.getOrPut(it) { NEUInternalName(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class RecalculatingValue<T>(private val expireTime: Duration, private val calcul
private var currentValue: Any? = UNINITIALIZED_VALUE
private var lastAccessTime = SimpleTimeMark.farPast()

@Deprecated("use \"by RecalculatingValue\" instead")
fun getValue(): T {
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
if (lastAccessTime.passedSince() > expireTime) {
currentValue = calculation()
lastAccessTime = SimpleTimeMark.now()
Expand All @@ -19,9 +18,6 @@ class RecalculatingValue<T>(private val expireTime: Duration, private val calcul
return currentValue as T
}

@Suppress("DEPRECATION")
override fun getValue(thisRef: Any?, property: KProperty<*>): T = getValue()

companion object {
private val UNINITIALIZED_VALUE = Any()
}
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -646,25 +646,6 @@ object RenderUtils {
this.renderRenderablesDouble(render, extraSpace, posLabel, true)
}

/**
* Accepts a single line to print.
* This line is a list of things to print. Can print String or ItemStack objects.
*/
@Deprecated("use List<Renderable>", ReplaceWith(""))
fun Position.renderSingleLineWithItems(
list: List<Any?>,
posLabel: String,
) {
if (list.isEmpty()) return
renderRenderable(
Renderable.horizontalContainer(
list.mapNotNull { Renderable.fromAny(it) },
),
posLabel = posLabel,
)
// TODO Future write that better
}

private fun Position.renderLine(line: List<Any?>, offsetY: Int, itemScale: Double = NEUItems.itemFontSize): Int {
GlStateManager.pushMatrix()
val (x, y) = transform()
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ object StringUtils {

fun String.toCleanChatComponent(): IChatComponent = ChatComponentText(this)

@Deprecated("This function strips internal formatting changes like the color of the pluses of the MVP+ rank")
fun IChatComponent.cleanPlayerName(displayName: Boolean = false): IChatComponent =
formattedText.cleanPlayerName(displayName).applyFormattingFrom(this)

fun IChatComponent.contains(string: String): Boolean = formattedText.contains(string)

fun String.width(): Int = Minecraft.getMinecraft().fontRendererObj.getStringWidth(this)
Expand Down
5 changes: 1 addition & 4 deletions versions/1.8.9/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "goalcomplete", "§6§lBINGO GOAL COMPLETE! §r§e(?&lt;name&gt;.*)" )</ID>
<ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "hiddengoal", ".*§7§eThe next hint will unlock in (?&lt;time&gt;.*)" )</ID>
<ID>RepoPatternRegexTest:BingoCardReader.kt$BingoCardReader$by patternGroup.pattern( "percentage", " {2}§8Top §.(?&lt;percentage&gt;.*)%" )</ID>
<ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "(§.)+Contribution Rewards.*", )</ID>
<ID>RepoPatternRegexTest:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "(?:§.)+Contribution Rewards.*", )</ID>
<ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "collection", "Reach (?&lt;amount&gt;[0-9]+(?:,\\d+)*) (?&lt;name&gt;.*) Collection\\.", )</ID>
<ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.found", " *§r§5§l✦ CRYSTAL FOUND §r§7\\(.§r§7/5§r§7\\)", )</ID>
<ID>RepoPatternRegexTest:BingoNextStepHelper.kt$BingoNextStepHelper$by patternGroup.pattern( "crystal.obtain", "Obtain a (?&lt;name&gt;\\w+) Crystal in the Crystal Hollows\\.", )</ID>
Expand Down Expand Up @@ -242,9 +242,6 @@
<ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "string.playerchat", "(?&lt;important&gt;.*?)(?:§[f7r])*: .*", )</ID>
<ID>RepoPatternRegexTest:UtilsPatterns.kt$UtilsPatterns$by patternGroup.pattern( "time.amount", "(?:(?&lt;y&gt;\\d+) ?y(?:\\w* ?)?)?(?:(?&lt;d&gt;\\d+) ?d(?:\\w* ?)?)?(?:(?&lt;h&gt;\\d+) ?h(?:\\w* ?)?)?(?:(?&lt;m&gt;\\d+) ?m(?:\\w* ?)?)?(?:(?&lt;s&gt;\\d+) ?s(?:\\w* ?)?)?", )</ID>
<ID>RepoPatternRegexTest:VisitorListener.kt$VisitorListener$by RepoPattern.pattern( "garden.visitor.offersaccepted", "§7Offers Accepted: §a(?&lt;offersAccepted&gt;\\d+)", )</ID>
<ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward", "(§.)+Reward", )</ID>
<ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "reward.contribution", "(§.)+Contribution Rewards.*", )</ID>
<ID>RepoPatternUnnamedGroup:BingoCardTips.kt$BingoCardTips$by patternGroup.pattern( "row.name", "(§.)+Row #.*", )</ID>
<ID>ReturnCount:ArachneChatMessageHider.kt$ArachneChatMessageHider$private fun shouldHide(message: String): Boolean</ID>
<ID>ReturnCount:BingoNextStepHelper.kt$BingoNextStepHelper$private fun readDescription(description: String): NextStep?</ID>
<ID>ReturnCount:BroodmotherFeatures.kt$BroodmotherFeatures$private fun onStageUpdate()</ID>
Expand Down
Loading