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


Java WorldGuardPlugin.getRegionManager方法代码示例

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


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

示例1: addRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
/**
 * Criar uma nova região no WorldGuard
 *
 * @param name O nome da nova região
 * @param center O lugar central dela (para ser baseado o tamanho)
 * @param larg Um número inteiro para representar a largura
 * @param comp Um número inteiro para representar o comprimento
 * @param priority A prioridade da região
 * @return Retorna a região que foi criada se for criada com sucesso. Se já houver uma região com esse nome OU houver uma falha, retorna null.
 */
@Nullable
public static ProtectedRegion addRegion ( final String name, final Location center, final int larg, final int comp, final int priority )
{
	Preconditions.checkArgument( center.getWorld().getName().equalsIgnoreCase( center.getWorld().getName() ), "Worlds not same!" );
	Location prim = new Location( center.getWorld(), center.getBlockX() + larg, center.getBlockY(), center.getBlockZ() );
	Location sec = new Location( center.getWorld(), center.getBlockX() - comp, center.getBlockY(), center.getBlockZ() - comp );
	prim = Framework.getMinimumPoint( prim, sec );
	sec = Framework.getMaximumPoint( prim, sec );
	final WorldGuardPlugin plugin = ( WorldGuardPlugin ) Framework.worldguard;
	final RegionManager rm = plugin.getRegionManager( center.getWorld() );
	if ( rm.hasRegion( name ) )
	{
		return null;
	}
	else
	{
		final ProtectedCuboidRegion cuboid = new ProtectedCuboidRegion( name, Framework.getWorldEditVector( prim ), Framework.getWorldEditVector( sec ) );
		cuboid.setPriority( priority );
		rm.addRegion( cuboid );
		return cuboid;
	}
}
 
开发者ID:ProjectSandstone,项目名称:EventoZero,代码行数:33,代码来源:Framework.java

示例2: protectIsland

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static boolean protectIsland(uSkyBlock plugin, CommandSender sender, IslandInfo islandConfig) {
    try {
        WorldGuardPlugin worldGuard = getWorldGuard();
        RegionManager regionManager = worldGuard.getRegionManager(plugin.getWorld());
        String regionName = islandConfig.getName() + "island";
        if (islandConfig != null && noOrOldRegion(regionManager, regionName, islandConfig)) {
            updateRegion(islandConfig);
            islandConfig.setRegionVersion(getVersion());
            return true;
        }
    } catch (Exception ex) {
        String name = islandConfig != null ? islandConfig.getLeader() : "Unknown";
        LogUtil.log(Level.SEVERE, "ERROR: Failed to protect " + name + "'s Island (" + sender.getName() + ")", ex);
    }
    return false;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:WorldGuardHandler.java

示例3: getNetherRegionAt

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static ProtectedRegion getNetherRegionAt(Location location) {
    if (!Settings.nether_enabled || location == null) {
        return null;
    }
    WorldGuardPlugin worldGuard = getWorldGuard();
    RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    if (regionManager == null) {
        return null;
    }
    Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(location);
    for (ProtectedRegion region : applicableRegions) {
        String id = region.getId().toLowerCase();
        if (!id.equalsIgnoreCase("__global__") && id.endsWith("nether")) {
            return region;
        }
    }
    return null;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:19,代码来源:WorldGuardHandler.java

示例4: SprawdzCzyWterenie

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static boolean  SprawdzCzyWterenie(Location loc,String nazwaAreny)
 {
  WorldGuardPlugin wg = getWorldGuard();
  Vector pt = toVector(loc); // This also takes a location
  RegionManager regionManager = wg.getRegionManager(loc.getWorld());
  ApplicableRegionSet set = regionManager.getApplicableRegions(pt);
  for (ProtectedRegion region : set) {
		   if(region.getId().equalsIgnoreCase(nazwaAreny)){
			  // System.out.println("Jestes w tym regionie"); 
			   //p.sendMessage("Jestes w tym regionie");
			   return true;
		   }
	}
 
return false;

 }
 
开发者ID:grzegorz2047,项目名称:AceOfSpadesMiniGame,代码行数:18,代码来源:CheckArea.java

示例5: allowSpawn

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
/**
 * Modifies the worldguard regions at the given location to allow spawning for PetBlocks.
 *
 * @param location location
 * @throws NoSuchMethodException     exception
 * @throws IllegalAccessException    exception
 * @throws InvocationTargetException exception
 */
public synchronized static void allowSpawn(Location location) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    final WorldGuardPlugin worldGuard = getWorldGuard();
    final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    final Iterable<?> set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
    for (final Object region1 : set) {
        final ProtectedRegion region = (ProtectedRegion) region1;
        if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
            region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
            flags.add(region);
        }
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:21,代码来源:WorldGuardConnection5.java

示例6: isAllowedToEnterRegionByRiding

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
/**
 * Checks if the player is riding his pet and entering a different region. Returns false if he isn't the owner of the region.
 *
 * @param player     player
 * @param cacheSpawn cacheSpawn
 * @return success
 * @throws InvocationTargetException exception
 * @throws IllegalAccessException    exception
 * @throws NoSuchMethodException     exception
 */
public static boolean isAllowedToEnterRegionByRiding(Player player, boolean cacheSpawn) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    final Optional<PetBlock> optPetBlock;
    if (!Config.getInstance().allowRidingOnRegionChanging() && ((optPetBlock = PetBlocksApi.getDefaultPetBlockController().getFromPlayer(player)).isPresent())) {
        if (((ArmorStand) optPetBlock.get().getArmorStand()).getPassenger() != null && ((ArmorStand) optPetBlock.get().getArmorStand()).getPassenger().equals(player) || cacheSpawn) {
            final Location location = player.getLocation();
            final WorldGuardPlugin worldGuard = getWorldGuard();
            final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
            final Iterable<?> set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
            List<ProtectedRegion> regionsList = null;
            if (cacheSpawn) {
                regionsList = new ArrayList<>();
            }
            for (final Object region1 : set) {
                final ProtectedRegion region = (ProtectedRegion) region1;
                if (!cacheSpawn && region.getOwners().size() > 0 && !region.getOwners().contains(player.getUniqueId())) {
                    if (cache.containsKey(player) && !cache.get(player).contains(region)) {
                        return false;
                    }
                }
                if (cacheSpawn) {
                    regionsList.add(region);
                }
            }
            if (cacheSpawn) {
                cache.put(player, regionsList);
            }
        }
    }
    return true;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:41,代码来源:WorldGuardConnection5.java

示例7: getRegionsFromLocation

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
/**
 * Returns a list of worldguard regions from the given location.
 *
 * @param location location
 * @return list
 * @throws NoSuchMethodException     exception
 * @throws IllegalAccessException    exception
 * @throws InvocationTargetException exception
 */
public static List<String> getRegionsFromLocation(Location location) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    final List<String> regionList = new ArrayList<>();
    final WorldGuardPlugin worldGuard = getWorldGuard();
    final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    final Iterable<?> set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
    for (final Object region1 : set) {
        final ProtectedRegion region = (ProtectedRegion) region1;
        regionList.add(region.getId());
    }
    return regionList;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:21,代码来源:WorldGuardConnection5.java

示例8: allowSpawn

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public synchronized static void allowSpawn(Location location) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException {
    final WorldGuardPlugin worldGuard = getWorldGuard();
    final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    final ApplicableRegionSet set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
    final Iterable<ProtectedRegion> regions = (Iterable<ProtectedRegion>) getMethod(set.getClass(), "getRegions").invoke(set);
    for (final ProtectedRegion region : regions) {
        if (region.getFlag(DefaultFlag.MOB_SPAWNING) == State.DENY) {
            region.setFlag(DefaultFlag.MOB_SPAWNING, State.ALLOW);
            flags.add(region);
        }
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:13,代码来源:WorldGuardConnection6.java

示例9: isAllowedToEnterRegionByRiding

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
/**
 * Checks if the player is riding his pet and entering a different region. Returns false if he isn't the owner of the region
 *
 * @param player     player
 * @param cacheSpawn cacheSpawn
 * @return success
 * @throws InvocationTargetException exception
 * @throws IllegalAccessException    exception
 * @throws NoSuchMethodException     exception
 */
public static boolean isAllowedToEnterRegionByRiding(Player player, boolean cacheSpawn) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
    final Optional<PetBlock> optPetBlock;
    if (!Config.getInstance().allowRidingOnRegionChanging() && ((optPetBlock = PetBlocksApi.getDefaultPetBlockController().getFromPlayer(player)).isPresent())) {
        if (((ArmorStand) optPetBlock.get().getArmorStand()).getPassenger() != null && ((ArmorStand) optPetBlock.get().getArmorStand()).getPassenger().equals(player) || cacheSpawn) {
            final Location location = player.getLocation();
            final WorldGuardPlugin worldGuard = getWorldGuard();
            final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
            final ApplicableRegionSet set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
            final Iterable<ProtectedRegion> regions = (Iterable<ProtectedRegion>) getMethod(set.getClass(), "getRegions").invoke(set);
            List<ProtectedRegion> regionsList = null;
            if (cacheSpawn) {
                regionsList = new ArrayList<>();
            }
            for (final ProtectedRegion region : regions) {
                if (!cacheSpawn && region.getOwners().size() > 0 && !region.getOwners().contains(player.getUniqueId())) {
                    if (cache.containsKey(player) && !cache.get(player).contains(region)) {
                        return false;
                    }
                }
                if (cacheSpawn) {
                    regionsList.add(region);
                }
            }
            if (cacheSpawn) {
                cache.put(player, regionsList);
            }
        }
    }
    return true;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:41,代码来源:WorldGuardConnection6.java

示例10: getRegionsFromLocation

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static List<String> getRegionsFromLocation(Location location) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    final List<String> regionList = new ArrayList<>();
    final WorldGuardPlugin worldGuard = getWorldGuard();
    final RegionManager regionManager = worldGuard.getRegionManager(location.getWorld());
    final ApplicableRegionSet set = ReflectionUtils.invokeMethodByObject(regionManager, "getApplicableRegions", new Class[]{location.getClass()}, new Object[]{location});
    final Iterable<ProtectedRegion> regions = (Iterable<ProtectedRegion>) getMethod(set.getClass(), "getRegions").invoke(set);
    for (final ProtectedRegion region : regions) {
        regionList.add(region.getId());
    }
    return regionList;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:12,代码来源:WorldGuardConnection6.java

示例11: checkProtectedRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public boolean checkProtectedRegion(Player player, Location loc) {
	if ((player != null) && (loc != null)) {
		wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
		if (wgp != null) {
			if (!PermissionInterface.CheckEnabledWorld(loc)) {
				return true;
			}
			RegionManager regionManager = wgp.getRegionManager(player.getWorld());

			ApplicableRegionSet set = regionManager.getApplicableRegions(loc);

			Iterator<ProtectedRegion> it = set.iterator();
			while (it.hasNext()) {
				String id = it.next().getId();
				String[] splits = id.split("_");
				if (splits.length == 2) {
					if (splits[1].equalsIgnoreCase("safedock") || splits[1].equalsIgnoreCase("red")
							|| splits[1].equalsIgnoreCase("blue")) {
						return true;
					}
				}

			}
			return false;
		}
		return false;
	}
	return true; // reach here in error, return true to protect property
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:30,代码来源:NavyCraft_PlayerListener.java

示例12: checkProtectedRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public boolean checkProtectedRegion(Location loc) {

		wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
		if ((wgp != null) && (loc != null)) {
			if ( !PermissionInterface.CheckEnabledWorld(loc) ) { return true; }
			RegionManager regionManager = wgp.getRegionManager(craft.world);

			ApplicableRegionSet set = regionManager.getApplicableRegions(loc);

			Iterator<ProtectedRegion> it = set.iterator();
			while (it.hasNext()) {
				String id = it.next().getId();

				String[] splits = id.split("_");
				if (splits.length == 2) {
					if (splits[1].equalsIgnoreCase("safedock") || splits[1].equalsIgnoreCase("red") || splits[1].equalsIgnoreCase("blue")) { return true; }
				}
			}
			return false;
		}
		return false;
	}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:23,代码来源:CraftMover.java

示例13: checkSafeDockRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public boolean checkSafeDockRegion(Location loc) {

		wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
		if ((wgp != null) && (loc != null)) {
			RegionManager regionManager = wgp.getRegionManager(craft.world);

			ApplicableRegionSet set = regionManager.getApplicableRegions(loc);

			Iterator<ProtectedRegion> it = set.iterator();
			while (it.hasNext()) {
				String id = it.next().getId();

				String[] splits = id.split("_");
				if (splits.length == 2) {
					if (splits[1].equalsIgnoreCase("safedock")) { return true; }
				}
			}
			return false;
		}
		return false;
	}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:22,代码来源:CraftMover.java

示例14: checkStorageRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static boolean checkStorageRegion(Location loc)
   {
   	
   	wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard");
   	if( wgp != null && loc != null)
   	{
   		if( !PermissionInterface.CheckEnabledWorld(loc) )
   		{
   			return false;
   		}
    	RegionManager regionManager = wgp.getRegionManager(loc.getWorld());
	
		ApplicableRegionSet set = regionManager.getApplicableRegions(loc);
		
		Iterator<ProtectedRegion> it = set.iterator();
		while( it.hasNext() )
		{
			String id = it.next().getId();
			String[] splits = id.split("_");
			if( splits.length == 2 )
			{
				if( splits[1].equalsIgnoreCase("storage") )
					return true;					
			}
	    }
		return false;
	}
   	return false;
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:30,代码来源:NavyCraft.java

示例15: checkRepairRegion

import com.sk89q.worldguard.bukkit.WorldGuardPlugin; //导入方法依赖的package包/类
public static boolean checkRepairRegion(Location loc)
   {
   	
   	wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard");
   	if( wgp != null && loc != null)
   	{
   		if( !!PermissionInterface.CheckEnabledWorld(loc) )
   		{
   			return false;
   		}
    	RegionManager regionManager = wgp.getRegionManager(loc.getWorld());
	
		ApplicableRegionSet set = regionManager.getApplicableRegions(loc);
		
		Iterator<ProtectedRegion> it = set.iterator();
		while( it.hasNext() )
		{
			String id = it.next().getId();
			String[] splits = id.split("_");
			if( splits.length == 2 )
			{
				if( splits[1].equalsIgnoreCase("repair") )
					return true;					
			}
	    }
		return false;
	}
   	return false;
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:30,代码来源:NavyCraft.java


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