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


Java RegionManager.getRegion方法代碼示例

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


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

示例1: isPVPEnabled

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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.managers.RegionManager; //導入方法依賴的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.managers.RegionManager; //導入方法依賴的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: addAudio

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例5: removeAudio

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例6: addDelay

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例7: removeDelay

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例8: importRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例9: getRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例10: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getMembers().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:22,代碼來源:ExprAllMembers.java

示例11: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> rfl = new ArrayList<String>();

	for (Entry<Flag<?>, Object> ra : pregion.getFlags().entrySet()) {
		rfl.add(ra.getKey().getName());
	}

	String[] s = new String[rfl.size()];
	return (String[]) rfl.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:26,代碼來源:ExprAllFlagsOfRegion.java

示例12: get

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
protected String[] get(Event event) {
	World world = (World) this.world.getSingle(event);
	if (world == null) {
		for (RegionManager a : WGBukkit.getPlugin().getRegionContainer().getLoaded()) {
			for (Entry<String, ProtectedRegion> b : a.getRegions().entrySet()) {
				if (b.getKey().equals(region.getSingle(event))) {
					world = Bukkit.getWorld(a.getName());
					break;
				}

			}
		}
	}

	RegionManager rm = WGBukkit.getRegionManager(world);
	ProtectedRegion pregion = rm.getRegion(region.getSingle(event));
	List<String> list = new ArrayList<String>(pregion.getOwners().getPlayers());

	String[] s = new String[list.size()];
	return (String[]) list.toArray(s);
}
 
開發者ID:Sharpjaws,項目名稱:SharpSK,代碼行數:22,代碼來源:ExprAllOwners.java

示例13: onMove

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的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

示例14: praseWGRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
private ProtectedRegion praseWGRegion(final World world, final int valueX, final int valueZ) {
    RegionManager manager = plugin.getWorldGuardPlugin().getRegionManager(world);
    String serverName = buildLandName(LandTypes.SERVER.toString(), valueX, valueZ);
    String shopName = buildLandName(LandTypes.SHOP.toString(), valueX, valueZ);
    String worldName = buildLandName(world.getName(), valueX, valueZ);
    if (manager.hasRegion(serverName)) {
        return manager.getRegion(serverName);

    } else if (manager.hasRegion(shopName)) {
        return manager.getRegion(shopName);

    } else if (manager.hasRegion(worldName)) {
        return manager.getRegion(worldName);

    }
    return null;
}
 
開發者ID:MineGaming,項目名稱:cubit,代碼行數:18,代碼來源:CubitregionManager.java

示例15: getRegion

import com.sk89q.worldguard.protection.managers.RegionManager; //導入方法依賴的package包/類
public ProtectedRegion getRegion(final com.sk89q.worldguard.LocalPlayer player, final Location loc) {
    RegionManager manager = this.worldguard.getRegionManager(loc.getWorld());
    if (manager == null) {
        if (this.worldguard.getGlobalStateManager().get(loc.getWorld()).useRegions) {
            System.out.println("Region capability is not enabled for WorldGuard.");
        } else {
            System.out.println("WorldGuard is not enabled for that world.");
        }
        return null;
    }
    final ProtectedRegion global = manager.getRegion("__global__");
    if (global != null && isAllowed(player, global)) {
        return global;
    }
    final ApplicableRegionSet regions = manager.getApplicableRegions(loc);
    for (final ProtectedRegion region : regions) {
        if (isAllowed(player, region)) {
            return region;
        }
    }
    return null;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:23,代碼來源:Worldguard.java


注:本文中的com.sk89q.worldguard.protection.managers.RegionManager.getRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。