mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-28 17:38:01 +01:00
cache bukkitworld
This commit is contained in:
parent
7f01f2d716
commit
71305e636c
@ -33,7 +33,6 @@ import com.plotsquared.core.inject.factory.ChunkCoordinatorFactory;
|
|||||||
import com.plotsquared.core.queue.BasicQueueCoordinator;
|
import com.plotsquared.core.queue.BasicQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ChunkCoordinator;
|
import com.plotsquared.core.queue.ChunkCoordinator;
|
||||||
import com.plotsquared.core.queue.LocalChunk;
|
import com.plotsquared.core.queue.LocalChunk;
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
|
||||||
import com.plotsquared.core.util.ChunkUtil;
|
import com.plotsquared.core.util.ChunkUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -77,13 +76,8 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockState getBlock(int x, int y, int z) {
|
@Override public BlockState getBlock(int x, int y, int z) {
|
||||||
org.bukkit.World worldObj = BukkitAdapter.adapt(getWorld());
|
Block block = getBukkitWorld().getBlockAt(x, y, z);
|
||||||
if (worldObj != null) {
|
|
||||||
Block block = worldObj.getBlockAt(x, y, z);
|
|
||||||
return BukkitBlockUtil.get(block);
|
return BukkitBlockUtil.get(block);
|
||||||
} else {
|
|
||||||
return BlockUtil.get(0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void start() {
|
@Override public void start() {
|
||||||
@ -227,11 +221,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
} catch (WorldEditException ignored) {
|
} catch (WorldEditException ignored) {
|
||||||
// Fallback to not so nice method
|
// Fallback to not so nice method
|
||||||
BlockData blockData = BukkitAdapter.adapt(block);
|
BlockData blockData = BukkitAdapter.adapt(block);
|
||||||
|
Chunk chunk = getBukkitWorld().getChunkAt(blockVector2.getX(), blockVector2.getZ());
|
||||||
if (bukkitWorld == null) {
|
|
||||||
bukkitWorld = Bukkit.getWorld(getWorld().getName());
|
|
||||||
}
|
|
||||||
Chunk chunk = bukkitWorld.getChunkAt(blockVector2.getX(), blockVector2.getZ());
|
|
||||||
|
|
||||||
Block existing = chunk.getBlock(x, y, z);
|
Block existing = chunk.getBlock(x, y, z);
|
||||||
final BlockState existingBaseBlock = BukkitAdapter.adapt(existing.getBlockData());
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user