diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-10 17:18:35 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-10 09:18:35 +0200 |
commit | fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d (patch) | |
tree | 034630ba350c42a5cfd582a2cfdc88bb15fb68cc /src/main/java/at | |
parent | 3397cc4474e3165865707182a5dcacf5bb4e68bd (diff) | |
download | skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.gz skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.tar.bz2 skyhanni-fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d.zip |
Backend: Remove some more deprecated functions and misc code cleanup (#1402)
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
43 files changed, 205 insertions, 278 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index e33295acd..a2a99eb20 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -710,7 +710,7 @@ class SkyHanniMod { loadModule(SackDisplay) loadModule(GardenStartLocation) loadModule(PetCandyUsedDisplay()) - loadModule(ServerRestartTitle()) + loadModule(ServerRestartTitle) loadModule(CityProjectFeatures()) loadModule(GardenPlotIcon) loadModule(GardenPlotBorders) @@ -758,7 +758,7 @@ class SkyHanniMod { loadModule(RiftMotesOrb()) loadModule(ChestValue()) loadModule(SlayerBossSpawnSoon()) - loadModule(RiftBloodEffigies()) + loadModule(RiftBloodEffigies) loadModule(RiftWiltedBerberisHelper()) loadModule(RiftHorsezookaHider()) loadModule(GriffinPetWarning()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index e762273f0..1e768df6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -11,7 +11,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 33 + const val CONFIG_VERSION = 34 fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/EliteFarmingWeightConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/EliteFarmingWeightConfig.java index 682236efb..1a681fddc 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/EliteFarmingWeightConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/EliteFarmingWeightConfig.java @@ -46,7 +46,7 @@ public class EliteFarmingWeightConfig { @Expose @ConfigOption(name = "ETA Goal", desc = "Override the Overtake ETA to show when you'll reach the specified rank (if not there yet). (Default: \"10,000\")") @ConfigEditorText - public String ETAGoalRank = "10000"; + public String etaGoalRank = "10000"; @Expose @ConfigOption(name = "Show below 200", desc = "Show the farming weight data even if you are below 200 weight.") diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index b05cc0e56..321e81e26 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropAccessory import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils @@ -28,7 +28,6 @@ class CropAccessoryData { ) private var loadedAccessoryThisProfile = false - private var ticks = 0 private var accessoryInBag: CropAccessory? = null private var accessoryInInventory = CropAccessory.NONE @@ -84,8 +83,7 @@ class CropAccessoryData { // Handle inventory detection @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!event.repeatSeconds(1)) return + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return accessoryInInventory = bestCropAccessory(InventoryUtils.getItemsInOwnInventory()) if (accessoryInInventory == CropAccessory.NONE) return diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt index ebfb4a892..eed541571 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt @@ -51,64 +51,64 @@ object MaxwellAPI { private var powers = mutableListOf<String>() - private val group = RepoPattern.group("data.maxwell") - private val chatPowerpattern by group.pattern( + private val patternGroup = RepoPattern.group("data.maxwell") + private val chatPowerpattern by patternGroup.pattern( "chat.power", "§eYou selected the §a(?<power>.*) §e(power )?for your §aAccessory Bag§e!" ) - private val inventoryPowerPattern by group.pattern( + private val inventoryPowerPattern by patternGroup.pattern( "inventory.power", "§7Selected Power: §a(?<power>.*)" ) - private val inventoryMPPattern by group.pattern( + private val inventoryMPPattern by patternGroup.pattern( "inventory.magicalpower", "§7Magical Power: §6(?<mp>[\\d,]+)" ) - private val thaumaturgyGuiPattern by group.pattern( + private val thaumaturgyGuiPattern by patternGroup.pattern( "gui.thaumaturgy", "Accessory Bag Thaumaturgy" ) - private val thaumaturgyStartPattern by group.pattern( + private val thaumaturgyStartPattern by patternGroup.pattern( "gui.thaumaturgy.start", "§7Your tuning:" ) - private val thaumaturgyDataPattern by group.pattern( + private val thaumaturgyDataPattern by patternGroup.pattern( "gui.thaumaturgy.data", "§(?<color>.)\\+(?<amount>[^ ]+)(?<icon>.) (?<name>.+)" ) - private val thaumaturgyMagicalPowerPattern by group.pattern( + private val thaumaturgyMagicalPowerPattern by patternGroup.pattern( "gui.thaumaturgy.magicalpower", "§7Total: §6(?<mp>\\d+) Magical Power" ) - private val statsTuningGuiPattern by group.pattern( + private val statsTuningGuiPattern by patternGroup.pattern( "gui.thaumaturgy.statstuning", "Stats Tuning" ) - private val statsTuningDataPattern by group.pattern( + private val statsTuningDataPattern by patternGroup.pattern( "thaumaturgy.statstuning", "§7You have: .+ §7\\+ §(?<color>.)(?<amount>[^ ]+) (?<icon>.)" ) - private val tuningAutoAssignedPattern by group.pattern( + private val tuningAutoAssignedPattern by patternGroup.pattern( "tuningpoints.chat.autoassigned", "§aYour §r§eTuning Points §r§awere auto-assigned as convenience!" ) - private val yourBagsGuiPattern by group.pattern( + private val yourBagsGuiPattern by patternGroup.pattern( "gui.yourbags", "Your Bags" ) - private val powerSelectedPattern by group.pattern( + private val powerSelectedPattern by patternGroup.pattern( "gui.selectedpower", "§aPower is selected!" ) - private val noPowerSelectedPattern by group.pattern( + private val noPowerSelectedPattern by patternGroup.pattern( "gui.noselectedpower", "(?:§.)*Visit Maxwell in the Hub to learn" ) - private val accessoryBagStack by group.pattern( + private val accessoryBagStack by patternGroup.pattern( "stack.accessorybag", "§.Accessory Bag" ) - private val redstoneCollectionRequirementPattern by group.pattern( + private val redstoneCollectionRequirementPattern by patternGroup.pattern( "collection.redstone.requirement", "(?:§.)*Requires (?:§.)*Redstone Collection I+(?:§.)*\\." ) diff --git a/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SecondPassedEvent.kt index 0175fefc5..d422a026f 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 == 0 + fun repeatSeconds(i: Int) = totalSeconds % i == 0 } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt index e1cd1dbca..9fca47fbc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/card/BingoCardDisplay.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.bingo.BingoCardUpdateEvent import at.hannibal2.skyhanni.features.bingo.BingoAPI import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal @@ -71,11 +71,9 @@ class BingoCardDisplay { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (event.repeatSeconds(1)) { - if (hasHiddenPersonalGoals) { - update() - } + fun onSecondPassed(event: SecondPassedEvent) { + if (hasHiddenPersonalGoals) { + update() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt index f44185c4c..2823d57d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chat/PlayerDeathMessages.kt @@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.features.chat import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.EntityUtils @@ -27,12 +27,10 @@ class PlayerDeathMessages { ) @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isHideFarDeathsEnabled()) return - if (event.repeatSeconds(1)) { - checkOtherPlayers() - } + checkOtherPlayers() } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt index ea94117af..176a40f59 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -34,19 +34,19 @@ class CroesusChestTracker { private val config get() = SkyHanniMod.feature.dungeon.chest - private val repoGroup = RepoPattern.group("dungeon.croesus") + private val patternGroup = RepoPattern.group("dungeon.croesus") - private val croesusPattern by repoGroup.pattern("inventory", "Croesus") - private val croesusEmptyPattern by repoGroup.pattern("empty", "§cNo treasures!") - private val kismetPattern by repoGroup.pattern("kismet.reroll", "§aReroll Chest") - private val kismetUsedPattern by repoGroup.pattern("kismet.used", "§aYou already rerolled a chest!") + private val croesusPattern by patternGroup.pattern("inventory", "Croesus") + private val croesusEmptyPattern by patternGroup.pattern("empty", "§cNo treasures!") + private val kismetPattern by patternGroup.pattern("kismet.reroll", "§aReroll Chest") + private val kismetUsedPattern by patternGroup.pattern("kismet.used", "§aYou already rerolled a chest!") - private val floorPattern by repoGroup.pattern("chest.floor", "§7Tier: §eFloor (?<floor>[IV]+)") - private val masterPattern by repoGroup.pattern("chest.master", ".*Master.*") + private val floorPattern by patternGroup.pattern("chest.floor", "§7Tier: §eFloor (?<floor>[IV]+)") + private val masterPattern by patternGroup.pattern("chest.master", ".*Master.*") - private val keyUsedPattern by repoGroup.pattern("chest.state.keyused", "§aNo more Chests to open!") - private val openedPattern by repoGroup.pattern("chest.state.opened", "§8Opened Chest:.*") - private val unopenedPattern by repoGroup.pattern("chest.state.unopened", "§8No Chests Opened!") + private val keyUsedPattern by patternGroup.pattern("chest.state.keyused", "§aNo more Chests to open!") + private val openedPattern by patternGroup.pattern("chest.state.opened", "§8Opened Chest:.*") + private val unopenedPattern by patternGroup.pattern("chest.state.unopened", "§8No Chests Opened!") private val kismetSlotId = 50 private val emptySlotId = 22 @@ -115,7 +115,7 @@ class CroesusChestTracker { private fun kismetDungeonChestSetup(event: InventoryFullyOpenedEvent) { chestInventory = DungeonChest.getByInventoryName(event.inventoryName) ?: return if (config.kismetStackSize) { - kismetAmountCache = getKismetAmount().toInt() + kismetAmountCache = getKismetAmount() } if (config.showUsedKismets) { val kismetItem = event.inventoryItems[kismetSlotId] ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 42a4c8850..33f7efab4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -4,9 +4,9 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.EntityHealthUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzKeyPressEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.EntityUtils @@ -84,15 +84,14 @@ object InquisitorWaypointShare { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (event.repeatSeconds(3)) { inquisitorsNearby = inquisitorsNearby.editCopy { removeIf { it.isDead } } } - if (event.repeatSeconds(1)) { - waypoints = waypoints.editCopy { values.removeIf { it.spawnTime.passedSince() > 75.seconds } } - } + + waypoints = waypoints.editCopy { values.removeIf { it.spawnTime.passedSince() > 75.seconds } } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt index 4bc6c02b5..9a68947dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/NewYearCakeReminder.kt @@ -2,10 +2,10 @@ package at.hannibal2.skyhanni.features.event.winter import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -23,14 +23,12 @@ class NewYearCakeReminder { "event.winter.newyearcake.reminder.sidebar", "§dNew Year Event!§f (?<time>.*)" ) - - private var cakeTime = false private var lastReminderSend = SimpleTimeMark.farPast() @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (event.message == "§aYou claimed a §r§cNew Year Cake§r§a!") { - makedClaimed() + markCakeClaimed() } } @@ -38,11 +36,11 @@ class NewYearCakeReminder { fun onInventoryOpen(event: InventoryFullyOpenedEvent) { // cake already claimed if (event.inventoryName == "Baker") { - makedClaimed() + markCakeClaimed() } } - private fun makedClaimed() { + private fun markCakeClaimed() { val playerSpecific = ProfileStorageData.playerSpecific ?: return playerSpecific.winter.cakeCollectedYear = SkyBlockTime.now().year } @@ -53,21 +51,10 @@ class NewYearCakeReminder { } @SubscribeEvent - fun onScoreboardChange(event: ScoreboardChangeEvent) { - cakeTime = event.newList.any { sidebarDetectionPattern.matches(it) } - } - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return - if (event.repeatSeconds(1)) { - check() - } - } - - private fun check() { - if (!cakeTime) return if (!config.newYearCakeReminder) return + if (!isCakeTime()) return if (ReminderUtils.isBusy()) return if (isClaimed()) return @@ -79,4 +66,6 @@ class NewYearCakeReminder { "openbaker" ) } + + private fun isCakeTime() = ScoreboardData.sidebarLinesFormatted.any { sidebarDetectionPattern.matches(it) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt index 4f1e3b5ea..ca700e2b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/AccountUpgradeReminder.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent 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.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -32,16 +32,11 @@ class AccountUpgradeReminder { } } + // TODO: Merge this logic with CityProjectFeatures reminder to reduce duplication @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return - if (event.repeatSeconds(1)) { - checkReminder() - } - } - // TODO: Merge this logic with CityProjectFeatures reminder to reduce duplication - private fun checkReminder() { if (!isEnabled()) return val playerSpecific = ProfileStorageData.playerSpecific ?: return if (ReminderUtils.isBusy()) return @@ -50,7 +45,6 @@ class AccountUpgradeReminder { val upgrade = playerSpecific.currentAccountUpgrade ?: return val nextCompletionTime = nextCompletionTime ?: return if (!nextCompletionTime.isInPast()) return - if (lastReminderSend.passedSince() < 30.seconds) return lastReminderSend = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt index c2bfd586e..f5f45862e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -38,12 +38,13 @@ import net.minecraft.client.gui.inventory.GuiEditSign import net.minecraft.inventory.ContainerChest import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds class CityProjectFeatures { private var display = emptyList<List<Any>>() private var inInventory = false - private var lastReminderSend = 0L + private var lastReminderSend = SimpleTimeMark.farPast() private val patternGroup = RepoPattern.group("fame.projects") private val contributeAgainPattern by patternGroup.pattern( @@ -65,14 +66,7 @@ class CityProjectFeatures { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!LorenzUtils.inSkyBlock) return - if (event.repeatSeconds(1)) { - checkDailyReminder() - } - } - - private fun checkDailyReminder() { + fun onSecondPassed(event: SecondPassedEvent) { if (!config.dailyReminder) return val playerSpecific = ProfileStorageData.playerSpecific ?: return if (ReminderUtils.isBusy()) return @@ -81,9 +75,8 @@ class CityProjectFeatures { if (playerSpecific.nextCityProjectParticipationTime == 0L) return if (System.currentTimeMillis() <= playerSpecific.nextCityProjectParticipationTime) return - - if (lastReminderSend + 30_000 > System.currentTimeMillis()) return - lastReminderSend = System.currentTimeMillis() + if (lastReminderSend.passedSince() < 30.seconds) return + lastReminderSend = SimpleTimeMark.now() ChatUtils.clickableChat( "Daily City Project Reminder! (Click here to disable this reminder)", diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 54e5d6c30..b6da38ccd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -4,8 +4,8 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.features.fishing.TotemOfCorruptionConfig.OutlineType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer @@ -35,16 +35,16 @@ class TotemOfCorruption { private var display = emptyList<String>() private var totems: List<Totem> = emptyList() - private val group = RepoPattern.group("fishing.totemofcorruption") - private val totemNamePattern by group.pattern( + private val patternGroup = RepoPattern.group("fishing.totemofcorruption") + private val totemNamePattern by patternGroup.pattern( "totemname", "§5§lTotem of Corruption" ) - private val timeRemainingPattern by group.pattern( + private val timeRemainingPattern by patternGroup.pattern( "timeremaining", "§7Remaining: §e(?:(?<min>\\d+)m )?(?<sec>\\d+)s" ) - private val ownerPattern by group.pattern( + private val ownerPattern by patternGroup.pattern( "owner", "§7Owner: §e(?<owner>.+)" ) @@ -56,7 +56,7 @@ class TotemOfCorruption { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!event.repeatSeconds(2)) return if (!isOverlayEnabled()) return @@ -148,7 +148,7 @@ class TotemOfCorruption { private fun isEffectiveAreaEnabled() = LorenzUtils.inSkyBlock && config.outlineType != OutlineType.NONE } -class Totem( +private class Totem( val location: LorenzVec, val timeRemaining: Duration, val ownerName: String, diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt index e4f81bf2e..dfd5c6533 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/AtmosphericFilterDisplay.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.enums.OutsideSbFeature import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.Season @@ -16,10 +16,9 @@ class AtmosphericFilterDisplay { private var display = "" @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (!GardenAPI.inGarden() && !config.outsideGarden) return - if (!event.repeatSeconds(1)) return display = drawDisplay(Season.getCurrentSeason() ?: return) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 3df7a8bbf..cf826429d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -15,7 +15,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables @@ -159,7 +159,7 @@ object FarmingFortuneDisplay { list.add(Renderable.string( "§6Farming Fortune§7: §e" + if (!recentlySwitchedTool && farmingFortune != -1.0) { - LorenzUtils.formatDouble(farmingFortune, 0) + farmingFortune.round(0).addSeparators() } else "§7" + (displayCrop.getLatestTrueFarmingFortune()?.addSeparators() ?: "?") )) add(Renderable.horizontalContainer(list)) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 055b79a02..6be8da28f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.test.command.ErrorManager @@ -74,8 +74,9 @@ object GardenNextJacobContest { "§(e○|6☘) §7(?<crop>.*)" ) - private val closeToNewYear = "§7Close to new SB year!" - private const val maxContestsPerYear = 124 + private const val CLOSE_TO_NEW_YEAR_TEXT = "§7Close to new SB year!" + private const val MAX_CONTESTS_PER_YEAR = 124 + private val contestDuration = 20.minutes private var lastWarningTime = SimpleTimeMark.farPast() @@ -146,7 +147,7 @@ object GardenNextJacobContest { } if (isCloseToNewYear()) { - newList.add(closeToNewYear) + newList.add(CLOSE_TO_NEW_YEAR_TEXT) } else { newList.add("§cOpen calendar for") newList.add("§cmore exact data!") @@ -166,9 +167,8 @@ object GardenNextJacobContest { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(2)) return if (inCalendar) return update() @@ -221,7 +221,7 @@ object GardenNextJacobContest { } // Skip if contests are already loaded for this year - if (contests.size == maxContestsPerYear) return + if (contests.size == MAX_CONTESTS_PER_YEAR) return // Manually loading contests for (item in items) { @@ -241,7 +241,7 @@ object GardenNextJacobContest { } // If contests were just fully saved - if (contests.size == maxContestsPerYear) { + if (contests.size == MAX_CONTESTS_PER_YEAR) { nextContestsAvailableAt = SkyBlockTime(SkyBlockTime.now().year + 1, 1, 2).toMillis() if (isSendEnabled()) { @@ -302,7 +302,7 @@ object GardenNextJacobContest { } return } - if (contests.size == maxContestsPerYear) { + if (contests.size == MAX_CONTESTS_PER_YEAR) { sendContests() } if (!SkyHanniMod.feature.storage.contestSendingAsked && config.shareAutomatically == ShareContestsEntry.ASK) { @@ -338,7 +338,7 @@ object GardenNextJacobContest { if (inCalendar) { val size = contests.size - val percentage = size.toDouble() / maxContestsPerYear + val percentage = size.toDouble() / MAX_CONTESTS_PER_YEAR val formatted = LorenzUtils.formatPercentage(percentage) list.add("§eDetected $formatted of farming contests this year") @@ -347,7 +347,7 @@ object GardenNextJacobContest { if (contests.isEmpty()) { if (isCloseToNewYear()) { - list.add(closeToNewYear) + list.add(CLOSE_TO_NEW_YEAR_TEXT) } else { list.add("§cOpen calendar to read Jacob contest times!") } @@ -361,7 +361,7 @@ object GardenNextJacobContest { if (nextContest != null) return drawNextContest(nextContest, list) if (isCloseToNewYear()) { - list.add(closeToNewYear) + list.add(CLOSE_TO_NEW_YEAR_TEXT) } else { list.add("§cOpen calendar to read Jacob contest times!") } @@ -378,7 +378,7 @@ object GardenNextJacobContest { ): MutableList<Any> { var duration = nextContest.endTime.timeUntil() if (duration > 4.days) { - list.add(closeToNewYear) + list.add(CLOSE_TO_NEW_YEAR_TEXT) return list } @@ -524,7 +524,7 @@ object GardenNextJacobContest { config.shareAutomatically == ShareContestsEntry.ASK // (Only call if isSendEnabled()) private fun fetchContestsIfAble() { - if (isFetchingContests || contests.size == maxContestsPerYear || !isFetchEnabled()) return + if (isFetchingContests || contests.size == MAX_CONTESTS_PER_YEAR || !isFetchEnabled()) return // Allows retries every 10 minutes when it's after 1 day into the new year val currentMills = System.currentTimeMillis() if (lastFetchAttempted + 600_000 > currentMills || currentMills < nextContestsAvailableAt) return @@ -565,7 +565,7 @@ object GardenNextJacobContest { ChatUtils.clickableChat("Click here to open your calendar!", "calendar") } - if (newContests.count() == maxContestsPerYear) { + if (newContests.count() == MAX_CONTESTS_PER_YEAR) { ChatUtils.chat("Successfully loaded this year's contests from elitebot.dev automatically!") contests = newContests @@ -585,7 +585,7 @@ object GardenNextJacobContest { } private fun sendContests() { - if (isSendingContests || contests.size != maxContestsPerYear || isCloseToNewYear()) return + if (isSendingContests || contests.size != MAX_CONTESTS_PER_YEAR || isCloseToNewYear()) return isSendingContests = true @@ -614,7 +614,7 @@ object GardenNextJacobContest { } else { ErrorManager.logErrorStateWithData( "Something went wrong submitting upcoming contests!", - "submitContestsToElite not sucessful" + "submitContestsToElite not successful" ) } } catch (e: Exception) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt index c8eebc10a..bffd6ac17 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/GardenComposterInventoryFeatures.kt @@ -4,14 +4,14 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.InventoryUtils.getUpperItems import at.hannibal2.skyhanni.utils.ItemUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.highlight @@ -48,14 +48,18 @@ class GardenComposterInventoryFeatures { if (line.endsWith(" Copper")) continue if (line == "") break val (itemName, amount) = ItemUtils.readItemAmount(line) ?: run { - ChatUtils.error("Could not read item '$line'") + ErrorManager.logErrorStateWithData( + "Error reading item line", + "could not read item line", + "line" to line + ) continue } - val internalName = NEUItems.getInternalNameOrNull(itemName) - if (internalName == null) { - ChatUtils.error( - "Error reading internal name for item '$itemName§c' " + - "(in GardenComposterInventoryFeatures)" + val internalName = NEUInternalName.fromItemNameOrNull(itemName) ?: run { + ErrorManager.logErrorStateWithData( + "Error reading internal name for item: $itemName", + "could not find internal name for", + "itemName" to itemName ) continue } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt index 5e6494f66..46ff67a2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt @@ -7,9 +7,9 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.ArmorDropsJson.DropInfo import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList @@ -51,6 +51,7 @@ object ArmorDropTracker { var drops: MutableMap<ArmorDropType, Int> = mutableMapOf() } + // Todo use repo pattern enum class ArmorDropType(val dropName: String, val chatMessage: String) { CROPIE("§9Cropie", "§6§lRARE CROP! §r§f§r§9Cropie §r§b(Armor Set Bonus)"), SQUASH("§5Squash", "§6§lRARE CROP! §r§f§r§5Squash §r§b(Armor Set Bonus)"), @@ -105,13 +106,11 @@ object ArmorDropTracker { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!GardenAPI.inGarden()) return if (!config.enabled) return - if (event.repeatSeconds(1)) { - checkArmor() - } + checkArmor() } private fun checkArmor() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 3b5ee8dab..3f796c47d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.garden.MoneyPerHourConfig.CustomFormatEntry import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.CropType.Companion.getByNameOrNull import at.hannibal2.skyhanni.features.garden.GardenAPI @@ -80,7 +80,7 @@ object CropMoneyDisplay { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (!event.repeatSeconds(5)) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt index eda69d483..71490fe2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt @@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.ChatUtils 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.OSUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables @@ -95,6 +96,7 @@ class FarmingWeightDisplay { event.move(3, "garden.eliteFarmingWeightETAGoalRank", "garden.eliteFarmingWeights.ETAGoalRank") event.move(3, "garden.eliteFarmingWeightIgnoreLow", "garden.eliteFarmingWeights.ignoreLow") event.move(14, "garden.eliteFarmingWeight.offScreenDropMessage", "garden.eliteFarmingWeights.showLbChange") + event.move(34, "garden.eliteFarmingWeights.ETAGoalRank", "garden.eliteFarmingWeights.etaGoalRank") } companion object { @@ -219,22 +221,22 @@ class FarmingWeightDisplay { } val totalWeight = (localWeight + weight) - return "§e" + LorenzUtils.formatDouble(totalWeight, 2) + return "§e" + totalWeight.round(2).addSeparators() } private fun getRankGoal(): Int { - val value = config.ETAGoalRank + val value = config.etaGoalRank var goal = 10000 // Check that the provided string is valid val parsed = value.toIntOrNull() ?: 0 if (parsed < 1 || parsed > goal) { - ChatUtils.error("Invalid Farming Weight Overtake Goal!") - ChatUtils.chat( - "§eEdit the Overtake Goal config value with a valid number [1-10000] to use this feature!", - false + ChatUtils.chatAndOpenConfig( + "Invalid Farming Weight Overtake Goal! Click here to edit the Overtake Goal config value " + + "to a valid number [1-10000] to use this feature!", + GardenAPI.config.eliteFarmingWeights::etaGoalRank ) - config.ETAGoalRank = goal.toString() + config.etaGoalRank = goal.toString() } else { goal = parsed } @@ -299,7 +301,7 @@ class FarmingWeightDisplay { " §7(§b$format§7)" } else "" - val weightFormat = LorenzUtils.formatDouble(weightUntilOvertake, 2) + val weightFormat = weightUntilOvertake.round(2).addSeparators() val text = "§e$weightFormat$timeFormat §7behind §b$nextName" return if (showRankGoal) { Renderable.string(text) 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 112fce914..43b3f8ab7 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 @@ -197,7 +197,7 @@ object GardenCropMilestoneDisplay { val format = (farmingFortuneSpeed * 60).addSeparators() lineMap[4] = Collections.singletonList("§7Crops/Minute§8: §e$format") - val formatBps = LorenzUtils.formatDouble(speed, config.blocksBrokenPrecision) + val formatBps = speed.round(config.blocksBrokenPrecision).addSeparators() lineMap[5] = Collections.singletonList("§7Blocks/Second§8: §e$formatBps") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt index 582f0b359..1faa94c81 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -2,9 +2,9 @@ package at.hannibal2.skyhanni.features.garden.visitor import at.hannibal2.skyhanni.config.features.garden.visitor.VisitorConfig.VisitorBlockBehaviour import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.ChatUtils @@ -63,9 +63,8 @@ class HighlightVisitorsOutsideOfGarden { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!config.highlightVisitors) return - if (!event.repeatSeconds(1)) return EntityUtils.getEntities<EntityLivingBase>() .filter { it !is EntityArmorStand && isVisitor(it) } .forEach { 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 2787215f0..256beb0de 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 @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.utils.LorenzColor 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.addSeparators @@ -103,7 +104,7 @@ enum class ItemAbility( duration /= 100 var d = duration.toDouble() d /= 10.0 - LorenzUtils.formatDouble(d) + d.round(1).addSeparators() } else { duration /= 1000 duration++ diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt index ca92ddb2b..1643c460a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/KingTalismanHelper.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.sorted import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc @@ -70,8 +70,7 @@ class KingTalismanHelper { kingLocation.distanceToPlayer() < 10 @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!event.repeatSeconds(1)) return + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return val storage = storage ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt index 9d0ce3c33..251466cc9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt @@ -8,8 +8,8 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.BossbarUpdateEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.APIUtil import at.hannibal2.skyhanni.utils.LorenzUtils @@ -89,8 +89,7 @@ class MiningEventTracker { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!event.repeatSeconds(1)) return + fun onSecondPassed(event: SecondPassedEvent) { if (!config.enabled) return if (!LorenzUtils.inSkyBlock || (!config.outsideMining && !LorenzUtils.inAdvancedMiningIsland())) return if (!canRequestAt.isInPast()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt index acab50046..7c483a63a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ServerRestartTitle.kt @@ -2,57 +2,40 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst 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.Companion.minutes import kotlin.time.Duration.Companion.seconds -class ServerRestartTitle { +object ServerRestartTitle { private val config get() = SkyHanniMod.feature.misc - - companion object { - private val restartingGroup = RepoPattern.group("features.misc.serverrestart") - private val restartingPattern by restartingGroup.pattern( - "time", - "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) ?§8.*" - ) - val restartingGreedyPattern by restartingGroup.pattern( - "greedy", - "§cServer closing.*" - ) - } + private val patternGroup = RepoPattern.group("features.misc.serverrestart") + private val restartingPattern by patternGroup.pattern( + "time", + "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) ?§8.*" + ) + val restartingGreedyPattern by patternGroup.pattern( + "greedy", + "§cServer closing.*" + ) @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.serverRestartTitle) return - if (!event.repeatSeconds(1)) return - - for (line in ScoreboardData.sidebarLinesFormatted) { - restartingPattern.matchMatcher(line) { - try { - val minutes = group("minutes").toInt().minutes - val seconds = group("seconds").toInt().seconds - val totalTime = minutes + seconds - if (totalTime > 2.minutes && totalTime.inWholeSeconds % 30 != 0L) return - val time = totalTime.format() - LorenzUtils.sendTitle("§cServer Restart in §b$time", 2.seconds) - } catch (e: Throwable) { - ErrorManager.logErrorWithData( - e, "Error reading server restart time from scoreboard", - "line" to line, - "restartPattern" to restartingPattern.pattern(), - ) - } - return - } + ScoreboardData.sidebarLinesFormatted.matchFirst(restartingPattern) { + val minutes = group("minutes").toInt().minutes + val seconds = group("seconds").toInt().seconds + val totalTime = minutes + seconds + if (totalTime > 2.minutes && totalTime.inWholeSeconds % 30 != 0L) return + val time = totalTime.format() + LorenzUtils.sendTitle("§cServer Restart in §b$time", 2.seconds) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 71b0f831d..6106e4c1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -38,7 +38,7 @@ import kotlin.math.roundToLong object EstimatedItemValue { - val config get() = SkyHanniMod.feature.inventory.estimatedItemValues + private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues private var display = emptyList<List<Any>>() private val cache = mutableMapOf<ItemStack, List<List<Any>>>() private var lastToolTipTime = 0L 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 1baf781ef..14812cd74 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 @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.misc.items +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -54,7 +55,7 @@ import java.util.Locale object EstimatedItemValueCalculator { - private val config get() = EstimatedItemValue.config + private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues private val additionalCostFunctions = listOf( ::addAttributeCost, ::addReforgeStone, diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt index c36fdbbf5..2c3e00803 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedWardrobePrice.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.misc.items +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent @@ -13,7 +14,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class EstimatedWardrobePrice { - private val config get() = EstimatedItemValue.config + private val config get() = SkyHanniMod.feature.inventory.estimatedItemValues var data = mutableMapOf<Int, MutableList<ItemStack>>() @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index 30356b9c9..f06a997ec 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.nether.kuudra.KuudraTier import at.hannibal2.skyhanni.features.nether.reputationhelper.CrimsonIsleReputationHelper @@ -71,7 +71,7 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (event.repeatSeconds(3)) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt index 17af7fd1a..7b673f65e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt @@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper @@ -31,11 +31,9 @@ class LivingCaveDefenseBlocks { class DefenseBlock(val entity: EntityOtherPlayerMP, val location: LorenzVec, var hidden: Boolean = false) @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (event.repeatSeconds(1)) { - staticBlocks = staticBlocks.editCopy { removeIf { it.entity.isDead } } - } + staticBlocks = staticBlocks.editCopy { removeIf { it.entity.isDead } } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt index aa8bc1889..f64d5b42c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingMetalSuitProgress.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.InventoryUtils @@ -56,9 +56,8 @@ class LivingMetalSuitProgress { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return - if (!event.repeatSeconds(1)) return val old = progressMap progressMap = buildMap { for (armor in InventoryUtils.getArmor().filterNotNull()) { 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 261229e09..b31c7fb40 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 @@ -28,24 +28,22 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes -class RiftBloodEffigies { +object RiftBloodEffigies { private val config get() = RiftAPI.config.area.stillgoreChateau.bloodEffigies private var locations: List<LorenzVec> = emptyList() private var effigiesTimes = cleanMap() - companion object { - private val group = RepoPattern.group("rift.area.stillgore.effegies") - val effigiesTimerPattern by group.pattern( - "respawn", - "§eRespawn §c(?<time>.*) §7\\(or click!\\)" - ) - val heartsPattern by group.pattern( - "heart", - "Effigies: (?<hearts>((§[7c])?⧯)*)" - ) - } + private val patternGroup = RepoPattern.group("rift.area.stillgore.effegies") + private val effigiesTimerPattern by patternGroup.pattern( + "respawn", + "§eRespawn §c(?<time>.*) §7\\(or click!\\)" + ) + val heartsPattern by patternGroup.pattern( + "heart", + "Effigies: (?<hearts>((§[7c])?⧯)*)" + ) @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt index 83890c360..2470eacda 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/kloon/KloonHacking.kt @@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzToolTipEvent +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.InventoryUtils @@ -39,11 +39,9 @@ class KloonHacking { private var nearestTerminal: KloonTerminal? = null @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!RiftAPI.inRift()) return - if (event.repeatSeconds(1)) { - checkHelmet() - } + checkHelmet() } private fun checkHelmet() { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt index a38de4fd3..7ba556680 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.rift.everywhere import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.ConditionalUtils @@ -86,7 +86,7 @@ object CruxTalismanDisplay { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!isEnabled()) return if (!event.repeatSeconds(2)) return if (!InventoryUtils.getItemsInOwnInventory().any { it.getInternalName().startsWith(partialName) }) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt index a4555eaf3..7724c7e22 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -3,8 +3,8 @@ package at.hannibal2.skyhanni.features.slayer.blaze import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.features.combat.damageindicator.BossType import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils @@ -16,24 +16,23 @@ class BlazeSlayerClearView { private var nearBlaze = false @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!LorenzUtils.inSkyBlock) return - if (event.repeatSeconds(3)) { - nearBlaze = DamageIndicatorManager.getDistanceTo( - BossType.SLAYER_BLAZE_1, - BossType.SLAYER_BLAZE_2, - BossType.SLAYER_BLAZE_3, - BossType.SLAYER_BLAZE_4, - BossType.SLAYER_BLAZE_TYPHOEUS_1, - BossType.SLAYER_BLAZE_TYPHOEUS_2, - BossType.SLAYER_BLAZE_TYPHOEUS_3, - BossType.SLAYER_BLAZE_TYPHOEUS_4, - BossType.SLAYER_BLAZE_QUAZII_1, - BossType.SLAYER_BLAZE_QUAZII_2, - BossType.SLAYER_BLAZE_QUAZII_3, - BossType.SLAYER_BLAZE_QUAZII_4, - ) < 10 - } + if (!event.repeatSeconds(3)) return + nearBlaze = DamageIndicatorManager.getDistanceTo( + BossType.SLAYER_BLAZE_1, + BossType.SLAYER_BLAZE_2, + BossType.SLAYER_BLAZE_3, + BossType.SLAYER_BLAZE_4, + BossType.SLAYER_BLAZE_TYPHOEUS_1, + BossType.SLAYER_BLAZE_TYPHOEUS_2, + BossType.SLAYER_BLAZE_TYPHOEUS_3, + BossType.SLAYER_BLAZE_TYPHOEUS_4, + BossType.SLAYER_BLAZE_QUAZII_1, + BossType.SLAYER_BLAZE_QUAZII_2, + BossType.SLAYER_BLAZE_QUAZII_3, + BossType.SLAYER_BLAZE_QUAZII_4, + ) < 10 } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index fb6b57bab..a3359202c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -5,8 +5,8 @@ import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.CheckRenderEntityEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled @@ -161,9 +161,8 @@ class EndermanSlayerFeatures { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onSecondPassed(event: SecondPassedEvent) { if (!IslandType.THE_END.isInIsland()) return - if (!event.repeatSeconds(1)) return nukekubiSkulls.removeAll { if (it.isDead) { diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 4ece06c55..43e3974da 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -337,9 +337,9 @@ class SkyHanniDebugsAndTests { fun copyLocation(args: Array<String>) { val location = LocationUtils.playerLocation() - val x = LorenzUtils.formatDouble(location.x + 0.001).replace(",", ".") - val y = LorenzUtils.formatDouble(location.y + 0.001).replace(",", ".") - val z = LorenzUtils.formatDouble(location.z + 0.001).replace(",", ".") + val x = (location.x + 0.001).round(1) + val y = (location.y + 0.001).round(1) + val z = (location.z + 0.001).round(1) if (args.size == 1 && args[0].equals("json", false)) { OSUtils.copyToClipboard("\"$x:$y:$z\"") return diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt index 3b1986d40..97a1342c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ColorUtils.kt @@ -34,5 +34,3 @@ object ColorUtils { fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) } - - diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index c292abafd..bf258dab9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.ChatUtils.lastButtonClicked import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.capAtMinecraftLength import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID @@ -133,11 +132,6 @@ object LorenzUtils { fun formatPercentage(percentage: Double, format: String?): String = DecimalFormat(format).format(percentage * 100).replace(',', '.') + "%" - @Deprecated("old code", ReplaceWith("d.round(round).addSeparators()")) - fun formatDouble(d: Double, round: Int = 1): String { - return d.round(round).addSeparators() - } - fun consoleLog(text: String) { SkyHanniMod.consoleLog(text) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 2330a6a1d..87a265c84 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -93,9 +93,6 @@ object NEUItems { return map } - @Deprecated("moved", ReplaceWith("NEUInternalName.fromItemNameOrNull(itemName)")) - fun getInternalNameOrNull(itemName: String): NEUInternalName? = NEUInternalName.fromItemNameOrNull(itemName) - fun getInternalName(itemStack: ItemStack): String? = ItemResolutionQuery(manager) .withCurrentGuiContext() .withItemStack(itemStack) @@ -171,9 +168,9 @@ object NEUItems { val translateX: Float val translateY: Float if (isSkull) { - val skulldiff = ((scaleMultiplier) * 2.5).toFloat() - translateX = x - skulldiff - translateY = y - skulldiff + val skullDiff = ((scaleMultiplier) * 2.5).toFloat() + translateX = x - skullDiff + translateY = y - skullDiff } else { translateX = x translateY = y @@ -277,19 +274,10 @@ object NEUItems { return result } - @Deprecated("Do not use strings as id", ReplaceWith("NEUItems.getMultiplier(internalName.asInternalName())")) - fun getMultiplier(internalName: String, tryCount: Int = 0): Pair<String, Int> { - val pair = getMultiplier(internalName.asInternalName(), tryCount) - return Pair(pair.first.asString(), pair.second) - } - fun getRecipes(internalName: NEUInternalName): Set<NeuRecipe> { - if (recipesCache.contains(internalName)) { - return recipesCache[internalName]!! + return recipesCache.getOrPut(internalName) { + manager.getRecipesFor(internalName.asString()) } - val recipes = manager.getRecipesFor(internalName.asString()) - recipesCache[internalName] = recipes - return recipes } fun NeuRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { ingredients } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index f9b1ceb7a..e2df5349f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -170,11 +170,11 @@ object NumberUtil { lastDecimal + decimal } - val pattern = "^[0-9]*$".toPattern() - val formatPattern = "^[0-9,.]*[kmb]?$".toPattern() + private val numberPattern = "^[0-9]*$".toPattern() + private val formatPattern = "^[0-9,.]*[kmb]?$".toPattern() fun String.isInt(): Boolean { - return isNotEmpty() && pattern.matcher(this).matches() + return isNotEmpty() && numberPattern.matcher(this).matches() } fun String.isFormatNumber(): Boolean { |