aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-04-10 17:18:35 +1000
committerGitHub <noreply@github.com>2024-04-10 09:18:35 +0200
commitfc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d (patch)
tree034630ba350c42a5cfd582a2cfdc88bb15fb68cc /src/main/java/at/hannibal2/skyhanni/utils
parent3397cc4474e3165865707182a5dcacf5bb4e68bd (diff)
downloadskyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.gz
skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.bz2
skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.zip
Backend: Remove some more deprecated functions and misc code cleanup (#1402)
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com> 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/ColorUtils.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt6
4 files changed, 8 insertions, 28 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt
index 3b1986d40..97a1342c1 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt
@@ -34,5 +34,3 @@ object ColorUtils {
fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff)
}
-
-
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c292abafd..bf258dab9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.test.TestBingo
import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull
-import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.StringUtils.capAtMinecraftLength
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID
@@ -133,11 +132,6 @@ object LorenzUtils {
fun formatPercentage(percentage: Double, format: String?): String =
DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%"
- @Deprecated("old code", ReplaceWith("d.round(round).addSeparators()"))
- fun formatDouble(d: Double, round: Int = 1): String {
- return d.round(round).addSeparators()
- }
-
fun consoleLog(text: String) {
SkyHanniMod.consoleLog(text)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 2330a6a1d..87a265c84 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -93,9 +93,6 @@ object NEUItems {
return map
}
- @Deprecated("moved", ReplaceWith("NEUInternalName.fromItemNameOrNull(itemName)"))
- fun getInternalNameOrNull(itemName: String): NEUInternalName? = NEUInternalName.fromItemNameOrNull(itemName)
-
fun getInternalName(itemStack: ItemStack): String? = ItemResolutionQuery(manager)
.withCurrentGuiContext()
.withItemStack(itemStack)
@@ -171,9 +168,9 @@ object NEUItems {
val translateX: Float
val translateY: Float
if (isSkull) {
- val skulldiff = ((scaleMultiplier) * 2.5).toFloat()
- translateX = x - skulldiff
- translateY = y - skulldiff
+ val skullDiff = ((scaleMultiplier) * 2.5).toFloat()
+ translateX = x - skullDiff
+ translateY = y - skullDiff
} else {
translateX = x
translateY = y
@@ -277,19 +274,10 @@ object NEUItems {
return result
}
- @Deprecated("Do not use strings as id", ReplaceWith("NEUItems.getMultiplier(internalName.asInternalName())"))
- fun getMultiplier(internalName: String, tryCount: Int = 0): Pair<String, Int> {
- val pair = getMultiplier(internalName.asInternalName(), tryCount)
- return Pair(pair.first.asString(), pair.second)
- }
-
fun getRecipes(internalName: NEUInternalName): Set<NeuRecipe> {
- if (recipesCache.contains(internalName)) {
- return recipesCache[internalName]!!
+ return recipesCache.getOrPut(internalName) {
+ manager.getRecipesFor(internalName.asString())
}
- val recipes = manager.getRecipesFor(internalName.asString())
- recipesCache[internalName] = recipes
- return recipes
}
fun NeuRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { ingredients }
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index f9b1ceb7a..e2df5349f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -170,11 +170,11 @@ object NumberUtil {
lastDecimal + decimal
}
- val pattern = "^[0-9]*$".toPattern()
- val formatPattern = "^[0-9,.]*[kmb]?$".toPattern()
+ private val numberPattern = "^[0-9]*$".toPattern()
+ private val formatPattern = "^[0-9,.]*[kmb]?$".toPattern()
fun String.isInt(): Boolean {
- return isNotEmpty() && pattern.matcher(this).matches()
+ return isNotEmpty() && numberPattern.matcher(this).matches()
}
fun String.isFormatNumber(): Boolean {