diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java index a07c3176a..a808e5e8b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/subDimMatching/SubDimensionLevelMatcher.java @@ -208,14 +208,18 @@ public class SubDimensionLevelMatcher implements AutoCloseable for (File testLevelFolder : this.potentialLevelFolders) { LOGGER.info("Testing level folder: [" + LodUtil.shortenString(testLevelFolder.getName(), 8) + "]"); + + FullDataSourceV2 testFullDataSource = null; try { // get the data source to compare against - IDhLevel tempLevel = new DhClientLevel(new ClientOnlySaveStructure(), this.currentClientLevel, testLevelFolder, false); - FullDataSourceV2 testFullDataSource = tempLevel.getFullDataProvider().getAsync(new DhSectionPos(this.playerData.playerBlockPos)).join(); - if (testFullDataSource == null) + try (IDhLevel tempLevel = new DhClientLevel(new ClientOnlySaveStructure(), this.currentClientLevel, testLevelFolder, false)) { - continue; + testFullDataSource = tempLevel.getFullDataProvider().getAsync(new DhSectionPos(this.playerData.playerBlockPos)).join(); + if (testFullDataSource == null) + { + continue; + } } @@ -334,6 +338,13 @@ public class SubDimensionLevelMatcher implements AutoCloseable // for now we are just assuming it is an unrelated file LOGGER.warn("Error checking level: "+e.getMessage(), e); } + finally + { + if (testFullDataSource != null) + { + try { testFullDataSource.close(); } catch (Exception ignore) {} + } + } }