aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-11 10:05:39 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-11 10:05:39 +0200
commite992f20bb98a4740f9069e931ec8ab4b1b1bce34 (patch)
tree101987b6add76f73f543bd1af195fc0afa34a452 /src/main/java/at
parent025e4d1f4799d980aa73a64ae75cfcded121a9f8 (diff)
downloadskyhanni-e992f20bb98a4740f9069e931ec8ab4b1b1bce34.tar.gz
skyhanni-e992f20bb98a4740f9069e931ec8ab4b1b1bce34.tar.bz2
skyhanni-e992f20bb98a4740f9069e931ec8ab4b1b1bce34.zip
Fixed int limit in sack api + sack display
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt38
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt8
2 files changed, 23 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
index c0604f5da..6ba933e40 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt
@@ -84,14 +84,14 @@ object SackAPI {
else null
}
- private fun NEUInternalName.sackPrice(stored: String) = when (sackDisplayConfig.priceFrom) {
- 0 -> (getPrice(true) * stored.formatNumber()).toInt().let { if (it < 0) 0 else it }
+ private fun NEUInternalName.sackPrice(stored: String): Long = when (sackDisplayConfig.priceFrom) {
+ 0 -> (getPrice(true) * stored.formatNumber()).toLong().let { if (it < 0) 0 else it }
1 -> try {
val npcPrice = getNpcPriceOrNull() ?: 0.0
- (npcPrice * stored.formatNumber()).toInt()
+ (npcPrice * stored.formatNumber()).toLong()
} catch (e: Exception) {
- 0
+ 0L
}
else -> 0
@@ -120,25 +120,25 @@ object SackAPI {
"Rough" -> {
gem.rough = stored
gem.roughPrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber().toInt())
+ if (savingSacks) setSackItem(internalName, stored.formatNumber())
}
"Flawed" -> {
gem.flawed = stored
gem.flawedPrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber().toInt())
+ if (savingSacks) setSackItem(internalName, stored.formatNumber())
}
"Fine" -> {
gem.fine = stored
gem.finePrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber().toInt())
+ if (savingSacks) setSackItem(internalName, stored.formatNumber())
}
"Flawless" -> {
gem.flawless = stored
gem.flawlessPrice = internalName.sackPrice(stored)
- if (savingSacks) setSackItem(internalName, stored.formatNumber().toInt())
+ if (savingSacks) setSackItem(internalName, stored.formatNumber())
}
}
gemstoneItem[name] = gem
@@ -152,13 +152,13 @@ object SackAPI {
item.colorCode = group("color")
item.stored = stored
item.total = group("total")
- if (savingSacks) setSackItem(item.internalName, item.stored.formatNumber().toInt())
+ if (savingSacks) setSackItem(item.internalName, item.stored.formatNumber())
item.price = if (isTrophySack) {
val trophyName =
internalName.asString().lowercase().substringBeforeLast("_").replace("_", "")
val filletValue =
TrophyFishManager.getInfoByName(trophyName)?.getFilletValue(sackRarity!!) ?: 0
- val storedNumber = stored.formatNumber().toInt()
+ val storedNumber = stored.formatNumber()
"MAGMA_FISH".asInternalName().sackPrice((filletValue * storedNumber).toString())
} else internalName.sackPrice(stored).coerceAtLeast(0)
@@ -248,7 +248,7 @@ object SackAPI {
if (sackData.containsKey(item.key)) {
val oldData = sackData[item.key]
var newAmount = oldData!!.amount + item.value
- var changed = newAmount - oldData.amount
+ var changed = (newAmount - oldData.amount).toInt()
if (newAmount < 0) {
newAmount = 0
changed = 0
@@ -256,7 +256,7 @@ object SackAPI {
sackData = sackData.editCopy { this[item.key] = SackItem(newAmount, changed, oldData.outdatedStatus) }
} else {
val newAmount = if (item.value > 0) item.value else 0
- sackData = sackData.editCopy { this[item.key] = SackItem(newAmount, newAmount, 2) }
+ sackData = sackData.editCopy { this[item.key] = SackItem(newAmount.toLong(), newAmount, 2) }
}
}
@@ -270,7 +270,7 @@ object SackAPI {
saveSackData()
}
- private fun setSackItem(item: NEUInternalName, amount: Int) {
+ private fun setSackItem(item: NEUInternalName, amount: Long) {
sackData = sackData.editCopy { this[item] = SackItem(amount, 0, 0) }
}
@@ -296,10 +296,10 @@ object SackAPI {
var flawed: String = "0",
var fine: String = "0",
var flawless: String = "0",
- var roughPrice: Int = 0,
- var flawedPrice: Int = 0,
- var finePrice: Int = 0,
- var flawlessPrice: Int = 0,
+ var roughPrice: Long = 0,
+ var flawedPrice: Long = 0,
+ var finePrice: Long = 0,
+ var flawlessPrice: Long = 0,
)
data class SackRune(
@@ -314,7 +314,7 @@ object SackAPI {
var colorCode: String = "",
var stored: String = "0",
var total: String = "0",
- var price: Int = 0,
+ var price: Long = 0,
)
}
@@ -322,7 +322,7 @@ object SackAPI {
// lastChange is set to 0 when value is refreshed in the sacks gui and when being set initially
// if it didn't change in an update the lastChange value will stay the same and not be set to 0
data class SackItem(
- @Expose val amount: Int,
+ @Expose val amount: Long,
@Expose val lastChange: Int,
@Expose val outdatedStatus: Int
)
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
index ad9a963e8..92c60bad5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt
@@ -37,7 +37,7 @@ object SackDisplay {
private fun drawDisplay(savingSacks: Boolean): List<List<Any>> {
val newDisplay = mutableListOf<List<Any>>()
- var totalPrice = 0
+ var totalPrice = 0L
var rendered = 0
SackAPI.getSacksData(savingSacks)
@@ -83,7 +83,7 @@ object SackDisplay {
)
if (colorCode == "§a") add(" §c§l(Full!)")
- if (config.showPrice && price != 0) add(" §7(§6${format(price)}§7)")
+ if (config.showPrice && price != 0L) add(" §7(§6${format(price)}§7)")
})
rendered++
}
@@ -137,7 +137,7 @@ object SackDisplay {
add(" ($rough-§a$flawed-§9$fine-§5$flawless)")
val price = (roughprice + flawedprice + fineprice + flawlessprice)
totalPrice += price
- if (config.showPrice && price != 0) add(" §7(§6${format(price)}§7)")
+ if (config.showPrice && price != 0L) add(" §7(§6${format(price)}§7)")
})
}
if (config.showPrice) newDisplay.addAsSingletonList("§eTotal price: §6${format(totalPrice)}")
@@ -145,7 +145,7 @@ object SackDisplay {
return newDisplay
}
- private fun format(price: Int) = if (config.priceFormat == 0) NumberUtil.format(price) else price.addSeparators()
+ private fun format(price: Long) = if (config.priceFormat == 0) NumberUtil.format(price) else price.addSeparators()
private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled