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


Java ProtectedRegion类代码示例

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


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

示例1: isPVPEnabled

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public static boolean isPVPEnabled(Location location) {
	String global = "__global__";
	if(plugin.getWorldGuard().getRegionManager(location.getWorld()) == null)	
		return true;
	RegionManager regionManager = plugin.getWorldGuard().getRegionManager(location.getWorld());
	ApplicableRegionSet arset = regionManager.getApplicableRegions(location);
	ProtectedRegion region = regionManager.getRegion(global);
	int priority = -10000;
	for(ProtectedRegion r : arset.getRegions()) { 
		if(r.getPriority() > priority) {
			region = r;
			priority = r.getPriority();
		}
	}
	if(region == null) {
		if(regionManager.getRegion(global) == null)
			return false;
		return "ALLOW".equals(regionManager.getRegion(global).getFlag(DefaultFlag.PVP).toString());
	}
	if(region.getFlag(DefaultFlag.PVP) == null)
		return true;
	return "ALLOW".equalsIgnoreCase(region.getFlag(DefaultFlag.PVP).toString());
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:24,代码来源:Utility.java

示例2: addMembers

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
/**
 * Adds a list of members to a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean addMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.addPlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:31,代码来源:WorldGuardManager.java

示例3: removeMembers

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
/**
 * Removes a list of members from a region.
 *
 * @param world World were the region is.
 * @param regionName The ID of the region.
 * @param playerNames Players to be added.
 * @return true on succes, false on failure.
 */
public boolean removeMembers(World world, String regionName, String[] playerNames) {
    RegionManager rm = wgp.getRegionManager(world);
    if (rm == null) {
        return false;
    }
    ProtectedRegion region = rm.getRegion(regionName);
    if (region == null) {
        return false;
    }
    DefaultDomain members = region.getMembers();
    for (String playerName : playerNames) {
        members.removePlayer(playerName);
    }
    region.setMembers(members);
    try {
        rm.save();
    } catch (ProtectionDatabaseException ex) {
        plugin.getLogger().log(Level.SEVERE, "Unexpected failure saving WorldGuard configuration: {0}", ex.toString());
        return false;
    }
    return true;
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:31,代码来源:WorldGuardManager.java

示例4: queryRegions

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
private Set<String> queryRegions(Location location) {
    RegionContainer container = worldGuard.getRegionContainer();
    RegionQuery query = container.createQuery();
    ApplicableRegionSet set = query.getApplicableRegions(location);

    if (set.size() == 0) {
        return Collections.emptySet();
    }

    final Set<String> regions = new HashSet<>();
    for (ProtectedRegion r : set.getRegions()) {
        regions.add(r.getId().toLowerCase());
    }

    return regions;
}
 
开发者ID:lucko,项目名称:ConditionalPerms,代码行数:17,代码来源:WorldGuardHook.java

示例5: addAudio

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public boolean addAudio(CommandSender sender, AudioTrack audio, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioTrack> audioTracks = getRegionSetFlag(region, plugin.getAudioFlag());
    if (!audioTracks.add(audio)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-audio-exists", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioFlag(), audioTracks)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.audio-added", audio, regionId);
    return true;
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:21,代码来源:RegionCommand.java

示例6: removeAudio

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public boolean removeAudio(CommandSender sender, AudioTrack audio, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioTrack> audioTracks = getRegionSetFlag(region, plugin.getAudioFlag());
    if (!audioTracks.remove(audio)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-audio-absent", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioFlag(), audioTracks)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.audio-removed", audio, regionId);
    return true;
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:21,代码来源:RegionCommand.java

示例7: addDelay

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public boolean addDelay(CommandSender sender, AudioDelay delay, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioDelay> audioDelays = getRegionSetFlag(region, plugin.getAudioDelayFlag());
    if (!audioDelays.add(delay)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-delay-exists", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioDelayFlag(), audioDelays)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.delay-added", delay, regionId);
    return true;
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:21,代码来源:RegionCommand.java

示例8: removeDelay

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public boolean removeDelay(CommandSender sender, AudioDelay delay, RegionManager regionManager, String regionId) {
    ProtectedRegion region = regionManager.getRegion(regionId);
    if (region == null) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-invalid-region", regionId);
        return false;
    }
    Set<AudioDelay> audioDelays = getRegionSetFlag(region, plugin.getAudioDelayFlag());
    if (!audioDelays.remove(delay)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.edit-delay-absent", regionId);
        return false;
    }

    if (!saveRegionSetFlag(regionManager, region, plugin.getAudioDelayFlag(), audioDelays)) {
        plugin.getMessenger().sendErrorMessage(sender, "failed.worldguard-save");
        return false;
    }

    plugin.getMessenger().sendMessage(sender, "succeeded.delay-removed", delay, regionId);
    return true;
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:21,代码来源:RegionCommand.java

示例9: importRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
@Override
protected boolean importRegion(String regionId, String audioId) {
    boolean imported = false;
    for (RegionManager regionManager : regionManagers) {
        // Region IDs are unique for each RegionAudio import, so no need to synchronize
        ProtectedRegion region = regionManager.getRegion(regionId);
        if (region != null) {
            AudioTrack audioTrack = new AudioTrack(audioId);
            Set<AudioTrack> audioTracks = region.getFlag(plugin.getAudioFlag());
            audioTracks = (audioTracks != null ? new HashSet<>(audioTracks) : new HashSet<AudioTrack>());
            if (audioTracks.add(audioTrack)) {
                region.setFlag(plugin.getAudioFlag(), audioTracks);
            }
            imported = true;
        }
    }
    return imported;
}
 
开发者ID:DeadmanDungeons,项目名称:AudioConnect,代码行数:19,代码来源:ImportCommand.java

示例10: getRegion

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public ProtectedRegion getRegion(final Player player, final Location loc)
{
    final com.sk89q.worldguard.LocalPlayer localplayer = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().wrapPlayer(player);
    RegionManager manager = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionManager(player.getWorld());
    final ProtectedRegion global = manager.getRegion("__global__");
    if (global != null && !isDenied(localplayer, global))
    {
        return global;
    }
    
    final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
    for (final ProtectedRegion region : regions)
    {
        if (!isDenied(localplayer, region))
        {
            return region;
        }
    }
    return null;
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:21,代码来源:FaweWorldEditFlag.java

示例11: onCrossBoundary

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
	if (!WorldGuardUtils.hasBypass(player))
	{
		if (!player.hasMetadata("WGEFP-TPOEF"))
		{
			com.sk89q.worldedit.Location location = toSet.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.TELEPORT_ON_ENTRY);
			if (location != null)
			{
				player.setMetadata("WGEFP-TPOEF", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
				player.teleport(BukkitUtil.toLocation(location));
			}
		}
	}
	
	return true;
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:20,代码来源:TeleportOnEntryFlag.java

示例12: onCrossBoundary

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean onCrossBoundary(Player player, Location from, Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
	if (!WorldGuardUtils.hasBypass(player))
	{
		if (!player.hasMetadata("WGEFP-TPOEF"))
		{
			for (ProtectedRegion exitd : exited)
			{
				com.sk89q.worldedit.Location location = exitd.getFlag(FlagUtils.TELEPORT_ON_EXIT);
				if (location != null)
				{
					player.setMetadata("WGEFP-TPOEF", new FixedMetadataValue(WorldGuardExtraFlagsPlugin.getPlugin(), null));
					player.teleport(BukkitUtil.toLocation(location));
					
					break;
				}
			}
		}
	}
	
	return true;
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:25,代码来源:TeleportOnExitFlag.java

示例13: doUnloadChunkFlagWorldCheck

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public static void doUnloadChunkFlagWorldCheck(World world)
{
	for (ProtectedRegion region : WorldGuardExtraFlagsPlugin.worldGuardPlugin.getRegionManager(world).getRegions().values())
	{
		if (region.getFlag(FlagUtils.CHUNK_UNLOAD) == State.DENY)
		{
			WorldGuardExtraFlagsPlugin.getPlugin().getLogger().info("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny");
			
			Location min = BukkitUtil.toLocation(world, region.getMinimumPoint());
			Location max = BukkitUtil.toLocation(world, region.getMaximumPoint());

			for(int x = min.getChunk().getX(); x <= max.getChunk().getX(); x++)
			{
				for(int z = min.getChunk().getZ(); z <= max.getChunk().getZ(); z++)
				{
					world.getChunkAt(x, z).load(true);
				}
			}
		}
	}
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:22,代码来源:WorldGuardExtraFlagsPlugin.java

示例14: addAmigo

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public static void addAmigo(Player p, String terreno, String amigo) {
	ProtectedRegion region = TerrenosManager.getTerreno(p.getName(), terreno);
	if (region != null) {
		region.getMembers().addPlayer(amigo);
		try {
			wg.getRegionManager(p.getWorld()).save();
			
		} catch (Exception e1) {
			p.sendMessage("�cOcorreu um erro interno, contate um administrador.");
			Utils.logError("Ocorreu um erro ao salvar o terreno. " + region.getId());
			e1.printStackTrace();
		}
		p.sendMessage(getMensagem("amigo_adicionado"));
	} else {
		p.sendMessage(getMensagem("nao_possui_este_terreno"));
	}
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:18,代码来源:TerrenosManager.java

示例15: delAmigo

import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入依赖的package包/类
public static void delAmigo(Player p, String terreno, String amigo) {
	ProtectedRegion region = TerrenosManager.getTerreno(p.getName(), terreno);
	if (region != null) {
		region.getMembers().removePlayer(amigo);
		try {
			wg.getRegionManager(p.getWorld()).save();
		} catch (Exception e1) {
			p.sendMessage("�cOcorreu um erro interno, contate um administrador.");
			Utils.logError("Ocorreu um erro ao salvar o terreno. " + region.getId());
			e1.printStackTrace();
		}
		p.sendMessage(getMensagem("amigo_removido"));
	} else {
		p.sendMessage(getMensagem("nao_possui_este_terreno"));
	}
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:17,代码来源:TerrenosManager.java


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