aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-04-23 15:36:00 +0200
committerGitHub <noreply@github.com>2024-04-23 15:36:00 +0200
commit7593f17065adedb57b4a2b714c91eb25ae7efd57 (patch)
tree4cb9c8e5158e1d12bc00edbb2f23d18720a2adbc /src/main/java/at/hannibal2/skyhanni/data
parent0596af7bad9097f1a38d42078fbece7e33e83375 (diff)
downloadskyhanni-7593f17065adedb57b4a2b714c91eb25ae7efd57.tar.gz
skyhanni-7593f17065adedb57b4a2b714c91eb25ae7efd57.tar.bz2
skyhanni-7593f17065adedb57b4a2b714c91eb25ae7efd57.zip
Fix: Maxwell Power not updating when unlocking a new Power (#1520)
Co-authored-by: Luna <me@alexia.lol> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt
index eed541571..d711273f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt
@@ -52,10 +52,14 @@ object MaxwellAPI {
private var powers = mutableListOf<String>()
private val patternGroup = RepoPattern.group("data.maxwell")
- private val chatPowerpattern by patternGroup.pattern(
+ private val chatPowerPattern by patternGroup.pattern(
"chat.power",
"§eYou selected the §a(?<power>.*) §e(power )?for your §aAccessory Bag§e!"
)
+ private val chatPowerUnlockedPattern by patternGroup.pattern(
+ "chat.power.unlocked",
+ "§eYour selected power was set to (?:§r)*§a(?<power>.*)(?:§r)*§e!"
+ )
private val inventoryPowerPattern by patternGroup.pattern(
"inventory.power",
"§7Selected Power: §a(?<power>.*)"
@@ -120,26 +124,29 @@ object MaxwellAPI {
if (!isEnabled()) return
val message = event.message.trimWhiteSpace().removeResets()
- chatPowerpattern.matchMatcher(message) {
- val power = group("power")
- currentPower = getPowerByNameOrNull(power)
- ?: return ErrorManager.logErrorWithData(
- UnknownMaxwellPower("Unknown power: $power"),
- "Unknown power: $power",
- "power" to power,
- "message" to message
- )
- }
+ chatPowerPattern.tryReadPower(message)
+ chatPowerUnlockedPattern.tryReadPower(message)
tuningAutoAssignedPattern.matchMatcher(event.message) {
- if (tunings?.isNotEmpty() == true) {
- val tuningsInScoreboard = ScoreboardElement.TUNING in CustomScoreboard.config.scoreboardEntries
- if (tuningsInScoreboard) {
- ChatUtils.chat("Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.")
- }
+ if (tunings.isNullOrEmpty()) return
+ val tuningsInScoreboard = ScoreboardElement.TUNING in CustomScoreboard.config.scoreboardEntries
+ if (tuningsInScoreboard) {
+ ChatUtils.chat("Talk to Maxwell and open the Tuning Page again to update the tuning data in scoreboard.")
}
}
}
+ private fun Pattern.tryReadPower(message: String) {
+ matchMatcher(message) {
+ val power = group("power")
+ currentPower = getPowerByNameOrNull(power) ?: return ErrorManager.logErrorWithData(
+ UnknownMaxwellPower("Unknown power: $power"),
+ "Unknown power: $power",
+ "power" to power,
+ "message" to message
+ )
+ }
+ }
+
// load earlier, so that other features can already use the api in this event
@SubscribeEvent(priority = EventPriority.HIGH)
fun onInventoryOpen(event: InventoryOpenEvent) {