diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-06-14 13:36:06 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-06-14 13:36:06 +0200 |
commit | 9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1 (patch) | |
tree | 3db7b5a80d23714519ae45b8b5ee16e7c11f0da6 | |
parent | 2f285d2944a00dfd2dab9bca8da2055a1506193e (diff) | |
download | skyhanni-9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1.tar.gz skyhanni-9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1.tar.bz2 skyhanni-9f55fd15544e187491d78e2c5ecf2f2ed8ac76f1.zip |
creating and using Number.format()
49 files changed, 195 insertions, 184 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index 93870b119..64a2e9387 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.TimeLimitedCache @@ -46,7 +46,7 @@ object SlayerAPI { val maxPrice = npcPrice.coerceAtLeast(price) val totalPrice = maxPrice * amount - val format = NumberUtil.format(totalPrice) + val format = totalPrice.format() val priceFormat = " §7(§6$format coins§7)" "$amountFormat$displayName$priceFormat" to totalPrice diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/steps/CollectionStep.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/steps/CollectionStep.kt index d3f33a27d..9689481d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/steps/CollectionStep.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/nextstephelper/steps/CollectionStep.kt @@ -1,10 +1,10 @@ package at.hannibal2.skyhanni.features.bingo.card.nextstephelper.steps import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format class CollectionStep(collectionName: String, amountNeeded: Int) : - ProgressionStep(NumberUtil.format(amountNeeded) + " $collectionName Collection", amountNeeded.toLong()) { + ProgressionStep(amountNeeded.format() + " $collectionName Collection", amountNeeded.toLong()) { val internalName by lazy { NEUInternalName.fromItemName(if (collectionName == "Mushroom") "Red Mushroom" else collectionName) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt index 864f4926d..9eb6483a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/BestiaryData.kt @@ -17,8 +17,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addButton -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision @@ -477,7 +477,7 @@ object BestiaryData { } private fun Long.formatNumber(): String = when (config.numberFormat) { - BestiaryConfig.NumberFormatEntry.SHORT -> NumberUtil.format(this) + BestiaryConfig.NumberFormatEntry.SHORT -> this.format() BestiaryConfig.NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index 8632f9d03..8f759415a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -38,6 +38,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -231,8 +232,8 @@ object DamageIndicatorManager { val currentDamage = data.damageCounter.currentDamage val currentHealing = data.damageCounter.currentHealing if (currentDamage != 0L || currentHealing != 0L) { - val formatDamage = "§c" + NumberUtil.format(currentDamage) - val formatHealing = "§a+" + NumberUtil.format(currentHealing) + val formatDamage = "§c" + currentDamage.format() + val formatHealing = "§a+" + currentHealing.format() val finalResult = if (currentHealing == 0L) { formatDamage } else if (currentDamage == 0L) { @@ -250,8 +251,8 @@ object DamageIndicatorManager { diff += 9f } for (damage in data.damageCounter.oldDamages) { - val formatDamage = "§c" + NumberUtil.format(damage.damage) + "/s" - val formatHealing = "§a+" + NumberUtil.format(damage.healing) + "/s" + val formatDamage = "§c" + damage.damage.format() + "/s" + val formatHealing = "§a+" + damage.healing.format() + "/s" val finalResult = if (damage.healing == 0L) { formatDamage } else if (damage.damage == 0L) { @@ -378,7 +379,7 @@ object DamageIndicatorManager { entityData.healthText = customHealthText } else { val color = NumberUtil.percentageColor(health, maxHealth) - entityData.healthText = color.getChatColor() + NumberUtil.format(health) + entityData.healthText = color.getChatColor() + health.format() } entityData.timeLastTick = System.currentTimeMillis() return entity.uniqueID to entityData @@ -532,7 +533,7 @@ object DamageIndicatorManager { return NumberUtil.percentageColor( calcHealth.toLong(), calcMaxHealth.toLong(), - ).getChatColor() + NumberUtil.format(calcHealth) + ).getChatColor() + calcHealth.format() } private fun checkMagmaCube( @@ -551,7 +552,7 @@ object DamageIndicatorManager { else -> { val color = NumberUtil.percentageColor(health.toLong(), 10_000_000) entityData.namePrefix = "§a6/6" - return color.getChatColor() + NumberUtil.format(health) + return color.getChatColor() + health.format() } } + " §f" @@ -595,7 +596,7 @@ object DamageIndicatorManager { if (calcHealth == -1) return null val color = NumberUtil.percentageColor(calcHealth.toLong(), maxHealth.toLong()) - return color.getChatColor() + NumberUtil.format(calcHealth) + return color.getChatColor() + calcHealth.format() } private fun checkEnderSlayer( @@ -653,7 +654,7 @@ object DamageIndicatorManager { } var result = NumberUtil.percentageColor( calcHealth.toLong(), calcMaxHealth.toLong(), - ).getChatColor() + NumberUtil.format(calcHealth) + ).getChatColor() + calcHealth.format() if (!SkyHanniMod.feature.slayer.endermen.phaseDisplay) { result = "" diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index 2cac59010..b9d60f507 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -216,13 +216,13 @@ object EnderNodeTracker { addAsSingletonList("§5§lEnder Node Tracker") addAsSingletonList("§d${data.totalNodesMined.addSeparators()} Ender Nodes mined") - addAsSingletonList("§6${format(lootProfit.values.sum())} Coins made") + addAsSingletonList("§6${lootProfit.values.sum().format()} Coins made") addAsSingletonList(" ") addAsSingletonList("§b${data.totalEndermiteNests.addSeparators()} §cEndermite Nest") for (item in EnderNode.entries.subList(0, 11)) { val count = (data.lootCount[item] ?: 0).addSeparators() - val profit = format(lootProfit[item] ?: 0.0) + val profit = (lootProfit[item] ?: 0.0).format() addAsSingletonList("§b$count ${item.displayName} §7(§6$profit§7)") } addAsSingletonList(" ") @@ -230,16 +230,16 @@ object EnderNodeTracker { val totalEnderArmor = calculateEnderArmor(data) addAsSingletonList( "§b${totalEnderArmor.addSeparators()} §5Ender Armor " + - "§7(§6${format(totalEnderArmor * 10_000)}§7)" + "§7(§6${(totalEnderArmor * 10_000).format()}§7)" ) for (item in EnderNode.entries.subList(11, 16)) { val count = (data.lootCount[item] ?: 0).addSeparators() - val profit = format(lootProfit[item] ?: 0.0) + val profit = (lootProfit[item] ?: 0.0).format() addAsSingletonList("§b$count ${item.displayName} §7(§6$profit§7)") } // enderman pet rarities val (c, u, r, e, l) = EnderNode.entries.subList(16, 21).map { (data.lootCount[it] ?: 0).addSeparators() } - val profit = format(EnderNode.entries.subList(16, 21).sumOf { lootProfit[it] ?: 0.0 }) + val profit = EnderNode.entries.subList(16, 21).sumOf { lootProfit[it] ?: 0.0 }.format() addAsSingletonList("§f$c§7-§a$u§7-§9$r§7-§5$e§7-§6$l §fEnderman Pet §7(§6$profit§7)") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt index 61e03cf97..d5e632d49 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt @@ -4,8 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision import io.github.moulberry.notenoughupdates.util.Utils import java.io.FileReader @@ -132,7 +132,7 @@ object GhostUtil { if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill.addSeparators() else currentKill.addSeparators() ) .replace("%percentNumber%", percent(GhostCounter.bestiaryCurrentKill.toDouble())) - .replace("%killNeeded%", NumberUtil.format(killNeeded)) + .replace("%killNeeded%", killNeeded.format()) .replace("%currentLevel%", currentLevel) .replace("%nextLevel%", nextLevel) .replace("&", "§") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt index 9fe716328..ddd59ec0c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt @@ -11,8 +11,8 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -67,7 +67,7 @@ object DianaProfitTracker { override fun getCoinName(item: TrackedItem) = "§6Dug Out Coins" override fun getCoinDescription(item: TrackedItem): List<String> { - val burrowDugCoinsFormat = NumberUtil.format(item.totalAmount) + val burrowDugCoinsFormat = item.totalAmount.format() return listOf( "§7Digging treasures gave you", "§6$burrowDugCoinsFormat coins §7in total." diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index dc0c3b6ff..8050b3471 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggTyp import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.DelayedRun -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow @@ -60,7 +60,7 @@ object HoppityEggsCompactChat { val mealName = lastChatMeal?.coloredName ?: "" return if (duplicate) { - val format = lastDuplicateAmount?.let { NumberUtil.format(it) } ?: "?" + val format = lastDuplicateAmount?.let { it.format() } ?: "?" val timeFormatted = lastDuplicateAmount?.let { ChocolateFactoryAPI.timeUntilNeed(it).format(maxUnits = 2) } ?: "?" diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt index e01c0386d..7cfbaad60 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/jerry/frozentreasure/FrozenTreasureTracker.kt @@ -15,8 +15,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -154,7 +154,7 @@ object FrozenTreasureTracker { fun formatNumber(amount: Number): String { if (amount is Int) return amount.addSeparators() - if (amount is Long) return NumberUtil.format(amount) + if (amount is Long) return amount.format() return "$amount" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index c707e2209..98f2b999a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -23,8 +23,8 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -167,7 +167,7 @@ object CityProjectFeatures { }) { inInventory && !NEUItems.neuHasFocus() }) val price = internalName.getPrice(false) * amount - val format = NumberUtil.format(price) + val format = price.format() list.add(" §7(§6$format§7)") add(list) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt index a9dba3cc1..7f0fd1c59 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt @@ -18,8 +18,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SimpleTimeMark @@ -71,7 +71,7 @@ object FishingProfitTracker { override fun getCoinName(item: TrackedItem) = "§6Fished Coins" override fun getCoinDescription(item: TrackedItem): List<String> { - val mobKillCoinsFormat = NumberUtil.format(item.totalAmount) + val mobKillCoinsFormat = item.totalAmount.format() return listOf( "§7You fished up §6$mobKillCoinsFormat coins §7already." ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt index e0aaa5719..5920ec977 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishFillet.kt @@ -10,8 +10,8 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import org.lwjgl.input.Keyboard @@ -32,7 +32,7 @@ object TrophyFishFillet { val filletValue = info.getFilletValue(rarity) * multiplier // TODO use magma fish member val filletPrice = filletValue * "MAGMA_FISH".asInternalName().getPrice() - event.toolTip.add("§7Fillet: §8${filletValue.addSeparators()} Magmafish §7(§6${NumberUtil.format(filletPrice)}§7)") + event.toolTip.add("§7Fillet: §8${filletValue.addSeparators()} Magmafish §7(§6${filletPrice.format()}§7)") } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt index 191dc125a..90c413576 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AnitaMedalProfit.kt @@ -20,7 +20,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraft.item.ItemStack @@ -97,15 +97,15 @@ object AnitaMedalProfit { if (itemPrice < 0) return val profit = itemPrice - fullCost - val profitFormat = NumberUtil.format(profit) + val profitFormat = profit.format() val color = if (profit > 0) "§6" else "§c" val hover = listOf( itemName, "", - "§7Item price: §6${NumberUtil.format(itemPrice)} ", + "§7Item price: §6${itemPrice.format()} ", // TODO add more exact material cost breakdown - "§7Material cost: §6${NumberUtil.format(fullCost)} ", + "§7Material cost: §6${fullCost.format()} ", "§7Final profit: §6${profitFormat} ", ) table.add( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index 1067312de..ec4c42119 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -173,7 +173,7 @@ object GardenLevelDisplay { if (next && line.contains(" ")) { val progress = overflow / needForOnlyNextLvl val progressBar = StringUtils.progressBar(progress, 20) - iterator.set("$progressBar §e${overflow.addSeparators()}§6/§e${format(needForOnlyNextLvl)}") + iterator.set("$progressBar §e${overflow.addSeparators()}§6/§e${needForOnlyNextLvl.format()}") iterator.add("") iterator.add("§b§lOVERFLOW XP:") iterator.add("§7▸ ${overflowTotal.addSeparators()}") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt index 352c7137e..0d63b579b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.events.RenderInventoryItemTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -52,7 +52,7 @@ object ComposterInventoryNumbers { if (slotNumber == 46 || slotNumber == 52) { stack.getLore().matchFirst(valuePattern) { val having = group("having").removeColor().formatInt() - val havingFormat = NumberUtil.format(having) + val havingFormat = having.format() val total = group("total").removeColor() val color = if (slotNumber == 46) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt index b198b3e3a..f9fd08f1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterOverlay.kt @@ -38,8 +38,8 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems @@ -369,9 +369,9 @@ object ComposterOverlay { val totalCostPreview = (fuelPricePerPreview + organicMatterPricePerPreview) * timeMultiplierPreview val materialCostFormatPreview = - if (totalCost != totalCostPreview) " §c➜ §6" + NumberUtil.format(totalCostPreview) else "" + if (totalCost != totalCostPreview) " §c➜ §6" + totalCostPreview.format() else "" val materialCostFormat = - " §7Material costs per $timeText: §6${NumberUtil.format(totalCost)}$materialCostFormatPreview" + " §7Material costs per $timeText: §6${totalCost.format()}$materialCostFormatPreview" newList.addAsSingletonList(materialCostFormat) val priceCompost = COMPOST.getPrice() @@ -379,8 +379,8 @@ object ComposterOverlay { val profitPreview = ((priceCompost * multiDropFactorPreview) - (fuelPricePerPreview + organicMatterPricePerPreview)) * timeMultiplierPreview - val profitFormatPreview = if (profit != profitPreview) " §c➜ §6" + NumberUtil.format(profitPreview) else "" - val profitFormat = " §7Profit per $timeText: §6${NumberUtil.format(profit)}$profitFormatPreview" + val profitFormatPreview = if (profit != profitPreview) " §c➜ §6" + profitPreview.format() else "" + val profitFormat = " §7Profit per $timeText: §6${profit.format()}$profitFormatPreview" newList.addAsSingletonList(profitFormat) newList.addAsSingletonList("") @@ -465,7 +465,7 @@ object ComposterOverlay { itemsNeeded: Double, onClick: (NEUInternalName) -> Unit, ) { - val format = NumberUtil.format(totalPrice) + val format = totalPrice.format() val selected = if (internalName == currentOrganicMatterItem || internalName == currentFuelItem) "§n" else "" val rawItemName = itemName.removeColor() val name = itemName.substring(0, 2) + selected + rawItemName diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt index 99fb3f147..d48ffb1dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt @@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest @@ -68,14 +68,14 @@ object GardenComposterInventoryFeatures { val lowestBin = internalName.getPrice() val price = lowestBin * amount fullPrice += price - val format = NumberUtil.format(price) + val format = price.format() list[i] = list[i] + " §7(§6$format§7)" amountItems++ } } if (amountItems > 1) { - val format = NumberUtil.format(fullPrice) + val format = fullPrice.format() list[indexFullCost] = list[indexFullCost] + " §7(§6$format§7)" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index b149dedad..cc9ca42ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -34,8 +34,8 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NEUItems.getNpcPrice import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getReforgeName import kotlinx.coroutines.launch @@ -281,7 +281,7 @@ object CropMoneyDisplay { } private fun format(moneyPerHour: Double) = if (config.compactPrice) { - NumberUtil.format(moneyPerHour) + moneyPerHour.format() } else { moneyPerHour.toLong().addSeparators() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt index 2323b5e30..0c0990ced 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrade import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrades import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment import at.hannibal2.skyhanni.utils.guide.GuideScrollPage @@ -86,14 +86,14 @@ class UpgradePage(val crop0: () -> CropType?, sizeX: Int, sizeY: Int, paddingX: ) // TODO cleaner formating add( Renderable.string( - "§6" + costPerFF?.let { NumberUtil.format(it) }, + "§6" + costPerFF?.let { it.format() }, horizontalAlign = HorizontalAlignment.CENTER, verticalAlign = VerticalAlignment.CENTER ) ) add( Renderable.string( - "§6" + cost?.let { NumberUtil.format(it) }, + "§6" + cost?.let { it.format() }, horizontalAlign = HorizontalAlignment.CENTER, verticalAlign = VerticalAlignment.CENTER ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt index 42b8b5d35..fec669858 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/AnitaExtraFarmingFortune.kt @@ -11,8 +11,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.indexOfFirst import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -64,7 +64,7 @@ object AnitaExtraFarmingFortune { // TODO: maybe only show the price when playing classic // if (!LorenzUtils.noTradeMode) { val price = jacobTickets * "JACOBS_TICKET".asInternalName().getPrice() - event.toolTip.add(index, " §7Price: §6${NumberUtil.format(price)} coins") + event.toolTip.add(index, " §7Price: §6${price.format()} coins") // } event.toolTip.add(index, "§aJacob Tickets §8x${jacobTickets.addSeparators()}") event.toolTip.add(index, "§6Gold medals: §8x$goldMedals") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt index c9759cd58..38d24d967 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenCropMilestoneInventory.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.indexOfFirst import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.StringUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -77,7 +77,7 @@ object GardenCropMilestoneInventory { event.toolTip.add(index, " ") val progressBar = StringUtils.progressBar(percentage, 19) - event.toolTip.add(index, "$progressBar §e${counter.addSeparators()}§6/§e${NumberUtil.format(maxCounter)}") + event.toolTip.add(index, "$progressBar §e${counter.addSeparators()}§6/§e${maxCounter.format()}") event.toolTip.add(index, "§7Progress to Tier $maxTier: §e$percentageFormat") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt index 625216f85..d18746e67 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/SkyMartCopperPrice.kt @@ -16,8 +16,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables @@ -61,17 +61,17 @@ object SkyMartCopperPrice { val profit = itemPrice - (otherItemsPrice ?: 0.0) val factor = profit / copper - val perFormat = NumberUtil.format(factor) + val perFormat = factor.format() val itemName = item.itemName val hover = buildList { add(itemName) add("") - add("§7Item price: §6${NumberUtil.format(itemPrice)} ") + add("§7Item price: §6${itemPrice.format()} ") otherItemsPrice?.let { - add("§7Additional cost: §6${NumberUtil.format(it)} ") + add("§7Additional cost: §6${it.format()} ") } - add("§7Profit per purchase: §6${NumberUtil.format(profit)} ") + add("§7Profit per purchase: §6${profit.format()} ") add("") add("§7Copper amount: §c${copper.addSeparators()} ") add("§7Profit per copper: §6${perFormat} ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt index 157f05c30..c809541ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/plots/GardenNextPlotPrice.kt @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -40,7 +40,7 @@ object GardenNextPlotPrice { val (itemName, amount) = it val lowestBin = NEUInternalName.fromItemName(itemName).getPrice() val price = lowestBin * amount - val format = NumberUtil.format(price) + val format = price.format() list[i] = list[i] + " §7(§6$format§7)" } ?: run { ErrorManager.logErrorStateWithData( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt index e81486ecd..f2aabc22b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestParticleLine.kt @@ -7,6 +7,8 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenPlotAPI +import at.hannibal2.skyhanni.features.garden.GardenPlotAPI.isBarn +import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.LocationUtils @@ -96,6 +98,7 @@ object PestParticleLine { private fun showMiddle(event: LorenzRenderWorldEvent) { if (locations.size <= 0) return val plot = GardenPlotAPI.getCurrentPlot() ?: return + if (plot.isBarn()) return val middle = plot.middle.copy(y = LocationUtils.playerLocation().y) if (middle.distanceToPlayer() > 15) return @@ -104,6 +107,7 @@ object PestParticleLine { } private fun draw(event: LorenzRenderWorldEvent, list: List<ParticleLocation>) { + 3.formatNum() val color = LorenzColor.YELLOW.toColor() for ((prev, next) in list.asSequence().zipWithNext()) { // TODO time in config diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt index 62ddfb5f8..fc45950c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestProfitTracker.kt @@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -63,7 +63,7 @@ object PestProfitTracker { override fun getCoinName(item: TrackedItem) = "§6Pest Kill Coins" override fun getCoinDescription(item: TrackedItem): List<String> { - val pestsCoinsFormat = NumberUtil.format(item.totalAmount) + val pestsCoinsFormat = item.totalAmount.format() return listOf( "§7Killing pests gives you coins.", "§7You got §6$pestsCoinsFormat coins §7that way." diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt index bd344bb51..af3582630 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt @@ -19,8 +19,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems @@ -224,7 +224,7 @@ object GardenVisitorDropStatistics { fun format(amount: Number): String { if (amount is Int) return amount.addSeparators() - if (amount is Long) return NumberUtil.format(amount) + if (amount is Long) return amount.format() return "$amount" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt index 98230dfcf..eb4fd7bc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt @@ -47,8 +47,8 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.allIngredients import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.drawString @@ -204,7 +204,7 @@ object GardenVisitorFeatures { if (config.shoppingList.showPrice) { val price = internalName.getPrice() * amount totalPrice += price - val format = NumberUtil.format(price) + val format = price.format() list.add(" §7(§6$format§7)") } @@ -213,7 +213,7 @@ object GardenVisitorFeatures { add(list) } if (totalPrice > 0) { - val format = NumberUtil.format(totalPrice) + val format = totalPrice.format() this[0] = listOf("§7Visitor Shopping List: §7(§6$format§7)") } } @@ -401,14 +401,14 @@ object GardenVisitorFeatures { if (config.inventory.experiencePrice) { gardenExperiencePattern.matchMatcher(formattedLine) { val gardenExp = group("amount").formatInt() - val pricePerCopper = NumberUtil.format((totalPrice / gardenExp).toInt()) + val pricePerCopper = (totalPrice / gardenExp).toInt().format() finalList.set(index, "$formattedLine §7(§6$pricePerCopper §7per)") } } copperPattern.matchMatcher(formattedLine) { val copper = group("amount").formatInt() - val pricePerCopper = NumberUtil.format((totalPrice / copper).toInt()) + val pricePerCopper = (totalPrice / copper).toInt().format() visitor.pricePerCopper = (totalPrice / copper).toInt() visitor.totalPrice = totalPrice // Estimate could be changed to most value per copper item, instead of green thumb @@ -434,7 +434,7 @@ object GardenVisitorFeatures { val price = internalName.getPrice() * amount if (config.inventory.showPrice) { - val format = NumberUtil.format(price) + val format = price.format() finalList[index] = "$formattedLine §7(§6$format§7)" } if (!readingShoppingList) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt index 05041df18..848e38799 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorRewardWarning.kt @@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.drawBorder import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -124,10 +124,10 @@ object VisitorRewardWarning { } blockedToolTip.add("") - val pricePerCopper = visitor.pricePerCopper?.let { NumberUtil.format(it) } + val pricePerCopper = visitor.pricePerCopper?.let { it.format() } // TODO remove !! - best by creating new class LoadedVisitor without any nullable objects val loss = visitor.totalPrice!! - visitor.totalReward!! - val formattedLoss = NumberUtil.format(loss.absoluteValue) + val formattedLoss = loss.absoluteValue.format() blockedToolTip.add(blockDescription(blockReason, pricePerCopper, loss, formattedLoss)) blockedToolTip.add(" §7(Bypass by holding ${KeyboardManager.getKeyName(config.bypassKey)})") diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt index 8aae8fe55..6e6f9e609 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeResets @@ -34,7 +34,7 @@ object CustomScoreboardUtils { } internal fun Number.formatNum(): String = when (displayConfig.numberFormat) { - DisplayConfig.NumberFormat.SHORT -> NumberUtil.format(this) + DisplayConfig.NumberFormat.SHORT -> this.format() DisplayConfig.NumberFormat.LONG -> this.addSeparators() else -> "0" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt index 5825436b8..04041bba1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ChestValue.kt @@ -24,8 +24,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addButton import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -202,9 +202,8 @@ object ChestValue { private fun Double.formatPrice(): String { return when (config.formatType) { - NumberFormatEntry.SHORT -> if (this > 1_000_000_000) NumberUtil.format(this, true) else NumberUtil.format( - this - ) + NumberFormatEntry.SHORT -> if (this > 1_000_000_000) this.format(true) else this + .format() NumberFormatEntry.LONG -> this.addSeparators() else -> "0" diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 21defeadc..03778e510 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -39,7 +39,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary @@ -263,7 +263,7 @@ object ItemDisplayOverlayFeatures { if (BINGO_GOAL_RANK.isSelected() && chestName == "Bingo Card" && lore.lastOrNull() == "§aGOAL REACHED") { lore.matchFirst(bingoGoalRankPattern) { val rank = group("rank").formatLong() - if (rank < 10000) return "§6${NumberUtil.format(rank)}" + if (rank < 10000) return "§6${rank.format()}" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt index 5423aa396..a6a7e860b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/PowerStoneGuideFeatures.kt @@ -13,7 +13,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.highlight import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -71,7 +71,7 @@ object PowerStoneGuideFeatures { val internalName = missing[event.slot.slotNumber] ?: return val totalPrice = internalName.getPrice() * 9 - event.toolTip.add(5, "9x from Bazaar: §6${NumberUtil.format(totalPrice)}") + event.toolTip.add(5, "9x from Bazaar: §6${totalPrice.format()}") } fun isEnabled() = LorenzUtils.inSkyBlock && SkyHanniMod.feature.inventory.powerStoneGuide 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 6fb1caaa2..ea48f4136 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -22,8 +22,8 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -112,13 +112,13 @@ object SackDisplay { NumberFormatEntry.DEFAULT -> { addAlignedNumber("$colorCode${stored.addSeparators()}") addString("§7/") - addAlignedNumber("§b${NumberUtil.format(total)}") + addAlignedNumber("§b${total.format()}") } NumberFormatEntry.FORMATTED -> { - addAlignedNumber("$colorCode${NumberUtil.format(stored)}") + addAlignedNumber("$colorCode${stored.format()}") addString("§7/") - addAlignedNumber("§b${NumberUtil.format(total)}") + addAlignedNumber("§b${total.format()}") } NumberFormatEntry.UNFORMATTED -> { @@ -285,7 +285,7 @@ object SackDisplay { } private fun format(price: Long) = if (config.priceFormat == PriceFormatEntry.FORMATTED) { - NumberUtil.format(price) + price.format() } else { price.addSeparators() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt index 631ee8175..04ccdb18e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/BazaarBestSellMethod.kt @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -60,7 +60,7 @@ object BazaarBestSellMethod { val data = internalName.getBazaarDataOrError() val totalDiff = (data.sellOfferPrice - data.instantBuyPrice) * having - val result = NumberUtil.format(totalDiff.toInt()) + val result = totalDiff.toInt().format() val name = internalName.itemName return "$name§7 sell difference: §6$result coins" diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt index 009a972d0..55cfef5e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/bazaar/CraftMaterialsFromBazaar.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.PrimitiveItemStack import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -61,14 +61,14 @@ object CraftMaterialsFromBazaar { val neededMaterials = mutableListOf<PrimitiveItemStack>() display = buildList { val totalPrice = calculateTotalPrice(recipeMaterials, 1) - add(Renderable.string("§7Craft $recipeName §7(§6${NumberUtil.format(totalPrice)}§7)")) + add(Renderable.string("§7Craft $recipeName §7(§6${totalPrice.format()}§7)")) for (item in recipeMaterials) { val material = item.internalName val amount = item.amount var text = "§8${amount.addSeparators()}x " + material.itemName if (material.isBazaarItem()) { neededMaterials.add(item) - text += " §6${NumberUtil.format(material.getPrice() * amount)}" + text += " §6${(material.getPrice() * amount).format()}" } add(Renderable.string(text)) } @@ -108,7 +108,7 @@ object CraftMaterialsFromBazaar { for ((material, amount) in neededMaterials) { val priceMultiplier = amount * multiplier val text = "§8${priceMultiplier.addSeparators()}x " + material.itemName + - " §6${NumberUtil.format(material.getPrice() * priceMultiplier)}" + " §6${(material.getPrice() * priceMultiplier).format()}" add(Renderable.optionalLink(text, onClick = { BazaarApi.searchForBazaarItem(material, priceMultiplier) })) @@ -131,7 +131,7 @@ object CraftMaterialsFromBazaar { val isThisMultiply = m == multiplier val nameColor = if (isThisMultiply) "§a" else "§e" val priceColor = if (isThisMultiply) "§6" else "§7" - val price = priceColor + NumberUtil.format(calculateTotalPrice(neededMaterials, m)) + val price = priceColor + calculateTotalPrice(neededMaterials, m).format() val text = "${nameColor}Mulitply x$m $price" if (!isThisMultiply) { add( diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index 8d8ea540f..79a416c07 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -15,8 +15,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.million import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull @@ -118,19 +118,19 @@ object ChocolateShopPrice { val profit = product.itemPrice - (product.otherItemPrice ?: 0.0) val factor = (profit / product.chocolate) * multiplier - val perFormat = NumberUtil.format(factor) + val perFormat = factor.format() val hover = buildList { add(product.name) add("") - add("§7Item price: §6${NumberUtil.format(product.itemPrice)} ") + add("§7Item price: §6${product.itemPrice.format()} ") product.otherItemPrice?.let { - add("§7Additional cost: §6${NumberUtil.format(it)} ") + add("§7Additional cost: §6${it.format()} ") } - add("§7Profit per purchase: §6${NumberUtil.format(profit)} ") + add("§7Profit per purchase: §6${profit.format()} ") add("") - add("§7Chocolate amount: §c${NumberUtil.format(product.chocolate)} ") + add("§7Chocolate amount: §c${product.chocolate.format()} ") add("§7Profit per million chocolate: §6${perFormat} ") add("") val formattedTimeUntilGoal = ChocolateAmount.CURRENT.formattedTimeUntilGoal(product.chocolate) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt index 75515717e..876759e92 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/WardrobeAPI.kt @@ -11,7 +11,7 @@ import at.hannibal2.skyhanni.utils.DelayedRun import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -96,10 +96,10 @@ object WardrobeAPI { var totalPrice = 0.0 for (stack in slot.armor.filterNotNull()) { val price = EstimatedItemValueCalculator.getTotalPrice(stack) - add(" §7- ${stack.name}: §6${NumberUtil.format(price)}") + add(" §7- ${stack.name}: §6${price.format()}") totalPrice += price } - if (totalPrice != 0.0) add(" §aTotal Value: §6§l${NumberUtil.format(totalPrice)} coins") + if (totalPrice != 0.0) add(" §aTotal Value: §6§l${totalPrice.format()} coins") } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt index fb6e9054a..358f79efa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ExcavatorProfitTracker.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData @@ -105,13 +105,13 @@ object ExcavatorProfitTracker { val fossilDustPrice = pricePer * fossilDustGained addAsSingletonList( Renderable.hoverTips( - "§7${NumberUtil.format(fossilDustGained)}x §fFossil Dust§7: §6${NumberUtil.format(fossilDustPrice)}", + "§7${fossilDustGained.format()}x §fFossil Dust§7: §6${fossilDustPrice.format()}", listOf( - "§7You gained §6${NumberUtil.format(fossilDustPrice)} coins §7in total", + "§7You gained §6${fossilDustPrice.format()} coins §7in total", "§7for all §e$fossilDustGained §fFossil Dust", "§7you have collected.", "", - "§7Price Per Fossil Dust: §6${NumberUtil.format(pricePer)}" + "§7Price Per Fossil Dust: §6${pricePer.format()}" ) ) ) @@ -142,9 +142,9 @@ object ExcavatorProfitTracker { val name = StringUtils.pluralize(timesExcavated.toInt(), scrapItem.itemName) addAsSingletonList( Renderable.hoverTips( - "$name §7price: §c-${NumberUtil.format(scrapPrice)}", + "$name §7price: §c-${scrapPrice.format()}", listOf( - "§7You paid §c${NumberUtil.format(scrapPrice)} coins §7in total", + "§7You paid §c${scrapPrice.format()} coins §7in total", "§7for all §e$timesExcavated $name", "§7you have used." ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt index 161330da5..2884ffb98 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/GlacitePowderFeatures.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ItemUtils.cleanName -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -27,7 +27,7 @@ object GlacitePowderFeatures { glacitePowderPattern.matchMatcher(event.stack.cleanName()) { val powder = group("amount").formatLong() - event.stackTip = "§b${NumberUtil.format(powder)}" + event.stackTip = "§b${powder.format()}" } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt index ee2b5fab2..4ad79da5c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/ProfitPerExcavation.kt @@ -8,8 +8,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -29,7 +29,7 @@ object ProfitPerExcavation { val pricePer = it.getPrice() if (pricePer == -1.0) continue val profit = amount * pricePer - val text = "§eFound $name §8${amount.addSeparators()}x §7(§6${NumberUtil.format(profit)}§7)" + val text = "§eFound $name §8${amount.addSeparators()}x §7(§6${profit.format()}§7)" map[text] = profit totalProfit += profit } @@ -38,12 +38,12 @@ object ProfitPerExcavation { val scrapItem = FossilExcavatorAPI.scrapItem val scrapPrice = scrapItem.getPrice() - map["${scrapItem.itemName}: §c-${NumberUtil.format(scrapPrice)}"] = -scrapPrice + map["${scrapItem.itemName}: §c-${scrapPrice.format()}"] = -scrapPrice totalProfit -= scrapPrice val hover = map.sortedDesc().keys.toMutableList() val profitPrefix = if (totalProfit < 0) "§c" else "§6" - val totalMessage = "Profit this excavation: $profitPrefix${NumberUtil.format(totalProfit)}" + val totalMessage = "Profit this excavation: $profitPrefix${totalProfit.format()}" hover.add("") hover.add("§e$totalMessage") ChatUtils.hoverableChat(totalMessage, hover) diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt index 73771d354..417a531c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/mineshaft/MineshaftCorpseProfitPer.kt @@ -8,8 +8,8 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule @@ -29,7 +29,7 @@ object MineshaftCorpseProfitPer { val pricePer = it.getPrice() if (pricePer == -1.0) continue val profit = amount * pricePer - val text = "§eFound $name §8${amount.addSeparators()}x §7(§6${NumberUtil.format(profit)}§7)" + val text = "§eFound $name §8${amount.addSeparators()}x §7(§6${profit.format()}§7)" map[text] = profit totalProfit += profit } @@ -42,13 +42,13 @@ object MineshaftCorpseProfitPer { val keyName = it.itemName val price = it.getPrice() - map["$keyName: §c-${NumberUtil.format(price)}"] = -price + map["$keyName: §c-${price.format()}"] = -price totalProfit -= price } val hover = map.sortedDesc().keys.toMutableList() val profitPrefix = if (totalProfit < 0) "§c" else "§6" - val totalMessage = "Profit for $name Corpse§e: $profitPrefix${NumberUtil.format(totalProfit)}" + val totalMessage = "Profit for $name Corpse§e: $profitPrefix${totalProfit.format()}" hover.add("") hover.add("§e$totalMessage") ChatUtils.hoverableChat(totalMessage, hover) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt index 55f34be5c..5d2abee6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PetExpTooltip.kt @@ -12,8 +12,8 @@ import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.ReflectionUtils.makeAccessible import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getPetExp import at.hannibal2.skyhanni.utils.StringUtils @@ -54,7 +54,7 @@ object PetExpTooltip { val addLegendaryColor = if (isBelowLegendary) "§6" else "" event.toolTip.add( index, - "$progressBar §e${petExperience.addSeparators()}§6/§e${NumberUtil.format(maxXp)}" + "$progressBar §e${petExperience.addSeparators()}§6/§e${maxXp.format()}" ) event.toolTip.add(index, "§7Progress to ${addLegendaryColor}Level $maxLevel: §e$percentageFormat") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index a2ed65ee7..ce9304caa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -27,8 +27,8 @@ import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer import net.minecraft.client.Minecraft @@ -213,7 +213,7 @@ object EstimatedItemValue { val numberFormat = if (config.exactPrice) { totalPrice.roundToLong().addSeparators() } else { - NumberUtil.format(totalPrice) + totalPrice.format() } list.add("§aTotal: §6§l$numberFormat coins") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index be83ff917..663b089b5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull -import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getArmorDye @@ -121,7 +121,7 @@ object EstimatedItemValueCalculator { ) if (price != null) { val name = attributes[0].first.fixMending().allLettersFirstUppercase() - list.add("§7Attribute §9$name ${attributes[0].second}§7: (§6${NumberUtil.format(price)}§7)",) + list.add("§7Attribute §9$name ${attributes[0].second}§7: (§6${price.format()}§7)",) return price } } @@ -134,7 +134,7 @@ object EstimatedItemValueCalculator { if (comboPrice != null) { val useless = isUselessAttribute(combo) val color = if (comboPrice > basePrice && !useless) "§6" else "§7" - list.add("§7Attribute Combo: ($color${NumberUtil.format(comboPrice)}§7)") + list.add("§7Attribute Combo: ($color${comboPrice.format()}§7)") if (!useless) { subTotal += addAttributePrice(comboPrice, basePrice) } @@ -159,7 +159,7 @@ object EstimatedItemValueCalculator { list.add( " $nameColor${ displayName.allLettersFirstUppercase() - } ${attr.second}§7: $priceColor${if (price != null) NumberUtil.format(price) else "Unknown"}", + } ${attr.second}§7: $priceColor${if (price != null) price.format() else "Unknown"}", ) } // Adding 0.1 so that we always show the estimated item value overlay @@ -214,8 +214,8 @@ object EstimatedItemValueCalculator { val applyCost = getReforgeStoneApplyCost(stack, reforge.reforgeCosts, internalName) ?: return 0.0 list.add("§7Reforge: §9${reforge.reforgeName}") - list.add(" §7Stone $reforgeStoneName §7(§6" + NumberUtil.format(reforgeStonePrice) + "§7)") - list.add(" §7Apply cost: (§6" + NumberUtil.format(applyCost) + "§7)") + list.add(" §7Stone $reforgeStoneName §7(§6" + reforgeStonePrice.format() + "§7)") + list.add(" §7Apply cost: (§6" + applyCost.format() + "§7)") return reforgeStonePrice + applyCost } @@ -264,7 +264,7 @@ object EstimatedItemValueCalculator { if (!stack.isRecombobulated()) return 0.0 val price = "RECOMBOBULATOR_3000".asInternalName().getPrice() - list.add("§7Recombobulated: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Recombobulated: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -272,7 +272,7 @@ object EstimatedItemValueCalculator { if (!stack.hasJalapenoBook()) return 0.0 val price = "JALAPENO_BOOK".asInternalName().getPrice() - list.add("§7Jalapeno Book: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Jalapeno Book: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -282,7 +282,7 @@ object EstimatedItemValueCalculator { val wtfHardcodedConduit = "ETHERWARP_CONDUIT".asInternalName() val wtfHardcodedMerger = "ETHERWARP_MERGER".asInternalName() val price = wtfHardcodedConduit.getPrice() + wtfHardcodedMerger.getPrice() - list.add("§7Etherwarp: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Etherwarp: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -290,7 +290,7 @@ object EstimatedItemValueCalculator { if (!stack.hasWoodSingularity()) return 0.0 val price = "WOOD_SINGULARITY".asInternalName().getPrice() - list.add("§7Wood Singularity: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Wood Singularity: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -298,7 +298,7 @@ object EstimatedItemValueCalculator { if (!stack.hasArtOfWar()) return 0.0 val price = "THE_ART_OF_WAR".asInternalName().getPrice() - list.add("§7The Art of War: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7The Art of War: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -306,7 +306,7 @@ object EstimatedItemValueCalculator { if (!stack.hasBookOfStats()) return 0.0 val price = "BOOK_OF_STATS".asInternalName().getPrice() - list.add("§7Book of Stats: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Book of Stats: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -315,7 +315,7 @@ object EstimatedItemValueCalculator { if (!stack.hasArtOfPeace()) return 0.0 val price = "THE_ART_OF_PEACE".asInternalName().getPrice() - list.add("§7The Art Of Peace: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7The Art Of Peace: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -336,13 +336,13 @@ object EstimatedItemValueCalculator { val wtfHardcodedHpb = "HOT_POTATO_BOOK".asInternalName() val hpbPrice = wtfHardcodedHpb.getPrice() * hpb - list.add("§7HPB's: §e$hpb§7/§e10 §7(§6" + NumberUtil.format(hpbPrice) + "§7)") + list.add("§7HPB's: §e$hpb§7/§e10 §7(§6" + hpbPrice.format() + "§7)") totalPrice += hpbPrice if (fuming > 0) { val wtfHardcodedFuming = "FUMING_POTATO_BOOK".asInternalName() val fumingPrice = wtfHardcodedFuming.getPrice() * fuming - list.add("§7Fuming: §e$fuming§7/§e5 §7(§6" + NumberUtil.format(fumingPrice) + "§7)") + list.add("§7Fuming: §e$fuming§7/§e5 §7(§6" + fumingPrice.format() + "§7)") totalPrice += fumingPrice } @@ -354,7 +354,7 @@ object EstimatedItemValueCalculator { val wtfHardcodedDumbFarmers = "FARMING_FOR_DUMMIES".asInternalName() val price = wtfHardcodedDumbFarmers.getPrice() * count - list.add("§7Farming for Dummies: §e$count§7/§e5 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Farming for Dummies: §e$count§7/§e5 §7(§6" + price.format() + "§7)") return price } @@ -363,7 +363,7 @@ object EstimatedItemValueCalculator { val broDilloMiningSoBad = "POLARVOID_BOOK".asInternalName() val price = broDilloMiningSoBad.getPrice() * count - list.add("§7Polarvoid: §e$count§7/§e5 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Polarvoid: §e$count§7/§e5 §7(§6" + price.format() + "§7)") return price } @@ -372,7 +372,7 @@ object EstimatedItemValueCalculator { val tfHardcodedItemAgain = "BOOKWORM_BOOK".asInternalName() val price = tfHardcodedItemAgain.getPrice() * count - list.add("§7Bookworm's Favorite Book: §e$count§7/§e5 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Bookworm's Favorite Book: §e$count§7/§e5 §7(§6" + price.format() + "§7)") return price } @@ -384,7 +384,7 @@ object EstimatedItemValueCalculator { val wtfHardcodedSilex = "SIL_EX".asInternalName() val price = wtfHardcodedSilex.getPrice() * tier - list.add("§7Silex: §e$tier§7/§e$maxTier §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Silex: §e$tier§7/§e$maxTier §7(§6" + price.format() + "§7)") return price } @@ -393,7 +393,7 @@ object EstimatedItemValueCalculator { val wtfHardcodedTuner = "TRANSMISSION_TUNER".asInternalName() val price = wtfHardcodedTuner.getPrice() * count - list.add("§7Transmission Tuners: §e$count§7/§e4 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Transmission Tuners: §e$count§7/§e4 §7(§6" + price.format() + "§7)") return price } @@ -402,7 +402,7 @@ object EstimatedItemValueCalculator { val wtfHardcodedTuner = "MANA_DISINTEGRATOR".asInternalName() val price = wtfHardcodedTuner.getPrice() * count - list.add("§7Mana Disintegrators: §e$count§7/§e10 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Mana Disintegrators: §e$count§7/§e10 §7(§6" + price.format() + "§7)") return price } @@ -428,7 +428,7 @@ object EstimatedItemValueCalculator { } } - list.add("§7Master Stars: §e$masterStars§7/§e5 §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Master Stars: §e$masterStars§7/§e5 §7(§6" + price.format() + "§7)") return price } @@ -442,11 +442,11 @@ object EstimatedItemValueCalculator { val price = internalName.getPriceOrNull() ?: continue totalPrice += price - val format = NumberUtil.format(price) + val format = price.format() map[" $name §7(§6$format§7)"] = price } if (map.isNotEmpty()) { - list.add("§7Drill upgrades: §6" + NumberUtil.format(totalPrice)) + list.add("§7Drill upgrades: §6" + totalPrice.format()) list += map.sortedDesc().keys } return totalPrice @@ -457,7 +457,7 @@ object EstimatedItemValueCalculator { val price = internalName.getPrice() val name = internalName.itemNameWithoutColor - list.add("§7$name: §a§l✔ §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7$name: §a§l✔ §7(§6" + price.format() + "§7)") return price } @@ -481,7 +481,7 @@ object EstimatedItemValueCalculator { val name = internalName.getNameOrRepoError() val displayname = name ?: "§c${internalName.asString()}" val color = if (shouldIgnorePrice) "§7" else "§6" - list.add("§7$label: $displayname §7($color" + NumberUtil.format(price) + "§7)") + list.add("§7$label: $displayname §7($color" + price.format() + "§7)") if (name == null) { list.add(" §8(Not yet in NEU Repo)") } @@ -496,7 +496,7 @@ object EstimatedItemValueCalculator { val price = internalName.getPrice() val name = internalName.itemName - list.add("§7Enrichment: $name §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Enrichment: $name §7(§6" + price.format() + "§7)") return price } @@ -519,11 +519,11 @@ object EstimatedItemValueCalculator { val price = internalName.getPriceOrNull() ?: continue totalPrice += price - val format = NumberUtil.format(price) + val format = price.format() map[" $name §7(§6$format§7)"] = price } if (map.isNotEmpty()) { - list.add("§7Ability Scrolls: §6" + NumberUtil.format(totalPrice)) + list.add("§7Ability Scrolls: §6" + totalPrice.format()) list += map.sortedDesc().keys } return totalPrice @@ -542,7 +542,7 @@ object EstimatedItemValueCalculator { return 0.0 } - list.add("§7Base item: $name §7(§6" + NumberUtil.format(price) + "§7)") + list.add("§7Base item: $name §7(§6" + price.format() + "§7)") return price } @@ -615,14 +615,14 @@ object EstimatedItemValueCalculator { val price = singlePrice * multiplier totalPrice += price - val format = NumberUtil.format(price) + val format = price.format() map[" $name §7(§6$format§7)"] = price } val enchantmentsCap: Int = config.enchantmentsCap.get() if (map.isNotEmpty()) { - list.add("§7Enchantments: §6" + NumberUtil.format(totalPrice)) + list.add("§7Enchantments: §6" + totalPrice.format()) var i = 0 for (entry in map.sortedDesc().keys) { if (i == enchantmentsCap) { @@ -655,7 +655,7 @@ object EstimatedItemValueCalculator { val price = internalName.getPrice() * amount totalPrice += price - val format = NumberUtil.format(price) + val format = price.format() val text = if (amount == 1) { " $name §7(§6$format§7)" @@ -666,7 +666,7 @@ object EstimatedItemValueCalculator { } if (priceMap.isNotEmpty()) { - list.add("§7Gemstones: §6" + NumberUtil.format(totalPrice)) + list.add("§7Gemstones: §6" + totalPrice.format()) list += priceMap.sortedDesc().keys } return totalPrice @@ -714,17 +714,17 @@ object EstimatedItemValueCalculator { val splitSlot = slot.key.split("_") // eg. SAPPHIRE_1 val colorCode = SkyBlockItemModifierUtils.GemstoneSlotType.getColorCode(splitSlot[0]) - val formattedPrice = NumberUtil.format(totalPrice - previousTotal) + val formattedPrice = (totalPrice - previousTotal).format() // eg. SAPPHIRE_1 -> Sapphire Slot 2 val displayName = splitSlot[0].lowercase(Locale.ENGLISH).replaceFirstChar(Char::uppercase) + " Slot" + - // If the slot index is 0, we don't need to specify - if (splitSlot[1] != "0") " " + (splitSlot[1].toInt() + 1) else "" + // If the slot index is 0, we don't need to specify + if (splitSlot[1] != "0") " " + (splitSlot[1].toInt() + 1) else "" priceMap[" §$colorCode $displayName §7(§6$formattedPrice§7)"] = totalPrice - previousTotal } - list.add("§7Gemstone Slot Unlock Cost: §6" + NumberUtil.format(totalPrice)) + list.add("§7Gemstone Slot Unlock Cost: §6" + totalPrice.format()) list += priceMap.sortedDesc().keys return totalPrice } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt index df91766cc..f8d8bc3ef 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/ShowMotesNpcSellPrice.kt @@ -19,8 +19,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getItemStack -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -180,7 +180,7 @@ object ShowMotesNpcSellPrice { } private fun Double.formatPrice(): String = when (config.inventoryValue.formatType) { - NumberFormatEntry.SHORT -> NumberUtil.format(this) + NumberFormatEntry.SHORT -> this.format() NumberFormatEntry.LONG -> this.addSeparators() else -> "0" } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt index 36f63647f..ee0bed48e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt @@ -18,8 +18,8 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -75,7 +75,7 @@ object SlayerProfitTracker { override fun getCoinName(item: TrackedItem) = "§6Mob Kill Coins" override fun getCoinDescription(item: TrackedItem): List<String> { - val mobKillCoinsFormat = NumberUtil.format(item.totalAmount) + val mobKillCoinsFormat = item.totalAmount.format() return listOf( "§7Killing mobs gives you coins (more with scavenger).", "§7You got §6$mobKillCoinsFormat coins §7that way." @@ -176,7 +176,7 @@ object SlayerProfitTracker { var profit = tracker.drawItems(data, { true }, this) val slayerSpawnCost = data.slayerSpawnCost if (slayerSpawnCost != 0L) { - val mobKillCoinsFormat = NumberUtil.format(slayerSpawnCost) + val mobKillCoinsFormat = slayerSpawnCost.format() addAsSingletonList( Renderable.hoverTips( " §7Slayer Spawn Costs: §c$mobKillCoinsFormat", @@ -200,7 +200,7 @@ object SlayerProfitTracker { } val coinFormat: (ItemTrackerData.TrackedItem) -> Pair<String, List<String>> = { item -> - val mobKillCoinsFormat = NumberUtil.format(item.totalAmount) + val mobKillCoinsFormat = item.totalAmount.format() val text = " §6Mob kill coins§7: §6$mobKillCoinsFormat" val lore = listOf( "§7Killing mobs gives you coins (more with scavenger)", diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index 8194e7b6d..d232189ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.getLorenzVec @@ -147,8 +148,8 @@ object SummoningMobManager { val maxHealth = entityLiving.baseMaxHealth val color = NumberUtil.percentageColor(currentHealth.toLong(), maxHealth.toLong()).getChatColor() - val currentFormat = NumberUtil.format(currentHealth) - val maxFormat = NumberUtil.format(maxHealth) + val currentFormat = currentHealth.format() + val maxFormat = maxHealth.format() summoningMob.lastDisplayName = "§a$name $color$currentFormat/$maxFormat" } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 742bc3654..c5ce8cea0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -36,19 +36,25 @@ object NumberUtil { ) ) + @Deprecated("outdated", ReplaceWith("value.format(preciseBillions)")) + fun format(value: Number, preciseBillions: Boolean = false): String = value.format(preciseBillions) + + // 1234 -> 1.2k + fun Number.format(preciseBillions: Boolean = false): String { + return compactFormat(this, preciseBillions) + } + /** * This code was modified and taken under CC BY-SA 3.0 license * @link https://stackoverflow.com/a/30661479 * @author assylias */ - - @JvmStatic - fun format(value: Number, preciseBillions: Boolean = false): String { + private fun compactFormat(value: Number, preciseBillions: Boolean = false): String { @Suppress("NAME_SHADOWING") val value = value.toLong() // Long.MIN_VALUE == -Long.MIN_VALUE, so we need an adjustment here - if (value == Long.MIN_VALUE) return format(Long.MIN_VALUE + 1, preciseBillions) - if (value < 0) return "-" + format(-value, preciseBillions) + if (value == Long.MIN_VALUE) return compactFormat(Long.MIN_VALUE + 1, preciseBillions) + if (value < 0) return "-" + compactFormat(-value, preciseBillions) if (value < 1000) return value.toString() // deal with small numbers diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 57595c1c1..2e8b990a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -13,8 +13,8 @@ import at.hannibal2.skyhanni.utils.KeyboardManager import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.format import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.renderables.Renderable import kotlin.time.Duration.Companion.seconds @@ -106,7 +106,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( internalName.itemName } - val priceFormat = NumberUtil.format(price) + val priceFormat = price.format() val hidden = itemProfit.hidden val newDrop = itemProfit.lastTimeUpdated.passedSince() < 10.seconds && config.showRecentDrops val numberColor = if (newDrop) "§a§l" else "§7" @@ -183,7 +183,7 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( val tips = if (totalAmount > 0) { val profitPerCatch = profit / totalAmount - val profitPerCatchFormat = NumberUtil.format(profitPerCatch) + val profitPerCatchFormat = profitPerCatch.format() listOf("§7Profit per $action: $profitPrefix$profitPerCatchFormat") } else emptyList() |