Only use the Modrinth api if the user clicks the changelog menu instead of when the config is opened

This commit is contained in:
coolGi
2023-05-22 23:51:19 +09:30
parent 883685de83
commit 1b60c66eec
2 changed files with 20 additions and 5 deletions
@@ -219,8 +219,6 @@ public abstract class ClassicConfigGUI {
// Changelog button
if (Config.Client.AutoUpdater.enableAutoUpdater.get()) {
if (!ModrinthGetter.initted)
ModrinthGetter.init();
this.addBtn(new TexturedButtonWidget(
// Where the button is on the screen
this.width - 28, this.height - 28,
@@ -231,9 +229,7 @@ public abstract class ClassicConfigGUI {
// Some textuary stuff
0, new ResourceLocation(ModInfo.ID, "textures/gui/changelog.png"), 20, 20,
// Create the button and tell it where to go
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this,
ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion())
)),
(buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(new ChangelogScreen(this)),
// Add a title to the button
#if PRE_MC_1_19
new TranslatableComponent(ModInfo.ID + ".updater.title")
@@ -1,6 +1,8 @@
package com.seibel.lod.common.wrappers.gui.updater;
import com.mojang.blaze3d.vertex.PoseStack;
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
import com.seibel.lod.core.wrapperInterfaces.IVersionConstants;
import com.seibel.lod.coreapi.ModInfo;
import com.seibel.lod.core.jar.installer.MarkdownFormatter;
import com.seibel.lod.core.jar.installer.ModrinthGetter;
@@ -31,12 +33,27 @@ public class ChangelogScreen extends Screen {
private List<String> changelog;
private TextArea changelogArea;
public ChangelogScreen(Screen parent) {
this(parent, null);
if (!ModrinthGetter.initted) // Make sure the modrinth stuff is initted
ModrinthGetter.init();
if (!ModrinthGetter.initted) // If its not initted the just close the screen
onClose();
setupChangelog(ModrinthGetter.getLatestIDForVersion(SingletonInjector.INSTANCE.get(IVersionConstants.class).getMinecraftVersion()));
}
public ChangelogScreen(Screen parent, String versionID) {
super(translate(ModInfo.ID + ".updater.title"));
this.parent = parent;
this.versionID = versionID;
if (versionID != null)
setupChangelog(versionID);
}
private void setupChangelog(String versionID) {
this.changelog = new ArrayList<>();
// Put the new version name at the very top of the change log
@@ -59,6 +76,8 @@ public class ChangelogScreen extends Screen {
// System.out.println(this.changelog);
}
@Override
protected void init() {
super.init();