From f91973d60948d449cc45a4add901e6fe43aebd62 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:21:43 +1100 Subject: Moved many regex patterns in the repo and code cleanup. #871 --- .../at/hannibal2/skyhanni/api/CollectionAPI.kt | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/api') diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index ff744cecd..1e991605e 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -14,13 +14,25 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull 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 -class CollectionAPI { - - // TODO USE SH-REPO - private val counterPattern = ".* §e(?.*)§6/.*".toPattern() - private val singleCounterPattern = "§7Total Collected: §e(?.*)".toPattern() +object CollectionAPI { + private val patternGroup = RepoPattern.group("data.collection.api") + private val counterPattern by patternGroup.pattern( + "counter", + ".* §e(?.*)§6/.*" + ) + private val singleCounterPattern by patternGroup.pattern( + "singlecounter", + "§7Total Collected: §e(?.*)" + ) + private val collectionTier0Pattern by patternGroup.pattern( + "tierzero", + "§7Progress to .* I: .*" + ) + + val collectionValue = mutableMapOf() @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { @@ -83,14 +95,6 @@ class CollectionAPI { collectionValue.addOrPut(internalName, event.amount.toLong()) } - companion object { - - // TODO USE SH-REPO - val collectionValue = mutableMapOf() - private val collectionTier0Pattern = "§7Progress to .* I: .*".toPattern() - - fun isCollectionTier0(lore: List) = lore.any { collectionTier0Pattern.matches(it) } - - fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName] - } + fun isCollectionTier0(lore: List) = lore.any { collectionTier0Pattern.matches(it) } + fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName] } -- cgit