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