aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-04-07 21:36:08 +1000
committerGitHub <noreply@github.com>2024-04-07 13:36:08 +0200
commitfcd404d862b4b051474898076fcc06b406d1ea91 (patch)
tree7659d22a41d1529a8d4ebaa62958bc0934596431 /src/main/java/at/hannibal2/skyhanni/utils
parent03c416202ccdec17cc46f6d07aae111fa977771a (diff)
downloadskyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.tar.gz
skyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.tar.bz2
skyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.zip
Backend: Remove a lot of deprecated code (#1371)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt10
5 files changed, 13 insertions, 56 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index d4c9b87a4..94558d949 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -76,25 +76,6 @@ object ItemUtils {
return list
}
- fun getItemsInInventoryWithSlots(withCursorItem: Boolean = false): Map<ItemStack, Int> {
- val map: LinkedHashMap<ItemStack, Int> = LinkedHashMap()
- val player = Minecraft.getMinecraft().thePlayer
- if (player == null) {
- ChatUtils.error("getItemsInInventoryWithSlots: player is null!")
- return map
- }
- for (slot in player.openContainer.inventorySlots) {
- if (slot.hasStack) {
- map[slot.stack] = slot.slotNumber
- }
- }
-
- if (withCursorItem && player.inventory != null && player.inventory.itemStack != null) {
- map[player.inventory.itemStack] = -1
- }
- return map
- }
-
fun hasAttributes(stack: ItemStack): Boolean {
if (stack.hasTagCompound()) {
val tagCompound = stack.tagCompound
@@ -306,10 +287,6 @@ object ItemUtils {
setStackDisplayName(value)
}
- @Deprecated("outdated", ReplaceWith("this.itemName"))
- val ItemStack.nameWithEnchantment: String?
- get() = itemName
-
fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName()?.equals("SKYBLOCK_MENU") ?: false
private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index df622503a..ef98c1264 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -132,12 +132,6 @@ object LorenzUtils {
fun formatPercentage(percentage: Double, format: String?): String =
DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%"
- @Deprecated("old code", ReplaceWith("i.addSeparators()"))
- fun formatInteger(i: Int): String = i.addSeparators()
-
- @Deprecated("old code", ReplaceWith("l.addSeparators()"))
- fun formatInteger(l: Long): String = l.addSeparators()
-
@Deprecated("old code", ReplaceWith("d.round(round).addSeparators()"))
fun formatDouble(d: Double, round: Int = 1): String {
return d.round(round).addSeparators()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 467afe55f..ce834e28c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -81,9 +81,6 @@ object NEUItems {
}
}
- @Deprecated("Use NEUInternalName rather than String", ReplaceWith("NEUInternalName.fromItemName(itemName)"))
- fun getRawInternalName(itemName: String): String = NEUInternalName.fromItemName(itemName).asString()
-
fun readAllNeuItems(): Map<String, NEUInternalName> {
allInternalNames.clear()
val map = mutableMapOf<String, NEUInternalName>()
@@ -138,21 +135,12 @@ object NEUItems {
return getNpcPriceOrNull()
}
- @Deprecated("Use NEUInternalName", ReplaceWith("internalName.asInternalName().getPrice(useSellingPrice)"))
- fun getPrice(internalName: String, useSellingPrice: Boolean = false): Double =
- internalName.asInternalName().getPrice(useSellingPrice)
-
fun NEUInternalName.getItemStackOrNull(): ItemStack? = ItemResolutionQuery(manager)
.withKnownInternalName(asString())
.resolveToItemStack()?.copy()
fun getItemStackOrNull(internalName: String) = internalName.asInternalName().getItemStackOrNull()
- // TODO remove
- @Deprecated("Use NEUInternalName rather than String", ReplaceWith("internalName.asInternalName().getItemStack()"))
- fun getItemStack(internalName: String): ItemStack =
- internalName.asInternalName().getItemStack()
-
fun NEUInternalName.getItemStack(): ItemStack =
getItemStackOrNull() ?: run {
getPriceOrNull() ?: return@run fallbackItem
@@ -210,7 +198,7 @@ object NEUItems {
private const val lightScaling = 2.47f // Adjust as needed
private const val g = 0.6f // Original Value taken from RenderHelper
private const val lightIntensity = lightScaling * g
- private val itemLightBuffer = GLAllocation.createDirectFloatBuffer(16);
+ private val itemLightBuffer = GLAllocation.createDirectFloatBuffer(16)
init {
itemLightBuffer.clear()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index 784b7e9ac..f9b1ceb7a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -3,15 +3,12 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.StringUtils.matches
import java.text.NumberFormat
-import java.util.Locale
import java.util.TreeMap
import kotlin.math.pow
import kotlin.math.roundToInt
object NumberUtil {
- @JvmField
- val nf: NumberFormat = NumberFormat.getInstance(Locale.US)
private val suffixes = TreeMap<Long, String>().apply {
this[1000L] = "k"
this[1000000L] = "M"
@@ -20,6 +17,7 @@ object NumberUtil {
this[1000000000000000L] = "P"
this[1000000000000000000L] = "E"
}
+
private val romanSymbols = TreeMap(
mapOf(
1000 to "M",
@@ -200,10 +198,6 @@ object NumberUtil {
return "${color.getChatColor()}$amount%"
}
- // TODO create new function formatLong, and eventually deprecate this function.
- @Deprecated("renamed", ReplaceWith("this.formatLong()"))
- fun String.formatNumber(): Long = formatLong()
-
fun String.formatDouble(): Double =
formatDoubleOrNull() ?: throw NumberFormatException("formatDouble failed for '$this'")
@@ -213,6 +207,9 @@ object NumberUtil {
fun String.formatInt(): Int =
formatDoubleOrNull()?.toInt() ?: throw NumberFormatException("formatInt failed for '$this'")
+ fun String.formatFloat(): Float =
+ formatDoubleOrNull()?.toFloat() ?: throw NumberFormatException("formatFloat failed for '$this'")
+
fun String.formatDoubleOrUserError(): Double? = formatDoubleOrNull() ?: run {
ChatUtils.userError("Not a valid number: '$this'")
return@run null
@@ -228,6 +225,11 @@ object NumberUtil {
return@run null
}
+ fun String.formatFloatOrUserError(): Float? = formatDoubleOrNull()?.toFloat() ?: run {
+ ChatUtils.userError("Not a valid number: '$this'")
+ return@run null
+ }
+
private fun String.formatDoubleOrNull(): Double? {
var text = lowercase().replace(",", "")
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
index b92cf5258..2aa542699 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
@@ -85,13 +85,9 @@ object TimeUtils {
val Duration.inWholeTicks: Int
get() = (inWholeMilliseconds / 50).toInt()
+ fun getDuration(string: String) = getMillis(string.replace("m", "m ").replace(" ", " ").trim())
- @Deprecated("Do no longer use long for time", ReplaceWith("TimeUtils.getDuration(string)"))
- fun getMillis(string: String) = getDuration(string).inWholeMilliseconds
-
- fun getDuration(string: String) = getMillis_(string.replace("m", "m ").replace(" ", " ").trim())
-
- private fun getMillis_(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) {
+ private fun getMillis(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) {
val years = group("y")?.toLong() ?: 0L
val days = group("d")?.toLong() ?: 0L
val hours = group("h")?.toLong() ?: 0L
@@ -131,7 +127,7 @@ object TimeUtils {
else -> {
throw RuntimeException("Invalid format: '$string'")
}
- }.toLong().toDuration(DurationUnit.MILLISECONDS)
+ }.milliseconds
}
fun SkyBlockTime.formatted(