diff options
Diffstat (limited to 'src')
35 files changed, 293 insertions, 364 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt index 2297b3cf5..4fbe0be37 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatFloat import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -97,7 +97,7 @@ object QuiverAPI { fillUpJaxPattern.matchMatcher(message) { val type = group("type") - val amount = group("amount").formatNumber().toFloat() + val amount = group("amount").formatFloat() val filledUpType = getArrowByNameOrNull(type) ?: return ErrorManager.logErrorWithData( UnknownArrowType("Unknown arrow type: $type"), @@ -110,7 +110,7 @@ object QuiverAPI { } fillUpPattern.matchMatcher(message) { - val flintAmount = group("flintAmount").formatNumber().toFloat() + val flintAmount = group("flintAmount").formatFloat() FLINT_ARROW_TYPE?.let { arrowAmount.addOrPut(it.internalName, flintAmount) } return @@ -118,7 +118,7 @@ object QuiverAPI { addedToQuiverPattern.matchMatcher(message) { val type = group("type") - val amount = group("amount").formatNumber().toFloat() + val amount = group("amount").formatFloat() val filledUpType = getArrowByNameOrNull(type) ?: return ErrorManager.logErrorWithData( diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index 6f96cafc1..fe7c388f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -20,7 +20,8 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -99,18 +100,12 @@ object SackAPI { else null } - private fun NEUInternalName.sackPrice(stored: String) = when (sackDisplayConfig.priceFrom) { - PriceFrom.BAZAAR -> (getPrice(true) * stored.formatLong()).toLong() - .let { if (it < 0) 0L else it } - - PriceFrom.NPC -> try { - val npcPrice = getNpcPriceOrNull() ?: 0.0 - (npcPrice * stored.formatLong()).toLong() - } catch (e: Exception) { - 0L + private fun NEUInternalName.sackPrice(stored: Int): Long { + return when (sackDisplayConfig.priceFrom) { + PriceFrom.BAZAAR -> (getPrice() * stored).toLong().coerceAtLeast(0) + PriceFrom.NPC -> (getNpcPriceOrNull() ?: 0.0).toLong() * stored + else -> 0L } - - else -> 0L } fun getSacksData(savingSacks: Boolean) { @@ -118,82 +113,79 @@ object SackAPI { for ((_, stack) in stackList) { val name = stack.name val lore = stack.getLore() - val gem = SackGemstone() - val rune = SackRune() - val item = SackOtherItem() - loop@ for (line in lore) { - if (isGemstoneSack) { - gemstonePattern.matchMatcher(line) { - val rarity = group("gemrarity") - val stored = group("stored") - gem.internalName = gemstoneMap[name.removeColor()] ?: NEUInternalName.NONE - if (gemstoneMap.containsKey(name.removeColor())) { - val internalName = "${rarity.uppercase()}_${ - name.uppercase().split(" ")[0].removeColor() - }_GEM".asInternalName() - - when (rarity) { - "Rough" -> { - gem.rough = stored - gem.roughPrice = internalName.sackPrice(stored) - if (savingSacks) setSackItem(internalName, stored.formatLong()) - } - - "Flawed" -> { - gem.flawed = stored - gem.flawedPrice = internalName.sackPrice(stored) - if (savingSacks) setSackItem(internalName, stored.formatLong()) - } - - "Fine" -> { - gem.fine = stored - gem.finePrice = internalName.sackPrice(stored) - if (savingSacks) setSackItem(internalName, stored.formatLong()) - } - } - gemstoneItem[name] = gem - } - } - } else { - numPattern.matchMatcher(line) { - val stored = group("stored") - val internalName = stack.getInternalName() - item.internalName = internalName - item.colorCode = group("color") - item.stored = stored - item.total = group("total") - - if (savingSacks) setSackItem(item.internalName, item.stored.formatLong()) - item.price = if (isTrophySack) { - val filletPerTrophy = FishingAPI.getFilletPerTrophy(stack.getInternalName()) - val filletValue = filletPerTrophy * stored.formatLong() - item.magmaFish = filletValue - "MAGMA_FISH".asInternalName().sackPrice(filletValue.toString()) - } else { - internalName.sackPrice(stored).coerceAtLeast(0) - } + if (isGemstoneSack) { + lore.matchFirst(gemstonePattern) { + val gem = SackGemstone() + val rarity = group("gemrarity") + val stored = group("stored").formatInt() + gem.internalName = gemstoneMap[name.removeColor()] ?: NEUInternalName.NONE + if (gemstoneMap.containsKey(name.removeColor())) { + val internalName = "${rarity.uppercase()}_${ + name.uppercase().split(" ")[0].removeColor() + }_GEM".asInternalName() + + when (rarity) { + "Rough" -> { + gem.rough = stored + gem.roughPrice = internalName.sackPrice(stored) + if (savingSacks) setSackItem(internalName, stored) + } - if (isRuneSack) { - val level = group("level") - rune.stack = stack - if (level == "I") { - rune.lvl1 = stored - continue@loop + "Flawed" -> { + gem.flawed = stored + gem.flawedPrice = internalName.sackPrice(stored) + if (savingSacks) setSackItem(internalName, stored) } - if (level == "II") { - rune.lvl2 = stored - continue@loop + + "Fine" -> { + gem.fine = stored + gem.finePrice = internalName.sackPrice(stored) + if (savingSacks) setSackItem(internalName, stored) } - if (level == "III") { + } + gemstoneItem[name] = gem + } + } + } else if (isRuneSack) { + val rune = SackRune() + for (line in lore) { + numPattern.matchMatcher(line) { + val level = group("level").romanToDecimal() + val stored = group("stored").formatInt() + rune.stack = stack + + when (level) { + 1 -> rune.lvl1 = stored + 2 -> rune.lvl2 = stored + 3 -> { rune.lvl3 = stored + runeItem[name] = rune } - runeItem.put(name, rune) - } else { - sackItem.put(name, item) } } } + } else { + lore.matchFirst(numPattern) { + val item = SackOtherItem() + val stored = group("stored").formatInt() + val internalName = stack.getInternalName() + item.internalName = internalName + item.colorCode = group("color") + item.stored = group("stored").formatInt() + item.total = group("total").formatInt() + + if (savingSacks) setSackItem(item.internalName, item.stored) + item.price = if (isTrophySack) { + val filletPerTrophy = FishingAPI.getFilletPerTrophy(stack.getInternalName()) + val filletValue = filletPerTrophy * stored + item.magmaFish = filletValue + "MAGMA_FISH".asInternalName().sackPrice(filletValue) + } else { + internalName.sackPrice(stored).coerceAtLeast(0) + } + sackItem[name] = item + } } } if (savingSacks) saveSackData() @@ -261,7 +253,7 @@ object SackAPI { if (sackData.containsKey(item.key)) { val oldData = sackData[item.key] var newAmount = oldData!!.amount + item.value - var changed = (newAmount - oldData.amount).toInt() + var changed = (newAmount - oldData.amount) if (newAmount < 0) { newAmount = 0 changed = 0 @@ -270,7 +262,7 @@ object SackAPI { } else { val newAmount = if (item.value > 0) item.value else 0 sackData = - sackData.editCopy { this[item.key] = SackItem(newAmount.toLong(), newAmount, SackStatus.OUTDATED) } + sackData.editCopy { this[item.key] = SackItem(newAmount, newAmount, SackStatus.OUTDATED) } } } @@ -284,7 +276,7 @@ object SackAPI { saveSackData() } - private fun setSackItem(item: NEUInternalName, amount: Long) { + private fun setSackItem(item: NEUInternalName, amount: Int) { sackData = sackData.editCopy { this[item] = SackItem(amount, 0, SackStatus.CORRECT) } } @@ -308,9 +300,9 @@ object SackAPI { data class SackGemstone( var internalName: NEUInternalName = NEUInternalName.NONE, - var rough: String = "0", - var flawed: String = "0", - var fine: String = "0", + var rough: Int = 0, + var flawed: Int = 0, + var fine: Int = 0, var roughPrice: Long = 0, var flawedPrice: Long = 0, var finePrice: Long = 0, @@ -318,28 +310,28 @@ object SackAPI { data class SackRune( var stack: ItemStack? = null, - var lvl1: String = "0", - var lvl2: String = "0", - var lvl3: String = "0", + var lvl1: Int = 0, + var lvl2: Int = 0, + var lvl3: Int = 0, ) data class SackOtherItem( var internalName: NEUInternalName = NEUInternalName.NONE, var colorCode: String = "", - var stored: String = "0", - var total: String = "0", + var stored: Int = 0, + var total: Int = 0, var price: Long = 0, - var magmaFish: Long = 0, + var magmaFish: Int = 0, ) - fun NEUInternalName.getAmountInSacksOrNull(): Long? = + fun NEUInternalName.getAmountInSacksOrNull(): Int? = fetchSackItem(this).takeIf { it.statusIsCorrectOrAlright() }?.amount - fun NEUInternalName.getAmountInSacks(): Long = getAmountInSacksOrNull() ?: 0 + fun NEUInternalName.getAmountInSacks(): Int = getAmountInSacksOrNull() ?: 0 } data class SackItem( - @Expose val amount: Long, + @Expose val amount: Int, @Expose val lastChange: Int, @Expose private val status: SackStatus?, ) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java deleted file mode 100644 index e8bb83a79..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/SacksJson.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; - -import com.google.gson.annotations.Expose; - -import java.util.List; - -public class SacksJson { - - @Deprecated - @Expose - public List<String> sackList; -} diff --git a/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt index d8290703d..0175fefc5 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt @@ -1,5 +1,5 @@ package at.hannibal2.skyhanni.events class SecondPassedEvent(private val totalSeconds: Int) : LorenzEvent() { - fun repeatSeconds(i: Int) = i % totalSeconds + fun repeatSeconds(i: Int) = i % totalSeconds == 0 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index 8f28038fa..0b0a444d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -11,9 +11,9 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option.KILLS @@ -44,7 +44,8 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal import at.hannibal2.skyhanni.utils.NumberUtil.roundToPrecision import at.hannibal2.skyhanni.utils.OSUtils @@ -103,7 +104,7 @@ object GhostCounter { private var skillText = "" private var lastParsedSkillSection = "" private var lastSkillProgressString: String? = null - private var lastXp: String = "0" + private var lastXp: Long = 0 private var gain: Int = 0 private var num: Double = 0.0 private var inMist = false @@ -292,41 +293,42 @@ object GhostCounter { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (event.repeatSeconds(1)) { - skillXPPattern.matchMatcher(skillText) { - val gained = group("gained").formatNumber().toDouble() - val current = group("current") - if (current != lastXp) { - val res = current.formatNumber().toString() - gain = (res.toLong() - lastXp.toLong()).toDouble().roundToInt() - num = (gain.toDouble() / gained) - if (gained in 150.0..450.0 && lastXp != "0" && num >= 0) { - KILLS.add(num) - KILLS.add(num, true) - Option.GHOSTSINCESORROW.add(num) - Option.KILLCOMBO.add(num) - Option.SKILLXPGAINED.add(gained * num.roundToLong()) - Option.SKILLXPGAINED.add(gained * num.roundToLong(), true) - storage?.bestiaryCurrentKill = storage?.bestiaryCurrentKill?.plus(num) ?: num - } - lastXp = res + + skillXPPattern.matchMatcher(skillText) { + val gained = group("gained").formatDouble() + val current = group("current").formatLong() + if (current != lastXp) { + gain = (current - lastXp).toDouble().roundToInt() + num = (gain.toDouble() / gained) + if (gained in 150.0..450.0 && lastXp != 0L && num >= 0) { + KILLS.add(num) + KILLS.add(num, true) + Option.GHOSTSINCESORROW.add(num) + Option.KILLCOMBO.add(num) + Option.SKILLXPGAINED.add(gained * num.roundToLong()) + Option.SKILLXPGAINED.add(gained * num.roundToLong(), true) + storage?.bestiaryCurrentKill = storage?.bestiaryCurrentKill?.plus(num) ?: num } + lastXp = current } - if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) { - notifyCTModule = false - if (isUsingCTGhostCounter()) { - clickableChat( - "GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", - "shimportghostcounterdata", - prefixColor = "§6", - ) - } + } + + if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) { + notifyCTModule = false + if (isUsingCTGhostCounter()) { + clickableChat( + "GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", + "shimportghostcounterdata", + prefixColor = "§6", + ) } - inMist = LorenzUtils.skyBlockArea == "The Mist" - update() } + + inMist = LorenzUtils.skyBlockArea == "The Mist" + update() + if (event.repeatSeconds(2)) { calculateXP() calculateETA() @@ -436,10 +438,10 @@ object GhostCounter { } killComboExpiredPattern.matchMatcher(event.message) { if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt()) { - Option.MAXKILLCOMBO.set(group("combo").formatNumber().toDouble()) + Option.MAXKILLCOMBO.set(group("combo").formatDouble()) } if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt(true)) { - Option.MAXKILLCOMBO.set(group("combo").formatNumber().toDouble(), true) + Option.MAXKILLCOMBO.set(group("combo").formatDouble(), true) } Option.KILLCOMBOCOINS.set(0.0) Option.KILLCOMBO.set(0.0) @@ -490,11 +492,11 @@ object GhostCounter { for (line in ghostStack.getLore()) { val l = line.removeColor().trim() if (l.startsWith("Kills: ")) { - kills = "Kills: (.*)".toRegex().find(l)?.groupValues?.get(1)?.formatNumber()?.toDouble() ?: 0.0 + kills = "Kills: (.*)".toRegex().find(l)?.groupValues?.get(1)?.formatDouble() ?: 0.0 } ghostXPPattern.matchMatcher(line.removeColor().trim()) { - storage?.bestiaryCurrentKill = if (kills > 0) kills else group("current").formatNumber().toDouble() - storage?.bestiaryKillNeeded = group("total").formatNumber().toDouble() + storage?.bestiaryCurrentKill = if (kills > 0) kills else group("current").formatDouble() + storage?.bestiaryKillNeeded = group("total").formatDouble() } } update() diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt index a39c59274..bff80b930 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/WikiManager.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment +import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems @@ -68,7 +68,7 @@ object WikiManager { private fun wikiTheItem(item: ItemStack, autoOpen: Boolean, useFandom: Boolean = config.useFandom) { val itemDisplayName = - (item.nameWithEnchantment ?: return).replace("§a✔ ", "").replace("§c✖ ", "") + item.itemName.replace("§a✔ ", "").replace("§c✖ ", "") val internalName = item.getInternalName().asString() val wikiUrlSearch = if (internalName != "NONE") internalName else itemDisplayName.removeColor() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index 47f742ded..cf893fd0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -16,7 +16,7 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -203,7 +203,7 @@ object DungeonAPI { val lore = inventoryItems[4]?.getLore() ?: return val line = lore.find { it.contains("Total Kills:") } ?: return val kills = totalKillsPattern.matchMatcher(line) { - group("kills").formatNumber().toInt() + group("kills").formatInt() } ?: return bossCollections[floor] = kills } 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 7724d4c5d..25b20b08a 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 @@ -12,7 +12,7 @@ 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.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -117,8 +117,7 @@ object DianaProfitTracker { } chatDugOutCoinsPattern.matchMatcher(message) { BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() - val coins = group("coins").formatNumber().toInt() - tracker.addCoins(coins) + tracker.addCoins(group("coins").formatInt()) tryHide(event) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt index 4fb025097..96baef5a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowHelper.kt @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine import at.hannibal2.skyhanni.utils.RenderUtils.drawColor import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText @@ -208,7 +209,8 @@ object GriffinBurrowHelper { event.drawColor(location, LorenzColor.LIGHT_PURPLE) val distance = location.distance(playerLocation) if (distance > 10) { - val formattedDistance = LorenzUtils.formatInteger(distance.toInt()) + // TODO use round(1) + val formattedDistance = distance.toInt().addSeparators() event.drawDynamicText(location.add(y = 1), "§d§lInquisitor §e${formattedDistance}m", 1.7) } else { event.drawDynamicText(location.add(y = 1), "§d§lInquisitor", 1.7) @@ -270,7 +272,7 @@ object GriffinBurrowHelper { val color = if (currentWarp != null && targetLocation == guessLocation) "§b" else "§f" event.drawDynamicText(guessLocation.add(y = 1), "${color}Guess", 1.5) if (distance > 5) { - val formattedDistance = LorenzUtils.formatInteger(distance.toInt()) + val formattedDistance = distance.toInt().addSeparators() event.drawDynamicText(guessLocation.add(y = 1), "§e${formattedDistance}m", 1.7, yOff = 10f) } } 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 dc6246abe..f13ea5824 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 @@ -19,7 +19,7 @@ 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.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -192,8 +192,7 @@ object FishingProfitTracker { @SubscribeEvent fun onChat(event: LorenzChatEvent) { coinsChatPattern.matchMatcher(event.message) { - val coins = group("coins").formatNumber() - tracker.addCoins(coins.toInt()) + tracker.addCoins(group("coins").formatInt()) addCatch() } } 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 dcafc6603..5409062f5 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 @@ -7,7 +7,8 @@ import at.hannibal2.skyhanni.features.fishing.trophy.TrophyFishManager.getFillet import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUItems +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 net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -27,7 +28,8 @@ class TrophyFishFillet { val rarity = TrophyRarity.getByName(trophyRarityName) ?: return val multiplier = if (Keyboard.KEY_LSHIFT.isKeyHeld()) event.itemStack.stackSize else 1 val filletValue = info.getFilletValue(rarity) * multiplier - val filletPrice = filletValue * NEUItems.getPrice("MAGMA_FISH") + // 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)") } 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 171aa503d..0d0494bf9 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 @@ -44,7 +44,6 @@ import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.renderables.Renderable import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -54,7 +53,6 @@ import kotlin.math.ceil import kotlin.math.floor import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.DurationUnit object ComposterOverlay { @@ -320,20 +318,20 @@ object ComposterOverlay { list.add(fuelItem.getItemStack()) newList.add(list) - val timePerCompost = ComposterAPI.timePerCompost(null).toLong(DurationUnit.MILLISECONDS) + val timePerCompost = ComposterAPI.timePerCompost(null) val upgrade = if (maxLevel) null else extraComposterUpgrade - val timePerCompostPreview = ComposterAPI.timePerCompost(upgrade).toLong(DurationUnit.MILLISECONDS) - val format = TimeUtils.formatDuration(timePerCompost) + val timePerCompostPreview = ComposterAPI.timePerCompost(upgrade) + val format = timePerCompost.format() val formatPreview = - if (timePerCompostPreview != timePerCompost) " §c➜ §b" + TimeUtils.formatDuration(timePerCompostPreview) else "" + if (timePerCompostPreview != timePerCompost) " §c➜ §b" + timePerCompostPreview.format() else "" newList.addAsSingletonList(" §7Time per Compost: §b$format$formatPreview") val timeText = currentTimeType.display.lowercase() val timeMultiplier = if (currentTimeType != TimeType.COMPOST) { - (currentTimeType.multiplier * 1000 / (timePerCompost.toDouble())) + (currentTimeType.multiplier * 1000.0 / (timePerCompost.inWholeMilliseconds)) } else 1.0 val timeMultiplierPreview = if (currentTimeType != TimeType.COMPOST) { - (currentTimeType.multiplier * 1000 / (timePerCompostPreview.toDouble())) + (currentTimeType.multiplier * 1000.0 / (timePerCompostPreview.inWholeMilliseconds)) } else 1.0 val multiDropFactor = ComposterAPI.multiDropChance(null) + 1 @@ -491,8 +489,7 @@ object ComposterOverlay { return } - val havingInSacks = internalName.getAmountInSacksOrNull() - if (havingInSacks == null) { + val havingInSacks = internalName.getAmountInSacksOrNull() ?: run { ChatUtils.sendCommandToServer("gfs ${internalName.asString()} ${itemsNeeded - havingInInventory}") // TODO Add sack type repo data @@ -504,7 +501,8 @@ object ComposterOverlay { "sax" ) return - } else if (havingInSacks == 0L) { + } + if (havingInSacks == 0) { SoundUtils.playErrorSound() if (LorenzUtils.noTradeMode) { ChatUtils.chat("No $itemName §efound in sacks.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index eec532ed1..112fce914 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.round +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUnit @@ -162,11 +163,11 @@ object GardenCropMilestoneDisplay { } lineMap[2] = if (crop.isMaxed()) { - val haveFormat = LorenzUtils.formatInteger(counter) + val haveFormat = counter.addSeparators() Collections.singletonList("§7Counter: §e$haveFormat") } else { - val haveFormat = LorenzUtils.formatInteger(have) - val needFormat = LorenzUtils.formatInteger(need) + val haveFormat = have.addSeparators() + val needFormat = need.addSeparators() Collections.singletonList("§e$haveFormat§8/§e$needFormat") } @@ -194,7 +195,7 @@ object GardenCropMilestoneDisplay { } } - val format = LorenzUtils.formatInteger(farmingFortuneSpeed * 60) + val format = (farmingFortuneSpeed * 60).addSeparators() lineMap[4] = Collections.singletonList("§7Crops/Minute§8: §e$format") val formatBps = LorenzUtils.formatDouble(speed, config.blocksBrokenPrecision) lineMap[5] = Collections.singletonList("§7Blocks/Second§8: §e$formatBps") @@ -266,8 +267,8 @@ object GardenCropMilestoneDisplay { val have = counter - cropsForCurrentTier val need = cropsForNextTier - cropsForCurrentTier - val haveFormat = LorenzUtils.formatInteger(have) - val needFormat = LorenzUtils.formatInteger(need) + val haveFormat = have.addSeparators() + val needFormat = need.addSeparators() val missing = need - have diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt index e503dfc82..43b0c37d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrade.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.garden.fortuneguide data class FortuneUpgrade( val description: String, val costCopper: Int?, + //todo make into NEUInternalName val requiredItem: String, val itemQuantity: Int, val fortuneIncrease: Double, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt index 2d33fd9b1..5abc89f80 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FortuneUpgrades.kt @@ -14,7 +14,8 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI.Companion.g import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getItemRarityOrCommon import at.hannibal2.skyhanni.utils.ItemUtils.itemName -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.addSuffix import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getFarmingForDummiesCount @@ -63,7 +64,7 @@ object FortuneUpgrades { // todo fix NEU price data not being loaded if run too early private fun MutableList<FortuneUpgrade>.populateAndSort(style: Int) { this.map { upgrade -> - val cost = (NEUItems.getPrice(upgrade.requiredItem) * (upgrade.itemQuantity)).toInt() + val cost = (upgrade.requiredItem.asInternalName().getPrice() * upgrade.itemQuantity).toInt() upgrade.cost = cost upgrade.costPerFF = (cost / upgrade.fortuneIncrease).toInt() } 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 5818566eb..e8134a337 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 @@ -4,8 +4,9 @@ import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.garden.fortuneguide.FortuneUpgrades import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.utils.GuiRenderUtils -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NumberUtil import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.MathHelper @@ -56,8 +57,8 @@ class UpgradePage : FFGuideGUI.FFGuidePage() { for ((index, upgrade) in upgradeList.withIndex()) { if (adjustedY + 25 * index < FFGuideGUI.guiTop + 20) continue if (adjustedY + 25 * index > FFGuideGUI.guiTop + 160) continue - val upgradeItem = upgrade.requiredItem.let { NEUItems.getItemStack(it) } - var formattedUpgrade = upgradeItem.nameWithEnchantment ?: return + val upgradeItem = upgrade.requiredItem.asInternalName().getItemStack() + var formattedUpgrade = upgradeItem.itemName if (adjustedY + 25 * index - 5 < FFGuideGUI.lastClickedHeight && FFGuideGUI.lastClickedHeight < adjustedY + 25 * index + 10) { FFGuideGUI.lastClickedHeight = 0 BazaarApi.searchForBazaarItem(formattedUpgrade, upgrade.itemQuantity) 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 6639f42da..2031a2ff1 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 @@ -20,7 +20,7 @@ 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.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -107,33 +107,33 @@ object GardenVisitorDropStatistics { val storage = GardenAPI.storage?.visitorDrops ?: return copperPattern.matchMatcher(message) { - val amount = group("amount").formatNumber().toInt() + val amount = group("amount").formatInt() storage.copper += amount saveAndUpdate() } farmingExpPattern.matchMatcher(message) { - val amount = group("amount").formatNumber() + val amount = group("amount").formatInt() storage.farmingExp += amount saveAndUpdate() } gardenExpPattern.matchMatcher(message) { - val amount = group("amount").formatNumber().toInt() + val amount = group("amount").formatInt() if (amount > 80) return // some of the low visitor milestones will get through but will be minimal storage.gardenExp += amount saveAndUpdate() } bitsPattern.matchMatcher(message) { - val amount = group("amount").formatNumber().toInt() + val amount = group("amount").formatInt() storage.bits += amount saveAndUpdate() } mithrilPowderPattern.matchMatcher(message) { - val amount = group("amount").formatNumber().toInt() + val amount = group("amount").formatInt() storage.mithrilPowder += amount saveAndUpdate() } gemstonePowderPattern.matchMatcher(message) { - val amount = group("amount").formatNumber().toInt() + val amount = group("amount").formatInt() storage.gemstonePowder += amount saveAndUpdate() } 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 9118db86e..2b25db259 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -23,7 +23,6 @@ import at.hannibal2.skyhanni.utils.NEUItems 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.formatNumber import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -70,15 +69,15 @@ object SackDisplay { val sackItems = SackAPI.sackItem.toList() if (sackItems.isNotEmpty()) { val sortedPairs: MutableMap<String, SackAPI.SackOtherItem> = when (config.sortingType) { - SortingTypeEntry.DESC_STORED -> sackItems.sortedByDescending { it.second.stored.formatNumber() } - SortingTypeEntry.ASC_STORED -> sackItems.sortedBy { it.second.stored.formatNumber() } + SortingTypeEntry.DESC_STORED -> sackItems.sortedByDescending { it.second.stored } + SortingTypeEntry.ASC_STORED -> sackItems.sortedBy { it.second.stored } SortingTypeEntry.DESC_PRICE -> sackItems.sortedByDescending { it.second.price } SortingTypeEntry.ASC_PRICE -> sackItems.sortedBy { it.second.price } - else -> sackItems.sortedByDescending { it.second.stored.formatNumber() } + else -> sackItems.sortedByDescending { it.second.stored } }.toMap().toMutableMap() sortedPairs.toList().forEach { (k, v) -> - if (v.stored == "0" && !config.showEmpty) { + if (v.stored == 0 && !config.showEmpty) { sortedPairs.remove(k) } } @@ -90,7 +89,7 @@ object SackDisplay { val (internalName, colorCode, stored, total, price, magmaFish) = item totalPrice += price if (rendered >= config.itemToShow) continue - if (stored == "0" && !config.showEmpty) continue + if (stored == 0 && !config.showEmpty) continue val itemStack = internalName.getItemStack() newDisplay.add(buildList { add(" §7- ") @@ -102,10 +101,13 @@ object SackDisplay { add( when (config.numberFormat) { - NumberFormatEntry.DEFAULT -> "$colorCode${stored}§7/§b${total}" - NumberFormatEntry.FORMATTED -> "$colorCode${NumberUtil.format(stored.formatNumber())}§7/§b${total}" + NumberFormatEntry.DEFAULT -> "$colorCode${stored}§7/§b${NumberUtil.format(total)}" + NumberFormatEntry.FORMATTED -> { + "$colorCode${NumberUtil.format(stored)}§7/§b${NumberUtil.format(total)}" + } + NumberFormatEntry.UNFORMATTED -> "$colorCode${stored}§7/§b${ - total.formatNumber().addSeparators() + total.addSeparators() }" else -> "$colorCode${stored}§7/§b${total}" @@ -121,7 +123,7 @@ object SackDisplay { listOf( "§6Magmafish: §b${magmaFish.addSeparators()}", "§6Magmafish value: §b${price / magmaFish}", - "§6Magmafish per: §b${magmaFish / stored.formatNumber()}" + "§6Magmafish per: §b${magmaFish / stored}" ) ) ) @@ -148,7 +150,7 @@ object SackDisplay { newDisplay.addButton( prefix = "§7Number format: ", - getName = NumberFormat.entries[config.numberFormat.ordinal].DisplayName, // todo avoid ordinal + getName = NumberFormat.entries[config.numberFormat.ordinal].displayName, // todo avoid ordinal onChange = { // todo avoid ordinal config.numberFormat = @@ -202,7 +204,7 @@ object SackDisplay { add(Renderable.optionalLink("$name: ", { BazaarApi.searchForBazaarItem(name.dropLast(1)) }) { !NEUItems.neuHasFocus() }) - add(" ($rough-§a$flawed-§9$fine)") + add(" (${rough.addSeparators()}-§a${flawed.addSeparators()}-§9${fine.addSeparators()})") val price = roughprice + flawedprice + fineprice totalPrice += price if (config.showPrice && price != 0L) add(" §7(§6${format(price)}§7)") @@ -234,14 +236,15 @@ object SackDisplay { enum class PriceFormat(val displayName: String) { FORMATED("Formatted"), - UNFORMATED("Unformatted") + UNFORMATED("Unformatted"), ; } - enum class NumberFormat(val DisplayName: String) { + enum class NumberFormat(val displayName: String) { DEFAULT("Default"), FORMATTED("Formatted"), - UNFORMATTED("Unformatted") + UNFORMATTED("Unformatted"), + ; } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt index 6d58aef09..d8e9fdd03 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.utils.LorenzColor 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.NumberUtil.addSeparators import kotlin.math.floor enum class ItemAbility( @@ -106,7 +107,7 @@ enum class ItemAbility( } else { duration /= 1000 duration++ - LorenzUtils.formatInteger(duration) + duration.addSeparators() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt index 01672ac98..5ce5cef87 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/powdertracker/PowderTracker.kt @@ -17,7 +17,7 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker @@ -141,7 +141,7 @@ object PowderTracker { reward.chatPattern.matchMatcher(msg) { tracker.modify { val count = it.rewards[reward] ?: 0 - var amount = group("amount").formatNumber() + var amount = group("amount").formatLong() if ((reward == PowderChestReward.MITHRIL_POWDER || reward == PowderChestReward.GEMSTONE_POWDER) && doublePowder) amount *= 2 it.rewards[reward] = count + amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt index 7db11478c..50f50e819 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/InGameDateDisplay.kt @@ -4,8 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.data.jsonobjects.repo.TabListJson import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -34,10 +34,10 @@ class InGameDateDisplay { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return + if (!config.useScoreboard && !event.repeatSeconds(config.refreshSeconds)) return - if (config.useScoreboard && !event.repeatSeconds(1)) return checkDate() } 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 a1750e5c0..1baf781ef 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 @@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.isRune import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName @@ -480,10 +479,7 @@ object EstimatedItemValueCalculator { return addCosmetic(internalName, list, "Rune", config.ignoreRunes) } - private fun NEUInternalName.getNameOrRepoError(): String? { - val stack = getItemStackOrNull() ?: return null - return stack.nameWithEnchantment ?: "§cItem Name Error" - } + private fun NEUInternalName.getNameOrRepoError(): String? = getItemStackOrNull()?.itemName private fun addAbilityScrolls(stack: ItemStack, list: MutableList<String>): Double { val abilityScrolls = stack.getAbilityScrolls() ?: return 0.0 @@ -684,7 +680,7 @@ object EstimatedItemValueCalculator { totalPrice += if (ingredient.isCoins) { ingredient.count } else { - getPrice(ingredient.internalItemId) * ingredient.count + ingredient.internalItemId.asInternalName().getPrice() * ingredient.count } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt index de0c57850..261229e09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/stillgorechateau/RiftBloodEffigies.kt @@ -4,10 +4,10 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.jsonobjects.repo.RiftEffigiesJson import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.ScoreboardRawChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.ChatUtils @@ -18,26 +18,22 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.minutes class RiftBloodEffigies { private val config get() = RiftAPI.config.area.stillgoreChateau.bloodEffigies private var locations: List<LorenzVec> = emptyList() - private var effigiesTimes = mapOf( - 0 to -1L, - 1 to -1L, - 2 to -1L, - 3 to -1L, - 4 to -1L, - 5 to -1L, - ) + private var effigiesTimes = cleanMap() companion object { private val group = RepoPattern.group("rift.area.stillgore.effegies") @@ -53,16 +49,11 @@ class RiftBloodEffigies { @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { - effigiesTimes = mapOf( - 0 to -1L, - 1 to -1L, - 2 to -1L, - 3 to -1L, - 4 to -1L, - 5 to -1L, - ) + effigiesTimes = cleanMap() } + private fun cleanMap() = (0..5).associateWith { SimpleTimeMark.farPast() } + @SubscribeEvent fun onDebugDataCollect(event: DebugDataCollectEvent) { event.title("Rift Blood Effigies") @@ -73,8 +64,7 @@ class RiftBloodEffigies { } event.addData { for ((number, duration) in effigiesTimes) { - val diff = duration - System.currentTimeMillis() - val time = TimeUtils.formatDuration(diff - 999) + val time = duration.timeUntil().format() add("$number: $time ($duration)") } } @@ -101,17 +91,17 @@ class RiftBloodEffigies { val split = hearts.split("§").drop(1) for ((index, s) in split.withIndex()) { val time = effigiesTimes[index]!! - val diff = time - System.currentTimeMillis() - if (diff < 0L) { + + if (time.isInPast()) { if (s == "7") { - if (time != 0L) { + if (time.isFarPast()) { ChatUtils.chat("Effigy #${index + 1} respawned!") - effigiesTimes = effigiesTimes.editCopy { this[index] = 0L } + effigiesTimes = effigiesTimes.editCopy { this[index] = SimpleTimeMark.farPast() } } } else { - if (time != -1L) { + if (time.isFarPast()) { ChatUtils.chat("Effigy #${index + 1} is broken!") - val endTime = System.currentTimeMillis() + 1_000 * 60 * 20 + val endTime = SimpleTimeMark.now() + 20.minutes effigiesTimes = effigiesTimes.editCopy { this[index] = endTime } } } @@ -120,8 +110,7 @@ class RiftBloodEffigies { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!event.repeatSeconds(1)) return + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return for (entity in EntityUtils.getEntitiesNearby<EntityArmorStand>(LocationUtils.playerLocation(), 6.0)) { @@ -130,8 +119,8 @@ class RiftBloodEffigies { val index = locations.indexOf(nearest) val string = group("time") - val time = TimeUtils.getMillis(string) - effigiesTimes = effigiesTimes.editCopy { this[index] = System.currentTimeMillis() + time } + val time = TimeUtils.getDuration(string) + effigiesTimes = effigiesTimes.editCopy { this[index] = SimpleTimeMark.now() + time } } } } @@ -144,23 +133,22 @@ class RiftBloodEffigies { val name = "Effigy #${index + 1}" val duration = effigiesTimes[index]!! - if (duration == -1L) { + if (duration.isFarPast()) { if (config.unknownTime) { event.drawWaypointFilled(location, LorenzColor.GRAY.toColor(), seeThroughBlocks = true) event.drawDynamicText(location, "§7Unknown Time ($name)", 1.5) continue } } else { - val diff = duration - System.currentTimeMillis() - if (duration <= 0L) { + if (duration.isFarPast()) { event.drawWaypointFilled(location, LorenzColor.RED.toColor(), seeThroughBlocks = true) event.drawDynamicText(location, "§cBreak $name!", 1.5) continue } - if (config.respawningSoon && diff < 60_000 * config.respwningSoonTime) { - val time = TimeUtils.formatDuration(diff - 999) + if (config.respawningSoon && duration.passedSince() < config.respwningSoonTime.minutes) { event.drawWaypointFilled(location, LorenzColor.YELLOW.toColor(), seeThroughBlocks = true) + val time = duration.timeUntil() event.drawDynamicText(location, "§e$name is respawning §b$time", 1.5) continue } @@ -172,7 +160,7 @@ class RiftBloodEffigies { } } - fun isEnabled() = RiftAPI.inRift() && RiftAPI.inStillgoreChateau() && config.enabled + fun isEnabled() = RiftAPI.inRift() && config.enabled && RiftAPI.inStillgoreChateau() @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index 34a19a01c..7b337a2e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -15,7 +15,8 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -37,7 +38,7 @@ object EnigmaSoulWaypoints { private var adding = true private val item by lazy { - val neuItem = NEUItems.getItemStack("SKYBLOCK_ENIGMA_SOUL") + val neuItem = "SKYBLOCK_ENIGMA_SOUL".asInternalName().getItemStack() Utils.createItemStack( neuItem.item, "§5Toggle Missing", diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt index c995fa405..8282bf1e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftTimer.kt @@ -8,10 +8,14 @@ import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.TimeUtils +import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds class RiftTimer { @@ -23,54 +27,53 @@ class RiftTimer { ) private var display = emptyList<String>() - private var maxTime = 0L - private var currentTime = 0L - private var latestTime = 0L + private var maxTime = 0.seconds + private var currentTime = 0.seconds + private var latestTime = 0.seconds private val changes = mutableMapOf<Long, String>() @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { display = emptyList() - maxTime = 0 - latestTime = 0 - currentTime = 0 + maxTime = 0.seconds + latestTime = 0.seconds + currentTime = 0.seconds } //todo use ActionBarValueUpdateEvent @SubscribeEvent fun onActionBarUpdate(event: ActionBarUpdateEvent) { if (!isEnabled()) return - for (entry in event.actionBar.split(" ")) { - timePattern.matchMatcher(entry) { - val color = group("color") - val newTime = getTime(group("time")) - if (color == "7") { - if (newTime > maxTime) { - maxTime = newTime - } + + event.actionBar.split(" ").matchFirst(timePattern) { + val color = group("color") + val newTime = TimeUtils.getDuration(group("time").replace("m", "m ")) + + if (color == "7") { + if (newTime > maxTime) { + maxTime = newTime } - currentTime = newTime - update() } + currentTime = newTime + update() } } - private fun getTime(time: String) = TimeUtils.getMillis(time.replace("m", "m ")) - private fun update() { if (currentTime != latestTime) { - val diff = (currentTime - latestTime) + 1000 + val diff = (currentTime - latestTime) + 1.seconds latestTime = currentTime if (latestTime != maxTime) { addDiff(diff) } } - val currentFormat = TimeUtils.formatDuration(currentTime) - val percentage = LorenzUtils.formatPercentage(currentTime.toDouble() / maxTime) + val currentFormat = currentTime.format() + val percentage = + LorenzUtils.formatPercentage(currentTime.inWholeMilliseconds.toDouble() / maxTime.inWholeMilliseconds) val percentageFormat = if (config.percentage.get()) " §7($percentage)" else "" - val maxTimeFormat = if (config.maxTime.get()) "§7/§b" + TimeUtils.formatDuration(maxTime) else "" - val color = if (currentTime <= 60_000) "§c" else if (currentTime <= 60_000 * 5) "§e" else "§b" + val maxTimeFormat = if (config.maxTime.get()) "§7/§b" + maxTime.format() else "" + val color = if (currentTime <= 1.minutes) "§c" else if (currentTime <= 5.minutes) "§e" else "§b" val firstLine = "§eRift Timer: $color$currentFormat$maxTimeFormat$percentageFormat" display = buildList { @@ -82,11 +85,11 @@ class RiftTimer { } } - private fun addDiff(diff: Long) { - val diffFormat = if (diff > 0) { - "§a+${TimeUtils.formatDuration(diff)}" - } else if (diff < 0) { - "§c-${TimeUtils.formatDuration(-diff)}" + private fun addDiff(diff: Duration) { + val diffFormat = if (diff > 0.seconds) { + "§a+${diff.format()}" + } else if (diff < 0.seconds) { + "§c-${(-diff).format()}" } else return changes[System.currentTimeMillis()] = diffFormat diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt index d4953fb41..5a0fc0cfe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -21,7 +21,7 @@ class SlayerBossSpawnSoon { " \\(?(?<progress>[0-9.,k]+)/(?<total>[0-9.,k]+)\\)?.*" ) - private var lastCompletion = 0f + private var lastCompletion = 0.0 private var warned = false @SubscribeEvent @@ -30,7 +30,7 @@ class SlayerBossSpawnSoon { if (!SlayerAPI.isInCorrectArea) return val completion = progressPattern.matchMatcher(event.newProgress.removeColor()) { - group("progress").formatNumber().toFloat() / group("total").formatNumber().toFloat() + group("progress").formatDouble() / group("total").formatDouble() } ?: return if (completion > config.percent / 100.0) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index e2ae877bb..386fbf98a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -7,15 +7,15 @@ import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SlayerChangeEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.nameWithEnchantment +import at.hannibal2.skyhanni.utils.ItemUtils.itemName import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -48,10 +48,10 @@ class SlayerRngMeterDisplay { private var lastItemDroppedTime = 0L @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (event.repeatSeconds(1) && lastItemDroppedTime != 0L && System.currentTimeMillis() > lastItemDroppedTime + 4_000) { + if (lastItemDroppedTime != 0L && System.currentTimeMillis() > lastItemDroppedTime + 4_000) { lastItemDroppedTime = 0L update() } @@ -64,7 +64,6 @@ class SlayerRngMeterDisplay { @SubscribeEvent fun onChat(event: LorenzChatEvent) { - if (!isEnabled()) return if (config.hideChat && SlayerAPI.isInCorrectArea) { @@ -74,7 +73,7 @@ class SlayerRngMeterDisplay { } val currentMeter = updatePattern.matchMatcher(event.message) { - group("exp").formatNumber() + group("exp").formatLong() } ?: return val storage = getStorage() ?: return @@ -137,7 +136,7 @@ class SlayerRngMeterDisplay { storage.itemGoal = "" storage.goalNeeded = -1 } else { - storage.itemGoal = selectedItem.nameWithEnchantment + storage.itemGoal = selectedItem.itemName val jsonObject = Constants.RNGSCORE["slayer"].asJsonObject.get(getCurrentSlayer()).asJsonObject storage.goalNeeded = jsonObject.get(selectedItem.getInternalName().asString()).asLong } diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 69d9c7887..a4b36db3b 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -33,7 +33,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName 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.getItemStackOrNull import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull @@ -240,8 +240,8 @@ class SkyHanniDebugsAndTests { list.add("$coloredName§7 (") for (itemName in item.value) { try { - val internalName = NEUItems.getRawInternalName(itemName) - list.add(NEUItems.getItemStack(internalName)) + val internalName = NEUInternalName.fromItemName(itemName) + list.add(internalName.getItemStack()) } catch (e: Error) { ChatUtils.debug("itemName '$itemName' is invalid for visitor '$name'") errors++ diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt index 9d2c0d3d4..27e9fcd90 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NEUInternalName -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -34,10 +34,10 @@ object TestCopyRngMeterValues { for (item in event.inventoryItems.values) { for (line in item.getLore()) { slayerPattern.matchMatcher(line) { - map[item.getInternalName()] = group("xp").formatNumber() + map[item.getInternalName()] = group("xp").formatLong() } dungeonPattern.matchMatcher(line) { - map[item.getInternalName()] = group("xp").formatNumber() + map[item.getInternalName()] = group("xp").formatLong() } } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index e29674fe9..1b640ed7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -93,11 +93,6 @@ object ErrorManager { logError(IllegalStateException(internalMessage), userMessage, ignoreErrorCache, noStackTrace, *extraData, betaOnly = betaOnly) } - @Deprecated("Use data as well", ReplaceWith("ErrorManager.logErrorWithData(throwable, message)")) - fun logError(throwable: Throwable, message: String) { - logError(throwable, message, ignoreErrorCache = false, noStackTrace = false) - } - fun logErrorWithData( throwable: Throwable, message: String, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index d4c9b87a4..94558d949 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -76,25 +76,6 @@ object ItemUtils { return list } - fun getItemsInInventoryWithSlots(withCursorItem: Boolean = false): Map<ItemStack, Int> { - val map: LinkedHashMap<ItemStack, Int> = LinkedHashMap() - val player = Minecraft.getMinecraft().thePlayer - if (player == null) { - ChatUtils.error("getItemsInInventoryWithSlots: player is null!") - return map - } - for (slot in player.openContainer.inventorySlots) { - if (slot.hasStack) { - map[slot.stack] = slot.slotNumber - } - } - - if (withCursorItem && player.inventory != null && player.inventory.itemStack != null) { - map[player.inventory.itemStack] = -1 - } - return map - } - fun hasAttributes(stack: ItemStack): Boolean { if (stack.hasTagCompound()) { val tagCompound = stack.tagCompound @@ -306,10 +287,6 @@ object ItemUtils { setStackDisplayName(value) } - @Deprecated("outdated", ReplaceWith("this.itemName")) - val ItemStack.nameWithEnchantment: String? - get() = itemName - fun isSkyBlockMenuItem(stack: ItemStack?): Boolean = stack?.getInternalName()?.equals("SKYBLOCK_MENU") ?: false private val itemAmountCache = mutableMapOf<String, Pair<String, Int>>() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index df622503a..ef98c1264 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -132,12 +132,6 @@ object LorenzUtils { fun formatPercentage(percentage: Double, format: String?): String = DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%" - @Deprecated("old code", ReplaceWith("i.addSeparators()")) - fun formatInteger(i: Int): String = i.addSeparators() - - @Deprecated("old code", ReplaceWith("l.addSeparators()")) - fun formatInteger(l: Long): String = l.addSeparators() - @Deprecated("old code", ReplaceWith("d.round(round).addSeparators()")) fun formatDouble(d: Double, round: Int = 1): String { return d.round(round).addSeparators() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 467afe55f..ce834e28c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -81,9 +81,6 @@ object NEUItems { } } - @Deprecated("Use NEUInternalName rather than String", ReplaceWith("NEUInternalName.fromItemName(itemName)")) - fun getRawInternalName(itemName: String): String = NEUInternalName.fromItemName(itemName).asString() - fun readAllNeuItems(): Map<String, NEUInternalName> { allInternalNames.clear() val map = mutableMapOf<String, NEUInternalName>() @@ -138,21 +135,12 @@ object NEUItems { return getNpcPriceOrNull() } - @Deprecated("Use NEUInternalName", ReplaceWith("internalName.asInternalName().getPrice(useSellingPrice)")) - fun getPrice(internalName: String, useSellingPrice: Boolean = false): Double = - internalName.asInternalName().getPrice(useSellingPrice) - fun NEUInternalName.getItemStackOrNull(): ItemStack? = ItemResolutionQuery(manager) .withKnownInternalName(asString()) .resolveToItemStack()?.copy() fun getItemStackOrNull(internalName: String) = internalName.asInternalName().getItemStackOrNull() - // TODO remove - @Deprecated("Use NEUInternalName rather than String", ReplaceWith("internalName.asInternalName().getItemStack()")) - fun getItemStack(internalName: String): ItemStack = - internalName.asInternalName().getItemStack() - fun NEUInternalName.getItemStack(): ItemStack = getItemStackOrNull() ?: run { getPriceOrNull() ?: return@run fallbackItem @@ -210,7 +198,7 @@ object NEUItems { private const val lightScaling = 2.47f // Adjust as needed private const val g = 0.6f // Original Value taken from RenderHelper private const val lightIntensity = lightScaling * g - private val itemLightBuffer = GLAllocation.createDirectFloatBuffer(16); + private val itemLightBuffer = GLAllocation.createDirectFloatBuffer(16) init { itemLightBuffer.clear() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 784b7e9ac..f9b1ceb7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -3,15 +3,12 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.StringUtils.matches import java.text.NumberFormat -import java.util.Locale import java.util.TreeMap import kotlin.math.pow import kotlin.math.roundToInt object NumberUtil { - @JvmField - val nf: NumberFormat = NumberFormat.getInstance(Locale.US) private val suffixes = TreeMap<Long, String>().apply { this[1000L] = "k" this[1000000L] = "M" @@ -20,6 +17,7 @@ object NumberUtil { this[1000000000000000L] = "P" this[1000000000000000000L] = "E" } + private val romanSymbols = TreeMap( mapOf( 1000 to "M", @@ -200,10 +198,6 @@ object NumberUtil { return "${color.getChatColor()}$amount%" } - // TODO create new function formatLong, and eventually deprecate this function. - @Deprecated("renamed", ReplaceWith("this.formatLong()")) - fun String.formatNumber(): Long = formatLong() - fun String.formatDouble(): Double = formatDoubleOrNull() ?: throw NumberFormatException("formatDouble failed for '$this'") @@ -213,6 +207,9 @@ object NumberUtil { fun String.formatInt(): Int = formatDoubleOrNull()?.toInt() ?: throw NumberFormatException("formatInt failed for '$this'") + fun String.formatFloat(): Float = + formatDoubleOrNull()?.toFloat() ?: throw NumberFormatException("formatFloat failed for '$this'") + fun String.formatDoubleOrUserError(): Double? = formatDoubleOrNull() ?: run { ChatUtils.userError("Not a valid number: '$this'") return@run null @@ -228,6 +225,11 @@ object NumberUtil { return@run null } + fun String.formatFloatOrUserError(): Float? = formatDoubleOrNull()?.toFloat() ?: run { + ChatUtils.userError("Not a valid number: '$this'") + return@run null + } + private fun String.formatDoubleOrNull(): Double? { var text = lowercase().replace(",", "") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt index b92cf5258..2aa542699 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt @@ -85,13 +85,9 @@ object TimeUtils { val Duration.inWholeTicks: Int get() = (inWholeMilliseconds / 50).toInt() + fun getDuration(string: String) = getMillis(string.replace("m", "m ").replace(" ", " ").trim()) - @Deprecated("Do no longer use long for time", ReplaceWith("TimeUtils.getDuration(string)")) - fun getMillis(string: String) = getDuration(string).inWholeMilliseconds - - fun getDuration(string: String) = getMillis_(string.replace("m", "m ").replace(" ", " ").trim()) - - private fun getMillis_(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) { + private fun getMillis(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) { val years = group("y")?.toLong() ?: 0L val days = group("d")?.toLong() ?: 0L val hours = group("h")?.toLong() ?: 0L @@ -131,7 +127,7 @@ object TimeUtils { else -> { throw RuntimeException("Invalid format: '$string'") } - }.toLong().toDuration(DurationUnit.MILLISECONDS) + }.milliseconds } fun SkyBlockTime.formatted( |