aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-01-20 10:06:38 +0100
committerGitHub <noreply@github.com>2024-01-20 10:06:38 +0100
commit2d11b0cfe4adf7b6535d91cbdf339e47898d925e (patch)
treeb52e4912cdd42fef593ddd040edd49fcd187b965 /src/main/java
parent1f950c47b505a47ca49be67b7f0d85c2c65ae1da (diff)
downloadskyhanni-2d11b0cfe4adf7b6535d91cbdf339e47898d925e.tar.gz
skyhanni-2d11b0cfe4adf7b6535d91cbdf339e47898d925e.tar.bz2
skyhanni-2d11b0cfe4adf7b6535d91cbdf339e47898d925e.zip
Feature: SkyblockXPInChat (#919)
Added Skyblock XP Chat. #919
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt70
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ActionBarValueUpdate.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt7
7 files changed, 88 insertions, 26 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 029a9dac9..31816f28c 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -66,6 +66,7 @@ import at.hannibal2.skyhanni.features.chat.ChatFilter
import at.hannibal2.skyhanni.features.chat.CompactBestiaryChatMessage
import at.hannibal2.skyhanni.features.chat.CompactSplashPotionMessage
import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages
+import at.hannibal2.skyhanni.features.chat.SkyblockXPInChat
import at.hannibal2.skyhanni.features.chat.Translator
import at.hannibal2.skyhanni.features.chat.WatchdogHider
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter
@@ -497,6 +498,7 @@ class SkyHanniMod {
loadModule(ViewRecipeCommand)
loadModule(PartyCommands)
loadModule(SummoningMobManager())
+ loadModule(SkyblockXPInChat())
loadModule(AreaMiniBossFeatures())
loadModule(MobHighlight())
loadModule(SpawnTimers())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
index 1784d916d..4e9a351a7 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/chat/ChatConfig.java
@@ -7,10 +7,9 @@ import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
-import org.lwjgl.input.Keyboard;
-
import java.util.ArrayList;
import java.util.List;
+import org.lwjgl.input.Keyboard;
public class ChatConfig {
@@ -118,4 +117,10 @@ public class ChatConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean translator = false;
+
+ @Expose
+ @ConfigOption(name = "Skyblock XP Chat", desc = "Sends the Skyblock XP message into the chat.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean skyBlockXPInChat = true;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
index cddf83d0b..e4f78142f 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
@@ -1,29 +1,61 @@
package at.hannibal2.skyhanni.data
+import at.hannibal2.skyhanni.events.ActionBarValueUpdate
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.intellij.lang.annotations.Language
-object ActionBarStatsData {
- // TODO USE SH-REPO
- private val patterns = mapOf(
- "health" to "§[c6](?<health>[\\d,]+)/[\\d,]+❤.*".toPattern(),
- "defense" to ".*§a(?<defense>[\\d,]+)§a❈.*".toPattern(),
- "mana" to ".*§b(?<mana>[\\d,]+)/[\\d,]+✎.*".toPattern(),
- "riftTime" to "§[a7](?<riftTime>[\\dms ]+)ф.*".toPattern(),
- )
-
- var groups = mutableMapOf("health" to "", "riftTime" to "", "defense" to "", "mana" to "")
-
- @SubscribeEvent
- fun onActionBar(event: LorenzActionBarEvent) {
- if (!LorenzUtils.inSkyBlock) return
-
- for ((groupName, pattern) in patterns) {
- pattern.matchMatcher(event.message) {
- groups[groupName] = group(groupName)
- }
+enum class ActionBarStatsData(@Language("RegExp") rawPattern: String) {
+ HEALTH(
+ // language=RegExp
+ "§[c6](?<health>[\\d,]+)/[\\d,]+❤.*"
+ ),
+ DEFENSE(
+ // language=RegExp
+ ".*§a(?<defense>[\\d,]+)§a❈.*"
+ ),
+ MANA(
+ // language=RegExp
+ ".*§b(?<mana>[\\d,]+)/[\\d,]+✎.*"
+ ),
+ RIFT_TIME(
+ // language=RegExp
+ "§[a7](?<riftTime>[\\dms ]+)ф.*"
+ ),
+ SKYBLOCK_XP(
+ // language=RegExp
+ ".*(§b\\+\\d+ SkyBlock XP §.\\([^()]+\\)§b \\(\\d+/\\d+\\)).*"
+ ),
+ ;
+
+ private val repoKey = name.replace("_", ".").lowercase()
+
+ internal val pattern by RepoPattern.pattern("actionbar.$repoKey", rawPattern)
+ var value: String = ""
+ private set
+
+ companion object {
+
+ init {
+ entries.forEach { it.pattern }
+ }
+
+ @SubscribeEvent
+ fun onActionBar(event: LorenzActionBarEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+
+ entries.mapNotNull { data ->
+ data.pattern.matchMatcher(event.message) {
+ val newValue = group(1)
+ if (data.value != newValue) {
+ data.value = newValue
+ ActionBarValueUpdate(data)
+ } else null
+ }
+ }.forEach { it.postAndCatch() }
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ActionBarValueUpdate.kt b/src/main/java/at/hannibal2/skyhanni/events/ActionBarValueUpdate.kt
new file mode 100644
index 000000000..f6afd98e2
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/ActionBarValueUpdate.kt
@@ -0,0 +1,5 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.data.ActionBarStatsData
+
+class ActionBarValueUpdate(val updated: ActionBarStatsData) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt
index e5e936fb0..83cddb287 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt
@@ -1,3 +1,3 @@
package at.hannibal2.skyhanni.events
-class LorenzActionBarEvent(val message: String) : LorenzEvent() \ No newline at end of file
+class LorenzActionBarEvent(val message: String) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt
new file mode 100644
index 000000000..a4b7604ce
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/SkyblockXPInChat.kt
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.features.chat
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ActionBarStatsData
+import at.hannibal2.skyhanni.events.ActionBarValueUpdate
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class SkyblockXPInChat {
+
+ val config get() = SkyHanniMod.feature.chat.skyBlockXPInChat
+
+ @SubscribeEvent
+ fun onActionBarValueUpdate(event: ActionBarValueUpdate) {
+ if (event.updated != ActionBarStatsData.SKYBLOCK_XP) return
+ if (!config) return
+ LorenzUtils.chat(event.updated.value)
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index 2f7be15ec..4c972750d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -166,13 +166,12 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
STATS({
- val groups = ActionBarStatsData.groups
val statString = if (!RiftAPI.inRift()) {
- "❤${groups["health"]} ❈${groups["defense"]} ✎${groups["mana"]}"
+ "❤${ActionBarStatsData.HEALTH.value} ❈${ActionBarStatsData.DEFENSE.value} ✎${ActionBarStatsData.MANA.value}"
} else {
- "${groups["riftTime"]}ф ✎${groups["mana"]}"
+ "${ActionBarStatsData.RIFT_TIME.value}ф ✎${ActionBarStatsData.MANA.value}"
}
- if (groups["mana"] != "") {
+ if (ActionBarStatsData.MANA.value != "") {
lastKnownDisplayStrings[STATS] = statString
}
lastKnownDisplayStrings[STATS] ?: ""