Java Code Examples for com.sk89q.worldguard.protection.regions.ProtectedRegion#getMinimumPoint()

The following examples show how to use com.sk89q.worldguard.protection.regions.ProtectedRegion#getMinimumPoint() . 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: WorldGuardSevenCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 5 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");
			
			BlockVector3 min = region.getMinimumPoint();
			BlockVector3 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);
					
					if (WorldGuardSevenCommunicator.supportsForceLoad)
					{
						world.getChunkAt(x, z).setForceLoaded(true);
					}
				}
			}
		}
	}
}
 
Example 3
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 4
Source File: SetBiomeTask.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public SetBiomeTask(uSkyBlock plugin, Location loc, Biome biome, Runnable onCompletion) {
    super(plugin, onCompletion);
    this.biome = biome;
    ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(loc);
    if (region != null) {
        minP = region.getMinimumPoint();
        maxP = region.getMaximumPoint();
    } else {
        minP = null;
        maxP = null;
    }
    world = loc.getWorld();
    chunks = WorldEditHandler.getChunks(new CuboidRegion(minP, maxP));
}
 
Example 5
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public static Region getRegion(World skyWorld, ProtectedRegion region) {
    return new CuboidRegion(new BukkitWorld(skyWorld), region.getMinimumPoint(), region.getMaximumPoint());
}
 
Example 6
Source File: RegionCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
private void showRegion(Player player, ProtectedRegion region) {
    int y = player.getLocation().getBlockY();
    BlockVector3 minP = region.getMinimumPoint();
    BlockVector3 maxP = region.getMaximumPoint();
    showRegion(player, y, minP, maxP);
}
 
Example 7
Source File: BiomeCommand.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean doExecute(String alias, final Player player, PlayerInfo pi, final IslandInfo island, Map<String, Object> data, final String... args) {
    if (args.length == 0) {
        if (!island.hasPerm(player, "canChangeBiome")) {
            player.sendMessage(tr("\u00a7cYou do not have permission to change the biome of your current island."));
        } else {
            player.openInventory(menu.displayBiomeGUI(player)); // Weird, that we show the UI
        }
    }
    if (args.length >= 1) {
        final String biome = args[0].toLowerCase();
        if (!island.hasPerm(player, "canChangeBiome")) {
            player.sendMessage(tr("\u00a74You do not have permission to change the biome of this island!"));
            return true;
        }
        Location location = player.getLocation();
        ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location);
        if (!plugin.playerIsOnOwnIsland(player) || region == null) {
            player.sendMessage(tr("\u00a7eYou must be on your island to change the biome!"));
            return true;
        }
        if (!biomeExists(biome)) {
            player.sendMessage(tr("\u00a7cYou have misspelled the biome name. Must be one of {0}", BIOMES.keySet()));
            return true;
        }
        int cooldown = plugin.getCooldownHandler().getCooldown(player, "biome");
        if (cooldown > 0) {
            player.sendMessage(tr("\u00a7eYou can change your biome again in {0,number,#} minutes.", cooldown / 60));
            return true;
        }
        if (!player.hasPermission("usb.biome." + biome.toLowerCase())) {
            player.sendMessage(tr("\u00a7cYou do not have permission to change your biome to that type."));
            return true;
        }
        BlockVector3 minP = region.getMinimumPoint();
        BlockVector3 maxP = region.getMaximumPoint();
        if (args.length == 2 && args[1].matches("[0-9]+")) {
            int radius = Integer.parseInt(args[1], 10);
            Location loc = location.clone().add(-radius, 0, -radius);
            if (region.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
                minP = BlockVector3.at(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
            }
            loc = location.clone().add(radius, 0, radius);
            if (region.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
                maxP = BlockVector3.at(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
            }
            player.sendMessage(tr("\u00a77The pixies are busy changing the biome near you to \u00a79{0}\u00a77, be patient.", biome));
        } else if (args.length == 2 && args[1].equalsIgnoreCase("chunk")) {
            Chunk chunk = location.clone().getChunk();
            minP = BlockVector3.at(chunk.getX() << 4, 0, chunk.getZ() << 4);
            maxP = BlockVector3.at((chunk.getX() << 4) + 15, location.getWorld().getMaxHeight(), (chunk.getZ() << 4) + 15);
            player.sendMessage(tr("\u00a77The pixies are busy changing the biome in your current chunk to \u00a79{0}\u00a77, be patient.", biome));
        } else if (args.length < 2 || args[1].equalsIgnoreCase("all")) {
            player.sendMessage(tr("\u00a77The pixies are busy changing the biome of your island to \u00a79{0}\u00a77, be patient.", biome));
        }
        Biome biomeEnum = BIOMES.get(biome);
        if (biomeEnum == null) {
            player.sendMessage(tr("\u00a7eInvalid biome {0} supplied!", biome));
            return true;
        }
        new SetBiomeTask(plugin, player.getWorld(), minP, maxP, biomeEnum, () -> {
            if (args.length == 1) {
                island.setBiome(biome);
                player.sendMessage(tr("\u00a7aYou have changed your island''s biome to {0}", biome.toUpperCase()));
                island.sendMessageToIslandGroup(true, marktr("{0} changed the island biome to {1}"), player.getName(), biome.toUpperCase());
                plugin.getCooldownHandler().resetCooldown(player, "biome", Settings.general_biomeChange);
            } else {
                player.sendMessage(tr("\u00a7aYou have changed {0} blocks around you to the {1} biome", args[1], biome.toUpperCase()));
                island.sendMessageToIslandGroup(true, marktr("{0} created an area with {1} biome"), player.getName(), biome.toUpperCase());
            }
        }).runTask(plugin);
    }
    return true;
}
 
Example 8
Source File: WorldGuardHandler5.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public org.bukkit.util.Vector getMinimumPoint(ProtectedRegion region) {
	BlockVector min = region.getMinimumPoint();
	return new org.bukkit.util.Vector(min.getX(), min.getY(), min.getZ());
}
 
Example 9
Source File: WorldGuardHandler7_beta_2.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Vector getMinimumPoint(ProtectedRegion region) {
	BlockVector3 min = region.getMinimumPoint();
	return new Vector(min.getX(), min.getY(), min.getZ());
}
 
Example 10
Source File: WorldGuardHandler6.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public org.bukkit.util.Vector getMinimumPoint(ProtectedRegion region) {
	BlockVector min = region.getMinimumPoint();
	return new org.bukkit.util.Vector(min.getX(), min.getY(), min.getZ());
}
 
Example 11
Source File: FastAsyncWorldEditWorldGuardHandler.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Vector getMinimumPoint(ProtectedRegion region) {
	BlockVector min = region.getMinimumPoint();
	return new Vector(min.getX(), min.getY(), min.getZ());
}
 
Example 12
Source File: WorldGuardHandler7_beta_1.java    From AreaShop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public org.bukkit.util.Vector getMinimumPoint(ProtectedRegion region) {
	BlockVector min = region.getMinimumPoint();
	return new org.bukkit.util.Vector(min.getX(), min.getY(), min.getZ());
}