From fcd404d862b4b051474898076fcc06b406d1ea91 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:36:08 +1000 Subject: Backend: Remove a lot of deprecated code (#1371) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/combat/ghostcounter/GhostCounter.kt | 78 +++++++++++----------- .../skyhanni/features/commands/WikiManager.kt | 4 +- .../skyhanni/features/dungeon/DungeonAPI.kt | 4 +- .../features/event/diana/DianaProfitTracker.kt | 5 +- .../features/event/diana/GriffinBurrowHelper.kt | 6 +- .../fishing/tracker/FishingProfitTracker.kt | 5 +- .../features/fishing/trophy/TrophyFishFillet.kt | 6 +- .../features/garden/composter/ComposterOverlay.kt | 20 +++--- .../garden/farming/GardenCropMilestoneDisplay.kt | 13 ++-- .../features/garden/fortuneguide/FortuneUpgrade.kt | 1 + .../garden/fortuneguide/FortuneUpgrades.kt | 5 +- .../garden/fortuneguide/pages/UpgradePage.kt | 9 +-- .../garden/visitor/GardenVisitorDropStatistics.kt | 14 ++-- .../skyhanni/features/inventory/SackDisplay.kt | 33 ++++----- .../itemabilities/abilitycooldown/ItemAbility.kt | 3 +- .../features/mining/powdertracker/PowderTracker.kt | 4 +- .../skyhanni/features/misc/InGameDateDisplay.kt | 6 +- .../misc/items/EstimatedItemValueCalculator.kt | 8 +-- .../area/stillgorechateau/RiftBloodEffigies.kt | 58 +++++++--------- .../rift/everywhere/EnigmaSoulWaypoints.kt | 5 +- .../skyhanni/features/rift/everywhere/RiftTimer.kt | 61 +++++++++-------- .../features/slayer/SlayerBossSpawnSoon.kt | 6 +- .../features/slayer/SlayerRngMeterDisplay.kt | 15 ++--- 23 files changed, 183 insertions(+), 186 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features') 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.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 = 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): 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 = 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(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() - 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() @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 { " \\(?(?[0-9.,k]+)/(?[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 } -- cgit