Java Code Examples for com.sk89q.worldedit.BlockVector#getBlockY()

The following examples show how to use com.sk89q.worldedit.BlockVector#getBlockY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Worldguard.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private static Region adapt(ProtectedRegion region) {
    if (region instanceof ProtectedCuboidRegion) {
        return new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
    }
    if (region instanceof GlobalProtectedRegion) {
        return RegionWrapper.GLOBAL();
    }
    if (region instanceof ProtectedPolygonalRegion) {
        ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
        BlockVector max = region.getMaximumPoint();
        BlockVector min = region.getMinimumPoint();
        return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
    }
    return new AdaptedRegion(region);
}
 
Example 2
Source File: RegionVisualizer.java    From HeavySpleef with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void run() {
	boolean finish = !player.isOnline();
	
	if (player.isOnline()) {
		Player bukkitPlayer = player.getBukkitPlayer();
		
		// Stores the current wool data
		byte data;
		
		if (currentRepetitions % 2 == 0) {
			data = LIME_WOOL_DATA;
		} else {
			data = RED_WOOL_DATA;
		}
		
		finish = currentRepetitions > REPETITIONS;
		Iterator<BlockVector> iterator = region.iterator();
		
		while (iterator.hasNext()) {
			BlockVector vec = iterator.next();
			
			int x = vec.getBlockX();
			int y = vec.getBlockY();
			int z = vec.getBlockZ();
			
			Location location = new Location(world, x, y, z);
			
			if (!finish) {
				bukkitPlayer.sendBlockChange(location, Material.WOOL, data);
			} else {
				Block block = world.getBlockAt(location);
				
				Material material = block.getType();
				data = block.getData();
				
				bukkitPlayer.sendBlockChange(location, material, data);
			}
		}
	}
	
	if (finish) {
		BukkitTask task = tasks.get(player);
		task.cancel();
		
		tasks.remove(player);
	}
	
	++currentRepetitions;
}