aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-06 23:51:02 +0100
committerGitHub <noreply@github.com>2024-03-06 23:51:02 +0100
commit0a95a791eb57a546fb5421594abae740faf1dfdb (patch)
tree82bfc13c544a60d496bab081b66ddd73e07d62a3 /src/main/java/at/hannibal2/skyhanni/data
parent28430fe85115334fb06fb7e3cc36da819f08dace (diff)
downloadskyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.gz
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.bz2
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.zip
Internal Changes: Many small code cleanups (#1101)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt11
5 files changed, 24 insertions, 25 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
index 138158ccb..64eac452b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenComposterUpgradesData.kt
@@ -16,8 +16,7 @@ class GardenComposterUpgradesData {
if (!GardenAPI.inGarden()) return
if (event.inventoryName != "Composter Upgrades") return
for (item in event.inventoryItems.values) {
- val itemName = item.name ?: continue
- ComposterUpgrade.regex.matchMatcher(itemName) {
+ ComposterUpgrade.regex.matchMatcher(item.name) {
val name = group("name")
val level = group("level")?.romanToDecimalIfNecessary() ?: 0
val composterUpgrade = ComposterUpgrade.getByName(name)!!
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
index e38e3d075..c52878003 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestonesCommunityFix.kt
@@ -13,7 +13,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
@@ -79,8 +80,7 @@ object GardenCropMilestonesCommunityFix {
crop: CropType,
wrongData: MutableList<String>,
) {
- val name = stack.name ?: return
- val rawNumber = name.removeColor().replace(crop.cropName, "").trim()
+ val rawNumber = stack.name.removeColor().replace(crop.cropName, "").trim()
val realTier = if (rawNumber == "") 0 else rawNumber.romanToDecimalIfNecessary()
val lore = stack.getLore()
@@ -97,7 +97,7 @@ object GardenCropMilestonesCommunityFix {
) - GardenCropMilestones.getCropsForTier(realTier, crop)
// debug("guessNextMax: ${guessNextMax.addSeparators()}")
val nextMax = amountPattern.matchMatcher(next) {
- group("max").formatNumber()
+ group("max").formatLong()
} ?: return
// debug("nextMax real: ${nextMax.addSeparators()}")
if (nextMax != guessNextMax) {
@@ -108,7 +108,7 @@ object GardenCropMilestonesCommunityFix {
val guessTotalMax = GardenCropMilestones.getCropsForTier(46, crop)
// println("guessTotalMax: ${guessTotalMax.addSeparators()}")
val totalMax = amountPattern.matchMatcher(total) {
- group("max").formatNumber()
+ group("max").formatLong()
} ?: return
// println("totalMax real: ${totalMax.addSeparators()}")
val totalOffBy = guessTotalMax - totalMax
@@ -150,7 +150,7 @@ object GardenCropMilestonesCommunityFix {
val (rawCrop, tier, amount) = split
val crop = LorenzUtils.enumValueOf<CropType>(rawCrop)
- if (tryFix(crop, tier.toInt(), amount.formatNumber().toInt())) {
+ if (tryFix(crop, tier.toInt(), amount.formatInt())) {
fixed++
} else {
alreadyCorrect++
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
index c15299ab3..e6c810852 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropUpgrades.kt
@@ -31,7 +31,7 @@ class GardenCropUpgrades {
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
if (event.inventoryName != "Crop Upgrades") return
event.inventoryItems.forEach { (_, item) ->
- val crop = item.name?.removeColor()?.let { CropType.getByNameOrNull(it) } ?: return@forEach
+ val crop = CropType.getByNameOrNull(item.name.removeColor()) ?: return@forEach
val level = item.getLore()
.firstNotNullOfOrNull { tierPattern.matchEntire(it)?.groups?.get(1)?.value?.toIntOrNull() } ?: 0
crop.setUpgradeLevel(level)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
index 73ca7ca17..e42bdb8af 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
@@ -19,7 +19,8 @@ import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull
import at.hannibal2.skyhanni.utils.NEUItems.getPrice
-import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
+import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -99,12 +100,12 @@ object SackAPI {
}
private fun NEUInternalName.sackPrice(stored: String) = when (sackDisplayConfig.priceFrom) {
- PriceFrom.BAZAAR -> (getPrice(true) * stored.formatNumber()).toLong()
+ PriceFrom.BAZAAR -> (getPrice(true) * stored.formatLong()).toLong()
.let { if (it < 0) 0L else it }
PriceFrom.NPC -> try {
val npcPrice = getNpcPriceOrNull() ?: 0.0
- (npcPrice * stored.formatNumber()).toLong()
+ (npcPrice * stored.formatLong()).toLong()
} catch (e: Exception) {
0L
}
@@ -115,7 +116,7 @@ object SackAPI {
fun getSacksData(savingSacks: Boolean) {
if (savingSacks) sackData = ProfileStorageData.sackProfiles?.sackContents ?: return
for ((_, stack) in stackList) {
- val name = stack.name ?: continue
+ val name = stack.name
val lore = stack.getLore()
val gem = SackGemstone()
val rune = SackRune()
@@ -135,19 +136,19 @@ object SackAPI {
"Rough" -> {
gem.rough = stored
gem.roughPrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber())
+ if (savingSacks) setSackItem(internalName, stored.formatLong())
}
"Flawed" -> {
gem.flawed = stored
gem.flawedPrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber())
+ if (savingSacks) setSackItem(internalName, stored.formatLong())
}
"Fine" -> {
gem.fine = stored
gem.finePrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber())
+ if (savingSacks) setSackItem(internalName, stored.formatLong())
}
}
gemstoneItem[name] = gem
@@ -162,10 +163,10 @@ object SackAPI {
item.stored = stored
item.total = group("total")
- if (savingSacks) setSackItem(item.internalName, item.stored.formatNumber())
+ if (savingSacks) setSackItem(item.internalName, item.stored.formatLong())
item.price = if (isTrophySack) {
val filletPerTrophy = FishingAPI.getFilletPerTrophy(stack.getInternalName())
- val filletValue = filletPerTrophy * stored.formatNumber()
+ val filletValue = filletPerTrophy * stored.formatLong()
item.magmaFish = filletValue
"MAGMA_FISH".asInternalName().sackPrice(filletValue.toString())
} else {
@@ -227,7 +228,7 @@ object SackAPI {
val sackChanges = ArrayList<SackChange>()
for (match in sackChangeRegex.findAll(sackChangeText)) {
- val delta = match.groups[1]!!.value.replace(",", "").toInt()
+ val delta = match.groups[1]!!.value.formatInt()
val item = match.groups[2]!!.value
val sacks = match.groups[3]!!.value.split(", ")
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
index 78a44cda3..5a6c7c819 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt
@@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.SkillExpGainEvent
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.NumberUtil.formatLong
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -40,8 +40,8 @@ class SkillExperience {
actionBarPattern.matchMatcher(event.actionBar) {
val skill = group("skill").lowercase()
- val overflow = group("overflow").formatNumber()
- val neededForNextLevel = group("needed").formatNumber()
+ val overflow = group("overflow").formatLong()
+ val neededForNextLevel = group("needed").formatLong()
val nextLevel = getLevelForExpExactly(neededForNextLevel)
val baseExp = getExpForLevel(nextLevel - 1)
val totalExp = baseExp + overflow
@@ -59,7 +59,7 @@ class SkillExperience {
if (event.inventoryName != "Your Skills") return
for ((_, stack) in event.inventoryItems) {
- val name = stack.name?.removeColor() ?: continue
+ val name = stack.name.removeColor()
if (!name.contains(" ")) continue
val lore = stack.getLore()
@@ -76,8 +76,7 @@ class SkillExperience {
val level = split[1].romanToDecimal()
val baseExp = getExpForLevel(level)
inventoryPattern.matchMatcher(line) {
- val rawNumber = group("number")
- val overflow = rawNumber.formatNumber()
+ val overflow = group("number").formatLong()
val experience = baseExp + overflow
skillExp[skillName] = experience
}