From f79fd5e06f8e3d2403d0f10fda3222a2d99cff55 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Mon, 22 Dec 2025 12:47:58 -0600 Subject: [PATCH] error handling in AbstactDhLevel chunk update --- .../core/level/AbstractDhLevel.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java index a855d3ab7..a84275d5a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/level/AbstractDhLevel.java @@ -192,23 +192,30 @@ public abstract class AbstractDhLevel implements IDhLevel return this.updateDataSourcesAsync(fullDataSource) .thenRun(() -> { - HashSet updatedChunkPosSet = this.updatedChunkPosSetBySectionPos.remove(fullDataSource.getPos()); - if (updatedChunkPosSet != null) + try { - for (DhChunkPos chunkPos : updatedChunkPosSet) + HashSet updatedChunkPosSet = this.updatedChunkPosSetBySectionPos.remove(fullDataSource.getPos()); + if (updatedChunkPosSet != null) { - // save after the data source has been updated to prevent saving the hash without the associated datasource - Integer chunkHash = this.updatedChunkHashesByChunkPos.remove(chunkPos); - if (this.chunkHashRepo != null && chunkHash != null) + for (DhChunkPos chunkPos : updatedChunkPosSet) { - this.chunkHashRepo.save(new ChunkHashDTO(chunkPos, chunkHash)); - } - - ApiEventInjector.INSTANCE.fireAllEvents( + // save after the data source has been updated to prevent saving the hash without the associated datasource + Integer chunkHash = this.updatedChunkHashesByChunkPos.remove(chunkPos); + if (this.chunkHashRepo != null && chunkHash != null) + { + this.chunkHashRepo.save(new ChunkHashDTO(chunkPos, chunkHash)); + } + + ApiEventInjector.INSTANCE.fireAllEvents( DhApiChunkModifiedEvent.class, new DhApiChunkModifiedEvent.EventParam(this.getLevelWrapper(), chunkPos.getX(), chunkPos.getZ())); + } } } + catch (Exception e) + { + LOGGER.error("Unexpected issue after onDataSourceSaveAsync, error: ["+e.getMessage()+"].", e); + } }); }