当前位置: 首页>>代码示例>>Java>>正文


Java ProtectedRegion.getMinimumPoint方法代码示例

本文整理汇总了Java中com.sk89q.worldguard.protection.regions.ProtectedRegion.getMinimumPoint方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectedRegion.getMinimumPoint方法的具体用法?Java ProtectedRegion.getMinimumPoint怎么用?Java ProtectedRegion.getMinimumPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldguard.protection.regions.ProtectedRegion的用法示例。


在下文中一共展示了ProtectedRegion.getMinimumPoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SetBiomeTask

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
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));
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:15,代码来源:SetBiomeTask.java

示例2: getWorldEditRegionsInSelection

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
 * Get all WorldGuard regions intersecting with a WorldEdit selection.
 * @param selection The selection to check
 * @return A list with all the WorldGuard regions intersecting with the selection
 */
public static List<ProtectedRegion> getWorldEditRegionsInSelection(Selection selection) {
	// Get all regions inside or intersecting with the WorldEdit selection of the player
	World world = selection.getWorld();
	RegionManager regionManager = AreaShop.getInstance().getWorldGuard().getRegionManager(world);
	ArrayList<ProtectedRegion> result = new ArrayList<>();
	Location selectionMin = selection.getMinimumPoint();
	Location selectionMax = selection.getMaximumPoint();
	for(ProtectedRegion region : regionManager.getRegions().values()) {
		BlockVector regionMin = region.getMinimumPoint();
		BlockVector regionMax = region.getMaximumPoint();
		if(
				(      // x part, resolves to true if the selection and region overlap anywhere on the x-axis
						(regionMin.getBlockX() <= selectionMax.getBlockX() && regionMin.getBlockX() >= selectionMin.getBlockX())
								|| (regionMax.getBlockX() <= selectionMax.getBlockX() && regionMax.getBlockX() >= selectionMin.getBlockX())
								|| (selectionMin.getBlockX() >= regionMin.getBlockX() && selectionMin.getBlockX() <= regionMax.getBlockX())
								|| (selectionMax.getBlockX() >= regionMin.getBlockX() && selectionMax.getBlockX() <= regionMax.getBlockX())
				) && ( // Y part, resolves to true if the selection and region overlap anywhere on the y-axis
						(regionMin.getBlockY() <= selectionMax.getBlockY() && regionMin.getBlockY() >= selectionMin.getBlockY())
								|| (regionMax.getBlockY() <= selectionMax.getBlockY() && regionMax.getBlockY() >= selectionMin.getBlockY())
								|| (selectionMin.getBlockY() >= regionMin.getBlockY() && selectionMin.getBlockY() <= regionMax.getBlockY())
								|| (selectionMax.getBlockY() >= regionMin.getBlockY() && selectionMax.getBlockY() <= regionMax.getBlockY())
				) && ( // Z part, resolves to true if the selection and region overlap anywhere on the z-axis
						(regionMin.getBlockZ() <= selectionMax.getBlockZ() && regionMin.getBlockZ() >= selectionMin.getBlockZ())
								|| (regionMax.getBlockZ() <= selectionMax.getBlockZ() && regionMax.getBlockZ() >= selectionMin.getBlockZ())
								|| (selectionMin.getBlockZ() >= regionMin.getBlockZ() && selectionMin.getBlockZ() <= regionMax.getBlockZ())
								|| (selectionMax.getBlockZ() >= regionMin.getBlockZ() && selectionMax.getBlockZ() <= regionMax.getBlockZ())
				)
		) {
			result.add(region);
		}
	}
	return result;
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:39,代码来源:Utils.java

示例3: updateRegionMarker

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
void updateRegionMarker(World world, ProtectedRegion region) {
    double[] x;
    double[] z;

    String regionId = region.getId();
    LandTypes cubitType = LandTypes.getLandType(regionId);
    RegionData regionData = new RegionData(world);
    regionData.setWGRegion(region);

    boolean hasOwner = false;
    if (regionData.getOwnersUUID().length >= 1) {
        hasOwner = true;
    }


    RegionType tn = region.getType();
    BlockVector l0 = region.getMinimumPoint();
    BlockVector l1 = region.getMaximumPoint();

    if (tn == RegionType.CUBOID) {
        x = new double[4];
        z = new double[4];
        x[0] = l0.getX();
        z[0] = l0.getZ();
        x[1] = l0.getX();
        z[1] = l1.getZ() + 1.0;
        x[2] = l1.getX() + 1.0;
        z[2] = l1.getZ() + 1.0;
        x[3] = l1.getX() + 1.0;
        z[3] = l0.getZ();
    } else {
        return;
    }
    String markerId = world.getName() + "_" + regionId;
    AreaMarker m = this.markerSet.findAreaMarker(markerId);
    if (m == null) {
        m = this.markerSet.createAreaMarker(markerId, regionId, false, world.getName(), x, z, false);
        if (m == null)
            return;
    } else {
        m.setCornerLocations(x, z);
        m.setLabel(regionId);
    }
    addStyle(m, regionData, cubitType, hasOwner);
    m.setDescription(formatInfoBox(regionData, m, cubitType, hasOwner));
}
 
开发者ID:MineGaming,项目名称:cubit,代码行数:47,代码来源:CubitDynmap.java

示例4: onCommand

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (cmd.getName().equalsIgnoreCase("room")) {
		if (args.length == 0) {
			showHelp(sender, label);
			return true;
		}
		if (args[0].equalsIgnoreCase("reload")) {
			plugin.reload();
			return true;
		}
		if (args[0].equalsIgnoreCase("add")) {
			if (sender instanceof Player) {
				// set and region name must be provided
				if (args.length < 3) {
					sender.sendMessage("§cIncorrect amount of arguments: " + "/roomrent add <set> <region> [regen]");
					return true;
				}
				Player player = ((Player) sender);
				// region must exist
				ProtectedRegion region = WorldGuardPlugin.inst().getRegionManager(player.getWorld()).getRegion(args[2]);
				if (region == null) {
					sender.sendMessage("§cThis region does not exist!");
					return true;
				}
				// the player must look at the sign
				Set<Material> transparent = new HashSet<Material>();
				transparent.add(Material.AIR);
				Block target = player.getTargetBlock(transparent, 15);
				if (target.getType() != Material.SIGN_POST && target.getType() != Material.WALL_SIGN) {
					sender.sendMessage("§cYou have to look at the sign!");
					return true;
				}
				// check if the world does not conflict with configuration
				String world = plugin.getConfig().getString("room_sets." + args[1] + ".world");
				if (world == null) {
					plugin.getConfig().set("room_sets." + args[1] + ".world", player.getWorld().getName());
				} else if (!world.equals(target.getWorld().getName())) {
					sender.sendMessage("§3This set is on another world!");
					return true;
				}
				// adding region to the config
				plugin.getConfig().set("room_sets." + args[1] + ".rooms." + args[2],
						target.getLocation().getBlockX() + ";" + target.getLocation().getBlockY() + ";"
						+ target.getLocation().getBlockZ());
				plugin.saveConfig();
				// if there is "regen" argument, add a schematic
				if (args.length > 3 && args[3].equalsIgnoreCase("regen")) {
					try {
						WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
						Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
						CuboidClipboard clipboard = new CuboidClipboard(size, region.getMinimumPoint());
						EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 64*64*64);
						CuboidRegion r = new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
						clipboard.copy(editSession, r);
						File worldDirectory = new File(plugin.getDataFolder(), world);
						worldDirectory.mkdir();
						clipboard.saveSchematic(new File(worldDirectory, args[2]));
					} catch (IOException | DataException e) {
						e.printStackTrace();
					}
				}
				sender.sendMessage("§2Region successfully added!");
				return true;
			}
			// the console cannot add rooms
			sender.sendMessage("Please edit the files manually and " + "use /roomrent reload");
			return true;
		}
		showHelp(sender, label);
		return true;
	}
	return false;
}
 
开发者ID:Co0sh,项目名称:RoomRent,代码行数:75,代码来源:RoomCommand.java

示例5: getRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
private static Region getRegion(World skyWorld, ProtectedRegion region) {
    return new CuboidRegion(new BukkitWorld(skyWorld), region.getMinimumPoint(), region.getMaximumPoint());
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:4,代码来源:WorldEditHandler.java

示例6: showRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
private void showRegion(Player player, ProtectedRegion region) {
    int y = player.getLocation().getBlockY();
    BlockVector minP = region.getMinimumPoint();
    BlockVector maxP = region.getMaximumPoint();
    showRegion(player, y, minP, maxP);
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:7,代码来源:RegionCommand.java

示例7: calculateVolume

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
 * Calculate the volume of the region (could be expensive for polygon regions).
 * @return Number of blocks in the region
 */
private long calculateVolume() {
	// Use own calculation for polygon regions, as WorldGuard does not implement it and returns 0
	ProtectedRegion region = getRegion();
	if(region instanceof ProtectedPolygonalRegion) {
		BlockVector min = region.getMinimumPoint();
		BlockVector max = region.getMaximumPoint();

		// Exact, but slow algorithm
		if(getWidth() * getDepth() < 100) {
			long surface = 0;
			for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
				for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
					if (region.contains(x, min.getBlockY(), z)) {
						surface++;
					}
				}
			}
			return surface * getHeight();
		}
		// Estimate, but quick algorithm
		else {
			List<BlockVector2D> points = region.getPoints();
			int numPoints = points.size();
			if(numPoints < 3) {
				return 0;
			}

			double area = 0;
			int x1, x2, z1, z2;
			for(int i = 0; i <= numPoints - 2; i++) {
				x1 = points.get(i).getBlockX();
				z1 = points.get(i).getBlockZ();

				x2 = points.get(i + 1).getBlockX();
				z2 = points.get(i + 1).getBlockZ();

				area = area + ((z1 + z2) * (x1 - x2));
			}

			x1 = points.get(numPoints - 1).getBlockX();
			z1 = points.get(numPoints - 1).getBlockZ();
			x2 = points.get(0).getBlockX();
			z2 = points.get(0).getBlockZ();

			area = area + ((z1 + z2) * (x1 - x2));
			area = Math.ceil(Math.abs(area) / 2);
			return (long)(area * getHeight());
		}
	} else {
		return region.volume();
	}
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:57,代码来源:GeneralRegion.java


注:本文中的com.sk89q.worldguard.protection.regions.ProtectedRegion.getMinimumPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。