Fix potential NPE

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-04-11 22:38:37 +02:00
parent 5812482922
commit afbc6d6a47

View File

@ -57,7 +57,7 @@ public class InstanceContainer extends Instance {
// (chunk index -> chunk) map, contains all the chunks in the instance // (chunk index -> chunk) map, contains all the chunks in the instance
// used as a monitor when access is required // used as a monitor when access is required
private final Long2ObjectSyncMap<Chunk> chunks = Long2ObjectSyncMap.hashmap(); private final Long2ObjectSyncMap<Chunk> chunks = Long2ObjectSyncMap.hashmap();
private final Long2ObjectSyncMap<CompletableFuture<Chunk>> loadingChunks = Long2ObjectSyncMap.hashmap(); private final Map<Long, CompletableFuture<Chunk>> loadingChunks = new ConcurrentHashMap<>();
private final Lock changingBlockLock = new ReentrantLock(); private final Lock changingBlockLock = new ReentrantLock();
private final Map<Point, Block> currentlyChangingBlocks = new HashMap<>(); private final Map<Point, Block> currentlyChangingBlocks = new HashMap<>();
@ -275,7 +275,7 @@ public class InstanceContainer extends Instance {
EventDispatcher.call(new InstanceChunkLoadEvent(this, chunk)); EventDispatcher.call(new InstanceChunkLoadEvent(this, chunk));
final CompletableFuture<Chunk> future = this.loadingChunks.remove(index); final CompletableFuture<Chunk> future = this.loadingChunks.remove(index);
assert future == completableFuture : "Invalid future: " + future; assert future == completableFuture : "Invalid future: " + future;
future.complete(chunk); completableFuture.complete(chunk);
}) })
.exceptionally(throwable -> { .exceptionally(throwable -> {
MinecraftServer.getExceptionManager().handleException(throwable); MinecraftServer.getExceptionManager().handleException(throwable);