Fix queue instantiation

This commit is contained in:
Jesse Boyd 2017-12-27 04:00:26 +11:00
parent 1cb4cb345f
commit 994856b8fd
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 18 additions and 5 deletions

View File

@ -36,6 +36,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -141,7 +142,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
public boolean queueChunkLoad(int cx, int cz, RunnableVal<CHUNK> operation) {
if (PAPER) {
try {
getImpWorld().getChunkAtAsync(cx, cz, new World.ChunkLoadCallback() {
new PaperChunkCallback(getImpWorld(), cx, cz) {
@Override
public void onLoad(Chunk bukkitChunk) {
try {
@ -155,7 +156,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
PAPER = false;
}
}
});
};
return true;
} catch (Throwable ignore) {
PAPER = false;

View File

@ -56,17 +56,17 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
public boolean queueChunkLoad(int cx, int cz, RunnableVal<ChunkSnapshot> operation) {
if (PAPER) {
try {
getImpWorld().getChunkAtAsync(cx, cz, new World.ChunkLoadCallback() {
new PaperChunkCallback(getImpWorld(), cx, cz) {
@Override
public void onLoad(Chunk chunk) {
try {
ChunkSnapshot snapshot = chunk.getChunkSnapshot();
operation.run(snapshot);
} catch (Throwable e) {
e.printStackTrace();
PAPER = false;
}
}
});
};
return true;
} catch (Throwable ignore) {
PAPER = false;

View File

@ -0,0 +1,12 @@
package com.boydti.fawe.bukkit.v0;
import org.bukkit.Chunk;
import org.bukkit.World;
public abstract class PaperChunkCallback {
public PaperChunkCallback(World world, int x, int z) {
world.getChunkAtAsync(x, z, chunk -> PaperChunkCallback.this.onLoad(chunk));
}
public abstract void onLoad(Chunk chunk);
}