diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricLoaderUpdateChecker.java b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricLoaderUpdateChecker.java index fcaeb16e..513714bd 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricLoaderUpdateChecker.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricLoaderUpdateChecker.java @@ -5,6 +5,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,6 +21,7 @@ import net.fabricmc.loader.api.SemanticVersion; import net.fabricmc.loader.api.Version; import net.fabricmc.loader.api.VersionParsingException; +import net.minecraft.text.Text; public class FabricLoaderUpdateChecker implements UpdateChecker { public static final Logger LOGGER = LoggerFactory.getLogger("Mod Menu/Fabric Update Checker"); @@ -111,7 +113,7 @@ private static UpdateInfo checkForUpdates0() throws IOException, InterruptedExce } LOGGER.debug("Fabric Loader has a matching update available!"); - return new FabricLoaderUpdateInfo(stableVersion); + return new FabricLoaderUpdateInfo(match.getFriendlyString(), stableVersion); } private static boolean isNewer(Version self, Version other) { @@ -123,9 +125,11 @@ private static Version getCurrentVersion() { } private static class FabricLoaderUpdateInfo implements UpdateInfo { + private final String version; private final boolean isStable; - private FabricLoaderUpdateInfo(boolean isStable) { + private FabricLoaderUpdateInfo(String version, boolean isStable) { + this.version = version; this.isStable = isStable; } @@ -134,6 +138,11 @@ public boolean isUpdateAvailable() { return true; } + @Override + public @Nullable Text getUpdateMessage() { + return Text.translatable("modmenu.install_version", this.version); + } + @Override public String getDownloadLink() { return "https://fabricmc.net/use/installer"; diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltLoaderUpdateChecker.java b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltLoaderUpdateChecker.java index 9b5da457..4f7eefc2 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltLoaderUpdateChecker.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltLoaderUpdateChecker.java @@ -5,6 +5,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import org.jetbrains.annotations.Nullable; import org.quiltmc.loader.api.QuiltLoader; import org.quiltmc.loader.api.Version; import org.quiltmc.loader.api.VersionFormatException; @@ -18,6 +19,8 @@ import com.terraformersmc.modmenu.util.HttpUtil; import com.terraformersmc.modmenu.util.JsonUtil; +import net.minecraft.text.Text; + public class QuiltLoaderUpdateChecker implements UpdateChecker { public static final Logger LOGGER = LoggerFactory.getLogger("Mod Menu/Quilt Update Checker"); private static final URI LOADER_VERSIONS = URI.create("https://meta.quiltmc.org/v3/versions/loader"); @@ -105,19 +108,7 @@ private static UpdateInfo checkForUpdates0() throws IOException, InterruptedExce } LOGGER.debug("Quilt Loader has a matching update available!"); - - UpdateChannel updateChannel; - var preRelease = match.preRelease(); - - if (preRelease.isEmpty()) { - updateChannel = UpdateChannel.RELEASE; - } else if (isStableOrBeta(preRelease)) { - updateChannel = UpdateChannel.BETA; - } else { - updateChannel = UpdateChannel.ALPHA; - } - - return new QuiltLoaderUpdateInfo(updateChannel); + return new QuiltLoaderUpdateInfo(match); } private static boolean isNewer(Version.Semantic self, Version.Semantic other) { @@ -133,10 +124,10 @@ private static boolean isStableOrBeta(String preRelease) { } private static class QuiltLoaderUpdateInfo implements UpdateInfo { - private final UpdateChannel updateChannel; + private final Version.Semantic version; - private QuiltLoaderUpdateInfo(UpdateChannel updateChannel) { - this.updateChannel = updateChannel; + private QuiltLoaderUpdateInfo(Version.Semantic version) { + this.version = version; } @Override @@ -144,6 +135,11 @@ public boolean isUpdateAvailable() { return true; } + @Override + public @Nullable Text getUpdateMessage() { + return Text.translatable("modmenu.install_version", this.version.raw()); + } + @Override public String getDownloadLink() { return "https://quiltmc.org/en/install/client"; @@ -151,7 +147,15 @@ public String getDownloadLink() { @Override public UpdateChannel getUpdateChannel() { - return this.updateChannel; + var preRelease = this.version.preRelease(); + + if (preRelease.isEmpty()) { + return UpdateChannel.RELEASE; + } else if (isStableOrBeta(preRelease)) { + return UpdateChannel.BETA; + } else { + return UpdateChannel.ALPHA; + } } } } diff --git a/src/main/resources/assets/modmenu/lang/en_us.json b/src/main/resources/assets/modmenu/lang/en_us.json index 7e4544ff..ba9380a9 100644 --- a/src/main/resources/assets/modmenu/lang/en_us.json +++ b/src/main/resources/assets/modmenu/lang/en_us.json @@ -63,6 +63,7 @@ "modmenu.experimental": "(Mod Menu update checker is experimental!)", "modmenu.childHasUpdate": "A child of this mod has an update available.", "modmenu.updateText": "v%s on %s", + "modmenu.install_version": "Install version %s", "modmenu.downloadLink": "Download", "modmenu.buymeacoffee": "Buy Me a Coffee",