cache bukkitworld

This commit is contained in:
dordsor21 2020-12-28 12:10:27 +00:00
parent 7f01f2d716
commit 71305e636c
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -33,7 +33,6 @@ import com.plotsquared.core.inject.factory.ChunkCoordinatorFactory;
import com.plotsquared.core.queue.BasicQueueCoordinator;
import com.plotsquared.core.queue.ChunkCoordinator;
import com.plotsquared.core.queue.LocalChunk;
import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.ChunkUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
@ -77,13 +76,8 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
}
@Override public BlockState getBlock(int x, int y, int z) {
org.bukkit.World worldObj = BukkitAdapter.adapt(getWorld());
if (worldObj != null) {
Block block = worldObj.getBlockAt(x, y, z);
return BukkitBlockUtil.get(block);
} else {
return BlockUtil.get(0, 0);
}
Block block = getBukkitWorld().getBlockAt(x, y, z);
return BukkitBlockUtil.get(block);
}
@Override public void start() {
@ -227,11 +221,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
} catch (WorldEditException ignored) {
// Fallback to not so nice method
BlockData blockData = BukkitAdapter.adapt(block);
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getWorld(getWorld().getName());
}
Chunk chunk = bukkitWorld.getChunkAt(blockVector2.getX(), blockVector2.getZ());
Chunk chunk = getBukkitWorld().getChunkAt(blockVector2.getX(), blockVector2.getZ());
Block existing = chunk.getBlock(x, y, z);
final BlockState existingBaseBlock = BukkitAdapter.adapt(existing.getBlockData());
@ -254,4 +244,11 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
}
}
private org.bukkit.World getBukkitWorld() {
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getWorld(getWorld().getName());
}
return bukkitWorld;
}
}