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 | |
| 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')
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 |
