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

The following examples show how to use com.sk89q.worldedit.BlockVector#getBlockX() . 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: WorldGuardSixCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 6 votes vote down vote up
@Override
public void doUnloadChunkFlagCheck(org.bukkit.World world)
{
	for (ProtectedRegion region : this.getRegionContainer().get(world).getRegions().values())
	{
		if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
		{
			System.out.println("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny");
			
			BlockVector min = region.getMinimumPoint();
			BlockVector max = region.getMaximumPoint();

			for(int x = min.getBlockX() >> 4; x <= max.getBlockX() >> 4; x++)
			{
				for(int z = min.getBlockZ() >> 4; z <= max.getBlockZ() >> 4; z++)
				{
					world.getChunkAt(x, z).load(true);
				}
			}
		}
	}
}
 
Example 2
Source File: WorldGuardFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean containsChunk(int chunkX, int chunkZ) {
    if (!large) return super.containsChunk(chunkX, chunkZ);
    BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
    ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
Example 3
Source File: WorldGuardFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean containsRegion(int mcaX, int mcaZ) {
    if (!large) return super.containsRegion(mcaX, mcaZ);
    BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
    BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
    ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
    ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
    return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
 
Example 4
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;
}