diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-02-16 21:21:43 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 11:21:43 +0100 |
commit | f91973d60948d449cc45a4add901e6fe43aebd62 (patch) | |
tree | 4c8c77ec4a9585a821651a034ebe5bed3308a6af /src/main/java/at/hannibal2/skyhanni/api | |
parent | 26fe548fa9a5cfe29b130a0a5585278df3429ee9 (diff) | |
download | skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.gz skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.tar.bz2 skyhanni-f91973d60948d449cc45a4add901e6fe43aebd62.zip |
Moved many regex patterns in the repo and code cleanup. #871
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/api')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt | 34 |
1 files changed, 19 insertions, 15 deletions
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(?<amount>.*)§6/.*".toPattern() - private val singleCounterPattern = "§7Total Collected: §e(?<amount>.*)".toPattern() +object CollectionAPI { + private val patternGroup = RepoPattern.group("data.collection.api") + private val counterPattern by patternGroup.pattern( + "counter", + ".* §e(?<amount>.*)§6/.*" + ) + private val singleCounterPattern by patternGroup.pattern( + "singlecounter", + "§7Total Collected: §e(?<amount>.*)" + ) + private val collectionTier0Pattern by patternGroup.pattern( + "tierzero", + "§7Progress to .* I: .*" + ) + + val collectionValue = mutableMapOf<NEUInternalName, Long>() @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<NEUInternalName, Long>() - private val collectionTier0Pattern = "§7Progress to .* I: .*".toPattern() - - fun isCollectionTier0(lore: List<String>) = lore.any { collectionTier0Pattern.matches(it) } - - fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName] - } + fun isCollectionTier0(lore: List<String>) = lore.any { collectionTier0Pattern.matches(it) } + fun getCollectionCounter(internalName: NEUInternalName): Long? = collectionValue[internalName] } |