當前位置: 首頁>>代碼示例>>Java>>正文


Java ProtectedRegion.contains方法代碼示例

本文整理匯總了Java中com.sk89q.worldguard.protection.regions.ProtectedRegion.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java ProtectedRegion.contains方法的具體用法?Java ProtectedRegion.contains怎麽用?Java ProtectedRegion.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sk89q.worldguard.protection.regions.ProtectedRegion的用法示例。


在下文中一共展示了ProtectedRegion.contains方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMove

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
@EventHandler
public void onMove(PlayerMoveEvent e){
	RegionManager rgManager = Util.getWorldGuard().getRegionManager(Bukkit.getWorld("kitpvp"));
	ProtectedRegion rg = rgManager.getRegion("kit");
	if(rg.contains(BukkitUtil.toVector(e.getTo())) && !Vars.guiHandler.getOpenInvs().containsKey(e.getPlayer()) && !IPlayerHandler.getPlayer(e.getPlayer()).gotKit){
		e.getPlayer().performCommand("kit");
	}
	
	GameMode gm = e.getPlayer().getGameMode();
	if((gm.equals(GameMode.SURVIVAL) || gm.equals(GameMode.ADVENTURE)) && e.getPlayer().getInventory().contains(Material.GLASS_BOTTLE) && e.getPlayer().getLocation().getWorld().getName().equals("kitpvp")){
		e.getPlayer().getInventory().remove(Material.GLASS_BOTTLE);
	}
	
	if(gm.equals(GameMode.ADVENTURE) && e.getPlayer().getWorld().getName().equals("faction")){
		e.getPlayer().setGameMode(GameMode.SURVIVAL);
	}
}
 
開發者ID:bobmandude9889,項目名稱:iZenith-PVP,代碼行數:18,代碼來源:PlayerMoveListener.java

示例2: getPlayersInRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
public static List<Player> getPlayersInRegion(World world, ProtectedRegion region) {
    // Note: This might be heavy - for large servers...
    List<Player> players = new ArrayList<>();
    if (region == null) {
        return players;
    }
    for (Player player : world.getPlayers()) {
        if (player != null && player.isOnline()) {
            Location p = player.getLocation();
            if (region.contains(p.getBlockX(), p.getBlockY(), p.getBlockZ())) {
                players.add(player);
            }
        }
    }
    return players;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:17,代碼來源:WorldGuardHandler.java

示例3: get

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
protected String[] get(Event event) {
	Location loc = this.loc.getSingle(event);
	String a = null;
	WorldGuardPlugin wg = (WorldGuardPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
	RegionManager regionManager = wg.getRegionContainer().get(loc.getWorld());

	for (ProtectedRegion reg : regionManager.getApplicableRegions(loc)) {

		if (reg.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
			a = reg.getId().toString();
		}
	}
	return new String[] { a };

}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:16,代碼來源:ExprRegionAt.java

示例4: containsLocation

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
public boolean containsLocation(Location loc, String regionId) {
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();
    ProtectedRegion region = WGBukkit.getRegionManager(loc.getWorld()).getRegion(regionId);

    return (region != null && region.contains(x, y, z));
}
 
開發者ID:elsiff,項目名稱:MoreFish,代碼行數:9,代碼來源:WorldGuardHooker.java

示例5: onCommand

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
@Override
public void onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
	WorldGuardPlugin wGuard = Util.getWorldGuard();
	
	RegionManager rgManager = wGuard.getRegionManager(Bukkit.getWorld("kitpvp"));
	ProtectedRegion rg = rgManager.getRegion("spawn");

	Player player = (Player) sender;
	Location loc = player.getLocation();
	
	if(rg.contains(BukkitUtil.toVector(loc)) || player.getWorld().getName().split("_")[0].equals("faction")){
		KitManager.openGUI(player);
	} else {
		sender.sendMessage(ChatColor.RED + "You are not allowed to use /kit in this area!");
	}
}
 
開發者ID:bobmandude9889,項目名稱:iZenith-PVP,代碼行數:17,代碼來源:KitCommand.java

示例6: onNPCSpawn

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onNPCSpawn(NPCSpawnEvent event) {
  Entity npc = event.getNpc();
  Location loc = npc.getLocation();
  List<String> regions = (List<String>) getData(event.getData(), WG_SPAWN_IN, List.class);
  if (regions != null) {
    WorldGuardPlugin wg = WGUtils.get();
    // Check that WorldGuard is available.
    if (wg == null) {
      warn("%s has the %s but WorldGuard is not available, thus the property was ignored.",
           event.getData().getId(), WG_SPAWN_IN);
      return;
    }
    
    RegionManager mgr = wg.getRegionManager(npc.getWorld());
    if (mgr == null) {
      return;
    }

    boolean foundRegion = false;
    boolean canSpawn = false;
    for (String regionStr : regions) {
      ProtectedRegion region = mgr.getRegion(regionStr);
      if (region == null) {
        continue;
      }
      foundRegion = true;
      if (region.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
        canSpawn = true;
      }
    }

    if (foundRegion && !canSpawn) {
      event.setCancelled(true);
    }
  }
}
 
開發者ID:SupaHam,項目名稱:NPCs,代碼行數:38,代碼來源:WorldGuardHandler.java

示例7: locationIsOnNetherIsland

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
public boolean locationIsOnNetherIsland(final Player player, final Location loc) {
    if (!isSkyNether(loc.getWorld())) {
        return false;
    }
    PlayerInfo playerInfo = playerLogic.getPlayerInfo(player);
    if (playerInfo != null && playerInfo.getHasIsland()) {
        Location p = playerInfo.getIslandNetherLocation();
        if (p == null) {
            return false;
        }
        ProtectedRegion region = WorldGuardHandler.getNetherRegionAt(p);
        return region != null && region.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    }
    return false;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:16,代碼來源:uSkyBlock.java

示例8: locationIsOnIsland

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
public boolean locationIsOnIsland(final Player player, final Location loc) {
    if (!isSkyWorld(loc.getWorld())) {
        return false;
    }
    PlayerInfo playerInfo = playerLogic.getPlayerInfo(player);
    if (playerInfo != null && playerInfo.getHasIsland()) {
        Location p = playerInfo.getIslandLocation();
        if (p == null) {
            return false;
        }
        ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(p);
        return region != null && region.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    }
    return false;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:16,代碼來源:uSkyBlock.java

示例9: getCreaturesInRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
public static List<LivingEntity> getCreaturesInRegion(World world, ProtectedRegion region) {
    List<LivingEntity> livingEntities = world.getLivingEntities();
    List<LivingEntity> creatures = new ArrayList<>();
    for (LivingEntity e : livingEntities) {
        if (region.contains(asVector(e.getLocation()))) {
            creatures.add(e);
        }
    }
    return creatures;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:11,代碼來源:WorldGuardHandler.java

示例10: getApplicableRegionsSet

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
@Override
public Set<ProtectedRegion> getApplicableRegionsSet(Location location) {
	Set<ProtectedRegion> result = new HashSet<>();
	Vector vector = new Vector(location.getX(), location.getY(), location.getZ());
	for(ProtectedRegion region : pluginInterface.getWorldGuard().getRegionManager(location.getWorld()).getRegions().values()) {
		if(region.contains(vector)) {
			result.add(region);
		}
	}
	return result;
}
 
開發者ID:NLthijs48,項目名稱:AreaShop,代碼行數:12,代碼來源:WorldGuardHandler5.java

示例11: insideRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
private boolean insideRegion(Player player, ProtectedRegion region){
	LocalPlayer lp = RegionFX.getWorldGuard().wrapPlayer(player);
	return region.contains(lp.getPosition());
}
 
開發者ID:applenick,項目名稱:RegionFX,代碼行數:5,代碼來源:EffectRegionManager.java

示例12: execute

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //導入方法依賴的package包/類
@Override
public void execute(CommandSender sender, String[] args) {
	if(!sender.hasPermission("areashop.setteleport") && !sender.hasPermission("areashop.setteleportall")) {
		plugin.message(sender, "setteleport-noPermission");
		return;
	}
	if(!(sender instanceof Player)) {
		plugin.message(sender, "onlyByPlayer");
		return;
	}
	Player player = (Player)sender;
	GeneralRegion region;
	if(args.length < 2) {
		// get the region by location
		List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
		if(regions.isEmpty()) {
			plugin.message(sender, "cmd-noRegionsAtLocation");
			return;
		} else if(regions.size() > 1) {
			plugin.message(sender, "cmd-moreRegionsAtLocation");
			return;
		} else {
			region = regions.get(0);
		}
	} else {
		region = plugin.getFileManager().getRegion(args[1]);
	}

	boolean owner;

	if(region == null) {
		plugin.message(player, "setteleport-noRentOrBuy", args[1]);
		return;
	}
	if(region instanceof RentRegion) {
		owner = player.getUniqueId().equals(((RentRegion)region).getRenter());
	} else {
		owner = player.getUniqueId().equals(((BuyRegion)region).getBuyer());
	}
	if(!player.hasPermission("areashop.setteleport")) {
		plugin.message(player, "setteleport-noPermission", region);
		return;
	} else if(!owner && !player.hasPermission("areashop.setteleportall")) {
		plugin.message(player, "setteleport-noPermissionOther", region);
		return;
	}

	ProtectedRegion wgRegion = region.getRegion();
	if(args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("reset") || args[2].equalsIgnoreCase("yes") || args[2].equalsIgnoreCase("true"))) {
		region.getTeleportFeature().setTeleport(null);
		region.update();
		plugin.message(player, "setteleport-reset", region);
		return;
	}
	if(!player.hasPermission("areashop.setteleportoutsideregion") && (wgRegion == null || !wgRegion.contains(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()))) {
		plugin.message(player, "setteleport-notInside", region);
		return;
	}
	region.getTeleportFeature().setTeleport(player.getLocation());
	region.update();
	plugin.message(player, "setteleport-success", region);
}
 
開發者ID:NLthijs48,項目名稱:AreaShop,代碼行數:63,代碼來源:SetteleportCommand.java

示例13: 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.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。