From 3043a37414a00ec24bfe7fdf071286a1426f8e9c Mon Sep 17 00:00:00 2001 From: Zkitefly <64117916+zkitefly@users.noreply.github.com> Date: Mon, 30 Jun 2025 19:15:13 +0800 Subject: [PATCH] update --- .../org/jackhuang/hmcl/mod/LocalModFile.java | 92 +------------------ 1 file changed, 1 insertion(+), 91 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalModFile.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalModFile.java index 679570caf..0f05a684b 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalModFile.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/LocalModFile.java @@ -19,21 +19,13 @@ package org.jackhuang.hmcl.mod; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; -import javafx.scene.image.Image; - -import org.jackhuang.hmcl.util.StringUtils; -import org.jackhuang.hmcl.util.io.CompressingUtils; import org.jackhuang.hmcl.util.io.FileUtils; import java.io.IOException; -import java.io.InputStream; -import java.nio.file.FileSystem; -import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import java.util.stream.Collectors; - import static org.jackhuang.hmcl.util.logging.Logger.LOG; /** @@ -69,13 +61,7 @@ public final class LocalModFile implements Comparable { this.version = version; this.gameVersion = gameVersion; this.url = url; - - String validatedLogoPath = validateLogoPath(file, logoPath); - if (validatedLogoPath != null) { - this.logoPath = validatedLogoPath; - } else { - this.logoPath = findLogoPath(file, mod.getId()); - } + this.logoPath = logoPath; activeProperty = new SimpleBooleanProperty(this, "active", !modManager.isDisabled(file)) { @Override @@ -216,82 +202,6 @@ public final class LocalModFile implements Comparable { return Objects.hash(getFileName()); } - private String validateLogoPath(Path modFile, String path) { - if (StringUtils.isBlank(path)) return null; - - try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modFile)) { - Path iconPath = fs.getPath(path); - if (!Files.exists(iconPath)) return null; - - try (InputStream stream = Files.newInputStream(iconPath)) { - Image image = new Image(stream, 40, 40, true, true); - - if (!image.isError() && - image.getWidth() > 0 && - image.getHeight() > 0 && - Math.abs(image.getWidth() - image.getHeight()) < 1) { - return path; - } - } catch (Exception e) { - LOG.warning("Failed to validate mod icon from: " + path, e); - } - } catch (IOException e) { - LOG.warning("Failed to access mod file for icon validation: " + path, e); - } - - return null; - } - - private String findLogoPath(Path modFile, String modId) { - List defaultPaths = new ArrayList<>(Arrays.asList( - "icon.png", - "logo.png", - "mod_logo.png", - "pack.png", - "logoFile.png", - "assets/icon.png", - "assets/logo.png", - "assets/mod_icon.png", - "assets/mod_logo.png", - "META-INF/icon.png", - "META-INF/logo.png", - "META-INF/mod_icon.png", - "textures/icon.png", - "textures/logo.png", - "textures/mod_icon.png", - "resources/icon.png", - "resources/logo.png", - "resources/mod_icon.png" - )); - - if (StringUtils.isNotBlank(modId)) { - defaultPaths.addAll(Arrays.asList( - "assets/" + modId + "/icon.png", - "assets/" + modId + "/logo.png", - "assets/" + modId.replace("-", "") + "/icon.png", - "assets/" + modId.replace("-", "") + "/logo.png", - modId + ".png", - modId + "-logo.png", - modId + "-icon.png", - modId + "_logo.png", - modId + "_icon.png", - "textures/" + modId + "/icon.png", - "textures/" + modId + "/logo.png", - "resources/" + modId + "/icon.png", - "resources/" + modId + "/logo.png" - )); - } - - for (String path : defaultPaths) { - String validatedPath = validateLogoPath(modFile, path); - if (validatedPath != null) { - return validatedPath; - } - } - - return null; - } - public static class ModUpdate { private final LocalModFile localModFile; private final RemoteMod.Version currentVersion;