Make sure we do not close the jar filesystem when cheking for mods (otherwise resources might fail)

This commit is contained in:
Frank 2021-08-24 16:59:59 +02:00
parent 617573ca09
commit f3bdaaac8e

View file

@ -51,18 +51,19 @@ public class ModUtil {
PathUtil.fileWalker(PathUtil.MOD_FOLDER.toFile(), false, (file -> {
try {
URI uri = URI.create("jar:" + file.toUri());
try (FileSystem fs = FileSystems.getFileSystem(uri)) {
final JarFile jarFile = new JarFile(file.toString());
FileSystem fs = FileSystems.getFileSystem(uri);
if (fs!=null) {
try {
Path modMetaFile = fs.getPath("fabric.mod.json");
if (modMetaFile != null) {
ModMetadata mc = ModMetadataParser.parseMetadata(logger, modMetaFile);
mods.put(mc.getId(), new ModInfo(mc, file));
}
catch (ParseMetadataException e) {
} catch (ParseMetadataException e) {
BCLib.LOGGER.error(e.getMessage());
}
}
}
catch (IOException e) {
BCLib.LOGGER.error(e.getMessage());
}