diff --git a/root.gradle.kts b/root.gradle.kts index a366f5406f32..4a1014034073 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -19,7 +19,7 @@ allprojects { * The version of the project. * Major version * Minor version - * Patch version + * Beta version */ version = "1.0.0" diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 1fa446617368..2777b94f7d81 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -109,7 +109,7 @@ class SkyHanniMod { const val MODID = "skyhanni" - private val modVersion: ModVersion by lazy { + val modVersion: ModVersion by lazy { ModVersion.fromString(Loader.instance().indexedModList[MODID]!!.version) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt similarity index 52% rename from src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt rename to src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt index 5ba59c148231..77d76671ed1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/RepoErrorData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ChangedChatErrorsJson.kt @@ -1,18 +1,20 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo +import at.hannibal2.skyhanni.utils.system.ModVersion import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName -data class RepoErrorJson( +data class ChangedChatErrorsJson( @Expose @SerializedName("changed_error_messages") val changedErrorMessages: List, ) data class RepoErrorData( - @Expose @SerializedName("message_exact") private var rawMessageExact: List?, - @Expose @SerializedName("message_starts_with") private var rawMessageStartsWith: List?, - @Expose @SerializedName("replace_message") var replaceMessage: String?, - @Expose @SerializedName("custom_message") var customMessage: String?, - @Expose @SerializedName("affected_versions") var affectedVersions: List = listOf(), + @Expose @SerializedName("message_exact") private val rawMessageExact: List?, + @Expose @SerializedName("message_starts_with") private val rawMessageStartsWith: List?, + @Expose @SerializedName("replace_message") val replaceMessage: String?, + @Expose @SerializedName("custom_message") val customMessage: String?, + @Expose @SerializedName("affected_versions") val affectedVersions: List = listOf(), + @Expose @SerializedName("fixed_in") val fixedIn: ModVersion?, ) { val messageExact get() = rawMessageExact.orEmpty() val messageStartsWith get() = rawMessageStartsWith.orEmpty() diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index 14ee9fd737c7..cb71f7d2a6a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -1,8 +1,8 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.jsonobjects.repo.ChangedChatErrorsJson import at.hannibal2.skyhanni.data.jsonobjects.repo.RepoErrorData -import at.hannibal2.skyhanni.data.jsonobjects.repo.RepoErrorJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils @@ -205,10 +205,10 @@ object ErrorManager { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - val data = event.getConstant("ChangedChatErrors") - val version = SkyHanniMod.version + val data = event.getConstant("ChangedChatErrors") + val version = SkyHanniMod.modVersion - repoErrors = data.changedErrorMessages.filter { version in it.affectedVersions } + repoErrors = data.changedErrorMessages.filter { it.fixedIn == null || version < it.fixedIn } } private fun buildExtraDataString(extraData: Array>): String { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt index 4784e87cb0d1..b34a6ba9d5b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/BaseGsonBuilder.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.SimpleTimeMark -import at.hannibal2.skyhanni.utils.json.SkyHanniTypeAdapters.registerTypeAdapter +import at.hannibal2.skyhanni.utils.system.ModVersion import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import com.google.gson.GsonBuilder import io.github.notenoughupdates.moulconfig.observer.PropertyTypeAdapterFactory @@ -29,6 +29,7 @@ object BaseGsonBuilder { .registerTypeAdapter(NEUInternalName::class.java, SkyHanniTypeAdapters.INTERNAL_NAME.nullSafe()) .registerTypeAdapter(LorenzRarity::class.java, SkyHanniTypeAdapters.RARITY.nullSafe()) .registerTypeAdapter(IslandType::class.java, SkyHanniTypeAdapters.ISLAND_TYPE.nullSafe()) + .registerTypeAdapter(ModVersion::class.java, SkyHanniTypeAdapters.MOD_VERSION.nullSafe()) .registerTypeAdapter( SkyHanniTracker.DefaultDisplayMode::class.java, SkyHanniTypeAdapters.TRACKER_DISPLAY_MODE.nullSafe(), diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt index 68c1d6888ac3..fa98d0587f82 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/SkyHanniTypeAdapters.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark +import at.hannibal2.skyhanni.utils.system.ModVersion import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker import com.google.gson.GsonBuilder import com.google.gson.TypeAdapter @@ -82,6 +83,11 @@ object SkyHanniTypeAdapters { { SkyblockStat.getValue(this.uppercase()) }, ) + val MOD_VERSION: TypeAdapter = SimpleStringTypeAdapter( + { asString }, + { ModVersion.fromString(this) }, + ) + val TRACKER_DISPLAY_MODE = SimpleStringTypeAdapter.forEnum() val ISLAND_TYPE = SimpleStringTypeAdapter.forEnum() val RARITY = SimpleStringTypeAdapter.forEnum() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt index efa8e45c2575..722f869da873 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/system/ModVersion.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.utils.system -data class ModVersion(val major: Int, val minor: Int, val patch: Int) { +data class ModVersion(val major: Int, val minor: Int, val beta: Int) { companion object { fun fromString(version: String): ModVersion { @@ -14,20 +14,20 @@ data class ModVersion(val major: Int, val minor: Int, val patch: Int) { } } - val isBeta = patch != 0 + val isBeta = beta != 0 val asString: String get() = toString() override fun toString(): String { - return "$major.$minor.$patch" + return "$major.$minor.$beta" } operator fun compareTo(other: ModVersion): Int { return when { major != other.major -> major.compareTo(other.major) minor != other.minor -> minor.compareTo(other.minor) - else -> patch.compareTo(other.patch) + else -> beta.compareTo(other.beta) } } }