diff options
author | Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> | 2024-02-10 00:24:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 00:24:52 +0100 |
commit | 4559e5ff05e19817a21ae49f1c0d8a97d273f6a1 (patch) | |
tree | e72dac91d07fc84bea80548c89e13276caa68b81 /src/main/java/at/hannibal2/skyhanni/utils/repopatterns | |
parent | d3a7cc4ab970b457b7950489da781539e45e0dce (diff) | |
download | skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.gz skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.tar.bz2 skyhanni-4559e5ff05e19817a21ae49f1c0d8a97d273f6a1.zip |
Splitting many utils functions from LorenzUtils up into other classes: ChatUtils, CollectionUtils, ConditionalUtils. And code cleanup #978
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/repopatterns')
5 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt index 6af2cf2fe..715c907e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPattern.kt @@ -42,6 +42,7 @@ import kotlin.reflect.KProperty * of slightly more options. */ interface RepoPattern : ReadOnlyProperty<Any?, Pattern> { + /** * Check whether [value] has been loaded remotely or from the fallback value at [defaultPattern]. In case this is * accessed off-thread there are no guarantees for the correctness of this value in relation to any specific call @@ -78,8 +79,8 @@ interface RepoPattern : ReadOnlyProperty<Any?, Pattern> { return value } - companion object { + /** * Obtain a reference to a [Pattern] backed by either a local regex, or a remote regex. * Check the documentation of [RepoPattern] for more information. diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGroup.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGroup.kt index 326f447d5..1b00e4d83 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGroup.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGroup.kt @@ -6,6 +6,7 @@ import org.intellij.lang.annotations.Language * A utility class for allowing easier definitions of [RepoPattern]s with a common prefix. */ class RepoPatternGroup internal constructor(val prefix: String) { + init { RepoPatternManager.verifyKeyShape(prefix) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGui.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGui.kt index 2a2393686..efc41bffa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternGui.kt @@ -12,7 +12,9 @@ import io.github.moulberry.moulconfig.xml.XMLUniverse * Gui for analyzing [RepoPattern]s */ class RepoPatternGui private constructor() { + companion object { + /** * Open the [RepoPatternGui] */ @@ -34,10 +36,10 @@ class RepoPatternGui private constructor() { .map { RepoPatternInfo(it) } private var searchCache = ObservableList(mutableListOf<RepoPatternInfo>()) - class RepoPatternInfo( - repoPatternImpl: RepoPatternImpl + repoPatternImpl: RepoPatternImpl, ) { + @field:Bind val key: String = repoPatternImpl.key diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternImpl.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternImpl.kt index 89e9f99ec..1116bbf76 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternImpl.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternImpl.kt @@ -10,6 +10,7 @@ class RepoPatternImpl( override val defaultPattern: String, override val key: String, ) : RepoPattern { + var compiledPattern: Pattern = Pattern.compile(defaultPattern) var wasLoadedRemotely = false override var wasOverridden = false @@ -37,7 +38,6 @@ class RepoPatternImpl( RepoPatternManager.checkExclusivity(owner, key) } - override val value: Pattern get() { return compiledPattern diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt index a0bc09da7..3e32cbcb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.events.PreInitFinishedEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.LorenzUtils.afterChange +import at.hannibal2.skyhanni.utils.ConditionalUtils.afterChange import at.hannibal2.skyhanni.utils.StringUtils.matches import net.minecraft.launchwrapper.Launch import net.minecraftforge.fml.common.FMLCommonHandler @@ -19,6 +19,7 @@ import java.util.regex.PatternSyntaxException * Manages [RepoPattern]s. */ object RepoPatternManager { + val allPatterns: Collection<RepoPatternImpl> get() = usedKeys.values /** @@ -77,7 +78,6 @@ object RepoPatternManager { reloadPatterns() } - @SubscribeEvent fun onConfigInit(event: ConfigLoadEvent) { config.forceLocal.afterChange { reloadPatterns() } |