diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt | 39 |
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) { |