diff options
| author | Luna <me@lunya.dev> | 2024-10-27 23:00:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-27 23:00:06 +0100 |
| commit | bf53508d3a8adf52e85b36c4f08414805cebd05b (patch) | |
| tree | 9a8cd76fe46539c6a302bd077fba424d4086c10b | |
| parent | 2490f8524a7faffb1dc8345f31b1d6d952682712 (diff) | |
| download | SkyHanni-bf53508d3a8adf52e85b36c4f08414805cebd05b.tar.gz SkyHanni-bf53508d3a8adf52e85b36c4f08414805cebd05b.tar.bz2 SkyHanni-bf53508d3a8adf52e85b36c4f08414805cebd05b.zip | |
Fix: Kick Duration not matching certain messages (#2837)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt index 8a309ad0b..89f80fb73 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/SkyBlockKickDuration.kt @@ -6,10 +6,12 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds @@ -24,11 +26,30 @@ object SkyBlockKickDuration { private var lastKickTime = SimpleTimeMark.farPast() private var hasWarned = false + private val patternGroup = RepoPattern.group("misc.kickduration") + + /** + * REGEX-TEST: §cYou were kicked while joining that server! + * REGEX-TEST: §cA kick occurred in your connection, so you were put in the SkyBlock lobby! + */ + private val kickPattern by patternGroup.pattern( + "kicked", + "§c(?:You were kicked while joining that server!|A kick occurred in your connection, so you were put in the SkyBlock lobby!)", + ) + + /** + * REGEX-TEST: §cThere was a problem joining SkyBlock, try again in a moment! + */ + private val problemJoiningPattern by patternGroup.pattern( + "problemjoining", + "§cThere was a problem joining SkyBlock, try again in a moment!", + ) + @SubscribeEvent fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return - if (event.message == "§cYou were kicked while joining that server!") { + if (kickPattern.matches(event.message)) { if (LorenzUtils.onHypixel && !LorenzUtils.inSkyBlock) { kickMessage = false showTime = true @@ -38,7 +59,7 @@ object SkyBlockKickDuration { } } - if (event.message == "§cThere was a problem joining SkyBlock, try again in a moment!") { + if (problemJoiningPattern.matches(event.message)) { kickMessage = false showTime = true lastKickTime = SimpleTimeMark.now() |
