From fc8d82ca5e95d13bcd2205406f1ddcf9e525eb6d Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:18:35 +1000 Subject: 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> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../features/garden/EliteFarmingWeightConfig.java | 2 +- .../hannibal2/skyhanni/data/CropAccessoryData.kt | 6 +-- .../java/at/hannibal2/skyhanni/data/MaxwellAPI.kt | 32 ++++++------ .../hannibal2/skyhanni/events/SecondPassedEvent.kt | 2 +- .../features/bingo/card/BingoCardDisplay.kt | 10 ++-- .../skyhanni/features/chat/PlayerDeathMessages.kt | 8 ++- .../features/dungeon/CroesusChestTracker.kt | 22 ++++----- .../event/diana/InquisitorWaypointShare.kt | 9 ++-- .../features/event/winter/NewYearCakeReminder.kt | 29 ++++------- .../features/fame/AccountUpgradeReminder.kt | 12 ++--- .../skyhanni/features/fame/CityProjectFeatures.kt | 19 +++----- .../skyhanni/features/fishing/TotemOfCorruption.kt | 14 +++--- .../features/garden/AtmosphericFilterDisplay.kt | 5 +- .../features/garden/FarmingFortuneDisplay.kt | 4 +- .../features/garden/GardenNextJacobContest.kt | 34 ++++++------- .../composter/GardenComposterInventoryFeatures.kt | 20 +++++--- .../features/garden/farming/ArmorDropTracker.kt | 9 ++-- .../features/garden/farming/CropMoneyDisplay.kt | 4 +- .../garden/farming/FarmingWeightDisplay.kt | 18 ++++--- .../garden/farming/GardenCropMilestoneDisplay.kt | 2 +- .../visitor/HighlightVisitorsOutsideOfGarden.kt | 5 +- .../itemabilities/abilitycooldown/ItemAbility.kt | 3 +- .../skyhanni/features/mining/KingTalismanHelper.kt | 5 +- .../mining/eventtracker/MiningEventTracker.kt | 5 +- .../skyhanni/features/misc/ServerRestartTitle.kt | 57 ++++++++-------------- .../features/misc/items/EstimatedItemValue.kt | 2 +- .../misc/items/EstimatedItemValueCalculator.kt | 3 +- .../features/misc/items/EstimatedWardrobePrice.kt | 3 +- .../dailyquest/DailyQuestHelper.kt | 4 +- .../area/livingcave/LivingCaveDefenseBlocks.kt | 8 ++- .../area/livingcave/LivingMetalSuitProgress.kt | 5 +- .../area/stillgorechateau/RiftBloodEffigies.kt | 22 ++++----- .../rift/area/westvillage/kloon/KloonHacking.kt | 8 ++- .../rift/everywhere/CruxTalismanDisplay.kt | 4 +- .../features/slayer/blaze/BlazeSlayerClearView.kt | 35 +++++++------ .../slayer/enderman/EndermanSlayerFeatures.kt | 5 +- .../skyhanni/test/SkyHanniDebugsAndTests.kt | 6 +-- .../java/at/hannibal2/skyhanni/utils/ColorUtils.kt | 2 - .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 6 --- .../java/at/hannibal2/skyhanni/utils/NEUItems.kt | 22 ++------- .../java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 6 +-- 43 files changed, 205 insertions(+), 278 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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, 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() - 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(?.*) §e(power )?for your §aAccessory Bag§e!" ) - private val inventoryPowerPattern by group.pattern( + private val inventoryPowerPattern by patternGroup.pattern( "inventory.power", "§7Selected Power: §a(?.*)" ) - private val inventoryMPPattern by group.pattern( + private val inventoryMPPattern by patternGroup.pattern( "inventory.magicalpower", "§7Magical Power: §6(?[\\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", "§(?.)\\+(?[^ ]+)(?.) (?.+)" ) - private val thaumaturgyMagicalPowerPattern by group.pattern( + private val thaumaturgyMagicalPowerPattern by patternGroup.pattern( "gui.thaumaturgy.magicalpower", "§7Total: §6(?\\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\\+ §(?.)(?[^ ]+) (?.)" ) - 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 (?[IV]+)") - private val masterPattern by repoGroup.pattern("chest.master", ".*Master.*") + private val floorPattern by patternGroup.pattern("chest.floor", "§7Tier: §eFloor (?[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 (?