aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
diff options
context:
space:
mode:
authorNetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com>2023-04-27 06:07:33 -0400
committerGitHub <noreply@github.com>2023-04-27 12:07:33 +0200
commit2dd1970d6d31ea1e2bbfa30b57141ea9a4720834 (patch)
tree4d5879b3eaecb851485436c3a266e3d5814d6d06 /src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
parentd889efc0ca80458442df14500b71092008bb95b2 (diff)
downloadskyhanni-2dd1970d6d31ea1e2bbfa30b57141ea9a4720834.tar.gz
skyhanni-2dd1970d6d31ea1e2bbfa30b57141ea9a4720834.tar.bz2
skyhanni-2dd1970d6d31ea1e2bbfa30b57141ea9a4720834.zip
Added Discord RPC (#35)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
new file mode 100644
index 000000000..5130e7080
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
@@ -0,0 +1,35 @@
+package at.hannibal2.skyhanni.data
+
+import at.hannibal2.skyhanni.events.LorenzActionBarEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class ActionBarStatsData {
+ private val pattern =
+ Pattern.compile("..((?:\\d|,)*)\\/(?:\\d|,)*(.) *..((?:\\d|,)*)..(. \\w*) *..((?:\\d|,)*)\\/(?:\\d|,)*(.*)")
+// Sample input: §c2,817/2,817❤ §a703§a❈ Defense §b3,479/3,479✎ Mana
+// Returns the following groups: 1 = 2,817; 2 = ❤; 3 = 703; 4 = ❈ Defense; 5 = 3,479; 6 = ✎ Mana
+
+ companion object {
+ var groups = listOf<String>()
+ }
+
+ @SubscribeEvent
+ fun onActionBar(event: LorenzActionBarEvent) {
+ groups = readGroups(event.message)
+ }
+
+ private fun readGroups(message: String): List<String> {
+ if (!LorenzUtils.inSkyBlock) return emptyList()
+
+ val matcher = pattern.matcher(message)
+ if (!matcher.matches()) return emptyList()
+
+ val list = mutableListOf<String>()
+ for (i in 1..matcher.groupCount()) {
+ list.add(matcher.group(i))
+ }
+ return list
+ }
+}