From 90221e57649d5df6859fb8102d091ea8f5eee9fa Mon Sep 17 00:00:00 2001 From: Prospector Date: Sat, 15 Jun 2024 10:56:41 -0400 Subject: [PATCH] Add support for QuickText in mod descriptions - Added support for QuickText in mod descriptions - Newlines in descriptions are no longer forced to be paragraphs, so single linebreaks are now allowd --- build.gradle | 8 ++ gradle.properties | 8 +- .../com/terraformersmc/modmenu/ModMenu.java | 11 +- .../modmenu/ModMenuModMenuCompat.java | 2 +- .../modmenu/TextPlaceholderApiCompat.java | 7 ++ .../gui/widget/DescriptionListWidget.java | 107 ++++++++++++------ .../terraformersmc/modmenu/util/HttpUtil.java | 4 +- .../modmenu/util/UpdateCheckerUtil.java | 3 +- .../terraformersmc/modmenu/util/mod/Mod.java | 79 +++++++------ .../modmenu/util/mod/ModSearch.java | 2 - 10 files changed, 143 insertions(+), 88 deletions(-) create mode 100644 src/main/java/com/terraformersmc/modmenu/TextPlaceholderApiCompat.java diff --git a/build.gradle b/build.gradle index 291748da..56a0bdf3 100644 --- a/build.gradle +++ b/build.gradle @@ -9,11 +9,15 @@ dependencies { mappings "net.fabricmc:yarn:$project.yarn_mappings:v2" mod "fabric-loader", "net.fabricmc:fabric-loader:$project.loader_version" + includeMod "fabric-api", fabricApi.module("fabric-api-base", project.fabric_version) includeMod "fabric-api", fabricApi.module("fabric-resource-loader-v0", project.fabric_version) includeMod "fabric-api", fabricApi.module("fabric-screen-api-v1", project.fabric_version) includeMod "fabric-api", fabricApi.module("fabric-key-binding-api-v1", project.fabric_version) includeMod "fabric-api", fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version) + + includeMod "text-placeholder-api", "eu.pb4:placeholder-api:${project.text_placeholder_api_version}" + compileOnly "org.quiltmc:quilt-loader:$project.quilt_loader_version" } @@ -26,4 +30,8 @@ repositories { name = 'Quilt' url = 'https://maven.quiltmc.org/repository/release' } + maven { + name = 'Nucleoid' + url = 'https://maven.nucleoid.xyz/' + } } diff --git a/gradle.properties b/gradle.properties index be6d5f62..40052ae3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,11 @@ org.gradle.jvmargs=-Xmx1G maven_group=com.terraformersmc archive_name=modmenu -minecraft_version=1.21-pre2 -yarn_mappings=1.21-pre2+build.2 +minecraft_version=1.21 +yarn_mappings=1.21+build.2 loader_version=0.15.11 fabric_version=0.100.1+1.21 +text_placeholder_api_version=2.4.0-pre.2+1.21 quilt_loader_version=0.17.7 # Project Metadata @@ -22,12 +23,13 @@ modrinth_slug=modmenu modrinth_id=mOgUt4GM modrinth_game_versions=1.21 modrinth_mod_loaders=fabric, quilt +modrinth_required_dependencies=P7dR8mSH,eXts2L7r # CurseForge Metadata curseforge_slug=modmenu curseforge_id=308702 curseforge_game_versions=1.21, Fabric, Quilt -curseforge_required_dependencies= +curseforge_required_dependencies=306612 curseforge_optional_dependencies= # Mod Loader Metadata diff --git a/src/main/java/com/terraformersmc/modmenu/ModMenu.java b/src/main/java/com/terraformersmc/modmenu/ModMenu.java index 3ff02381..b126b7dc 100644 --- a/src/main/java/com/terraformersmc/modmenu/ModMenu.java +++ b/src/main/java/com/terraformersmc/modmenu/ModMenu.java @@ -45,8 +45,9 @@ public class ModMenu implements ClientModInitializer { private static final List apiImplementations = new ArrayList<>(); private static int cachedDisplayedModCount = -1; - public static boolean runningQuilt = FabricLoader.getInstance().isModLoaded("quilt_loader"); - public static boolean devEnvironment = FabricLoader.getInstance().isDevelopmentEnvironment(); + public static final boolean RUNNING_QUILT = FabricLoader.getInstance().isModLoaded("quilt_loader"); + public static final boolean DEV_ENVIRONMENT = FabricLoader.getInstance().isDevelopmentEnvironment(); + public static final boolean TEXT_PLACEHOLDER_COMPAT = FabricLoader.getInstance().isModLoaded("placeholder-api"); public static Screen getConfigScreen(String modid, Screen menuScreen) { for (ModMenuApi api : apiImplementations) { @@ -72,7 +73,10 @@ public void onInitializeClient() { Map updateCheckers = new HashMap<>(); Map providedUpdateCheckers = new HashMap<>(); + // Ignore deprecations, they're from Quilt Loader being in the dev env + //noinspection deprecation FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> { + //noinspection deprecation ModMetadata metadata = entrypoint.getProvider().getMetadata(); String modId = metadata.getId(); try { @@ -88,10 +92,11 @@ public void onInitializeClient() { }); // Fill mods map + //noinspection deprecation for (ModContainer modContainer : FabricLoader.getInstance().getAllMods()) { Mod mod; - if (runningQuilt) { + if (RUNNING_QUILT) { mod = new QuiltMod(modContainer, modpackMods); } else { mod = new FabricMod(modContainer, modpackMods); diff --git a/src/main/java/com/terraformersmc/modmenu/ModMenuModMenuCompat.java b/src/main/java/com/terraformersmc/modmenu/ModMenuModMenuCompat.java index 34c4be77..4ed4991e 100644 --- a/src/main/java/com/terraformersmc/modmenu/ModMenuModMenuCompat.java +++ b/src/main/java/com/terraformersmc/modmenu/ModMenuModMenuCompat.java @@ -25,7 +25,7 @@ public Map> getProvidedConfigScreenFactories() { @Override public Map getProvidedUpdateCheckers() { - if (ModMenu.runningQuilt) { + if (ModMenu.RUNNING_QUILT) { return Map.of("quilt_loader", new QuiltLoaderUpdateChecker()); } else { return Map.of("fabricloader", new FabricLoaderUpdateChecker()); diff --git a/src/main/java/com/terraformersmc/modmenu/TextPlaceholderApiCompat.java b/src/main/java/com/terraformersmc/modmenu/TextPlaceholderApiCompat.java new file mode 100644 index 00000000..e8248db6 --- /dev/null +++ b/src/main/java/com/terraformersmc/modmenu/TextPlaceholderApiCompat.java @@ -0,0 +1,7 @@ +package com.terraformersmc.modmenu; + +import eu.pb4.placeholders.api.parsers.NodeParser; + +public class TextPlaceholderApiCompat { + public static final NodeParser PARSER = NodeParser.builder().quickText().build(); +} diff --git a/src/main/java/com/terraformersmc/modmenu/gui/widget/DescriptionListWidget.java b/src/main/java/com/terraformersmc/modmenu/gui/widget/DescriptionListWidget.java index 28a802c5..c16f9d07 100644 --- a/src/main/java/com/terraformersmc/modmenu/gui/widget/DescriptionListWidget.java +++ b/src/main/java/com/terraformersmc/modmenu/gui/widget/DescriptionListWidget.java @@ -27,26 +27,40 @@ import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; public class DescriptionListWidget extends EntryListWidget { private static final Text HAS_UPDATE_TEXT = Text.translatable("modmenu.hasUpdate"); private static final Text EXPERIMENTAL_TEXT = Text.translatable("modmenu.experimental").formatted(Formatting.GOLD); private static final Text MODRINTH_TEXT = Text.translatable("modmenu.modrinth"); - private static final Text DOWNLOAD_TEXT = Text.translatable("modmenu.downloadLink").formatted(Formatting.BLUE).formatted(Formatting.UNDERLINE); + private static final Text DOWNLOAD_TEXT = Text.translatable("modmenu.downloadLink") + .formatted(Formatting.BLUE) + .formatted(Formatting.UNDERLINE); private static final Text CHILD_HAS_UPDATE_TEXT = Text.translatable("modmenu.childHasUpdate"); private static final Text LINKS_TEXT = Text.translatable("modmenu.links"); - private static final Text SOURCE_TEXT = Text.translatable("modmenu.source").formatted(Formatting.BLUE).formatted(Formatting.UNDERLINE); + private static final Text SOURCE_TEXT = Text.translatable("modmenu.source") + .formatted(Formatting.BLUE) + .formatted(Formatting.UNDERLINE); private static final Text LICENSE_TEXT = Text.translatable("modmenu.license"); - private static final Text VIEW_CREDITS_TEXT = Text.translatable("modmenu.viewCredits").formatted(Formatting.BLUE).formatted(Formatting.UNDERLINE); + private static final Text VIEW_CREDITS_TEXT = Text.translatable("modmenu.viewCredits") + .formatted(Formatting.BLUE) + .formatted(Formatting.UNDERLINE); private static final Text CREDITS_TEXT = Text.translatable("modmenu.credits"); private final ModsScreen parent; private final TextRenderer textRenderer; private ModListEntry lastSelected = null; - public DescriptionListWidget(MinecraftClient client, int width, int height, int y, int itemHeight, ModsScreen parent) { + public DescriptionListWidget(MinecraftClient client, + int width, + int height, + int y, + int itemHeight, + ModsScreen parent) { super(client, width, height, y, itemHeight); this.parent = parent; this.textRenderer = client.textRenderer; @@ -85,14 +99,15 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de int wrapWidth = getRowWidth() - 5; Mod mod = lastSelected.getMod(); - String description = mod.getTranslatedDescription(); - if (!description.isEmpty()) { - for (OrderedText line : textRenderer.wrapLines(Text.literal(description.replaceAll("\n", "\n\n")), wrapWidth)) { + Text description = mod.getFormattedDescription(); + if (!description.getString().isEmpty()) { + for (OrderedText line : textRenderer.wrapLines(description, wrapWidth)) { children().add(new DescriptionEntry(line)); } } - if (ModMenuConfig.UPDATE_CHECKER.getValue() && !ModMenuConfig.DISABLE_UPDATE_CHECKER.getValue().contains(mod.getId())) { + if (ModMenuConfig.UPDATE_CHECKER.getValue() && !ModMenuConfig.DISABLE_UPDATE_CHECKER.getValue() + .contains(mod.getId())) { UpdateInfo updateInfo = mod.getUpdateInfo(); if (updateInfo != null && updateInfo.isUpdateAvailable()) { children().add(emptyEntry); @@ -100,7 +115,9 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de int index = 0; for (OrderedText line : textRenderer.wrapLines(HAS_UPDATE_TEXT, wrapWidth - 11)) { DescriptionEntry entry = new DescriptionEntry(line); - if (index == 0) entry.setUpdateTextEntry(); + if (index == 0) { + entry.setUpdateTextEntry(); + } children().add(entry); index += 1; @@ -111,7 +128,9 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de } if (updateInfo instanceof ModrinthUpdateInfo modrinthUpdateInfo) { - Text updateText = Text.translatable("modmenu.updateText", VersionUtil.stripPrefix(modrinthUpdateInfo.getVersionNumber()), MODRINTH_TEXT) + Text updateText = Text.translatable("modmenu.updateText", + VersionUtil.stripPrefix(modrinthUpdateInfo.getVersionNumber()), + MODRINTH_TEXT) .formatted(Formatting.BLUE) .formatted(Formatting.UNDERLINE); @@ -125,7 +144,9 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de updateMessage = DOWNLOAD_TEXT; } else { if (downloadLink != null) { - updateMessage = updateMessage.copy().formatted(Formatting.BLUE).formatted(Formatting.UNDERLINE); + updateMessage = updateMessage.copy() + .formatted(Formatting.BLUE) + .formatted(Formatting.UNDERLINE); } } for (OrderedText line : textRenderer.wrapLines(updateMessage, wrapWidth - 16)) { @@ -143,7 +164,9 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de int index = 0; for (OrderedText line : textRenderer.wrapLines(CHILD_HAS_UPDATE_TEXT, wrapWidth - 11)) { DescriptionEntry entry = new DescriptionEntry(line); - if (index == 0) entry.setUpdateTextEntry(); + if (index == 0) { + entry.setUpdateTextEntry(); + } children().add(entry); index += 1; @@ -170,7 +193,9 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de links.forEach((key, value) -> { int indent = 8; - for (OrderedText line : textRenderer.wrapLines(Text.translatable(key).formatted(Formatting.BLUE).formatted(Formatting.UNDERLINE), wrapWidth - 16)) { + for (OrderedText line : textRenderer.wrapLines(Text.translatable(key) + .formatted(Formatting.BLUE) + .formatted(Formatting.UNDERLINE), wrapWidth - 16)) { children().add(new LinkEntry(line, value, indent)); indent = 16; } @@ -219,7 +244,8 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de var role = iterator.next(); var roleName = role.getKey(); - for (var line : textRenderer.wrapLines(this.creditsRoleText(roleName), wrapWidth - 16)) { + for (var line : textRenderer.wrapLines(this.creditsRoleText(roleName), + wrapWidth - 16)) { children().add(new DescriptionEntry(line, indent)); indent = 16; } @@ -266,42 +292,45 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de RenderSystem.depthFunc(515); RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); - RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE); + RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, + GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, + GlStateManager.SrcFactor.ZERO, + GlStateManager.DstFactor.ONE); RenderSystem.setShader(GameRenderer::getPositionColorProgram); bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); bufferBuilder.vertex(this.getX(), (this.getY() + 4), 0.0F). - color(0, 0, 0, 0); + color(0, 0, 0, 0); bufferBuilder.vertex(this.getRight(), (this.getY() + 4), 0.0F). - color(0, 0, 0, 0); - + color(0, 0, 0, 0); + bufferBuilder.vertex(this.getRight(), this.getY(), 0.0F). - color(0, 0, 0, 255); - + color(0, 0, 0, 255); + bufferBuilder.vertex(this.getX(), this.getY(), 0.0F). - color(0, 0, 0, 255); - + color(0, 0, 0, 255); + bufferBuilder.vertex(this.getX(), this.getBottom(), 0.0F). - color(0, 0, 0, 255); - + color(0, 0, 0, 255); + bufferBuilder.vertex(this.getRight(), this.getBottom(), 0.0F). - - color(0, 0, 0, 255); - + + color(0, 0, 0, 255); + bufferBuilder.vertex(this.getRight(), (this.getBottom() - 4), 0.0F). - color(0, 0, 0, 0); - + color(0, 0, 0, 0); + bufferBuilder.vertex(this.getX(), (this.getBottom() - 4), 0.0F). - color(0, 0, 0, 0); - + color(0, 0, 0, 0); + try { builtBuffer = bufferBuilder.end(); BufferRenderer.drawWithGlobalProgram(builtBuffer); @@ -360,7 +389,8 @@ private Text creditsRoleText(String roleName) { // Fixes common role names people use in English (e.g. Author -> Authors) var fallback = roleName.endsWith("r") ? roleName + "s" : roleName; - return Text.translatableWithFallback("modmenu.credits.role." + translationKey, fallback).append(Text.literal(":")); + return Text.translatableWithFallback("modmenu.credits.role." + translationKey, fallback) + .append(Text.literal(":")); } protected class DescriptionEntry extends ElementListWidget.Entry { @@ -383,7 +413,16 @@ public DescriptionEntry setUpdateTextEntry() { } @Override - public void render(DrawContext DrawContext, int index, int y, int x, int itemWidth, int itemHeight, int mouseX, int mouseY, boolean isSelected, float delta) { + public void render(DrawContext DrawContext, + int index, + int y, + int x, + int itemWidth, + int itemHeight, + int mouseX, + int mouseY, + boolean isSelected, + float delta) { if (updateTextEntry) { UpdateAvailableBadge.renderBadge(DrawContext, x + indent, y); x += 11; diff --git a/src/main/java/com/terraformersmc/modmenu/util/HttpUtil.java b/src/main/java/com/terraformersmc/modmenu/util/HttpUtil.java index bf91b600..82ccd94c 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/HttpUtil.java +++ b/src/main/java/com/terraformersmc/modmenu/util/HttpUtil.java @@ -22,8 +22,8 @@ public static HttpResponse request(HttpRequest.Builder builder, HttpRespo } private static String buildUserAgent() { - String env = ModMenu.devEnvironment ? "/development" : ""; - String loader = ModMenu.runningQuilt ? "quilt" : "fabric"; + String env = ModMenu.DEV_ENVIRONMENT ? "/development" : ""; + String loader = ModMenu.RUNNING_QUILT ? "quilt" : "fabric"; var modMenuVersion = getModMenuVersion(); var minecraftVersion = SharedConstants.getGameVersion().getName(); diff --git a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java index a9423ae2..a6eb232b 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java +++ b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java @@ -9,7 +9,6 @@ import com.terraformersmc.modmenu.config.ModMenuConfig; import com.terraformersmc.modmenu.util.mod.Mod; import com.terraformersmc.modmenu.util.mod.ModrinthUpdateInfo; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.toast.SystemToast; @@ -88,7 +87,7 @@ public static void checkForModrinthUpdates() { }); String mcVer = SharedConstants.getGameVersion().getName(); - List loaders = ModMenu.runningQuilt ? List.of("fabric", "quilt") : List.of("fabric"); + List loaders = ModMenu.RUNNING_QUILT ? List.of("fabric", "quilt") : List.of("fabric"); List updateChannels; UpdateChannel preferredChannel = UpdateChannel.getUserPreference(); diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java index 268b3a08..61ea05e9 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java @@ -1,9 +1,12 @@ package com.terraformersmc.modmenu.util.mod; +import com.terraformersmc.modmenu.ModMenu; +import com.terraformersmc.modmenu.TextPlaceholderApiCompat; import com.terraformersmc.modmenu.api.UpdateChecker; import com.terraformersmc.modmenu.api.UpdateInfo; import com.terraformersmc.modmenu.config.ModMenuConfig; import com.terraformersmc.modmenu.util.mod.fabric.FabricIconHandler; +import eu.pb4.placeholders.api.ParserContext; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.text.Text; @@ -15,103 +18,96 @@ import java.util.stream.Collectors; public interface Mod { - @NotNull - String getId(); + @NotNull String getId(); - @NotNull - String getName(); + @NotNull String getName(); @NotNull default String getTranslatedName() { String translationKey = "modmenu.nameTranslation." + getId(); - if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_NAMES.getValue()) && I18n.hasTranslation(translationKey)) { + if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_NAMES.getValue()) && I18n.hasTranslation( + translationKey)) { return I18n.translate(translationKey); } return getName(); } - @NotNull - NativeImageBackedTexture getIcon(FabricIconHandler iconHandler, int i); + @NotNull NativeImageBackedTexture getIcon(FabricIconHandler iconHandler, int i); @NotNull default String getSummary() { - return getTranslatedSummary(); + String string = getTranslatedSummary(); + return ModMenu.TEXT_PLACEHOLDER_COMPAT ? TextPlaceholderApiCompat.PARSER.parseText(string, ParserContext.of()) + .getString() : string; } @NotNull default String getTranslatedSummary() { String translationKey = "modmenu.summaryTranslation." + getId(); - if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_DESCRIPTIONS.getValue()) && I18n.hasTranslation(translationKey)) { + if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_DESCRIPTIONS.getValue()) && I18n.hasTranslation( + translationKey)) { return I18n.translate(translationKey); } return getTranslatedDescription(); } - @NotNull - String getDescription(); + @NotNull String getDescription(); @NotNull default String getTranslatedDescription() { String translatableDescriptionKey = "modmenu.descriptionTranslation." + getId(); - if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_DESCRIPTIONS.getValue()) && I18n.hasTranslation(translatableDescriptionKey)) { + if ((getId().equals("minecraft") || getId().equals("java") || ModMenuConfig.TRANSLATE_DESCRIPTIONS.getValue()) && I18n.hasTranslation( + translatableDescriptionKey)) { return I18n.translate(translatableDescriptionKey); } return getDescription(); } - @NotNull - String getVersion(); + default Text getFormattedDescription() { + String string = getTranslatedDescription(); + return ModMenu.TEXT_PLACEHOLDER_COMPAT ? TextPlaceholderApiCompat.PARSER.parseText(string, + ParserContext.of()) : Text.literal(string); + } - @NotNull - String getPrefixedVersion(); + @NotNull String getVersion(); - @NotNull - List getAuthors(); + @NotNull String getPrefixedVersion(); + + @NotNull List getAuthors(); /** * @return a mapping of contributors to their roles. */ - @NotNull - Map> getContributors(); + @NotNull Map> getContributors(); /** * @return a mapping of roles to each contributor with that role. */ - @NotNull - SortedMap> getCredits(); + @NotNull SortedMap> getCredits(); - @NotNull - Set getBadges(); + @NotNull Set getBadges(); - @Nullable - String getWebsite(); + @Nullable String getWebsite(); - @Nullable - String getIssueTracker(); + @Nullable String getIssueTracker(); - @Nullable - String getSource(); + @Nullable String getSource(); - @Nullable - String getParent(); + @Nullable String getParent(); - @NotNull - Set getLicense(); + @NotNull Set getLicense(); - @NotNull - Map getLinks(); + @NotNull Map getLinks(); boolean isReal(); boolean allowsUpdateChecks(); - @Nullable - UpdateChecker getUpdateChecker(); + @Nullable UpdateChecker getUpdateChecker(); void setUpdateChecker(@Nullable UpdateChecker updateChecker); - @Nullable - UpdateInfo getUpdateInfo(); + @Nullable UpdateInfo getUpdateInfo(); void setUpdateInfo(@Nullable UpdateInfo updateInfo); @@ -121,7 +117,8 @@ default boolean hasUpdate() { return false; } - return updateInfo.isUpdateAvailable() && updateInfo.getUpdateChannel().compareTo(ModMenuConfig.UPDATE_CHANNEL.getValue()) >= 0; + return updateInfo.isUpdateAvailable() && updateInfo.getUpdateChannel() + .compareTo(ModMenuConfig.UPDATE_CHANNEL.getValue()) >= 0; } default @Nullable String getSha512Hash() throws IOException { diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/ModSearch.java b/src/main/java/com/terraformersmc/modmenu/util/mod/ModSearch.java index 95fb0c4b..8c5b530e 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/ModSearch.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/ModSearch.java @@ -33,7 +33,6 @@ private static int passesFilters(ModsScreen screen, Mod mod, String query) { String modName = mod.getName(); String modTranslatedName = mod.getTranslatedName(); String modDescription = mod.getDescription(); - String modTranslatedDescription = mod.getTranslatedDescription(); String modSummary = mod.getSummary(); String library = I18n.translate("modmenu.searchTerms.library"); @@ -58,7 +57,6 @@ private static int passesFilters(ModsScreen screen, Mod mod, String query) { } if (modDescription.toLowerCase(Locale.ROOT).contains(query) // Search default mod description - || modTranslatedDescription.toLowerCase(Locale.ROOT).contains(query) // Search localized mod description || modSummary.toLowerCase(Locale.ROOT).contains(query) // Search mod summary || authorMatches(mod, query) // Search via author || library.contains(query) && mod.getBadges().contains(Mod.Badge.LIBRARY) // Search for lib mods