Skip to content

Commit

Permalink
Fix queue instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
boy0001 committed Dec 26, 2017
1 parent 1cb4cb3 commit 994856b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand Down Expand Up @@ -141,7 +142,7 @@ public void sendChunkUpdatePLIB(FaweChunk chunk, FawePlayer... players) {
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 {
Expand All @@ -155,7 +156,7 @@ public void onLoad(Chunk bukkitChunk) {
PAPER = false;
}
}
});
};
return true;
} catch (Throwable ignore) {
PAPER = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public BukkitQueue_All(String world) {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 994856b

Please sign in to comment.