Modrinth as default Update location (can be configured to revert to curseforge as default)

This commit is contained in:
Frank 2022-11-16 17:28:58 +01:00
parent f63f0ef5fc
commit 4d626b23b2
7 changed files with 81 additions and 14 deletions

View file

@ -80,8 +80,47 @@ public class UpdatesScreen extends BCLibLayoutScreen {
row.addText(fit(), fit(), Component.literal(" -> "));
row.addText(fit(), fit(), Component.literal(updated)).setColor(ColorUtil.GREEN);
row.addFiller();
if (nfo != null && nfo.getMetadata().getContact().get("homepage").isPresent()) {
row.addButton(fit(), fit(), Component.translatable("bclib.updates.curseforge_link"))
boolean createdDownloadLink = false;
if (nfo != null
&& nfo.getMetadata().getCustomValue("bclib") != null
&& nfo.getMetadata().getCustomValue("bclib").getAsObject().get("downloads") != null) {
CustomValue.CvObject downloadLinks = nfo.getMetadata()
.getCustomValue("bclib")
.getAsObject()
.get("downloads")
.getAsObject();
String link = null;
Component name = null;
if (Configs.CLIENT_CONFIG.preferModrinthForUpdates() && downloadLinks.get("modrinth") != null) {
link = downloadLinks.get("modrinth").getAsString();
name = Component.translatable("bclib.updates.modrinth_link");
// row.addButton(fit(), fit(), Component.translatable("bclib.updates.modrinth_link"))
// .onPress((bt) -> {
// this.openLink(downloadLinks.get("modrinth").getAsString());
// }).centerVertical();
// createdDownloadLink = true;
} else if (downloadLinks.get("curseforge") != null) {
link = downloadLinks.get("curseforge").getAsString();
name = Component.translatable("bclib.updates.curseforge_link");
// row.addButton(fit(), fit(), Component.translatable("bclib.updates.curseforge_link"))
// .onPress((bt) -> {
// this.openLink(downloadLinks.get("curseforge").getAsString());
// }).centerVertical();
// createdDownloadLink = true;
}
if (link != null) {
createdDownloadLink = true;
final String finalLink = link;
row.addButton(fit(), fit(), name)
.onPress((bt) -> {
this.openLink(finalLink);
}).centerVertical();
}
}
if (!createdDownloadLink && nfo != null && nfo.getMetadata().getContact().get("homepage").isPresent()) {
row.addButton(fit(), fit(), Component.translatable("bclib.updates.download_link"))
.onPress((bt) -> {
this.openLink(nfo.getMetadata().getContact().get("homepage").get());
}).centerVertical();

View file

@ -11,7 +11,6 @@ public class ClientConfig extends NamedPathConfig {
"didShowWelcome",
"version"
);
@ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> CHECK_VERSIONS = ConfigToken.Boolean(
true,
"check",
@ -24,12 +23,20 @@ public class ClientConfig extends NamedPathConfig {
"ui"
);
@ConfigUI(leftPadding = 8)
public static final ConfigToken<Boolean> PREFER_MODRINTH_FOR_UPDATES = ConfigToken.Boolean(
true,
"preferModrinthForUpdates",
"ui"
);
@ConfigUI(hide = true)
public static final ConfigToken<Boolean> FORCE_BETTERX_PRESET = ConfigToken.Boolean(
true,
"forceBetterXPreset",
"ui"
);
@ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> SUPPRESS_EXPERIMENTAL_DIALOG = ConfigToken.Boolean(
false,
"suppressExperimentalDialogOnLoad",
@ -107,6 +114,8 @@ public class ClientConfig extends NamedPathConfig {
"rendering",
(config) -> config.get(CUSTOM_FOG_RENDERING)
);
@ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> SURVIES_ON_HINT = ConfigToken.Boolean(
true,
"survives_on_hint",
@ -194,8 +203,12 @@ public class ClientConfig extends NamedPathConfig {
public void setForceBetterXPreset(boolean v) {
set(FORCE_BETTERX_PRESET, v);
}
public boolean survivesOnHint() {
return get(ClientConfig.SURVIES_ON_HINT);
}
public boolean preferModrinthForUpdates() {
return get(ClientConfig.PREFER_MODRINTH_FOR_UPDATES);
}
}

View file

@ -3,11 +3,7 @@ package org.betterx.bclib.config;
import org.betterx.bclib.BCLib;
public class MainConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> VERBOSE_LOGGING = ConfigToken.Boolean(
true,
"verbose",
Configs.MAIN_INFO_CATEGORY
);
public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(
true,
@ -15,7 +11,7 @@ public class MainConfig extends NamedPathConfig {
Configs.MAIN_PATCH_CATEGORY
);
@ConfigUI(leftPadding = 8, topPadding = 8)
@ConfigUI(leftPadding = 8)
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(
false,
"repairBiomesOnLoad",
@ -24,6 +20,13 @@ public class MainConfig extends NamedPathConfig {
APPLY_PATCHES)
);
@ConfigUI(topPadding = 8)
public static final ConfigToken<Boolean> VERBOSE_LOGGING = ConfigToken.Boolean(
true,
"verbose",
Configs.MAIN_INFO_CATEGORY
);
public MainConfig() {
super(BCLib.MOD_ID, "main", true, true);

View file

@ -131,10 +131,10 @@ public class VersionChecker implements Runnable {
}
if (mod.n != null && mod.v != null && KNOWN_MODS.contains(mod.n)) {
String installedVersion = ModUtil.getModVersion(mod.n);
boolean isNew = ModUtil.isLargerVersion(mod.v, installedVersion) && !installedVersion.equals(
"0.0.0");
boolean isNew = ModUtil.isLargerVersion(mod.v, installedVersion)
&& !installedVersion.equals("0.0.0");
BCLib.LOGGER.info(" - " + mod.n + ":" + mod.v + (isNew ? " (update available)" : ""));
if (isNew)
if (true || isNew)
NEW_VERSIONS.add(mod);
}
}