Merge 1c29bc520a83c5ec379c9c093e5cbaba4f729568 into 9969dc60c5278340b6b9a4d7facdde620e99d1f5

This commit is contained in:
Glavo 2025-08-02 14:31:25 +00:00 committed by GitHub
commit 30f257c816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,9 +20,11 @@ package org.jackhuang.hmcl.ui.versions;
import org.jackhuang.hmcl.mod.RemoteModRepository;
import org.jackhuang.hmcl.util.Pair;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.IOUtils;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
@ -121,9 +123,11 @@ public enum ModTranslations {
return true;
}
try {
String modData = IOUtils.readFullyAsString(ModTranslations.class.getResourceAsStream(resourceName));
mods = Arrays.stream(modData.split("\n")).filter(line -> !line.startsWith("#")).map(Mod::new).collect(Collectors.toList());
//noinspection DataFlowIssue
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(
ModTranslations.class.getResourceAsStream(resourceName), StandardCharsets.UTF_8))) {
mods = reader.lines().filter(line -> !line.startsWith("#")).map(Mod::new).collect(Collectors.toList());
return true;
} catch (Exception e) {
LOG.warning("Failed to load " + resourceName, e);