当前位置: 首页>>代码示例>>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;未经允许,请勿转载。