aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-12-03 19:05:19 -0800
committerGitHub <noreply@github.com>2023-12-04 04:05:19 +0100
commit66fc6034b563b30854de121385d67140f605004e (patch)
treeee1124c0521f28f5e7bc929d1fdb4677de0682fd /src/main/java/at/hannibal2/skyhanni
parented92dd80eda5b2441688e4c2808404304bd49a43 (diff)
downloadskyhanni-66fc6034b563b30854de121385d67140f605004e.tar.gz
skyhanni-66fc6034b563b30854de121385d67140f605004e.tar.bz2
skyhanni-66fc6034b563b30854de121385d67140f605004e.zip
Internal Change: Cleanup DungeonMilestonesDisplay & Remove matchRegex (#646)
Code cleanup in DungeonMilestoneDisplay. #646
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt30
2 files changed, 20 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
index b4cb10958..c73584d10 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
@@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.chat
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.LorenzChatEvent
-import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpaceAndResets
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -427,7 +427,7 @@ class ChatFilter {
* @see messagesStartsWithMap
*/
private fun String.isPresent(key: String) = this in (messagesMap[key] ?: emptyList()) ||
- (patternsMap[key] ?: emptyList()).any { it.matchMatcher(this) { } != null } ||
+ (patternsMap[key] ?: emptyList()).any { it.matches(this) } ||
(messagesContainsMap[key] ?: emptyList()).any { this.contains(it) } ||
(messagesStartsWithMap[key] ?: emptyList()).any { this.startsWith(it) }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
index b3a6a1f59..fc5462901 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt
@@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
-import at.hannibal2.skyhanni.utils.StringUtils.matchRegex
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.concurrent.fixedRateTimer
@@ -15,25 +15,28 @@ class DungeonMilestonesDisplay {
private val config get() = SkyHanniMod.feature.dungeon
companion object {
+
+ // TODO USE SH-REPO
+ private val milestonePatternList = listOf(
+ "§e§l(.*) Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)".toPattern(),
+ "§e§lArcher Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Ranged Damage so far! §r§a(.*)".toPattern(),
+ "§e§lHealer Milestone §r§e.§r§7: You have healed §r§a(.*)§r§7 Damage so far! §r§a(.*)".toPattern(),
+ "§e§lTank Milestone §r§e.§r§7: You have tanked and dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)s".toPattern()
+ )
+
private var display = ""
var color = ""
var currentMilestone = 0
var timeReached = 0L
- fun isMilestoneMessage(message: String): Boolean = when {
- message.matchRegex("§e§l(.*) Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lArcher Milestone §r§e.§r§7: You have dealt §r§c(.*)§r§7 Ranged Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lHealer Milestone §r§e.§r§7: You have healed §r§a(.*)§r§7 Damage so far! §r§a(.*)") -> true
- message.matchRegex("§e§lTank Milestone §r§e.§r§7: You have tanked and dealt §r§c(.*)§r§7 Total Damage so far! §r§a(.*)s") -> true
-
- else -> false
- }
+ fun isMilestoneMessage(message: String): Boolean = milestonePatternList.any { it.matches(message) }
}
init {
fixedRateTimer(name = "skyhanni-dungeon-milestone-display", period = 200) {
- if (!isEnabled()) return@fixedRateTimer
- checkVisibility()
+ if (isEnabled()) {
+ checkVisibility()
+ }
}
}
@@ -84,7 +87,10 @@ class DungeonMilestonesDisplay {
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
if (!isEnabled()) return
- config.showMileStonesDisplayPos.renderString(color + display, posLabel = "Dungeon Milestone")
+ config.showMileStonesDisplayPos.renderString(
+ color + display,
+ posLabel = "Dungeon Milestone"
+ )
}
private fun isEnabled() = LorenzUtils.inDungeons && config.showMilestonesDisplay