Skip to content

Commit 9d042ba

Browse files
committed
fix: clear "broken" flag when unloaded but not removed
1 parent 4f2326f commit 9d042ba

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

c2me-rewrites-chunk-system/src/main/java/com/ishland/c2me/rewrites/chunksystem/common/statuses/ReadFromDisk.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,17 @@ public CompletionStage<Void> downgradeFromThis(ChunkLoadingContext context, Canc
198198
return asyncSaveFuture;
199199
}
200200
}, ((IThreadedAnvilChunkStorage) context.tacs()).getMainThreadExecutor())
201-
.thenCompose(Function.identity());
201+
.thenCompose(Function.identity())
202+
.whenComplete((unused, throwable) -> {
203+
try {
204+
if ((context.holder().getFlags() & ItemHolder.FLAG_BROKEN) != 0) {
205+
LOGGER.warn("Broken chunk {} was unloaded", context.holder().getKey());
206+
context.holder().clearFlag(ItemHolder.FLAG_BROKEN);
207+
}
208+
} catch (Throwable t) {
209+
t.printStackTrace();
210+
}
211+
});
202212
}
203213

204214
private CompletionStage<Void> asyncSave(ChunkLoadingContext context, Chunk chunk) {

0 commit comments

Comments
 (0)