當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。