diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-03 03:24:50 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-03 03:24:50 +0100 |
commit | d4ee6c0e61a2543a654ade7be19b0effe95fb8d1 (patch) | |
tree | 2ff9e1c7d7e913cfa6e01c14ff93e2fe1b712aa0 /src/main | |
parent | 6e36d679df0444f19a65c6c81dd26e5b344a2cd7 (diff) | |
download | skyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.tar.gz skyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.tar.bz2 skyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.zip |
Increased performance and decreased ram usage.
Diffstat (limited to 'src/main')
5 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt index 470c8d171..d2726c3aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt @@ -17,6 +17,7 @@ class SkillExperience { // TODO USE SH-REPO private val actionBarPattern = ".*§3\\+.* (?<skill>.*) \\((?<overflow>.*)/(?<needed>.*)\\).*".toPattern() private val inventoryPattern = ".* §e(?<number>.*)§6/.*".toPattern() + private val actionBarLowLevelPattern = ".*§3+(?<add>.+) (?<skill>.*) \\((?<percentage>.*)%\\).*".toPattern() @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { @@ -37,8 +38,7 @@ class SkillExperience { skillExp[skill] = totalExp SkillExpGainEvent(skill).postAndCatch() } - val pattern = ".*§3+(?<add>.+) (?<skill>.*) \\((?<percentage>.*)%\\).*".toPattern() - pattern.matchMatcher(event.message) { + actionBarLowLevelPattern.matchMatcher(event.message) { val skill = group("skill").lowercase() SkillExpGainEvent(skill).postAndCatch() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt index a2dc399d8..4428fd072 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/MinionCraftHelper.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.hasEnchantments import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NEUItems.getCachedIngredients import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -130,7 +131,7 @@ class MinionCraftHelper { val recipes = NEUItems.getRecipes(minion) for (recipe in recipes) { - for (ingredient in recipe.ingredients) { + for (ingredient in recipe.getCachedIngredients()) { val ingredientInternalName = ingredient.internalItemId if (ingredientInternalName == internalName) return true @@ -161,7 +162,7 @@ class MinionCraftHelper { for (recipe in NEUItems.getRecipes(internalId)) { if (recipe !is CraftingRecipe) continue - for (ingredient in recipe.ingredients) { + for (ingredient in recipe.getCachedIngredients()) { val id = ingredient.internalItemId if (!id.contains("_GENERATOR_") && !allIngredients.contains(id)) { allIngredients.add(id) @@ -184,7 +185,7 @@ class MinionCraftHelper { for (minionId in tierOneMinionsFiltered) { for (recipe in NEUItems.getRecipes(minionId)) { if (recipe !is CraftingRecipe) continue - if (recipe.ingredients.any { help.contains(it.internalItemId) }) { + if (recipe.getCachedIngredients().any { help.contains(it.internalItemId) }) { val name = recipe.output.itemStack.name!!.removeColor() val abc = name.replace(" I", " 0") minions[abc] = minionId.replace("_1", "_0") diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt index 8284c0605..c596b2eab 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorTracker.kt @@ -59,7 +59,6 @@ object TrevorTracker { peltsPerSecond.clear() peltsPerHour = 0 stoppedChecks = 0 - saveAndUpdate() } private fun formatDisplay(map: List<List<Any>>): List<List<Any>> { diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt index 454ce6afa..8ae9f0c5e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt @@ -64,10 +64,10 @@ class PacketTest { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { + if (!enabled) return val packet = event.packet val packetName = packet.javaClass.simpleName - if (!enabled) return // Keep alive if (packetName == "S00PacketKeepAlive") return diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index 007d9f1d5..7965a2ded 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -17,6 +17,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe +import io.github.moulberry.notenoughupdates.recipes.Ingredient import io.github.moulberry.notenoughupdates.recipes.NeuRecipe import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery import io.github.moulberry.notenoughupdates.util.Utils @@ -34,6 +35,7 @@ object NEUItems { private val itemNameCache = mutableMapOf<String, NEUInternalName>() // item name -> internal name private val multiplierCache = mutableMapOf<String, Pair<String, Int>>() private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>() + private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>() private val enchantmentNamePattern = Pattern.compile("^(?<format>(?:§.)+)(?<name>[^§]+) (?<level>[IVXL]+)$") var allItemsCache = mapOf<String, NEUInternalName>() // item name -> internal name var allInternalNames = mutableListOf<NEUInternalName>() @@ -244,7 +246,7 @@ object NEUItems { if (recipe !is CraftingRecipe) continue val map = mutableMapOf<String, Int>() - for (ingredient in recipe.ingredients) { + for (ingredient in recipe.getCachedIngredients()) { val count = ingredient.count.toInt() var internalItemId = ingredient.internalItemId // ignore cactus green @@ -297,6 +299,8 @@ object NEUItems { return recipes } + fun NeuRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { ingredients } + fun neuHasFocus(): Boolean { if (AuctionSearchOverlay.shouldReplace()) return true if (BazaarSearchOverlay.shouldReplace()) return true |