下面列出了怎么用org.bukkit.event.world.ChunkPopulateEvent的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public synchronized void onChunkFinishedGeneration(ChunkPopulateEvent evt) {
Chunk chunk = evt.getChunk();
UUID world = chunk.getWorld().getUID();
Vector2i chunkPos = new Vector2i(chunk.getX(), chunk.getZ());
listeners.forEach(l -> l.onChunkFinishedGeneration(world, chunkPos));
}
private void pasteTree(ChunkPopulateEvent e, int x, int z, Tree tree) {
for (int y = e.getWorld().getMaxHeight(); y > 30; y--) {
Block current = e.getWorld().getBlockAt(x, y, z);
if (!current.getType().isSolid() && current.getType() != Material.WATER && current.getType() != Material.SEAGRASS && current.getType() != Material.TALL_SEAGRASS && !(current.getBlockData() instanceof Waterlogged && ((Waterlogged) current.getBlockData()).isWaterlogged()) && tree.isSoil(current.getRelative(0, -1, 0).getType()) && isFlat(current)) {
Schematic.pasteSchematic(new Location(e.getWorld(), x, y, z), tree);
break;
}
}
}