updated dependencies and updated all usages accordingly, replaced deprecated methods, and updated project to JDK 25
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.mhsl.minenet.minigames.util;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import net.minestom.server.instance.InstanceContainer;
|
||||
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
|
||||
import net.minestom.server.instance.batch.Batch;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
@@ -24,27 +25,19 @@ public class BatchUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadAndApplyBatch(Batch batch, InstanceContainer instance, Runnable onFinish) {
|
||||
public static void loadAndApplyBatch(AbsoluteBlockBatch batch, InstanceContainer instance, Runnable onFinish) {
|
||||
batch.awaitReady();
|
||||
long[] affectedChunks = BatchUtil.getAffectedChunks(batch);
|
||||
ChunkUtils.optionalLoadAll(instance, affectedChunks, null).thenRun(() -> batch.apply(instance, onFinish));
|
||||
ChunkUtils.optionalLoadAll(instance, affectedChunks, null).thenRun(() -> batch.apply(instance, b -> onFinish.run()));
|
||||
}
|
||||
|
||||
public static void loadAndApplyBatchBlocking(Batch batch, InstanceContainer instance) {
|
||||
public static void loadAndApplyBatchBlocking(AbsoluteBlockBatch batch, InstanceContainer instance) {
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
batch.awaitReady();
|
||||
long[] affectedChunks = BatchUtil.getAffectedChunks(batch);
|
||||
CompletableFuture<Void> loadChunksTask = ChunkUtils.optionalLoadAll(instance, affectedChunks, null);
|
||||
|
||||
Runnable completerTask = () -> {
|
||||
System.out.println("COMPLETE");
|
||||
future.complete(null);
|
||||
};
|
||||
|
||||
loadChunksTask.thenRun(() -> {
|
||||
System.out.println("BEGIN");
|
||||
batch.apply(instance, completerTask);
|
||||
});
|
||||
loadChunksTask.thenRun(() -> batch.apply(instance, b -> future.complete(null)));
|
||||
|
||||
try {
|
||||
future.get();
|
||||
|
||||
Reference in New Issue
Block a user