diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java index 66dc33d2..f2ce74eb 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java @@ -17,6 +17,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import static net.minecraft.world.level.Level.*; @@ -93,23 +94,25 @@ public LongList getHighlightsSnapshot(final ResourceKey dimensionId) { @Override public void handleWorldChange() { - try { - Futures.whenAllComplete(saveAllChunks()) + Futures.whenAllComplete(saveAllChunks()) .run(() -> { reset(); initializeWorld(); loadChunksInActualDimension(); - }, Runnable::run) - .get(); - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error handling {} cache world change", databaseName, e); - } + }, Globals.cacheRefreshExecutorService.get()); } public synchronized void reset() { this.worldCacheInitialized = false; this.currentWorldId = null; - if (this.executorService != null) this.executorService.shutdown(); + if (this.executorService != null) { + this.executorService.shutdown(); + try { + this.executorService.awaitTermination(3L, TimeUnit.SECONDS); + } catch (final Throwable e) { + XaeroPlus.LOGGER.error("Timed out waiting for {} executor to shutdown", databaseName, e); + } + } if (this.database != null) this.database.close(); this.dimensionCacheMap.clear(); this.database = null; @@ -219,14 +222,9 @@ public void onEnable() { @Override public void onDisable() { - try { - Futures.whenAllComplete(saveAllChunks()) - .run(() -> reset(), - Runnable::run) - .get(); - } catch (Exception e) { - XaeroPlus.LOGGER.error("Error handling {} cache disable", databaseName, e); - } + Futures.whenAllComplete(saveAllChunks()) + .run(() -> reset(), + Globals.cacheRefreshExecutorService.get()); } @Override diff --git a/settings.gradle.kts b/settings.gradle.kts index d03d7721..824863f9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,7 +9,7 @@ pluginManagement { } } gradle.extra.apply { - set("mod_version", "2.24.6") + set("mod_version", "2.24.7") set("minecraft_version", "1.20.6") set("parchment_version", "2024.06.16") set("worldmap_version_fabric", "1.39.0")