diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-04-05 05:46:27 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-04 20:46:27 +0200 |
| commit | 15db91ced38a8cc4c7c16565422fce5566c6057c (patch) | |
| tree | 487804f98d4cad7316ea8b4f0f033fe530b2c4a5 | |
| parent | 52afdbf62ef5c35403132696918b9cfcc8faffdb (diff) | |
| download | SkyHanni-15db91ced38a8cc4c7c16565422fce5566c6057c.tar.gz SkyHanni-15db91ced38a8cc4c7c16565422fce5566c6057c.tar.bz2 SkyHanni-15db91ced38a8cc4c7c16565422fce5566c6057c.zip | |
Backend: matchFirst function for lists of strings (#1353)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
28 files changed, 219 insertions, 274 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index 75941dcd6..c24e9b1cc 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -13,7 +13,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatLong -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -51,13 +51,11 @@ object CollectionAPI { val inventoryName = event.inventoryName if (inventoryName.endsWith(" Collection")) { val stack = event.inventoryItems[4] ?: return - loop@ for (line in stack.getLore()) { - singleCounterPattern.matchMatcher(line) { - val counter = group("amount").formatLong() - val name = inventoryName.split(" ").dropLast(1).joinToString(" ") - val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name) - collectionValue[internalName] = counter - } + stack.getLore().matchFirst(singleCounterPattern) { + val counter = group("amount").formatLong() + val name = inventoryName.split(" ").dropLast(1).joinToString(" ") + val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name) + collectionValue[internalName] = counter } CollectionUpdateEvent().postAndCatch() } @@ -77,11 +75,9 @@ object CollectionAPI { } val internalName = incorrectCollectionNames[name] ?: NEUInternalName.fromItemName(name) - loop@ for (line in lore) { - counterPattern.matchMatcher(line) { - val counter = group("amount").formatLong() - collectionValue[internalName] = counter - } + lore.matchFirst(counterPattern) { + val counter = group("amount").formatLong() + collectionValue[internalName] = counter } } CollectionUpdateEvent().postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt index 54131f4bf..72210ad63 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeResets @@ -162,15 +163,11 @@ object BitsAPI { return } - for (line in cookieStack.getLore()) { - bitsAvailableMenuPattern.matchMatcher(line) { - val amount = group("toClaim").formatInt() - if (bitsToClaim != amount) { - bitsToClaim = amount - sendEvent() - } - - return + cookieStack.getLore().matchFirst(bitsAvailableMenuPattern) { + val amount = group("toClaim").formatInt() + if (bitsToClaim != amount) { + bitsToClaim = amount + sendEvent() } } return diff --git a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt index 5f61f0330..0038f4448 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GardenCropMilestones.kt @@ -7,8 +7,8 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -25,11 +25,9 @@ object GardenCropMilestones { ) fun getCropTypeByLore(itemStack: ItemStack): CropType? { - for (line in itemStack.getLore()) { - cropPattern.matchMatcher(line) { - val name = group("name") - return CropType.getByNameOrNull(name) - } + itemStack.getLore().matchFirst(cropPattern) { + val name = group("name") + return CropType.getByNameOrNull(name) } return null } @@ -40,11 +38,9 @@ object GardenCropMilestones { for ((_, stack) in event.inventoryItems) { val crop = getCropTypeByLore(stack) ?: continue - for (line in stack.getLore()) { - totalPattern.matchMatcher(line) { - val amount = group("name").formatNumber() - crop.setCounter(amount) - } + stack.getLore().matchFirst(totalPattern) { + val amount = group("name").formatLong() + crop.setCounter(amount) } } CropMilestoneUpdateEvent().postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 7fc50447f..3ea3a9008 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -72,7 +73,7 @@ class HypixelData { ) private val scoreboardVisitingAmoutPattern by patternGroup.pattern( "scoreboard.visiting.amount", - "\\s+§.✌ §.\\(§.(?<currentamount>\\d+)§.\\/(?<maxamount>\\d+)\\)" + "\\s+§.✌ §.\\(§.(?<currentamount>\\d+)§./(?<maxamount>\\d+)\\)" ) private val guestPattern by patternGroup.pattern( "guesting.scoreboard", @@ -127,19 +128,15 @@ class HypixelData { if (LorenzUtils.lastWorldSwitch.passedSince() < 1.seconds) return if (!TabListData.fullyLoaded) return - ScoreboardData.sidebarLinesFormatted.forEach { - serverIdScoreboardPattern.matchMatcher(it) { - val serverType = if (group("servertype") == "M") "mega" else "mini" - serverId = "$serverType${group("serverid")}" - return - } + ScoreboardData.sidebarLinesFormatted.matchFirst(serverIdScoreboardPattern) { + val serverType = if (group("servertype") == "M") "mega" else "mini" + serverId = "$serverType${group("serverid")}" + return } - TabListData.getTabList().forEach { - serverIdTablistPattern.matchMatcher(it) { - serverId = group("serverid") - return - } + TabListData.getTabList().matchFirst(serverIdTablistPattern) { + serverId = group("serverid") + return } ErrorManager.logErrorWithData( @@ -172,10 +169,8 @@ class HypixelData { } fun getMaxPlayersForCurrentServer(): Int { - for (line in ScoreboardData.sidebarLinesFormatted) { - scoreboardVisitingAmoutPattern.matchMatcher(line) { - return group("maxamount").toInt() - } + ScoreboardData.sidebarLinesFormatted.matchFirst(scoreboardVisitingAmoutPattern) { + return group("maxamount").toInt() } return if (serverId?.startsWith("mega") == true) 80 else 26 } @@ -255,16 +250,14 @@ class HypixelData { @SubscribeEvent fun onTabListUpdate(event: TabListUpdateEvent) { - for (line in event.tabList) { - UtilsPatterns.tabListProfilePattern.matchMatcher(line) { - var newProfile = group("profile").lowercase() - // Hypixel shows the profile name reversed while in the Rift - if (RiftAPI.inRift()) newProfile = newProfile.reversed() - if (profileName == newProfile) return - profileName = newProfile - ProfileJoinEvent(newProfile).postAndCatch() - return - } + event.tabList.matchFirst(UtilsPatterns.tabListProfilePattern) { + var newProfile = group("profile").lowercase() + + // Hypixel shows the profile name reversed while in the Rift + if (RiftAPI.inRift()) newProfile = newProfile.reversed() + if (profileName == newProfile) return + profileName = newProfile + ProfileJoinEvent(newProfile).postAndCatch() } } @@ -320,15 +313,13 @@ class HypixelData { skyBlock = inSkyBlock } - private fun checkProfileName(): Boolean { - if (profileName.isEmpty()) { - val text = TabListData.getTabList().firstOrNull { it.contains("Profile:") } ?: return true - UtilsPatterns.tabListProfilePattern.matchMatcher(text) { - profileName = group("profile").lowercase() - ProfileJoinEvent(profileName).postAndCatch() - } + private fun checkProfileName() { + if (profileName.isNotEmpty()) return + + TabListData.getTabList().matchFirst(UtilsPatterns.tabListProfilePattern) { + profileName = group("profile").lowercase() + ProfileJoinEvent(profileName).postAndCatch() } - return false } private fun checkHypixel() { @@ -364,24 +355,22 @@ class HypixelData { } private fun checkIsland() { - var newIsland = "" + var foundIsland = "" TabListData.fullyLoaded = false - for (line in TabListData.getTabList()) { - islandNamePattern.matchMatcher(line) { - newIsland = group("island").removeColor() - TabListData.fullyLoaded = true - } + TabListData.getTabList().matchFirst(islandNamePattern) { + foundIsland = group("island").removeColor() + TabListData.fullyLoaded = true } // Can not use color coding, because of the color effect (§f§lSKYB§6§lL§e§lOCK§A§L GUEST) val guesting = guestPattern.matches(ScoreboardData.objectiveTitle.removeColor()) - val islandType = getIslandType(newIsland, guesting) + val islandType = getIslandType(foundIsland, guesting) if (skyBlockIsland != islandType) { IslandChangeEvent(islandType, skyBlockIsland).postAndCatch() if (islandType == IslandType.UNKNOWN) { - ChatUtils.debug("Unknown island detected: '$newIsland'") - loggerIslandChange.log("Unknown: '$newIsland'") + ChatUtils.debug("Unknown island detected: '$foundIsland'") + loggerIslandChange.log("Unknown: '$foundIsland'") } else { loggerIslandChange.log(islandType.name) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt index 622683066..2e42bb002 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ProfileStorageData.kt @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.TabListData import at.hannibal2.skyhanni.utils.UtilsPatterns import net.minecraftforge.fml.common.eventhandler.EventPriority @@ -51,11 +51,9 @@ object ProfileStorageData { fun onTabListUpdate(event: TabListUpdateEvent) { if (!LorenzUtils.inSkyBlock) return - for (line in event.tabList) { - UtilsPatterns.tabListProfilePattern.matchMatcher(line) { - noTabListTime = SimpleTimeMark.farPast() - return - } + event.tabList.matchFirst(UtilsPatterns.tabListProfilePattern) { + noTabListTime = SimpleTimeMark.farPast() + return } noTabListTime = SimpleTimeMark.now() diff --git a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt index f4266f800..ff8f4b5e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/PurseAPI.kt @@ -1,12 +1,12 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent +import at.hannibal2.skyhanni.events.ScoreboardChangeEvent import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble import at.hannibal2.skyhanni.utils.NumberUtil.million -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -32,13 +32,11 @@ object PurseAPI { } @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - for (line in ScoreboardData.sidebarLinesFormatted) { - val newPurse = coinsPattern.matchMatcher(line) { - group("coins").formatDouble() - } ?: continue + fun onScoreboardChange(event: ScoreboardChangeEvent) { + event.newList.matchFirst(coinsPattern) { + val newPurse = group("coins").formatDouble() val diff = newPurse - currentPurse - if (diff == 0.0) continue + if (diff == 0.0) return currentPurse = newPurse PurseChangeEvent(diff, getCause(diff)).postAndCatch() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index f0eca0fd9..1543aaf01 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -88,11 +89,8 @@ object DungeonAPI { } fun getTime(): String { - loop@ for (line in ScoreboardData.sidebarLinesFormatted) { - timePattern.matchMatcher(line.removeColor()) { - if (!matches()) continue@loop - return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14 - } + ScoreboardData.sidebarLinesFormatted.matchFirst(timePattern) { + return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14 } return "" } @@ -121,12 +119,10 @@ object DungeonAPI { @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (dungeonFloor == null) { - for (line in ScoreboardData.sidebarLinesFormatted) { - floorPattern.matchMatcher(line) { - val floor = group("floor") - dungeonFloor = floor - DungeonEnterEvent(floor).postAndCatch() - } + ScoreboardData.sidebarLinesFormatted.matchFirst(floorPattern) { + val floor = group("floor") + dungeonFloor = floor + DungeonEnterEvent(floor).postAndCatch() } } if (dungeonFloor != null && playerClass == null) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt index 107156f2e..90e401fc5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt @@ -9,9 +9,9 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -34,13 +34,10 @@ object UniqueGiftCounter { val storage = storage ?: return - for (line in item.getLore()) { - giftedAmountPattern.matchMatcher(line) { - val amount = group("amount").formatNumber().toInt() - storage.amountGifted = amount - update() - return - } + item.getLore().matchFirst(giftedAmountPattern) { + val amount = group("amount").formatInt() + storage.amountGifted = amount + update() } } 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 0fd475647..c2bfd586e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fame/CityProjectFeatures.kt @@ -27,7 +27,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.RenderUtils.highlight import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.renderables.Renderable @@ -123,15 +123,13 @@ class CityProjectFeatures { val lore = item.getLore() val completed = lore.lastOrNull()?.let { completedPattern.matches(it) } ?: false if (completed) continue - for (line in lore) { - contributeAgainPattern.matchMatcher(line) { - val rawTime = group("time") - if (rawTime.contains("Soon!")) return@matchMatcher - val duration = TimeUtils.getDuration(rawTime) - val endTime = now + duration - if (endTime < nextTime) { - nextTime = endTime - } + lore.matchFirst(contributeAgainPattern) { + val rawTime = group("time") + if (!rawTime.contains("Soon!")) return@matchFirst + val duration = TimeUtils.getDuration(rawTime) + val endTime = now + duration + if (endTime < nextTime) { + nextTime = endTime } } if (item.name != "§eContribute this component!") continue 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 21e4175f1..23e9b8a5e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -327,6 +327,9 @@ object FarmingFortuneDisplay { reforgeFortune = 0.0 itemBaseFortune = 0.0 greenThumbFortune = 0.0 + + //TODO code cleanup + for (line in tool?.getLore()!!) { tooltipFortunePattern.matchMatcher(line) { displayedFortune = group(1)!!.toDouble() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt index c4f85ae45..f233ab97f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -78,15 +79,12 @@ class GardenCropMilestoneFix { @SubscribeEvent fun onTabListUpdate(event: TabListUpdateEvent) { - for (line in event.tabList) { - tabListPattern.matchMatcher(line) { - val tier = group("tier").toInt() - val percentage = group("percentage").toDouble() - val cropName = group("crop") - - check(cropName, tier, percentage) - return - } + event.tabList.matchFirst(tabListPattern) { + val tier = group("tier").toInt() + val percentage = group("percentage").toDouble() + val cropName = group("crop") + + check(cropName, tier, percentage) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index 40df08a57..54db1d71d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -87,7 +88,7 @@ class GardenLevelDisplay { "SkyBlock Menu" -> event.inventoryItems[10] ?: return else -> return } - gardenItemNamePattern.matchMatcher(item.name.removeColor()) {} ?: return + if (!gardenItemNamePattern.matches(item.name.removeColor())) return var nextLevelExp = 0L var currentLevel = 0 for (line in item.getLore()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt index 5747032cf..c740812a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterInventoryNumbers.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matchFirst import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -37,41 +37,36 @@ class ComposterInventoryNumbers { // Composts Available if (slotNumber == 13) { - for (line in stack.getLore()) { - amountPattern.matchMatcher(line) { - val total = group("amount").formatInt() - event.offsetY = -2 - event.offsetX = -20 - event.stackTip = "§6${total.addSeparators()}" - return - } |
