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/test | |
| 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/test')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt | 8 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt index e418f6043..348d05cb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import com.google.gson.GsonBuilder import com.google.gson.annotations.Expose import net.minecraft.item.ItemStack @@ -41,7 +42,10 @@ object TestCopyBestiaryValues { var bracket: Int = 0 } - val pattern = "\\[Lv(?<lvl>.*)] (?<text>.*)".toPattern() + private val bestiaryTypePattern by RepoPattern.pattern( + "test.bestiary.type", + "\\[Lv(?<lvl>.*)] (?<text>.*)" + ) @SubscribeEvent(priority = EventPriority.LOW) fun onLateInventoryOpen(event: InventoryUpdatedEvent) { @@ -85,7 +89,7 @@ object TestCopyBestiaryValues { for (i in 10..43) { val stack = inventoryItems[i] ?: continue val stackName = stack.name ?: continue - pattern.matchMatcher(stackName.removeColor()) { + bestiaryTypePattern.matchMatcher(stackName.removeColor()) { val lvl = group("lvl").toInt() var text = group("text").lowercase().replace(" ", "_") diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt index 5ab1effb7..9d2c0d3d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyRngMeterValues.kt @@ -11,17 +11,26 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object TestCopyRngMeterValues { + private val patternGroup = RepoPattern.group("test.dev.copyrng") + private val slayerPattern by patternGroup.pattern( + "slayer", + "§7Slayer XP: §d.*§5/§d(?<xp>.*)" + ) + private val dungeonPattern by patternGroup.pattern( + "dungeon", + "§7Dungeon Score: §d.*§5/§d(?<xp>.*)" + ) + @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!SkyHanniMod.feature.dev.debug.copyRngMeter) return val map = mutableMapOf<NEUInternalName, Long>() - val slayerPattern = "§7Slayer XP: §d.*§5/§d(?<xp>.*)".toPattern() - val dungeonPattern = "§7Dungeon Score: §d.*§5/§d(?<xp>.*)".toPattern() for (item in event.inventoryItems.values) { for (line in item.getLore()) { slayerPattern.matchMatcher(line) { |
