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